Still in progress: flexible local magnitude estimation.

This commit is contained in:
Ludger Küperkoch 2017-06-21 16:42:26 +02:00
parent 477aacbb4a
commit 9f164fc075
2 changed files with 21 additions and 10 deletions

View File

@ -253,8 +253,8 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
picks[station]['P'].update(props) picks[station]['P'].update(props)
evt = moment_mag.updated_event() evt = moment_mag.updated_event()
local_mag = LocalMagnitude(corr_dat, evt, local_mag = LocalMagnitude(corr_dat, evt,
parameter.get('sstop'), True,\ parameter.get('sstop'), parameter.get('WAscaling'), \
iplot) True, iplot)
for station, amplitude in local_mag.amplitudes.items(): for station, amplitude in local_mag.amplitudes.items():
picks[station]['S']['Ao'] = amplitude.generic_amplitude picks[station]['S']['Ao'] = amplitude.generic_amplitude
evt = local_mag.updated_event() evt = local_mag.updated_event()
@ -311,8 +311,8 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
picks[station]['P'].update(props) picks[station]['P'].update(props)
evt = moment_mag.updated_event() evt = moment_mag.updated_event()
local_mag = LocalMagnitude(corr_dat, evt, local_mag = LocalMagnitude(corr_dat, evt,
parameter.get('sstop'), True, \ parameter.get('sstop'), parameter.get('WAscaling'), \
iplot) True, iplot)
for station, amplitude in local_mag.amplitudes.items(): for station, amplitude in local_mag.amplitudes.items():
picks[station]['S']['Ao'] = amplitude.generic_amplitude picks[station]['S']['Ao'] = amplitude.generic_amplitude
evt = local_mag.updated_event() evt = local_mag.updated_event()

View File

@ -38,10 +38,10 @@ class Magnitude(object):
def __init__(self, stream, event, verbosity=False, iplot=0): def __init__(self, stream, event, verbosity=False, iplot=0):
self._type = "M" self._type = "M"
self._stream = stream
self._plot_flag = iplot self._plot_flag = iplot
self._verbosity = verbosity self._verbosity = verbosity
self._event = event self._event = event
self._stream = stream
self._magnitudes = dict() self._magnitudes = dict()
def __str__(self): def __str__(self):
@ -153,10 +153,11 @@ class LocalMagnitude(Magnitude):
_amplitudes = dict() _amplitudes = dict()
def __init__(self, stream, event, calc_win, verbosity=False, iplot=0): def __init__(self, stream, event, calc_win, wascaling=None, verbosity=False, iplot=0):
super(LocalMagnitude, self).__init__(stream, event, verbosity, iplot) super(LocalMagnitude, self).__init__(stream, event, verbosity, iplot)
self._calc_win = calc_win self._calc_win = calc_win
self._wascaling = wascaling
self._type = 'ML' self._type = 'ML'
self.calc() self.calc()
@ -168,6 +169,10 @@ class LocalMagnitude(Magnitude):
def calc_win(self, value): def calc_win(self, value):
self._calc_win = value self._calc_win = value
@property
def wascaling(self):
return self._wascaling
@property @property
def amplitudes(self): def amplitudes(self):
return self._amplitudes return self._amplitudes
@ -251,10 +256,16 @@ class LocalMagnitude(Magnitude):
self.event.amplitudes.append(amplitude) self.event.amplitudes.append(amplitude)
self.amplitudes = (station, amplitude) self.amplitudes = (station, amplitude)
# using standard Gutenberg-Richter relation # using standard Gutenberg-Richter relation
# TODO make the ML calculation more flexible by allowing # or scale WA amplitude with given scaling relation
# use of custom relation functions if self.wascaling == None:
magnitude = ope.StationMagnitude( print("Calculating original Richter magnitude ...")
mag=np.log10(a0) + richter_magnitude_scaling(delta)) magnitude = ope.StationMagnitude(mag=np.log10(a0) \
+ richter_magnitude_scaling(delta))
else:
print("Calculating scaled local magnitude ...")
magnitude = ope.StationMagnitude(mag=np.log10(a0) \
+ self.wascaling[0] * np.log10(delta) + self.wascaling[1]
* delta + self.wascaling[2])
magnitude.origin_id = self.origin_id magnitude.origin_id = self.origin_id
magnitude.waveform_id = pick.waveform_id magnitude.waveform_id = pick.waveform_id
magnitude.amplitude_id = amplitude.resource_id magnitude.amplitude_id = amplitude.resource_id