This commit is contained in:
parent
bfc745dd30
commit
bf5c371459
@ -7,6 +7,7 @@ import argparse
|
|||||||
import datetime
|
import datetime
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
|
|
||||||
import pylot.core.loc.focmec as focmec
|
import pylot.core.loc.focmec as focmec
|
||||||
import pylot.core.loc.hash as hash
|
import pylot.core.loc.hash as hash
|
||||||
@ -283,7 +284,11 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
corr_dat = None
|
corr_dat = None
|
||||||
if metadata:
|
if metadata:
|
||||||
# rotate stations to ZNE
|
# rotate stations to ZNE
|
||||||
|
try:
|
||||||
wfdat = check4rotated(wfdat, metadata)
|
wfdat = check4rotated(wfdat, metadata)
|
||||||
|
except Exception as e:
|
||||||
|
print('Could not rotate station {} to ZNE:\n{}'.format(wfdat[0].stats.station,
|
||||||
|
traceback.format_exc()))
|
||||||
if locflag:
|
if locflag:
|
||||||
print("Restitute data ...")
|
print("Restitute data ...")
|
||||||
corr_dat = restitute_data(wfdat.copy(), metadata, ncores=ncores)
|
corr_dat = restitute_data(wfdat.copy(), metadata, ncores=ncores)
|
||||||
|
@ -137,8 +137,8 @@ def call_autopickstation(input_tuple):
|
|||||||
return autopickstation(wfstream, pickparam, verbose, fig_dict=fig_dict, iplot=iplot, metadata=metadata,
|
return autopickstation(wfstream, pickparam, verbose, fig_dict=fig_dict, iplot=iplot, metadata=metadata,
|
||||||
origin=origin)
|
origin=origin)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
tbe = traceback.format_exc()
|
||||||
return traceback.format_exc(), wfstream[0].stats.station
|
return tbe, wfstream[0].stats.station
|
||||||
|
|
||||||
|
|
||||||
def autopickstation(wfstream, pickparam, verbose=False,
|
def autopickstation(wfstream, pickparam, verbose=False,
|
||||||
@ -254,19 +254,22 @@ def autopickstation(wfstream, pickparam, verbose=False,
|
|||||||
# split components
|
# split components
|
||||||
zdat = wfstream.select(component="Z")
|
zdat = wfstream.select(component="Z")
|
||||||
if len(zdat) == 0: # check for other components
|
if len(zdat) == 0: # check for other components
|
||||||
|
print('HIT: 3')
|
||||||
zdat = wfstream.select(component="3")
|
zdat = wfstream.select(component="3")
|
||||||
edat = wfstream.select(component="E")
|
edat = wfstream.select(component="E")
|
||||||
if len(edat) == 0: # check for other components
|
if len(edat) == 0: # check for other components
|
||||||
edat = wfstream.select(component="2")
|
edat = wfstream.select(component="2")
|
||||||
|
print('HIT: 2')
|
||||||
ndat = wfstream.select(component="N")
|
ndat = wfstream.select(component="N")
|
||||||
if len(ndat) == 0: # check for other components
|
if len(ndat) == 0: # check for other components
|
||||||
ndat = wfstream.select(component="1")
|
ndat = wfstream.select(component="1")
|
||||||
|
print('HIT: 1')
|
||||||
|
|
||||||
picks = {}
|
picks = {}
|
||||||
station = zdat[0].stats.station
|
station = wfstream[0].stats.station
|
||||||
|
|
||||||
if not zdat:
|
if not zdat:
|
||||||
print('No z-component found for station {}. STOP'.format(wfstream[0].stats.station))
|
print('No z-component found for station {}. STOP'.format(station))
|
||||||
return picks, station
|
return picks, station
|
||||||
|
|
||||||
if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None:
|
if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None:
|
||||||
|
@ -279,7 +279,7 @@ class AICPicker(AutoPicker):
|
|||||||
try:
|
try:
|
||||||
imaxs, = argrelmax(dataslope)
|
imaxs, = argrelmax(dataslope)
|
||||||
imax = imaxs[0]
|
imax = imaxs[0]
|
||||||
except ValueError as e:
|
except (ValueError, IndexError) as e:
|
||||||
print(e, 'picker: argrelmax not working!')
|
print(e, 'picker: argrelmax not working!')
|
||||||
imax = np.argmax(dataslope)
|
imax = np.argmax(dataslope)
|
||||||
iislope = islope[0][0:imax + 1]
|
iislope = islope[0][0:imax + 1]
|
||||||
|
@ -606,14 +606,18 @@ def wadaticheck(pickdic, dttolerance, iplot=0, fig_dict=None):
|
|||||||
ibad = 0
|
ibad = 0
|
||||||
|
|
||||||
for key in list(pickdic.keys()):
|
for key in list(pickdic.keys()):
|
||||||
if pickdic[key]['P']['weight'] < 4 and pickdic[key]['S']['weight'] < 4:
|
ppick = pickdic[key].get('P')
|
||||||
|
spick = pickdic[key].get('S')
|
||||||
|
if not ppick or not spick:
|
||||||
|
continue
|
||||||
|
if ppick['weight'] < 4 and spick['weight'] < 4:
|
||||||
# calculate S-P time
|
# calculate S-P time
|
||||||
spt = pickdic[key]['S']['mpp'] - pickdic[key]['P']['mpp']
|
spt = spick['mpp'] - ppick['mpp']
|
||||||
# add S-P time to dictionary
|
# add S-P time to dictionary
|
||||||
pickdic[key]['SPt'] = spt
|
pickdic[key]['SPt'] = spt
|
||||||
# add P onsets and corresponding S-P times to list
|
# add P onsets and corresponding S-P times to list
|
||||||
UTCPpick = UTCDateTime(pickdic[key]['P']['mpp'])
|
UTCPpick = UTCDateTime(ppick['mpp'])
|
||||||
UTCSpick = UTCDateTime(pickdic[key]['S']['mpp'])
|
UTCSpick = UTCDateTime(spick['mpp'])
|
||||||
Ppicks.append(UTCPpick.timestamp)
|
Ppicks.append(UTCPpick.timestamp)
|
||||||
Spicks.append(UTCSpick.timestamp)
|
Spicks.append(UTCSpick.timestamp)
|
||||||
SPtimes.append(spt)
|
SPtimes.append(spt)
|
||||||
@ -870,9 +874,12 @@ def checkPonsets(pickdic, dttolerance, jackfactor=5, iplot=0, fig_dict=None):
|
|||||||
Ppicks = []
|
Ppicks = []
|
||||||
stations = []
|
stations = []
|
||||||
for station in pickdic:
|
for station in pickdic:
|
||||||
if pickdic[station]['P']['weight'] < 4:
|
pick = pickdic[station].get('P')
|
||||||
|
if not pick:
|
||||||
|
continue
|
||||||
|
if pick['weight'] < 4:
|
||||||
# add P onsets to list
|
# add P onsets to list
|
||||||
UTCPpick = UTCDateTime(pickdic[station]['P']['mpp'])
|
UTCPpick = UTCDateTime(pick['mpp'])
|
||||||
Ppicks.append(UTCPpick.timestamp)
|
Ppicks.append(UTCPpick.timestamp)
|
||||||
stations.append(station)
|
stations.append(station)
|
||||||
|
|
||||||
|
@ -975,6 +975,9 @@ def check4rotated(data, metadata=None, verbosity=1):
|
|||||||
except (KeyError, TypeError) as e:
|
except (KeyError, TypeError) as e:
|
||||||
print('Failed to rotate trace {}, no azimuth or dip available in metadata'.format(trace_id))
|
print('Failed to rotate trace {}, no azimuth or dip available in metadata'.format(trace_id))
|
||||||
return wfstream
|
return wfstream
|
||||||
|
if len(wfstream) < 3:
|
||||||
|
print('Failed to rotate Stream {}, not enough components available.'.format(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],
|
z, n, e = rotate2zne(wfstream[0], azimuts[0], dips[0],
|
||||||
|
Loading…
Reference in New Issue
Block a user