From db7686112450021de9778185a805dc707ed93ce3 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling Date: Fri, 25 Jul 2014 14:16:11 +0200 Subject: [PATCH] added write support for Events in QuakeML and JSON format utilizing ObsPy --- pylot/core/read/data.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pylot/core/read/data.py b/pylot/core/read/data.py index a61ae69b..ab9b57ec 100644 --- a/pylot/core/read/data.py +++ b/pylot/core/read/data.py @@ -3,7 +3,8 @@ import os from obspy.core import (read, Stream) -from obspy.core.event import Event +from obspy.core.event import (Event, Catalog) +from pylot.core.util import fnConstructor class Data(object): @@ -44,6 +45,25 @@ class Data(object): else: self.evtdata = Event() + def exportEvent(self, fnout=None, format='QUAKEML'): + + if fnout is None: + fnout = self.event.resource_id.__str__().split('/')[-1] + # handle forbidden filenames especially on windows systems + fnout = fnConstructor(fnout) + + format = format.upper().strip() + + # export event to QuakeML or JSON via ObsPy + if format in 'QUAKEML' or 'JSON': + cat = Catalog() + cat.append(self.event) + cat.write(fnout + format.lower(), format=format) + + # export event to VelEst format + if format in 'VELEST': + pass + class GenericDataStructure(object): '''