-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcleanup_events.m
78 lines (66 loc) · 1.75 KB
/
cleanup_events.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% script to remove events that are close in the time that may interference with each other.
% written by Ge Jin,[email protected]
clear;
eventmatpath = './eventmat/';
csmatpath = './CSmeasure/';
eikonalpath = './eikonal/';
% Setup parameters
setup_parameters
% Setup Error Codes for Bad data
setup_ErrorCode
lalim = parameters.lalim;
lolim = parameters.lolim;
gridsize = parameters.gridsize;
gridsize = gridsize*3;
xnode = [lalim(1),mean(lalim),lalim(2)];
ynode = [lolim(1),mean(lolim),lolim(2)];
[xi yi] = meshgrid(xnode,ynode);
matfiles = dir([eventmatpath,'/*_',parameters.component,'.mat']);
for ie = 1:length(matfiles)
% read in the events information
temp = load([eventmatpath,matfiles(ie).name]);
event = temp.event;
disp(event.id)
evotimes(ie) = event.otime;
evlas(ie) = event.evla;
evlos(ie) = event.evlo;
evids(ie) = {event.id};
isgood(ie) = 1;
dist = deg2km(distance(xi,yi,evlas(ie),evlos(ie)));
win_start(ie) = evotimes(ie) + min(dist(:)/5);
win_end(ie) = evotimes(ie) + max(dist(:)/2);
if ~isfield(event,'stadata')
isgood(ie)=0;
elseif length(event.stadata)<5
isgood(ie)=0;
end
end % end of event loop
for ie = 1:length(evlas)
for je = 1:length(evlas)
if ie == je
continue;
end
if win_start(ie) > win_start(je) && win_start(ie) < win_end(je)
isgood(ie) = 0;
isgood(je) = 0;
end
if win_end(ie) > win_start(je) && win_end(ie) < win_end(je)
isgood(ie) = 0;
isgood(je) = 0;
end
end
end
disp('Bad events:')
badind = find(isgood == 0);
for ie = badind
disp(evids(ie));
end
%com = input('Do you want to delete these events? y/n','s');
com = 'y';
if com == 'y'
for ie = badind
delete([eventmatpath,char(evids(ie)),'*.mat'])
delete([csmatpath ,char(evids(ie)),'*.mat'])
delete([eikonalpath ,char(evids(ie)),'*.mat'])
end
end