From a61ffa143d7a52f1ecc1d61b475648627fc380ad Mon Sep 17 00:00:00 2001
From: "E. Joshua Rigler" <erigler@usgs.gov>
Date: Tue, 15 Nov 2022 18:29:39 -0700
Subject: [PATCH] Don't modify algorithm state inside process() method

---
 geomagio/algorithm/AverageAlgorithm.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/geomagio/algorithm/AverageAlgorithm.py b/geomagio/algorithm/AverageAlgorithm.py
index b065f51f..692ff5c8 100644
--- a/geomagio/algorithm/AverageAlgorithm.py
+++ b/geomagio/algorithm/AverageAlgorithm.py
@@ -122,9 +122,9 @@ class AverageAlgorithm(Algorithm):
 
         self.outlocation = self.outlocation or timeseries[0].stats.location
 
-        self.min_count = self.min_count or len(self.observatories)
-        self.min_count_start = self.min_count_start or timeseries[0].stats.starttime
-        self.min_count_end = self.min_count_end or timeseries[0].stats.endtime
+        min_count = self.min_count or len(self.observatories)
+        min_count_start = self.min_count_start or timeseries[0].stats.starttime
+        min_count_end = self.min_count_end or timeseries[0].stats.endtime
 
         scale_values = self.scales or ([1] * len(timeseries))
         lat_corr = {}
@@ -160,16 +160,16 @@ class AverageAlgorithm(Algorithm):
         average_data = numpy.nansum(combined, axis=0) / count_data
 
         # apply min_count
-        average_data[count_data < self.min_count] = numpy.nan
+        average_data[count_data < min_count] = numpy.nan
 
         # apply min_count_start and min_count_end
         # NOTE: the logic here is not very intuitive, but it works as intended
         utc_datetimes = timeseries[0].times(type="utcdatetime")
         average_data[
-            (count_data < timeseries.count()) & (utc_datetimes > self.min_count_end)
+            (count_data < timeseries.count()) & (utc_datetimes > min_count_end)
         ] = numpy.nan
         average_data[
-            (count_data < timeseries.count()) & (utc_datetimes < self.min_count_start)
+            (count_data < timeseries.count()) & (utc_datetimes < min_count_start)
         ] = numpy.nan
 
         # create first output trace metadata
-- 
GitLab