From 182264293ca332218d18d0c932f01178ab92fda5 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 3 Jul 2023 09:52:20 -0500
Subject: [PATCH] snapshot...

---
 modules/aeolus/datasource.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/aeolus/datasource.py b/modules/aeolus/datasource.py
index b6920a93..ce0891e7 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
 
-- 
GitLab