-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsta_lta.m
49 lines (42 loc) · 1.33 KB
/
sta_lta.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
% calculate sta and lta and trigger for an exceedance over a threshold
function itm = sta_lta(ev)
% ev = 'event_0007'
cd (strcat('~/Desktop/LAB/15_11_2018/',ev, '/ReceiverTZero/'))
% ! mkdir sta_lta
lis = dir(strcat('~/Desktop/LAB/15_11_2018/', ev, '/ReceiverTZero/*RF'));
for i = 1:length(lis)
rfseis = readsac(lis(i).name); % r component
dt = rfseis.headerA(1); % sample rate
nt = rfseis.nsamps; % no of sample points
time = 0.01*(0:1:numel(rfseis.data)-1);
aseries = abs( hilbert(rfseis.data) ); % averaging based on hilbert abs
lta = mean(aseries(time <= 40));
threshold = 3;
st_win = fix(5/dt);
s_wave1 = fix(75/dt); % S wave is assumed at 80
s_wave2 = fix(90/dt);
for j = s_wave1 + 1:s_wave2
sta = mean(aseries(j - st_win : j));
sra(j) = sta / lta;
end
% for j = 1 + st_win:nt
% sta = mean(aseries(j - st_win : j));
% sra(j) = sta / lta;
% end
%
% figure
% plot(time, sra, 'k', 'linewidth', 1.5)
% hold on
% plot(time, rfseis.data, 'LineWidth', 1.5)
% hold off
%
itm = (sra > threshold);
if (sum(itm) >= 1)
rfseis.filename
cmd = sprintf('cp "%s" sta_lta/', rfseis.filename );
system(cmd)
end
% itms = sum(itm==1); % get number of the triggers
% trigger(i,itms)
end
cd ../../