From c52277e4a2271ea653b25daee84167c0b6235611 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Mon, 26 Sep 2016 15:55:56 +0200 Subject: [PATCH] [new] added attributes, properties and special method __str__ to the Magnitude superclass -> improves significantly convenience of sub-class programming --- pylot/core/analysis/magnitude.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index 7d6a29e4..4a3cef8f 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -32,10 +32,26 @@ class Magnitude(object): Base class object for Magnitude calculation within PyLoT. """ - def __init__(self, stream): + def __init__(self, stream, event, verbosity=False): + self._plot_flag = False + self._verbosity = verbosity + self._event = event self._stream = stream self._magnitudes = dict() + def __str__(self): + print('number of stations used: {0}\n'.format(len(self.magnitudes.values()))) + print('\tstation\tmagnitude') + for s, m in self.magnitudes.items(): print('\t{0}\t{1}'.format(s, m)) + + @property + def plot_flag(self): + return self._plot_flag + + @plot_flag.setter + def plot_flag(self, value): + self._plot_flag = value + @property def stream(self): return self._stream @@ -44,6 +60,14 @@ class Magnitude(object): def stream(self, value): self._stream = value + @property + def event(self): + return self._event + + @property + def arrivals(self): + return self._event.origins[0].arrivals + @property def magnitudes(self): return self._magnitudes @@ -233,8 +257,8 @@ class RichterMagnitude(Magnitude): 'sensitivity': 1 } - def __init__(self, stream, t0, calc_win): - super(RichterMagnitude, self).__init__(stream) + def __init__(self, stream, event, t0, calc_win, verbosity=False): + super(RichterMagnitude, self).__init__(stream, event, verbosity) self._t0 = t0 self._calc_win = calc_win