Skip to content

Commit

Permalink
Fix era5/eth issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BSchilperoort committed Aug 8, 2023
1 parent e0949e3 commit dee6566
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/zampy/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def __init__(self, recipe_filename: str) -> None:
# Load & parse recipe
recipe = recipe_loader(recipe_filename)

start_year, end_year = recipe["download"]["years"]
self.start_year, self.end_year = recipe["download"]["years"]
self.timebounds = TimeBounds(
np.datetime64(f"{start_year}"), np.datetime64(f"{end_year}")
np.datetime64(f"{self.start_year}-01-01T00:00"),
np.datetime64(f"{self.end_year}-12-13T23:59"),
)
self.spatialbounds = SpatialBounds(*recipe["download"]["bbox"])

Expand Down Expand Up @@ -119,8 +120,11 @@ def run(self) -> None:
comp = dict(zlib=True, complevel=5)
encoding = {var: comp for var in ds.data_vars}
fname = ( # e.g. "era5_2010-2020.nc"
f"{dataset_name.lower()}_"
f"{self.timebounds.start}-{self.timebounds.end}"
".nc"
f"{dataset_name.lower()}_" f"{self.start_year}-{self.end_year}" ".nc"
)
ds.to_netcdf(path=self.data_dir / fname, encoding=encoding)

print(
"Finished running the recipe. Output data can be found at:\n"
f" {self.data_dir}"
)

0 comments on commit dee6566

Please sign in to comment.