diff --git a/geomagio/TimeseriesUtility.py b/geomagio/TimeseriesUtility.py index 2797b938c68bb33e077c100f2ee32ce901e05fdd..c54d7498399639c8deda626b3dc0fc20a486f432 100644 --- a/geomagio/TimeseriesUtility.py +++ b/geomagio/TimeseriesUtility.py @@ -388,17 +388,20 @@ def has_any_channels(stream, channels, starttime, endtime): bool: True if any data found between starttime/endtime """ # process if any channels have data not covering the time range - input_gaps = get_stream_gaps(stream=stream, channels=channels) - for channel in channels: - if channel not in input_gaps: - continue - channel_gaps = input_gaps[channel] - if len(channel_gaps) == 0: - # no gaps in channel - return True - for gap in channel_gaps: - if not (starttime >= gap[0] and starttime <= gap[1] and endtime < gap[2]): - # gap doesn't span channel + for trace in stream: + if trace.stats.channel in channels: + gaps = get_trace_gaps(trace) + if len(gaps) == 0: + # no gaps in trace; + # "any" critierion achieved for stream + return True + nodata = [ + (starttime >= gap[0] and starttime <= gap[1] and endtime < gap[2]) + for gap in gaps + ] + if not any(nodata): + # no gaps in trace span interval; + # "any" criterion achieved for stream return True # didn't find any data return False