Skip to content
Snippets Groups Projects
Commit 195c4240 authored by Erin (Josh) Rigler's avatar Erin (Josh) Rigler
Browse files

Fix has_any_channels method

The has_any_channels method in TimeseriesUtility.py did not properly
handle streams with multiple traces with the same channel, but different
stations (or networks, or locations). It should work now.
parent b7a146f7
No related branches found
No related tags found
1 merge request!202Fixes for AverageAlgorithm - 20221207
...@@ -388,17 +388,20 @@ def has_any_channels(stream, channels, starttime, endtime): ...@@ -388,17 +388,20 @@ def has_any_channels(stream, channels, starttime, endtime):
bool: True if any data found between starttime/endtime bool: True if any data found between starttime/endtime
""" """
# process if any channels have data not covering the time range # process if any channels have data not covering the time range
input_gaps = get_stream_gaps(stream=stream, channels=channels) for trace in stream:
for channel in channels: if trace.stats.channel in channels:
if channel not in input_gaps: gaps = get_trace_gaps(trace)
continue if len(gaps) == 0:
channel_gaps = input_gaps[channel] # no gaps in trace;
if len(channel_gaps) == 0: # "any" critierion achieved for stream
# no gaps in channel return True
return True nodata = [
for gap in channel_gaps: (starttime >= gap[0] and starttime <= gap[1] and endtime < gap[2])
if not (starttime >= gap[0] and starttime <= gap[1] and endtime < gap[2]): for gap in gaps
# gap doesn't span channel ]
if not any(nodata):
# no gaps in trace span interval;
# "any" criterion achieved for stream
return True return True
# didn't find any data # didn't find any data
return False return False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment