From b8c26a6588dde1e6fb9aca120adfb3d912256bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Wed, 4 Nov 2015 16:52:39 +0100 Subject: [PATCH 1/4] Implemented extended function writephases for writing phases to HYPO71-input phase file. --- autoPyLoT.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/autoPyLoT.py b/autoPyLoT.py index 1e60e54d..06a3bdef 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -113,7 +113,7 @@ def autoPyLoT(inputfile): # write phases to NLLoc-phase file writephases(picks, 'NLLoc', phasefile) - # For locating the events we have to modify the NLLoc-control file! + # For locating the event the NLLoc-control file has to be modified! # create comment line for NLLoc-control file # NLLoc-output file nllocout = '%s/loc/%s_%s' % (nllocroot, event, nllocoutpatter) @@ -155,7 +155,7 @@ def autoPyLoT(inputfile): # write phases to NLLoc-phase file writephases(picks, 'NLLoc', phasefile) - # For locating the event we have to modify the NLLoc-control file! + # For locating the event the NLLoc-control file has to be modified! # create comment line for NLLoc-control file NLLoc-output file nllocout = '%s/loc/%s_%s' % (nllocroot, parameter.getParam('eventID'), nllocoutpatter) locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0' % (phasefile, ttpatter, nllocout) @@ -174,9 +174,13 @@ def autoPyLoT(inputfile): # locate the event subprocess.call([nlloccall, locfile]) ########################################################## + # write phase files for various location routines + # HYPO71 + hypo71file = '%s/%s/autoPyLoT_HYPO71.pha' % (datapath, parameter.getParam('eventID')) + writephases(picks, 'HYPO71', hypo71file) + - print '------------------------------------------' print '-------Finished event %s!-------' % parameter.getParam('eventID') print '------------------------------------------' From 3fa4a3197829a9f2ea7c9f8ce0bd7835daa81358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Wed, 4 Nov 2015 16:53:03 +0100 Subject: [PATCH 2/4] Extended function writephases for writing phases to HYPO71-input phase file. --- pylot/core/pick/utils.py | 77 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 28de1716..8319d90a 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -8,7 +8,7 @@ :author: Ludger Kueperkoch / MAGS2 EP3 working group """ - +import pdb import numpy as np import matplotlib.pyplot as plt from obspy.core import Stream, UTCDateTime @@ -937,7 +937,7 @@ def writephases(arrivals, fformat, filename): Function of methods to write phases to the following standard file formats used for locating earthquakes: - HYPO71, NLLoc, VELEST, HYPOSAT, HYPOINVERSE and hypoDD + HYPO71, NLLoc, VELEST, HYPOSAT, and hypoDD :param: arrivals :type: dictionary containing all phase information including @@ -999,11 +999,80 @@ def writephases(arrivals, fformat, filename): mm, ss_ms)) - fid.close() + elif fformat == 'HYPO71': + print ("Writing phases to %s for HYPO71" % filename) + fid = open("%s" % filename, 'w') + # write header + fid.write(' EQ001\n') + for key in arrivals: + if arrivals[key]['P']['weight'] < 4: + Ponset = arrivals[key]['P']['mpp'] + Sonset = arrivals[key]['S']['mpp'] + pweight = arrivals[key]['P']['weight'] + sweight = arrivals[key]['S']['weight'] + fm = arrivals[key]['P']['fm'] + if fm is None: + fm = '-' + Ao = arrivals[key]['S']['Ao'] + if Ao is None: + Ao = '' + else: + Ao = str('%7.2f' % Ao) + year = Ponset.year + if year >= 2000: + year = year -2000 + else: + year = year - 1900 + month = Ponset.month + day = Ponset.day + hh = Ponset.hour + mm = Ponset.minute + ss = Ponset.second + ms = Ponset.microsecond + ss_ms = ss + ms / 1000000.0 + if pweight < 2: + pstr = 'I' + elif pweight >= 2: + pstr = 'E' + if arrivals[key]['S']['weight'] < 4: + Sss = Sonset.second + Sms = Sonset.microsecond + Sss_ms = Sss + Sms / 1000000.0 + Sss_ms = str('%5.02f' % Sss_ms) + if sweight < 2: + sstr = 'I' + elif sweight >= 2: + sstr = 'E' + fid.write('%s%sP%s%d %02d%02d%02d%02d%02d%5.2f %s%sS %d %s\n' % (key, + pstr, + fm, + pweight, + year, + month, + day, + hh, + mm, + ss_ms, + Sss_ms, + sstr, + sweight, + Ao)) + else: + fid.write('%s%sP%s%d %02d%02d%02d%02d%02d%5.2f %s\n' % (key, + pstr, + fm, + pweight, + year, + month, + day, + hh, + mm, + ss_ms, + Ao)) - + fid.close() if __name__ == '__main__': From 686395defc9404f807861ed1e32af5e1f71bd23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Thu, 5 Nov 2015 08:49:44 +0100 Subject: [PATCH 3/4] Marginal changes --- autoPyLoT.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/autoPyLoT.py b/autoPyLoT.py index 1d6fb6cf..ecef9770 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -172,17 +172,12 @@ def autoPyLoT(inputfile): # locate the event subprocess.call([nlloccall, locfile]) ########################################################## -<<<<<<< HEAD # write phase files for various location routines # HYPO71 hypo71file = '%s/%s/autoPyLoT_HYPO71.pha' % (datapath, parameter.getParam('eventID')) writephases(picks, 'HYPO71', hypo71file) -======= - ->>>>>>> 223902f2d4a9fe992730bb1ba925bfa432f26550 - print '------------------------------------------' print '-------Finished event %s!-------' % parameter.getParam('eventID') print '------------------------------------------' From d74aeb237c86a0fc2983362112eaa629043b5d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Thu, 5 Nov 2015 08:51:50 +0100 Subject: [PATCH 4/4] Implemented phase writing in multiple event processing mode. --- autoPyLoT.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoPyLoT.py b/autoPyLoT.py index ecef9770..71a8031f 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -131,6 +131,10 @@ def autoPyLoT(inputfile): # locate the event subprocess.call([nlloccall, locfile]) ########################################################## + # write phase files for various location routines + # HYPO71 + hypo71file = '%s/%s/autoPyLoT_HYPO71.pha' % (datapath, eventID) + writephases(picks, 'HYPO71', hypo71file) print '------------------------------------------' print '-----Finished event %s!-----' % event