From 85829b22ebb28421df2b7fa9e72ec2747f870528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Wed, 28 Jun 2017 12:38:21 +0200 Subject: [PATCH] Write header in ObsPy-generated NLLoc-observation file. --- pylot/core/io/data.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index 47e74053..a5449092 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -187,12 +187,23 @@ class Data(object): self.get_evt_data().write(fnout + fnext, format=evtformat) # try exporting event via ObsPy - else: + elif fnext == '.obs': try: self.get_evt_data().write(fnout + fnext, format=evtformat) except KeyError as e: raise KeyError('''{0} export format 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): """