[update] autopicker - obspyDMT (WIP)
This commit is contained in:
parent
47d6aeabff
commit
08124174b1
42
autoPyLoT.py
42
autoPyLoT.py
@ -34,7 +34,7 @@ __version__ = _getVersionString()
|
|||||||
|
|
||||||
|
|
||||||
def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, eventid=None, savepath=None,
|
def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, eventid=None, savepath=None,
|
||||||
savexml=True, station='all', iplot=0, ncores=0):
|
savexml=True, station='all', iplot=0, ncores=0, obspyDMT_wfpath=False):
|
||||||
"""
|
"""
|
||||||
Determine phase onsets automatically utilizing the automatic picking
|
Determine phase onsets automatically utilizing the automatic picking
|
||||||
algorithms by Kueperkoch et al. 2010/2012.
|
algorithms by Kueperkoch et al. 2010/2012.
|
||||||
@ -114,6 +114,8 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
locflag = input_dict['locflag']
|
locflag = input_dict['locflag']
|
||||||
if 'savexml' in input_dict:
|
if 'savexml' in input_dict:
|
||||||
savexml = input_dict['savexml']
|
savexml = input_dict['savexml']
|
||||||
|
if 'obspyDMT_wfpath' in input_dict:
|
||||||
|
obspyDMT_wfpath = input_dict['obspyDMT_wfpath']
|
||||||
|
|
||||||
if not parameter:
|
if not parameter:
|
||||||
if inputfile:
|
if inputfile:
|
||||||
@ -175,6 +177,14 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
print("!!No source parameter estimation possible!!")
|
print("!!No source parameter estimation possible!!")
|
||||||
print(" !!! ")
|
print(" !!! ")
|
||||||
|
|
||||||
|
wfpath_extension = ''
|
||||||
|
if obspyDMT_wfpath not in [None, False]:
|
||||||
|
wfpath_extension = obspyDMT_wfpath
|
||||||
|
print('Using obspyDMT structure. There will be no restitution, as pre-processed data are expected.')
|
||||||
|
if wfpath_extension != 'processed':
|
||||||
|
print('WARNING: Expecting wfpath_extension to be "processed" for'
|
||||||
|
' pre-processed data but received "{}" instead!!!'.format(wfpath_extension))
|
||||||
|
|
||||||
if not input_dict:
|
if not input_dict:
|
||||||
# started in production mode
|
# started in production mode
|
||||||
datapath = datastructure.expandDataPath()
|
datapath = datastructure.expandDataPath()
|
||||||
@ -184,16 +194,16 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
events = [events for events in glob.glob(os.path.join(datapath, '*')) if os.path.isdir(events)]
|
events = [events for events in glob.glob(os.path.join(datapath, '*')) if os.path.isdir(events)]
|
||||||
elif fnames == 'None' and parameter['eventID'] is not '*' and not type(parameter['eventID']) == list:
|
elif fnames == 'None' and parameter['eventID'] is not '*' and not type(parameter['eventID']) == list:
|
||||||
# single event processing
|
# single event processing
|
||||||
events = glob.glob(os.path.join(datapath, parameter['eventID']))
|
events = glob.glob(os.path.join(datapath, parameter['eventID'], wfpath_extension))
|
||||||
elif fnames == 'None' and type(parameter['eventID']) == list:
|
elif fnames == 'None' and type(parameter['eventID']) == list:
|
||||||
# multiple event processing
|
# multiple event processing
|
||||||
events = []
|
events = []
|
||||||
for eventID in parameter['eventID']:
|
for eventID in parameter['eventID']:
|
||||||
events.append(os.path.join(datapath, eventID))
|
events.append(os.path.join(datapath, eventID, wfpath_extension))
|
||||||
else:
|
else:
|
||||||
# autoPyLoT was initialized from GUI
|
# autoPyLoT was initialized from GUI
|
||||||
events = []
|
events = []
|
||||||
events.append(eventid)
|
events.append(os.path.join(eventid, wfpath_extension))
|
||||||
evID = os.path.split(eventid)[-1]
|
evID = os.path.split(eventid)[-1]
|
||||||
locflag = 2
|
locflag = 2
|
||||||
else:
|
else:
|
||||||
@ -204,7 +214,8 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
for eventID in eventid:
|
for eventID in eventid:
|
||||||
events.append(os.path.join(datapath,
|
events.append(os.path.join(datapath,
|
||||||
parameter['database'],
|
parameter['database'],
|
||||||
eventID))
|
eventID,
|
||||||
|
wfpath_extension))
|
||||||
|
|
||||||
if not events:
|
if not events:
|
||||||
print('autoPyLoT: No events given. Return!')
|
print('autoPyLoT: No events given. Return!')
|
||||||
@ -218,7 +229,10 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
allpicks = {}
|
allpicks = {}
|
||||||
glocflag = locflag
|
glocflag = locflag
|
||||||
for eventpath in events:
|
for eventpath in events:
|
||||||
evID = os.path.split(eventpath)[-1]
|
if not wfpath_extension:
|
||||||
|
evID = os.path.split(eventpath)[-1]
|
||||||
|
else:
|
||||||
|
evID = os.path.split(os.path.split(eventpath)[0])[-1]
|
||||||
fext = '.xml'
|
fext = '.xml'
|
||||||
filename = os.path.join(eventpath, 'PyLoT_' + evID + fext)
|
filename = os.path.join(eventpath, 'PyLoT_' + evID + fext)
|
||||||
try:
|
try:
|
||||||
@ -267,13 +281,17 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
wfdat = check4gaps(wfdat)
|
wfdat = check4gaps(wfdat)
|
||||||
wfdat = check4doubled(wfdat)
|
wfdat = check4doubled(wfdat)
|
||||||
wfdat = trim_station_components(wfdat, trim_start=True, trim_end=False)
|
wfdat = trim_station_components(wfdat, trim_start=True, trim_end=False)
|
||||||
metadata = read_metadata(parameter.get('invdir'))
|
if not wfpath_extension:
|
||||||
# rotate stations to ZNE
|
metadata = read_metadata(parameter.get('invdir'))
|
||||||
wfdat = check4rotated(wfdat, metadata)
|
else:
|
||||||
|
metadata = None
|
||||||
corr_dat = None
|
corr_dat = None
|
||||||
if locflag:
|
if metadata:
|
||||||
print("Restitute data ...")
|
# rotate stations to ZNE
|
||||||
corr_dat = restitute_data(wfdat.copy(), *metadata, ncores=ncores)
|
wfdat = check4rotated(wfdat, metadata)
|
||||||
|
if locflag:
|
||||||
|
print("Restitute data ...")
|
||||||
|
corr_dat = restitute_data(wfdat.copy(), *metadata, ncores=ncores)
|
||||||
if not corr_dat and locflag:
|
if not corr_dat and locflag:
|
||||||
locflag = 2
|
locflag = 2
|
||||||
print('Working on event %s. Stations: %s' % (eventpath, station))
|
print('Working on event %s. Stations: %s' % (eventpath, station))
|
||||||
|
@ -283,6 +283,8 @@ def autopickstation(wfstream, pickparam, verbose=False,
|
|||||||
if use_taup is True:
|
if use_taup is True:
|
||||||
Lc = np.inf
|
Lc = np.inf
|
||||||
print('autopickstation: use_taup flag active.')
|
print('autopickstation: use_taup flag active.')
|
||||||
|
if not metadata:
|
||||||
|
metadata = [None, None]
|
||||||
if not metadata[1]:
|
if not metadata[1]:
|
||||||
print('Warning: Could not use TauPy to estimate onsets as there are no metadata given.')
|
print('Warning: Could not use TauPy to estimate onsets as there are no metadata given.')
|
||||||
else:
|
else:
|
||||||
|
@ -78,7 +78,7 @@ class CharacteristicFunction(object):
|
|||||||
return self.cut
|
return self.cut
|
||||||
|
|
||||||
def setCut(self, cut):
|
def setCut(self, cut):
|
||||||
self.cut = cut
|
self.cut = (int(cut[0]), int(cut[1]))
|
||||||
|
|
||||||
def getTime1(self):
|
def getTime1(self):
|
||||||
return self.t1
|
return self.t1
|
||||||
|
Loading…
Reference in New Issue
Block a user