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

Remove idomain from Dataset #250

Merged
merged 5 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 13 additions & 27 deletions docs/examples/01_basic_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -76,7 +75,7 @@
"steady_state = True\n",
"start_time = \"2015-1-1\"\n",
"add_northsea = True\n",
"starting_head = 1.0\n"
"starting_head = 1.0"
]
},
{
Expand All @@ -103,7 +102,7 @@
")\n",
"\n",
"if add_northsea:\n",
" ds = nlmod.read.rws.add_northsea(ds, cachedir=cachedir)\n"
" ds = nlmod.read.rws.add_northsea(ds, cachedir=cachedir)"
]
},
{
Expand Down Expand Up @@ -134,7 +133,7 @@
"ic = nlmod.gwf.ic(ds, gwf, starting_head=starting_head)\n",
"\n",
"# Create the output control package\n",
"oc = nlmod.gwf.oc(ds, gwf)\n"
"oc = nlmod.gwf.oc(ds, gwf)"
]
},
{
Expand All @@ -152,7 +151,7 @@
"ds.update(rws_ds)\n",
"\n",
"# build ghb package\n",
"ghb = nlmod.gwf.ghb(ds, gwf, bhead=f\"{da_name}_stage\", cond=f\"{da_name}_cond\")\n"
"ghb = nlmod.gwf.ghb(ds, gwf, bhead=f\"{da_name}_stage\", cond=f\"{da_name}_cond\")"
]
},
{
Expand All @@ -167,7 +166,7 @@
"ds.update(ahn_ds)\n",
"\n",
"# build surface level drain package\n",
"drn = nlmod.gwf.surface_drain_from_ds(ds, gwf, resistance=10.0)\n"
"drn = nlmod.gwf.surface_drain_from_ds(ds, gwf, resistance=10.0)"
]
},
{
Expand All @@ -177,8 +176,8 @@
"outputs": [],
"source": [
"# add constant head cells at model boundaries\n",
"ds.update(nlmod.grid.mask_model_edge(ds, ds[\"idomain\"]))\n",
"chd = nlmod.gwf.chd(ds, gwf, mask=\"edge_mask\", head=\"starting_head\")\n"
"ds.update(nlmod.grid.mask_model_edge(ds))\n",
"chd = nlmod.gwf.chd(ds, gwf, mask=\"edge_mask\", head=\"starting_head\")"
]
},
{
Expand All @@ -193,7 +192,7 @@
"ds.update(knmi_ds)\n",
"\n",
"# create recharge package\n",
"rch = nlmod.gwf.rch(ds, gwf)\n"
"rch = nlmod.gwf.rch(ds, gwf)"
]
},
{
Expand All @@ -209,7 +208,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds\n"
"ds"
]
},
{
Expand All @@ -228,7 +227,7 @@
"metadata": {},
"outputs": [],
"source": [
"nlmod.sim.write_and_run(sim, ds, write_ds=True, script_path=\"01_basic_model.ipynb\")\n"
"nlmod.sim.write_and_run(sim, ds, write_ds=True, script_path=\"01_basic_model.ipynb\")"
]
},
{
Expand All @@ -246,7 +245,7 @@
"outputs": [],
"source": [
"ax = nlmod.plot.modelgrid(ds)\n",
"nlmod.plot.surface_water(ds, ax=ax)\n"
"nlmod.plot.surface_water(ds, ax=ax)"
]
},
{
Expand All @@ -265,7 +264,7 @@
"fig, axes = nlmod.plot.get_map(ds.extent, nrows=2, ncols=2, figsize=14)\n",
"ds[\"ahn\"].plot(ax=axes[0][0])\n",
"ds[\"botm\"][0].plot(ax=axes[0][1])\n",
"ds[\"idomain\"][0].plot(ax=axes[1][0])\n",
"nlmod.layers.get_idomain(ds)[0].plot(ax=axes[1][0])\n",
"ds[\"edge_mask\"][0].plot(ax=axes[1][1])\n",
"\n",
"fig, axes = nlmod.plot.get_map(ds.extent, nrows=2, ncols=2, figsize=14)\n",
Expand All @@ -274,24 +273,11 @@
"ds[\"kh\"][1].plot(ax=axes[1][0])\n",
"ds[\"recharge\"].plot(ax=axes[1][1]);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "artesia",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.10.12"
"name": "python"
}
},
"nbformat": 4,
Expand Down
12 changes: 2 additions & 10 deletions docs/examples/03_local_grid_refinement.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -44,7 +43,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -116,7 +114,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -191,7 +188,7 @@
"drn = nlmod.gwf.surface_drain_from_ds(ds, gwf, resistance=10.0)\n",
"\n",
"# add constant head cells at model boundaries\n",
"ds.update(nlmod.grid.mask_model_edge(ds, ds[\"idomain\"]))\n",
"ds.update(nlmod.grid.mask_model_edge(ds))\n",
"chd = nlmod.gwf.chd(ds, gwf, mask=\"edge_mask\", head=\"starting_head\")"
]
},
Expand Down Expand Up @@ -219,7 +216,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -238,7 +234,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -272,7 +267,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -289,7 +283,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -308,7 +301,7 @@
"\n",
"nlmod.plot.data_array(ds[\"ahn\"], ds, ax=axes[0][0])\n",
"nlmod.plot.data_array(ds[\"botm\"][0], ds, ax=axes[0][1])\n",
"nlmod.plot.data_array(ds[\"idomain\"][0], ds, ax=axes[1][0])\n",
"nlmod.plot.data_array(nlmod.layers.get_idomain(ds)[0], ds, ax=axes[1][0])\n",
"nlmod.plot.data_array(ds[\"edge_mask\"][0], ds, ax=axes[1][1])\n",
"\n",
"fig, axes = nlmod.plot.get_map(extent, nrows=2, ncols=2, figsize=(14, 11))\n",
Expand All @@ -319,7 +312,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
26 changes: 4 additions & 22 deletions docs/examples/06_gridding_vector_data.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -33,7 +32,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -57,7 +55,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -116,15 +113,13 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Points"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -165,7 +160,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -208,7 +202,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -249,7 +242,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -290,7 +282,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -328,7 +319,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -374,7 +364,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -411,14 +400,11 @@
"# add a nodata value\n",
"ds.attrs[\"nodata\"] = -999\n",
"\n",
"# create an idomain of ones except for the first cell which is zero\n",
"idomain = np.ones((ds.dims[\"layer\"], ds.dims[\"y\"], ds.dims[\"x\"]))\n",
"idomain[0, 0, 0] = 0\n",
"ds[\"idomain\"] = (\"layer\", \"y\", \"x\"), idomain"
"# set the thickness of the first cell to 0, so this cell will become inactive\n",
"ds['top'][0,0] = ds['botm'][0,0,0]"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -441,7 +427,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -465,7 +450,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -501,7 +485,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -523,7 +506,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -540,14 +522,14 @@
"outputs": [],
"source": [
"# create a reclist with col1 (str), col2 (DataArray), col3 (int)\n",
"idomain = nlmod.layers.get_idomain(ds)\n",
"reclist5 = nlmod.grid.da_to_reclist(\n",
" ds, mask3d, col1=ds[\"idomain\"], col2=\"da1\", col3=9, layer=0, only_active_cells=False\n",
" ds, mask3d, col1=idomain, col2=\"da1\", col3=9, layer=0, only_active_cells=False\n",
")\n",
"reclist5"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
6 changes: 2 additions & 4 deletions nlmod/dims/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .. import util
from ..epsg28992 import EPSG_28992
from . import resample
from .layers import fill_nan_top_botm_kh_kv, set_idomain
from .layers import fill_nan_top_botm_kh_kv

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -167,16 +167,14 @@ def to_model_ds(
ds = set_ds_attrs(ds, model_name, model_ws)
ds.attrs["transport"] = int(transport)

# fill nan's and add idomain
# fill nan's
if fill_nan:
ds = fill_nan_top_botm_kh_kv(
ds,
anisotropy=anisotropy,
fill_value_kh=fill_value_kh,
fill_value_kv=fill_value_kv,
)
else:
ds = set_idomain(ds, remove_nan_layers=False)

return ds

Expand Down
Loading