-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFun_SetGreenModel1.m
More file actions
59 lines (53 loc) · 2 KB
/
Copy pathFun_SetGreenModel1.m
File metadata and controls
59 lines (53 loc) · 2 KB
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
function [ob,g]=Fun_SetGreenModel1(ob,g,grid,srate)
% =========================================================================
% !!! Do not double-count or run again !!!
% !!! Do not double-count or run again !!!
% Rearrange and process Green function
% Original Green's-function dimension:
% g = [Nt, 3, Nsta*Nsub]
% Target dimension:
% g = [Nt, 3*Nsta, Nsub]
% Component order after rearrangement:
% [E1...EN, N1...NN, U1...UN]
% =========================================================================
% Match the Green's-function time length to the observation
nObs=size(ob,1);
nGre=size(g,1);
nUse=min(nObs,nGre); % common time window
ob=ob(1:nUse,:,:);
g=g(1:nUse,:,:);
% =========================================================================
nsta=size(ob,3);
nsub=prod(grid);
if size(g,3) ~= nsta*nsub
error(['The number of Green''s-function traces does not match ', ...
'Nsta * Nsub.']);
end
% Extract 3-component Green's functions
gE = reshape(g(:, 1, :), [nUse, nsta, nsub]);
gN = reshape(g(:, 2, :), [nUse, nsta, nsub]);
gU = reshape(g(:, 3, :), [nUse, nsta, nsub]);
% Combine E, N, and U components
g = cat(2, gE, gN, gU);
% Convert Green's functions from velocity to displacement
g = cumsum(g, 1)/srate;
% =========================================================================
% !!! Do not double-count or run again !!!
% !!! Do not double-count or run again !!!
% Rearrange and process waveforms
% Original observation dimension:
% ob = [Nt, 3, Nsta]
% Convert it into:
% ob = [Nt, 3*Nsta]
% Final component order:
% [E1...EN, N1...NN, U1...UN]
ob = permute(ob, [1, 3, 2]);
ob = reshape(ob, nUse, []);
% Baseline correction
for iTrace=1:size(ob,2)
ob(:,iTrace)=cor_baseline(ob(:,iTrace),nUse);
end
% Convert Units
ob = cumsum(ob, 1)/srate; % First: acceleration --> velocity
ob = cumsum(ob, 1)/srate; % Second: velocity --> displacement
end