diff --git a/modules/aeolus/datasource.py b/modules/aeolus/datasource.py index b6920a93bce4600d78c8bda904452e7df74031eb..ce0891e7cb497e6bd62e6de3d1ae0218ecd41039 100644 --- a/modules/aeolus/datasource.py +++ b/modules/aeolus/datasource.py @@ -80,8 +80,10 @@ def get_parameters_fmwk_amvs(filename='/ships19/cloud/scratch/4TH_AMV_INTERCOMPA class Files: def __init__(self, files_path, file_time_span, pattern): self.flist = [] + self.ftimes = [] + self.dto_s = [] + if os.path.isdir(files_path): - # for path in Path(files_path).rglob(pattern): for path in glob.glob(files_path + pattern, recursive=True): self.flist.append(path) elif fnmatch.fnmatch(os.path.basename(files_path), pattern): # check if this single file matches pattern @@ -89,7 +91,6 @@ class Files: if len(self.flist) == 0: raise GenericException('no matching files found in: ' + files_path + ' matching: ' + pattern) - self.ftimes = [] self.span_seconds = datetime.timedelta(minutes=file_time_span).seconds for pname in self.flist: @@ -97,12 +98,17 @@ class Files: dto_start = dto dto_end = dto + datetime.timedelta(minutes=file_time_span) self.ftimes.append((dto_start.timestamp(), dto_end.timestamp())) + self.dto_s.append(dto) self.ftimes = np.array(self.ftimes) self.flist = np.array(self.flist) - sidxs = np.argsort(self.ftimes[:, 0]) + self.dto_s = np.array(self.dto_s) + + sidxs = np.argsort(self.ftimes[:, 0]) # sort on start time + self.ftimes = self.ftimes[sidxs, :] self.flist = self.flist[sidxs] + self.dto_s = self.dto_s[sidxs] self._current_index = 0