Skip to content

Commit

Permalink
Merge pull request #257 from ArtesiaWater/time_discretization_issues
Browse files Browse the repository at this point in the history
Improve time discretization
  • Loading branch information
dbrakenhoff authored Sep 4, 2023
2 parents 14bd019 + 658b4ef commit 89fe3ea
Show file tree
Hide file tree
Showing 26 changed files with 334 additions and 107 deletions.
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 @@ -98,7 +98,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 @@ -96,11 +96,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

0 comments on commit 89fe3ea

Please sign in to comment.