From c24e2e9c0bb98180c9d11214b5312b614d9fe69f Mon Sep 17 00:00:00 2001
From: "E. Joshua Rigler" <erigler@usgs.gov>
Date: Fri, 18 Nov 2022 17:24:18 -0700
Subject: [PATCH] Check for gaps in multi-observatory Stream

The method TimeseriesUtility.get_stream_gaps() would over-write gaps[channel] if
there were multiple Traces in a stream that were the same channel, but different
observatories. This is a typical situation when using the AverageAlgorithm.
---
 geomagio/TimeseriesUtility.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/geomagio/TimeseriesUtility.py b/geomagio/TimeseriesUtility.py
index 357161426..2797b938c 100644
--- a/geomagio/TimeseriesUtility.py
+++ b/geomagio/TimeseriesUtility.py
@@ -205,7 +205,10 @@ def get_stream_gaps(stream, channels=None):
         channel = trace.stats.channel
         if channels is not None and channel not in channels:
             continue
-        gaps[channel] = get_trace_gaps(trace)
+        if channel in gaps:
+            gaps[channel].extend(get_trace_gaps(trace))
+        else:
+            gaps[channel] = get_trace_gaps(trace)
     return gaps
 
 
-- 
GitLab