Skip to content
Snippets Groups Projects
Commit 5d212963 authored by Hal Simpson's avatar Hal Simpson
Browse files

Added routines to return the number of seconds in a given interval, and to...

Added routines to return the number of seconds in a given interval, and to detect if 'new' data exists between two data sets
parent 5f919298
No related branches found
No related tags found
No related merge requests found
...@@ -39,9 +39,12 @@ def get_merged_gaps(gaps, channels): ...@@ -39,9 +39,12 @@ def get_merged_gaps(gaps, channels):
for channel in channels: for channel in channels:
gap_stream.extend(gaps[channel]) gap_stream.extend(gaps[channel])
if len(gap_stream) == 0:
return []
sorted_gaps = sorted(gap_stream, key=lambda starttime: starttime[1]) sorted_gaps = sorted(gap_stream, key=lambda starttime: starttime[1])
merged_gaps = [] merged_gaps = []
new_gap = None
gap = sorted_gaps[0] gap = sorted_gaps[0]
for i in range(1,len(sorted_gaps)): for i in range(1,len(sorted_gaps)):
nxtgap = sorted_gaps[i] nxtgap = sorted_gaps[i]
...@@ -54,3 +57,22 @@ def get_merged_gaps(gaps, channels): ...@@ -54,3 +57,22 @@ def get_merged_gaps(gaps, channels):
merged_gaps.append(gap) merged_gaps.append(gap)
return merged_gaps return merged_gaps
def is_new_data(input_gaps, output_gaps):
for output_gap in output_gaps:
for input_gap in input_gaps:
if (output_gap[0] >= input_gap[0] and
output_gap[0] <= input_gap[1] and
output_gap[1] <= input_gap[1]):
return False
return True
def get_seconds_of_interval(interval):
if interval == 'second':
return 1
if interval == 'minute':
return 60
if interval == 'hourly':
return 3600
if interval == 'daily':
return 86400
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