From c59775e6cde7fb1bf4b503634e184feca3a6db5b Mon Sep 17 00:00:00 2001 From: Rigdon <arigdon@igskcicgltgm031.gs.doi.net> Date: Tue, 8 Aug 2017 11:37:50 -0600 Subject: [PATCH] Added more compatibility to observatory and channel initializations --- geomagio/algorithm/AverageAlgorithm.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/geomagio/algorithm/AverageAlgorithm.py b/geomagio/algorithm/AverageAlgorithm.py index f030fd0e3..b716ecf57 100644 --- a/geomagio/algorithm/AverageAlgorithm.py +++ b/geomagio/algorithm/AverageAlgorithm.py @@ -29,11 +29,13 @@ class AverageAlgorithm(Algorithm): """ - def __init__(self): + def __init__(self, observatories=None, channel=None): Algorithm.__init__(self) self._npts = -1 self._stt = -1 self._stats = None + self.obs = observatories + self.ch = channel self.observatoryMetadata = ObservatoryMetadata() def check_stream(self, timeseries): @@ -46,6 +48,23 @@ class AverageAlgorithm(Algorithm): stream to be checked. """ + # Initialize observatories based on either command arguments + # or _init_ inputs + if self.obs: + self.observatories = self.obs + if not hasattr(self, 'observatories'): + obs = [] + for series in timeseries: + obs.append(series.stats.station) + self.observatories = obs + + # Initialize channel based on either command arguments or + # _init_ inputs + if self.ch: + self.outchannel = self.ch + if not hasattr(self, 'outchannel'): + self.outchannel = timeseries[0].stats.channel + # A stream produced by EdgeFactory should always pass these checks. # must have only one channel for each observatory -- GitLab