Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple improvements #289

Merged
merged 20 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
07e8bd8
Multiple improvements
rubencalje Nov 14, 2023
7858195
Simplify fill_top_and_bottom
rubencalje Nov 14, 2023
fc656ff
Remove the layer dimension in top returned from get_regis
rubencalje Nov 14, 2023
af8aed8
Also remove the layer dimension in top returned from get_geotop
rubencalje Nov 14, 2023
29ad60c
Fix codacy issues
rubencalje Nov 14, 2023
ba0b40b
Make sure add_geotop_to_regis_layers works without a layer dimension …
rubencalje Nov 15, 2023
9f3b5d8
Make sure insert_layer works without a layer dimension in ds
rubencalje Nov 15, 2023
e475d0c
Fix some geotop-errors
rubencalje Nov 15, 2023
294c748
Change mapserver layer for level areas of Wetterkip Fryslan
rubencalje Nov 15, 2023
34275ec
Change extent of test, as Wetterskip Frysland does not return any geo…
rubencalje Nov 16, 2023
3a363fc
Update url for level areas of noorderzijlvest
rubencalje Nov 16, 2023
a70d3fb
Process comments from @dbrakenhoff and other fixes
rubencalje Nov 17, 2023
e2f76a5
Process more comments and improve tests
rubencalje Nov 17, 2023
b6df910
Revert change which causes failed tests everywhere
rubencalje Nov 17, 2023
3c33531
Add tests from plot.flopy, gwt and hfb
rubencalje Nov 17, 2023
a11a2a6
Update 11_grid_rotation.ipynb
rubencalje Nov 20, 2023
d492552
Merge branch 'multiple_improvements' of https://github.com/gwmod/nlmo…
rubencalje Nov 20, 2023
e19520c
Make a copy of the dataset in most methods in nlmod.layers
rubencalje Nov 20, 2023
6c4376c
Add docstrings and minor change in `set_model_top`
rubencalje Nov 21, 2023
ba3c851
Process comments from @dbrakenhoff
rubencalje Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/examples/04_modifying_layermodels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@
"metadata": {},
"outputs": [],
"source": [
"layer_names = []\n",
"colors_new = {}\n",
"\n",
"for j, i in split_reindexer.items():\n",
" if j not in colors:\n",
" colors[j] = colors[i]"
Expand Down
5 changes: 1 addition & 4 deletions docs/examples/11_grid_rotation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@
"oc = nlmod.gwf.oc(ds, gwf)\n",
"\n",
"# create recharge package\n",
"rch = nlmod.gwf.rch(ds, gwf)\n",
"\n",
"# create storage package\n",
"sto = nlmod.gwf.sto(ds, gwf)"
"rch = nlmod.gwf.rch(ds, gwf)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/12_layer_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"outputs": [],
"source": [
"f, ax = nlmod.plot.get_map(extent, figsize=5)\n",
"nlmod.plot.data_array(regis[\"top\"].max(\"layer\"), edgecolor=\"k\")"
"nlmod.plot.data_array(regis[\"top\"], edgecolor=\"k\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/17_unsaturated_zone_flow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"y = np.floor(y / 100) * 100\n",
"dx = dy = 100\n",
"extent = [x, x + dx, y, y + dy]\n",
"regis = nlmod.read.regis.get_regis(extent, cachename=\"regis.nc\", cachedir=cachedir)"
"regis = nlmod.read.regis.get_regis(extent, drop_layer_dim_from_top=False, cachename=\"regis.nc\", cachedir=cachedir)"
]
},
{
Expand Down
14 changes: 8 additions & 6 deletions nlmod/dims/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def to_model_ds(
return ds


def extrapolate_ds(ds, mask=None):
def extrapolate_ds(ds, mask=None, layer="layer"):
"""Fill missing data in layermodel based on nearest interpolation.

Used for ensuring layer model contains data everywhere. Useful for
Expand All @@ -190,18 +190,20 @@ def extrapolate_ds(ds, mask=None):
----------
ds : xarray.DataSet
Model layer DataSet
mask: np.ndarray, optional
mask : np.ndarray, optional
Boolean mask for each cell, with a value of True if its value needs to
be determined. When mask is None, it is determined from the botm-
variable. The default is None.
layer : str, optional
The name of the layer dimension. The default is 'layer'.

Returns
-------
ds : xarray.DataSet
filled layermodel
"""
if mask is None:
mask = np.isnan(ds["botm"]).all("layer").data
mask = np.isnan(ds["botm"]).all(layer).data
if not mask.any():
# all of the model cells are is inside the known area
return ds
Expand All @@ -225,9 +227,9 @@ def extrapolate_ds(ds, mask=None):
data = ds[key].data
if ds[key].dims == dims:
if np.isnan(data[mask]).sum() > 0: # do not update if no NaNs
data[mask] = data[~mask, i]
elif ds[key].dims == ("layer",) + dims:
for lay in range(len(ds["layer"])):
data[mask] = data[~mask][i]
elif ds[key].dims == (layer,) + dims:
for lay in range(len(ds[layer])):
if np.isnan(data[lay, mask]).sum() > 0: # do not update if no NaNs
data[lay, mask] = data[lay, ~mask][i]
else:
Expand Down
Loading