autoPyLoT appends manual picks to xml-file, and manualPyLoT appends automatic picks to xml-file.

This commit is contained in:
Ludger Küperkoch 2017-06-26 14:47:36 +02:00
parent b0405cf213
commit bec8604904
2 changed files with 30 additions and 7 deletions

View File

@ -353,7 +353,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
if evt is not None:
data.applyEVTData(evt, 'event')
fnqml = '%s/PyLoT_%s' % (event, evID)
data.exportEvent(fnqml)
data.exportEvent(fnqml, fnext='.xml', fcheck='manual')
# HYPO71
hypo71file = '%s/PyLoT_%s_HYPO71_phases' % (event, evID)
hypo71.export(picks, hypo71file, parameter)

View File

@ -145,12 +145,13 @@ class Data(object):
# handle forbidden filenames especially on windows systems
return fnConstructor(str(ID))
def exportEvent(self, fnout, fnext='.xml'):
def exportEvent(self, fnout, fnext='.xml', fcheck='auto'):
"""
:param fnout:
:param fnext:
:param fcheck:
:raise KeyError:
"""
from pylot.core.util.defaults import OUTPUTFORMATS
@ -162,7 +163,29 @@ class Data(object):
'supported'.format(e, fnext)
raise FormatError(errmsg)
# check for already existing xml-file
if fnext == '.xml':
if os.path.isfile(fnout + fnext):
print("xml-file already exists! Check content ...")
cat_old = read_events(fnout + fnext)
checkflag = 0
for j in range(len(cat_old.events[0].picks)):
if cat_old.events[0].picks[j].method_id.id.split('/')[1] == fcheck:
print("Found %s pick(s), append to new catalog." % fcheck)
checkflag = 1
break
if checkflag == 1:
self.get_evt_data().write(fnout + fnext, format=evtformat)
cat_new = read_events(fnout + fnext)
cat_new.append(cat_old.events[0])
cat_new.write(fnout + fnext, format=evtformat)
else:
self.get_evt_data().write(fnout + fnext, format=evtformat)
else:
self.get_evt_data().write(fnout + fnext, format=evtformat)
# try exporting event via ObsPy
else:
try:
self.get_evt_data().write(fnout + fnext, format=evtformat)
except KeyError as e: