sacfilename='data/2005.295.00.36.25.0000.YZ.BOOE..BHZ.D.SAC';
clear min;
sacfilename='2005.297.00.36.25.0000.YZ.BOOE..BHZ.D.SAC';
sacfilename='2005.308.00.36.25.0000.YZ.BOOE..BHZ.D.SAC';
sacfilename='2005.324.00.36.25.0000.YZ.BOOE..BHZ.D.SAC';
sacfilename='2005.297.00.00.01.0000.YZ.AFDE..BHZ.D.SAC'

station='booe'
%read in trace (DC filter -> trace2), power vector sy, jsec (seconds julian)  
[trace2,fs,sy,jsec]=loadsac(sacfilename);
[eventliston,eventlistoff] = tagevents(sy,1e4,8e3,1.0*fs);  % tag events
%   sy is abs of trace somewhat smoothed and DC filtered
%   1e4 is trigger level for this
%   8e3 is untrigger level for this
%   1.0 is min distance in s allowed between off of previous and on of next
framehz=0.5; % Hz frame sampling speed for filterbank
[e]=dobank(trace2,fs,framehz); % compute filterbank
% in this the filterbank frequencies cuts frequencies are set
clim = 10.0;  % in db
[clistv] = docolor(eventliston,eventlistoff,clim,e,fs,framehz)
%  make colors and make list of good events
% in this routine set clim, the db level for the color you are choosing
%   also can rewrite to choose the color that this limit is chosen by

autoplot;  %plot out all events

% below I figure out how to locate a single event in the event list by a
% time
day = 295;
ysec = dhmstos(day,1,29,4,0.0); % #235
t_string='295:01:29:04';
timev = ysec - jsec;  % seconds from beginning of file
[y,i]=min(abs(timev*fs-eventliston));
timev2 = eventliston(i)/fs;

figure;
pltevent(trace2,timev2,fs,e,framehz,['booe' t_string]);

% experiment with plotting one event!
    %k=1
    %timei = eventliston(clistv(k));
    %timestring = tstring(jsec,timevec,timei);
    %pltevent(trace2,eventliston(clistv(k))/fs,fs,e,framehz,timestring);
    %epsname = [timestring  '.eps']
    %print('-depsc',epsname); % prints the figure out to a file