From a8aa480cd9e32e62bda2e28b64bbcdaf3ba6cb95 Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Tue, 6 Jun 2023 11:42:14 -0500 Subject: [PATCH] make Files iterable --- modules/aeolus/datasource.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/aeolus/datasource.py b/modules/aeolus/datasource.py index 7b2a987e..1b076129 100644 --- a/modules/aeolus/datasource.py +++ b/modules/aeolus/datasource.py @@ -102,6 +102,8 @@ class Files: self.ftimes = self.ftimes[sidxs, :] self.flist = self.flist[sidxs] + self._current_index = 0 + def get_datetime(self, pathname): pass @@ -131,6 +133,17 @@ class Files: def get_parameters(self): pass + def __iter__(self): + return self + + def __next__(self): + if self._current_index < len(self.flist): + self._current_index += 1 + return self.flist[self._current_index] + else: + self._current_index = 0 + raise StopIteration + class GOESL1B(Files): def __init__(self, files_path, band='14', pattern='OR_ABI-L1b-RadC-M*C14'+'*.nc'): -- GitLab