Skip to content

Commit

Permalink
Merge pull request #134 from chime-experiment/kef/fix_time_range
Browse files Browse the repository at this point in the history
fix: we were missing the information about the timerange contained in the filename
  • Loading branch information
anjakefala authored Dec 13, 2019
2 parents a792193 + ec3694c commit d9956d2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dias/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import glob

from datetime import datetime
from datetime import timedelta

from caput import config
from dias.utils import str2timedelta, str2datetime, str2bytes
Expand Down Expand Up @@ -192,9 +193,16 @@ def filter_files_by_time(
file_list = []
for f in files:
# obtain file's date from name
# files have naming structure YYYYmmddT*
file_time = re.search("(\d*)T.*", f).groups()[0]
file_time = datetime.strptime(file_time, "%Y%m%d")
# folders have naming structure YYYYmmddT*
# files have naming structure *_%.h5
# where * is the number of seconds after the folder_datetime that the data was acquired
# % is the fraction of a second
folder_datetime = re.search("(\d*T\d*)Z.*", f).groups()[0]
folder_datetime = datetime.strptime(folder_datetime, "%Y%m%dT%H%M%S")
# we are not going to care about the fractions of a second
file_seconds = re.search("(\d*)_\d\d\d\d.h5", f).groups()[0]

file_time = folder_datetime + timedelta(seconds=int(file_seconds))

if (file_time >= start_time) and (file_time <= stop_time):
file_list.append(f)
Expand Down

0 comments on commit d9956d2

Please sign in to comment.