Write header in ObsPy-generated NLLoc-observation file.

This commit is contained in:
Ludger Küperkoch 2017-06-28 12:38:21 +02:00
parent cb1fb60eec
commit 85829b22eb

View File

@ -187,12 +187,23 @@ class Data(object):
self.get_evt_data().write(fnout + fnext, format=evtformat) self.get_evt_data().write(fnout + fnext, format=evtformat)
# try exporting event via ObsPy # try exporting event via ObsPy
else: elif fnext == '.obs':
try: try:
self.get_evt_data().write(fnout + fnext, format=evtformat) self.get_evt_data().write(fnout + fnext, format=evtformat)
except KeyError as e: except KeyError as e:
raise KeyError('''{0} export format raise KeyError('''{0} export format
not implemented: {1}'''.format(evtformat, e)) not implemented: {1}'''.format(evtformat, e))
# write header afterwards
evtdata = self.get_evt_data()
evid = str(evtdata.resource_id).split('/')[1]
header = '# EQEVENT: Label: EQ%s Loc: X 0.00 Y 0.00 Z 10.00 OT 0.00 \n' % evid
nllocfile = open(fnout + fnext)
l = nllocfile.readlines()
nllocfile.close()
l.insert(0, header)
nllocfile = open(fnout + fnext, 'w')
nllocfile.write("".join(l))
nllocfile.close()
def getComp(self): def getComp(self):
""" """