Flexible calculation of local magnitude including station magntiude scaling as well as network magnitude scaling.

auoPyLot-output-file names have prefix event ID.
This commit is contained in:
Ludger Küperkoch 2017-06-22 15:04:16 +02:00
parent 8e8b3e0462
commit 71876638c8
4 changed files with 55 additions and 36 deletions

View File

@ -18,7 +18,7 @@ import pylot.core.loc.nll as nll
#from PySide.QtGui import QWidget, QInputDialog
from pylot.core.analysis.magnitude import MomentMagnitude, LocalMagnitude
from pylot.core.io.data import Data
from pylot.core.io.inputs import PylotParameter
from pylot.core.io.inputs import AutoPickParameter
from pylot.core.pick.autopick import autopickevent, iteratepicker
from pylot.core.util.dataprocessing import restitute_data, read_metadata, \
remove_underscores
@ -35,7 +35,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
:param inputfile: path to the input file containing all parameter
information for automatic picking (for formatting details, see.
`~pylot.core.io.inputs.PylotParameter`
`~pylot.core.io.inputs.AutoPickParameter`
:type inputfile: str
:return:
@ -71,13 +71,13 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
if not parameter:
if inputfile:
parameter = PylotParameter(inputfile)
parameter = AutoPickParameter(inputfile)
iplot = parameter['iplot']
else:
print('No parameters set and no input file given. Choose either of both.')
return
else:
if not type(parameter) == PylotParameter:
if not type(parameter) == AutoPickParameter:
print('Wrong input type for parameter: {}'.format(type(parameter)))
return
if inputfile:
@ -252,12 +252,17 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
for station, props in moment_mag.moment_props.items():
picks[station]['P'].update(props)
evt = moment_mag.updated_event()
net_mw = moment_mag.net_magnitude()
print("Network moment magnitude: %4.1f" % net_mw.mag)
# calculate local (Richter) magntiude
local_mag = LocalMagnitude(corr_dat, evt,
parameter.get('sstop'), parameter.get('WAscaling'), \
True, iplot)
for station, amplitude in local_mag.amplitudes.items():
picks[station]['S']['Ao'] = amplitude.generic_amplitude
evt = local_mag.updated_event()
evt = local_mag.updated_event(parameter.get('magscaling'))
net_ml = local_mag.net_magnitude()
print("Network local magnitude: %4.1f" % net_ml.mag)
else:
print("autoPyLoT: No NLLoc-location file available!")
print("No source parameter estimation possible!")
@ -310,14 +315,17 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
for station, props in moment_mag.moment_props.items():
picks[station]['P'].update(props)
evt = moment_mag.updated_event()
net_mw = moment_mag.net_magnitude()
print("Network moment magnitude: %4.1f" % net_mw.mag)
# calculate local (Richter) magntiude
local_mag = LocalMagnitude(corr_dat, evt,
parameter.get('sstop'), parameter.get('WAscaling'), \
True, iplot)
for station, amplitude in local_mag.amplitudes.items():
picks[station]['S']['Ao'] = amplitude.generic_amplitude
evt = local_mag.updated_event()
net_mw = moment_mag.net_magnitude()
print("Network moment magnitude: %4.1f" % net_mw.mag)
evt = local_mag.updated_event(parameter.get('magscaling'))
net_ml = local_mag.net_magnitude(parameter.get('magscaling'))
print("Network local magnitude: %4.1f" % net_ml.mag)
else:
print("autoPyLoT: No NLLoc-location file available! Stop iteration!")
locflag = 9
@ -328,26 +336,26 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
data.applyEVTData(picks)
if evt is not None:
data.applyEVTData(evt, 'event')
fnqml = '%s/autoPyLoT' % event
fnqml = '%s/picks_%s' % (event, evID)
data.exportEvent(fnqml)
# HYPO71
hypo71file = '%s/autoPyLoT_HYPO71_phases' % event
hypo71file = '%s/%s_HYPO71_phases' % (event, evID)
hypo71.export(picks, hypo71file, parameter)
# HYPOSAT
hyposatfile = '%s/autoPyLoT_HYPOSAT_phases' % event
hyposatfile = '%s/%s_HYPOSAT_phases' % (event, evID)
hyposat.export(picks, hyposatfile, parameter)
if locflag == 1:
# VELEST
velestfile = '%s/autoPyLoT_VELEST_phases.cnv' % event
velestfile = '%s/%s_VELEST_phases.cnv' % (event, evID)
velest.export(picks, velestfile, parameter, evt)
# hypoDD
hypoddfile = '%s/autoPyLoT_hypoDD_phases.pha' % event
hypoddfile = '%s/%s_hypoDD_phases.pha' % (event, evID)
hypodd.export(picks, hypoddfile, parameter, evt)
# FOCMEC
focmecfile = '%s/autoPyLoT_FOCMEC.in' % event
focmecfile = '%s/%s_FOCMEC.in' % (event, evID)
focmec.export(picks, focmecfile, parameter, evt)
# HASH
hashfile = '%s/autoPyLoT_HASH' % event
hashfile = '%s/%s_HASH' % (event, evID)
hash.export(picks, hashfile, parameter, evt)
endsplash = '''------------------------------------------\n'

View File

@ -1 +1 @@
f91e1-dirty
8e8b-dirty

View File

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
"""
Created autumn/winter 2015.
Revised/extended summer 2017.
:author: Ludger Küperkoch / MAGS2 EP3 working group
"""
@ -115,17 +116,24 @@ class Magnitude(object):
def calc(self):
pass
def updated_event(self):
self.event.magnitudes.append(self.net_magnitude())
def updated_event(self, magscaling=None):
self.event.magnitudes.append(self.net_magnitude(magscaling))
return self.event
def net_magnitude(self):
def net_magnitude(self, magscaling=None):
if self:
# TODO if an average Magnitude instead of the median is calculated
# StationMagnitudeContributions should be added to the returned
# Magnitude object
# mag_error => weights (magnitude error estimate from peak_to_peak, calcsourcespec?)
# weights => StationMagnitdeContribution
if magscaling is not None and str(magscaling) is not '[0.0, 0.0]':
# scaling necessary
print("Scaling network magnitude ...")
mag = ope.Magnitude(
mag=np.median([M.mag for M in self.magnitudes.values()]) *\
magscaling[0] + magscaling[1],
magnitude_type=self.type,
origin_id=self.origin_id,
station_count=len(self.magnitudes),
azimuthal_gap=self.origin_id.get_referred_object().quality.azimuthal_gap)
else:
# no saling necessary
mag = ope.Magnitude(
mag=np.median([M.mag for M in self.magnitudes.values()]),
magnitude_type=self.type,
@ -153,7 +161,7 @@ class LocalMagnitude(Magnitude):
_amplitudes = dict()
def __init__(self, stream, event, calc_win, wascaling=None, verbosity=False, iplot=0):
def __init__(self, stream, event, calc_win, wascaling, verbosity=False, iplot=0):
super(LocalMagnitude, self).__init__(stream, event, verbosity, iplot)
self._calc_win = calc_win
@ -257,12 +265,13 @@ class LocalMagnitude(Magnitude):
self.amplitudes = (station, amplitude)
# using standard Gutenberg-Richter relation
# or scale WA amplitude with given scaling relation
if self.wascaling == None:
if str(self.wascaling) == '[0.0, 0.0, 0.0]':
print("Calculating original Richter magnitude ...")
magnitude = ope.StationMagnitude(mag=np.log10(a0) \
+ richter_magnitude_scaling(delta))
else:
print("Calculating scaled local magnitude ...")
a0 = a0 * 1e03 # mm to nm (see Havskov & Ottemöller, 2010)
magnitude = ope.StationMagnitude(mag=np.log10(a0) \
+ self.wascaling[0] * np.log10(delta) + self.wascaling[1]
* delta + self.wascaling[2])

View File

@ -278,12 +278,14 @@ defaults = {'rootpath': {'type': str,
'value': 1.0},
'WAscaling': {'type': (float, float, float),
'tooltip': 'Scaling relation (log(Ao)+Alog(r)+Br+C) of Wood-Anderson amplitude Ao [nm]',
'value': (1.0, 1.0, 1.0)},
'tooltip': 'Scaling relation (log(Ao)+Alog(r)+Br+C) of Wood-Anderson amplitude Ao [nm] \
If zeros are set, original Richter magnitude is calculated!',
'value': (0., 0., 0.)},
'magscaling': {'type': (float, float),
'tooltip': 'Scaling relation for derived local magnitude [a*Ml+b]',
'value': (1.0, 1.0)}
'tooltip': 'Scaling relation for derived local magnitude [a*Ml+b]. \
If zeros are set, no scaling is of network magnitude is applied.',
'value': (0., 0.)}
}
settings_main={