diff --git a/geomagio/algorithm/AverageAlgorithm.py b/geomagio/algorithm/AverageAlgorithm.py index b716ecf576122bf1856bc3cd93caed2963e61b6e..c09476e474124bab76dc298e8c5ac2e69ce242bc 100644 --- a/geomagio/algorithm/AverageAlgorithm.py +++ b/geomagio/algorithm/AverageAlgorithm.py @@ -34,8 +34,8 @@ class AverageAlgorithm(Algorithm): self._npts = -1 self._stt = -1 self._stats = None - self.obs = observatories - self.ch = channel + self.observatories = observatories + self.outchannel = channel self.observatoryMetadata = ObservatoryMetadata() def check_stream(self, timeseries): @@ -48,23 +48,6 @@ 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 @@ -105,6 +88,11 @@ class AverageAlgorithm(Algorithm): new stream object containing the averaged values. """ + # If outchannel is not initialized it defaults to the + # channel input channel + if not self.outchannel: + self.outchannel = timeseries[0].stats.channel + self.check_stream(timeseries) # initialize array for data to be appended @@ -185,13 +173,13 @@ class AverageAlgorithm(Algorithm): """ self.observatories = arguments.observatory - if len(arguments.outchannels) > 1: - raise AlgorithmException( - 'Only 1 channel can be specified') if arguments.outchannels: - self.outchannel = arguments.outchannels[0] - else: - self.outchannel = 'MSD' + self.outchannel = arguments.outchannels + if len(self.outchannel) > 1: + raise AlgorithmException( + 'Only 1 channel can be specified') + + self.scales = arguments.average_observatory_scale if self.scales[0] is not None: if len(self.observatories) != len(self.scales):