From bd81e006a13d4ba7f59e5f680fd09d8d36ede1c2 Mon Sep 17 00:00:00 2001 From: Bas des Tombe Date: Wed, 10 Apr 2024 15:15:48 +0200 Subject: [PATCH] Configuration of cache_netcdf usages --- nlmod/cache.py | 3 +++ nlmod/dims/grid.py | 2 +- nlmod/read/ahn.py | 2 +- nlmod/read/knmi.py | 2 +- nlmod/read/rws.py | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nlmod/cache.py b/nlmod/cache.py index 3902fb72..ad193d06 100644 --- a/nlmod/cache.py +++ b/nlmod/cache.py @@ -628,6 +628,9 @@ def ds_contains(ds, coords_2d=False, coords_3d=False, coords_time=False, datavar coords.append("x") coords.append("y") attrs.append("extent") + + if "gridtype" in ds.attrs: + attrs.append("gridtype") if "angrot" in ds.attrs: attrs.append("angrot") diff --git a/nlmod/dims/grid.py b/nlmod/dims/grid.py index 6ab6f997..bb48d52e 100644 --- a/nlmod/dims/grid.py +++ b/nlmod/dims/grid.py @@ -1846,7 +1846,7 @@ def get_vertices(ds, vert_per_cid=4, epsilon=0, rotated=False): return vertices_da -@cache.cache_netcdf() +@cache.cache_netcdf(coords_2d=True) def mask_model_edge(ds, idomain=None): """get data array which is 1 for every active cell (defined by idomain) at the boundaries of the model (xmin, xmax, ymin, ymax). Other cells are 0. diff --git a/nlmod/read/ahn.py b/nlmod/read/ahn.py index 6e35f704..301637a8 100644 --- a/nlmod/read/ahn.py +++ b/nlmod/read/ahn.py @@ -19,7 +19,7 @@ logger = logging.getLogger(__name__) -@cache.cache_netcdf() +@cache.cache_netcdf(coords_2d=True) def get_ahn(ds=None, identifier="AHN4_DTM_5m", method="average", extent=None): """Get a model dataset with ahn variable. diff --git a/nlmod/read/knmi.py b/nlmod/read/knmi.py index f6625729..f6e0b27e 100644 --- a/nlmod/read/knmi.py +++ b/nlmod/read/knmi.py @@ -13,7 +13,7 @@ logger = logging.getLogger(__name__) -@cache.cache_netcdf() +@cache.cache_netcdf(coords_2d=True, coords_time=True) def get_recharge(ds, method="linear", most_common_station=False): """add multiple recharge packages to the groundwater flow model with knmi data by following these steps: diff --git a/nlmod/read/rws.py b/nlmod/read/rws.py index 956c4751..01d5b4e2 100644 --- a/nlmod/read/rws.py +++ b/nlmod/read/rws.py @@ -37,7 +37,7 @@ def get_gdf_surface_water(ds): return gdf_swater -@cache.cache_netcdf() +@cache.cache_netcdf(coords_2d=True) def get_surface_water(ds, da_basename): """create 3 data-arrays from the shapefile with surface water: