Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/gf/fd_rotation.py: 0%
51 statements
« prev ^ index » next coverage.py v6.5.0, created at 2024-02-27 10:58 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2024-02-27 10:58 +0000
2from pyrocko import gf, trace
5comp_azi = {
6 'N': 0.0,
7 'E': 90.0,
8 'D': 0.0}
10comp_dip = {
11 'N': 0.0,
12 'E': 0.0,
13 'D': 90.0}
16def fd_rot_surface_targets(delta, target):
18 assert target.interpolation == 'multilinear'
19 assert target.quantity == 'displacement'
21 targets = []
22 for kn in [-1, 0, 1]:
23 for ke in [-1, 0, 1]:
24 for comp in 'NED':
25 targets.append(gf.Target(
26 codes=target.codes[:3] + (comp,),
27 quantity='displacement',
28 lat=target.lat,
29 lon=target.lon,
30 north_shift=target.north_shift + kn * delta,
31 east_shift=target.east_shift + ke * delta,
32 azimuth=comp_azi[comp],
33 dip=comp_dip[comp],
34 interpolation='multilinear',
35 store_id=target.store_id))
37 return targets
40def fd_rot_surface_postprocess(delta, traces, rfmax=0.8):
42 deltat = traces[0].deltat
43 fnyquist = 0.5 / deltat
44 fmax = rfmax * fnyquist
45 tpad = 2.0 / fmax
46 tmin = min(tr.tmin for tr in traces)
47 tmax = max(tr.tmax for tr in traces)
48 traces_prepared = []
50 for tr in traces:
51 tr.extend(tmin-tpad, tmax+tpad, fillmethod='repeat')
52 tr_filt = tr.transfer(
53 tfade=tpad,
54 freqlimits=(-1., -1., fmax, fnyquist),
55 demean=False)
57 traces_prepared.append(tr_filt)
59 tr_filt.set_location('filtered')
61 # trace.snuffle(traces + traces_prepared)
63 d = trace.get_traces_data_as_array(traces_prepared)
64 d = d.reshape((3, 3, 3, d.shape[1]))
66 kn, ke, kd = 0, 1, 2
67 il, ic, ih = 0, 1, 2
69 dd_de = (d[ic, ih, kd] - d[ic, il, kd]) / (2.*delta)
70 dd_dn = (d[ih, ic, kd] - d[il, ic, kd]) / (2.*delta)
71 dn_de = (d[ic, ih, kn] - d[ic, il, kn]) / (2.*delta)
72 de_dn = (d[ih, ic, ke] - d[il, ic, ke]) / (2.*delta)
74 d_rot = [
75 dd_de,
76 - dd_dn,
77 0.5 * (de_dn - dn_de)]
79 traces_rot = []
80 for comp, data in zip('NED', d_rot):
81 tr = trace.Trace(
82 network=traces[0].network,
83 station=traces[0].station,
84 location=traces[0].location,
85 channel='ROT_%s' % comp,
86 deltat=deltat,
87 tmin=tmin,
88 ydata=data)
89 # tr.differentiate(1)
90 traces_rot.append(tr)
92 traces_dis, traces_vel, traces_acc = [], [], []
93 for comp, data in zip('NED', d[ic, ic, :]):
94 tr_dis = traces[0].copy()
95 tr_dis.set_ydata(data)
96 tr_dis.set_codes(channel='DIS_%s' % comp)
97 tr_vel = tr_dis.differentiate(1, inplace=False)
98 tr_vel.set_codes(channel='VEL_%s' % comp)
99 tr_acc = tr_dis.differentiate(2, inplace=False)
100 tr_acc.set_codes(channel='ACC_%s' % comp)
101 traces_dis.append(tr_dis)
102 traces_vel.append(tr_vel)
103 traces_acc.append(tr_acc)
105 return traces_dis, traces_vel, traces_acc, traces_rot