Skip to content
Snippets Groups Projects
Commit 49657ebe authored by Alan De Smet's avatar Alan De Smet
Browse files

aitf.ancil.GFS needs custom get_cachefilesets

parent 52489fde
Branches
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import sys
import datetime as dt
sys.path.append(os.path.abspath('..'))
import csppfetch
import csppfetch.daterange
from csppfetch.roundtozero import roundtozero
################################################################################
......@@ -104,6 +105,34 @@ class GFSDownloader(csppfetch.Downloader):
local = self._expand(self.local, time, hours_str)
return {url:local}
def get_cache_filesets(self, start = None, end = None):
# A copy of Downloader's implementation, but we don't use
# self._daterange; we call daterange.daterange directly so we can pass
# in a step of self.forecast_step instead of self.period. We do this
# because although our period is only every 6 hours, we change which
# files someone might want every _3_. That is to process 5Z data, we'd
# use the 0Z GFS data's 3 and 6 hour forecasts, but for 7Z data, we'd
# use the 0Z GFS data's 6 and 9 hour forecasts.
#
# Perhaps the ablity to override the period here should be in the
# parent class? Or maybe this case is too specialized to bother.
if self.oldest_cache < dt.timedelta(days=0):
raise ValueError(f"oldest_cache should be positive; it is {self.oldest_cache}")
if end is None: end = dt.datetime.now()
if start is None: start = end - self.oldest_cache
if start > end:
raise ValueError(f"start ({start}) should be before end ({end})")
fileset_list_list = []
for time in csppfetch.daterange.daterange(end, start, -self.forecast_step, inclusive=True):
fileset_list = self.get_filesets_for_time(time)
fileset_list_list.append(fileset_list)
return fileset_list_list
def get_filesets_for_time(self, scan_time):
generated_time = self._nearest_preceeding_time(scan_time)
time_since_gen = scan_time - generated_time
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment