From 5a87d0d3b363c7515ecc17e50330c3df7a460e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Thu, 2 Mar 2017 11:11:00 +0100 Subject: [PATCH] Additional phase export formated for hypoDD. --- pylot/core/io/phases.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index 842fecba..e5435e8e 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import pdb import glob import obspy.core.event as ope import os @@ -656,6 +655,33 @@ def writephases(arrivals, fformat, filename, parameter, eventinfo=None): fid.write('%-4sS%d%6.2f\n' % (stat, Sweight, Srt)) fid.close() + elif fformat == 'hypoDD': + print ("Writing phases to %s for hypoDD" % filename) + fid = open("%s" % filename, 'w') + # get event information needed for hypoDD-phase file + eventsource = eventinfo.origins[0] + stime = eventsource['time'] + event = parameter.get('eventID') + hddID = event.split('.')[0][1:5] + # write header + fid.write('# %d %d %d %d %d %5.2f %7.4f +%6.4f %7.4f %4.2f 0.1 0.5 %4.2f %s\n' % ( + stime.year, stime.month, stime.day, stime.hour, stime.minute, stime.second, + eventsource['latitude'], eventsource['longitude'], eventsource['depth'] / 1000, + eventinfo.magnitudes[0]['mag'], eventsource['quality']['standard_error'], hddID)) + for key in arrivals: + if arrivals[key].has_key('P'): + # P onsets + if arrivals[key]['P']['weight'] < 4: + Ponset = arrivals[key]['P']['mpp'] + Prt = Ponset - stime # onset time relative to source time + fid.write('%s %6.3f 1 P\n' % (key, Prt)) + # S onsets + if arrivals[key]['S']['weight'] < 4: + Sonset = arrivals[key]['S']['mpp'] + Srt = Sonset - stime # onset time relative to source time + fid.write('%s %6.3f 1 S\n' % (key, Srt)) + + fid.close() def merge_picks(event, picks): """