Skip to content

Commit

Permalink
Creating new cache used full ds instead of reduced ds (#340)
Browse files Browse the repository at this point in the history
* Creating new cache used full ds instead of reduced ds

Required to ensure that the cached function does not use data_vars that not explicitly required

* Format cache to please  codacy

* Better support for vertex grids

* remove option to store delr/delc as attrs

* remove option to store delr/delc as attrs

* update polygons_from_model_ds to to use new delr/delc datavars

* add delr and delc to datavars in ds_to_structured_grid

* remove delr/delc attr check in structured_da_to_ds

* get_recharge uses coords3d to determine first active layer

* add delr/delc to datavars for surface water functions

* formatting

* formatting

* remove coords that number from 0 to N (these are not listed in coords)

* remove delr and delc from datavars is vertexgrid

* do not check time attrs start and time_units

* do not check time coord attributes

* formatting

* skip delr/delc when writing files

* rename bathymetry tests

* comment still in dutch: bathymetry

* comment still in dutch: bathymetry

* use last delr to set extent

* use brackets (was failing for me without)

* Cache: Implemented inline suggestions made by David

---------

Co-authored-by: Davíd Brakenhoff <d.brakenhoff@artesia-water.nl>
  • Loading branch information
bdestombe and dbrakenhoff committed May 14, 2024
1 parent 0380026 commit ba81ff6
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 108 deletions.
10 changes: 9 additions & 1 deletion docs/examples/02_surface_water.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
"xlim = ax.get_xlim()\n",
"ylim = ax.get_ylim()\n",
"gwf.modelgrid.plot(ax=ax)\n",
"ax.set_xlim(xlim[0], xlim[0] + ds.delr * 1.1)\n",
"ax.set_xlim(xlim[0], xlim[0] + ds.delr[-1] * 1.1)\n",
"ax.set_ylim(ylim)\n",
"ax.set_title(f\"Surface water shapes in cell: {cid}\")"
]
Expand Down Expand Up @@ -788,6 +788,14 @@
"cbar = fig.colorbar(qm, shrink=1.0)\n",
"cbar.set_label(\"head [m NAP]\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1cbc42bf",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/cache_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import xarray as xr


@nlmod.cache.cache_netcdf
@nlmod.cache.cache_netcdf()
def func_to_create_a_dataset(number):
"""create a dataarray as an example for the caching method.
Expand Down
Loading

0 comments on commit ba81ff6

Please sign in to comment.