From 231e7dafa93d00ade36a222109c604db79a2cca5 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Wed, 28 Sep 2016 11:01:09 +0200 Subject: [PATCH] [new] added a function to easily add amplitude information to a given Obspy event object --- pylot/core/io/phases.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index d3064f6f..7871f4bb 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -15,6 +15,24 @@ from pylot.core.pick.utils import select_for_phase from pylot.core.util.utils import getOwner, full_range, four_digits +def add_amplitudes(event, amplitudes): + amplitude_list = [] + for pick in event.picks: + try: + a0 = amplitudes[pick.waveform_id.station_code] + amplitude = ope.Amplitude(generic_amplitude=a0 * 1e-3) + amplitude.unit = 'm' + amplitude.category = 'point' + amplitude.waveform_id = pick.waveform_id + amplitude.magnitude_hint = 'ML' + amplitude.pick_id = pick.resource_id + amplitude.type = 'AML' + amplitude_list.append(amplitude) + except KeyError: + continue + event.amplitudes = amplitude_list + return event + def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs): """ readPILOTEvent - function @@ -549,4 +567,4 @@ def merge_picks(event, picks): if p.waveform_id.station_code == station and p.phase_hint == phase: p.time, p.time_errors = time, err del time, err, phase, station - return event \ No newline at end of file + return event