From 69a023e04842a6d331799c01e6ee2b6a4c23383a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Mon, 26 Oct 2015 09:41:02 +0100 Subject: [PATCH] Introduced new function for writing phases files for various kinds of location tools. --- pylot/core/pick/utils.py | 46 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 16fd2cec..233bb70d 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -7,7 +7,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 @@ -74,7 +74,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None): # if EPick stays NaN the signal window size will be doubled while np.isnan(EPick): if count > 0: - print("\nearllatepicker: Doubled signal window size %s time(s) " + print("earllatepicker: Doubled signal window size %s time(s) " "because of NaN for earliest pick." %count) isigDoubleWinStart = pis[-1] + 1 isignalDoubleWin = np.arange(isigDoubleWinStart, @@ -928,6 +928,48 @@ def checkZ4S(X, pick, zfac, checkwin, iplot): return returnflag + +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 + + :param: arrivals + :type: dictionary containing all phase information including + station ID, phase, first motion, weight (uncertainty), + .... + + :param: fformat + :type: string, chosen file format (location routine), + choose between NLLoc, HYPO71, HYPOSAT, VELEST, + HYPOINVERSE, and hypoDD + + :param: filename, full path and name of phase file + :type: string + ''' + + + if fformat == 'NLLoc': + print ("Writing phases to %s for NLLoc" % filename) + fid = open("%s" % filename, 'w') + # write header + fid.write('# EQEVENT: Label: EQ001 Loc: X 0.00 Y 0.00 Z 10.00 OT 0.00 \n') + for key in arrivals: + if arrivals[key]['P']['weight'] < 4: + # NLLoc only knows weight 0 (do not use pick) + # and weight 1 (use pick) + NLLocweight = 1 + # write phase information to file + fid.write('%s \n' % key) + + fid.close() + + + + + if __name__ == '__main__': import doctest doctest.testmod()