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

Improve time discretization #257

Merged
merged 27 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
15d19e1
improve time discretization:
dbrakenhoff Aug 28, 2023
78b620c
update STO pkg
dbrakenhoff Aug 28, 2023
ec31953
update recharge pkg for new ds time discretization
dbrakenhoff Aug 28, 2023
f239cb2
update get_tdis_perioddata
dbrakenhoff Aug 28, 2023
36cebae
update tests for new time discretization
dbrakenhoff Aug 28, 2023
06c4e3c
black
dbrakenhoff Aug 28, 2023
c5ffc29
codacy
dbrakenhoff Aug 28, 2023
6082bd4
process @OnnoEbbens comments
dbrakenhoff Aug 30, 2023
21dd905
process @OnnoEbbens comments
dbrakenhoff Aug 30, 2023
505a985
remove commented code
dbrakenhoff Aug 31, 2023
361c509
pin pandas version < 2.1.0
dbrakenhoff Aug 31, 2023
9ff2a84
add pin to ci not RTD...
dbrakenhoff Aug 31, 2023
5bc7da3
process comments @rubencalje
dbrakenhoff Aug 31, 2023
54160a4
Add perlen and default value for start
rubencalje Aug 31, 2023
f5c5da2
minor docstring update
rubencalje Aug 31, 2023
3bfc28e
Allow time to be a single value as well
rubencalje Aug 31, 2023
d32c937
remove default value of start
rubencalje Aug 31, 2023
3322919
Fix tests
rubencalje Aug 31, 2023
d620084
Update notebooks
rubencalje Aug 31, 2023
fb17b73
Make sure time is converted to an iterable a bit earlier
rubencalje Aug 31, 2023
d796995
Add knmi bugfix
rubencalje Sep 1, 2023
f270efd
Fix new warning in pandas 2.1.0
rubencalje Sep 1, 2023
f7159c9
Fix other problems in notebooks
rubencalje Sep 1, 2023
cfa3d3a
Fix last notebook bugs
rubencalje Sep 1, 2023
e4d009f
Remove start_date_time check in modpath
rubencalje Sep 1, 2023
652196e
codacy + json error nb11
dbrakenhoff Sep 4, 2023
658b4ef
update log message
dbrakenhoff Sep 4, 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
2 changes: 1 addition & 1 deletion docs/examples/00_model_from_scratch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds = nlmod.time.set_ds_time(ds, time=pd.Timestamp.today())"
"ds = nlmod.time.set_ds_time(ds, time=pd.Timestamp.today(), start=1)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/01_basic_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"\n",
"# add time discretisation\n",
"ds = nlmod.time.set_ds_time(\n",
" ds, start_time=start_time, steady_state=steady_state, perlen=365 * 5\n",
" ds, start=start_time, steady=steady_state, perlen=365 * 5\n",
")\n",
"\n",
"if add_northsea:\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/02_surface_water.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
"ds = nlmod.to_model_ds(layer_model, model_name, model_ws, delr=delr, delc=delc)\n",
"\n",
"# create model time dataset\n",
"ds = nlmod.time.set_ds_time(ds, start_time=start_time, steady_state=True)\n",
"ds = nlmod.time.set_ds_time(ds, start=start_time, steady=True, perlen=1)\n",
"\n",
"ds"
]
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/03_local_grid_refinement.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@
"# add time discretisation\n",
"ds = nlmod.time.set_ds_time(\n",
" ds,\n",
" start_time=start_time,\n",
" steady_state=steady_state,\n",
" start=start_time,\n",
" steady=steady_state,\n",
" steady_start=steady_start,\n",
" transient_timesteps=transient_timesteps,\n",
" perlen=perlen,\n",
" perlen=[perlen] * (transient_timesteps+1),\n",
")"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/08_gis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"outputs": [],
"source": [
"ds_struc = xr.load_dataset(\n",
" os.path.join(model_ws, \"cache\", f\"{model_name}.nc\"), mask_and_scale=False\n",
" os.path.join(model_ws, f\"{model_name}.nc\"), mask_and_scale=False\n",
")\n",
"ds_struc"
]
Expand Down Expand Up @@ -111,7 +111,7 @@
"outputs": [],
"source": [
"ds_vert = xr.load_dataset(\n",
" os.path.join(model_ws, \"cache\", f\"{model_name}.nc\"), mask_and_scale=False\n",
" os.path.join(model_ws, f\"{model_name}.nc\"), mask_and_scale=False\n",
")\n",
"\n",
"# get modelgrid\n",
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/09_schoonhoven.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds = nlmod.time.set_ds_time(ds, time=time)\n"
"ds = nlmod.time.set_ds_time(ds, time=time, start=3652)\n"
]
},
{
Expand Down Expand Up @@ -338,6 +338,7 @@
" \"identificatie\"\n",
"].isin(ids_oude_haven)\n",
"lakes = bgt_grid[mask].copy()\n",
"lakes[\"name\"] = \"\"\n",
"lakes.loc[lakes[\"identificatie\"].isin(ids_grote_gracht), \"name\"] = \"grote gracht\"\n",
"lakes.loc[lakes[\"identificatie\"].isin(ids_oude_haven), \"name\"] = \"oude haven\"\n",
"bgt_grid = bgt_grid[~mask]\n"
Expand Down Expand Up @@ -502,7 +503,7 @@
" colorbar_label=\"head [m NAP]\",\n",
" title=\"mean head\",\n",
")\n",
"bgt.plot(ax=ax, edgecolor=\"k\", facecolor=\"none\");"
"bgt.plot(ax=pc.axes, edgecolor=\"k\", facecolor=\"none\");"
]
},
{
Expand Down Expand Up @@ -552,7 +553,7 @@
"x = 118228\n",
"y = 439870\n",
"head_point = nlmod.gwf.get_head_at_point(head, x=x, y=y, ds=ds)\n",
"fig, ax = plt.subplots(1, 1, figsize=(10, 3))\n",
"fig, ax = plt.subplots(1, 1, figsize=(10, 8))\n",
"handles = head_point.plot.line(ax=ax, hue=\"layer\")\n",
"ax.set_ylabel(\"head [m NAP]\");"
]
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/10_modpath.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"model_ws = \"ijmuiden\"\n",
"model_name = \"IJm_planeten\"\n",
"\n",
"ds = xr.open_dataset(os.path.join(model_ws, \"cache\", f\"{model_name}.nc\"))"
"ds = xr.open_dataset(os.path.join(model_ws, f\"{model_name}.nc\"))"
]
},
{
Expand Down Expand Up @@ -128,7 +128,7 @@
"outputs": [],
"source": [
"# run modpath model\n",
"nlmod.modpath.write_and_run(mpf, nb_path=\"10_modpath.ipynb\")"
"nlmod.modpath.write_and_run(mpf, script_path=\"10_modpath.ipynb\")"
]
},
{
Expand Down Expand Up @@ -228,7 +228,7 @@
"outputs": [],
"source": [
"# run modpath model\n",
"nlmod.modpath.write_and_run(mpf, nb_path=\"10_modpath.ipynb\")"
"nlmod.modpath.write_and_run(mpf, script_path=\"10_modpath.ipynb\")"
]
},
{
Expand Down Expand Up @@ -332,7 +332,7 @@
"outputs": [],
"source": [
"# run modpath model\n",
"nlmod.modpath.write_and_run(mpf, nb_path=\"10_modpath.ipynb\")"
"nlmod.modpath.write_and_run(mpf, script_path=\"10_modpath.ipynb\")"
]
},
{
Expand Down Expand Up @@ -440,7 +440,7 @@
"outputs": [],
"source": [
"# run modpath model\n",
"nlmod.modpath.write_and_run(mpf, nb_path=\"10_modpath.ipynb\")"
"nlmod.modpath.write_and_run(mpf, script_path=\"10_modpath.ipynb\")"
]
},
{
Expand Down
10 changes: 8 additions & 2 deletions docs/examples/11_grid_rotation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"# this period will determine the recharge-value and the ratio between summer and\n",
"# winter stage of the surface water.\n",
"\n",
"ds = nlmod.time.set_ds_time(ds, time=\"2023-1-1\")"
"ds = nlmod.time.set_ds_time(ds, time=\"2023-1-1\", start=\"2013\")"
]
},
{
Expand Down Expand Up @@ -358,8 +358,14 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "artesia",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/13_plot_methods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
"source": [
"model_name = \"Schoonhoven\"\n",
"model_ws = \"schoonhoven\"\n",
"figdir, cachedir = nlmod.util.get_model_dirs(model_ws)\n",
"ds = xr.open_dataset(os.path.join(cachedir, f\"{model_name}.nc\"))\n",
"ds = xr.open_dataset(os.path.join(model_ws, f\"{model_name}.nc\"))\n",
"\n",
"# add calculated heads\n",
"ds[\"head\"] = nlmod.gwf.get_heads_da(ds)\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/14_stromingen_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"source": [
"# set model time settings\n",
"t = date_range(tmin, tmax, freq=freq)\n",
"ds = nlmod.time.set_ds_time(ds, time=t, steady_start=True)\n",
"ds = nlmod.time.set_ds_time(ds, start=3652, time=t, steady_start=True)\n",
"\n",
"# build the modflow6 gwf model\n",
"gwf = nlmod.gwf.ds_to_gwf(ds)"
Expand Down
8 changes: 3 additions & 5 deletions docs/examples/16_groundwater_transport.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,10 @@
"# add time discretisation\n",
"ds = nlmod.time.set_ds_time(\n",
" ds,\n",
" start_time=start_time,\n",
" steady_state=False,\n",
" start=start_time,\n",
" steady=False,\n",
" steady_start=True,\n",
" steady_start_perlen=1,\n",
" transient_timesteps=10,\n",
" perlen=365.0,\n",
" perlen=[365.0]*10,\n",
")\n",
"\n",
"if ds.transport == 1:\n",
Expand Down
Loading