Skip to content
Snippets Groups Projects
Commit d383cdcd authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 97d9f46e
Branches
No related tags found
No related merge requests found
......@@ -28,7 +28,8 @@ class AMVFiles:
self.flist = glob.glob(files_path + pattern)
self.band = band
self.ftimes = []
for pname in self.flist: # TODO: make better with regular expressions (someday)
self.span_seconds = datetime.timedelta(minutes=file_time_span).seconds
for pname in self.flist:
dto = self.get_datetime(pname)
dto_start = dto
dto_end = dto + datetime.timedelta(minutes=file_time_span)
......@@ -47,14 +48,22 @@ class AMVFiles:
def get_file_containing_time(self, timestamp):
k = -1
for i in range(len(self.ftimes)):
if (timestamp >= self.ftimes[i][0]) and (timestamp < self.ftimes[i][1]):
for i in range(len(self.ftimes.shape[0])):
if (timestamp >= self.ftimes[i, 0]) and (timestamp < self.ftimes[i, 1]):
k = i
break
if k < 0:
return None, None, None
return self.flist[k], self.ftimes[k], k
return self.flist[k], self.ftimes[k, 0], k
def get_file(self, timestamp):
diff = self.ftimes[:, 0] - timestamp
midx = np.argmin(np.abs(diff))
if np.abs(self.ftimes[midx, 0] - timestamp) < self.span_seconds:
return self.flist[midx], self.ftimes[midx, 0], midx
else:
return None, None, None
def get_parameters(self):
pass
......@@ -172,7 +181,7 @@ def match_amvs_to_raobs(raob_dict, raob_time, amv_files, filepath=None):
match_dict = {}
if filepath is None:
filepath, ftime, f_idx = amv_files.get_file_containing_time(raob_time)
filepath, ftime, f_idx = amv_files.get_file(raob_time)
ds = Dataset(filepath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment