Bug workaround: sometimes rotate2zne fails resulting in an permanent
error
This commit is contained in:
parent
9486d7aced
commit
7023bc4ce4
@ -960,26 +960,31 @@ def check4rotated(data, metadata=None, verbosity=1):
|
|||||||
return wfstream
|
return wfstream
|
||||||
# to rotate all traces must have same length, so trim them
|
# to rotate all traces must have same length, so trim them
|
||||||
wfstream = trim_station_components(wfstream, trim_start=True, trim_end=True)
|
wfstream = trim_station_components(wfstream, trim_start=True, trim_end=True)
|
||||||
z, n, e = rotate2zne(wfstream[0], azimuts[0], dips[0],
|
try:
|
||||||
wfstream[1], azimuts[1], dips[1],
|
z, n, e = rotate2zne(wfstream[0], azimuts[0], dips[0],
|
||||||
wfstream[2], azimuts[2], dips[2])
|
wfstream[1], azimuts[1], dips[1],
|
||||||
print('check4rotated: rotated trace {} to ZNE'.format(trace_id))
|
wfstream[2], azimuts[2], dips[2])
|
||||||
# replace old data with rotated data, change the channel code to ZNE
|
print('check4rotated: rotated trace {} to ZNE'.format(trace_id))
|
||||||
z_index = dips.index(min(
|
# replace old data with rotated data, change the channel code to ZNE
|
||||||
dips)) # get z-trace index, z has minimum dip of -90 (dip is measured from 0 to -90, with -90 being vertical)
|
z_index = dips.index(min(
|
||||||
wfstream[z_index].data = z
|
dips)) # get z-trace index, z has minimum dip of -90 (dip is measured from 0 to -90, with -90 being vertical)
|
||||||
wfstream[z_index].stats.channel = wfstream[z_index].stats.channel[0:-1] + 'Z'
|
wfstream[z_index].data = z
|
||||||
del trace_ids[z_index]
|
wfstream[z_index].stats.channel = wfstream[z_index].stats.channel[0:-1] + 'Z'
|
||||||
for trace_id in trace_ids:
|
del trace_ids[z_index]
|
||||||
coordinates = metadata.get_coordinates(trace_id, t_start)
|
for trace_id in trace_ids:
|
||||||
dip, az = coordinates['dip'], coordinates['azimuth']
|
coordinates = metadata.get_coordinates(trace_id, t_start)
|
||||||
trace = wfstream.select(id=trace_id)[0]
|
dip, az = coordinates['dip'], coordinates['azimuth']
|
||||||
if az > 315 or az <= 45 or az > 135 and az <= 225:
|
trace = wfstream.select(id=trace_id)[0]
|
||||||
trace.data = n
|
if az > 315 or az <= 45 or az > 135 and az <= 225:
|
||||||
trace.stats.channel = trace.stats.channel[0:-1] + 'N'
|
trace.data = n
|
||||||
elif az > 45 and az <= 135 or az > 225 and az <= 315:
|
trace.stats.channel = trace.stats.channel[0:-1] + 'N'
|
||||||
trace.data = e
|
elif az > 45 and az <= 135 or az > 225 and az <= 315:
|
||||||
trace.stats.channel = trace.stats.channel[0:-1] + 'E'
|
trace.data = e
|
||||||
|
trace.stats.channel = trace.stats.channel[0:-1] + 'E'
|
||||||
|
except (ValueError) as e:
|
||||||
|
print(e)
|
||||||
|
return wfstream
|
||||||
|
|
||||||
return wfstream
|
return wfstream
|
||||||
|
|
||||||
if metadata is None:
|
if metadata is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user