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

Update to 0.5.2 #160

Merged
merged 67 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
9f8ef5f
Update version.py
rubencalje Feb 21, 2023
3796bba
Add extra tests
rubencalje Feb 21, 2023
63dd5e7
Update tests and simplify nlmod.get_ds a bit more (#146)
rubencalje Feb 23, 2023
dcef7f8
Test if coverage report is added to dev when ci is performed on push …
rubencalje Feb 23, 2023
b25551a
add workspace to gitignore
OnnoEbbens Feb 23, 2023
9799a74
Minor changes grid, surface_water and geotop
rubencalje Mar 2, 2023
c11b60f
fix for #147
OnnoEbbens Mar 6, 2023
7a9e8d4
ensure geoeenheden are ints
dbrakenhoff Mar 7, 2023
027abe2
add lake example
OnnoEbbens Mar 7, 2023
543907b
add a transport attribute to model dataset
dbrakenhoff Mar 7, 2023
02e66ff
add auxiliary variable support to to_reclist functions
dbrakenhoff Mar 7, 2023
772bed4
update gwf for gwt modeling
dbrakenhoff Mar 7, 2023
8e9b315
add gwt submodule
dbrakenhoff Mar 7, 2023
14bf5da
add gwt submodule
dbrakenhoff Mar 7, 2023
4083467
add mini function for registering IMS package
dbrakenhoff Mar 7, 2023
56b2122
update imports to include gwt and sort
dbrakenhoff Mar 7, 2023
fb088a3
add show_versions
dbrakenhoff Mar 7, 2023
134156b
add first nb for groundwater transport
dbrakenhoff Mar 7, 2023
8ff68cf
black + isort
dbrakenhoff Mar 7, 2023
175e1ab
black+isort
dbrakenhoff Mar 9, 2023
a012f50
Merge remote-tracking branch 'origin/dev' into gwt
dbrakenhoff Mar 9, 2023
6859de6
transport flag in ds
dbrakenhoff Mar 9, 2023
507fd51
add aux support to *_to_reclist functions
dbrakenhoff Mar 9, 2023
3ff8ca9
add aggregate_by_weighted_mean_to_ds function
dbrakenhoff Mar 9, 2023
9d1221c
improve gwf
dbrakenhoff Mar 9, 2023
304cb94
add mask to model_datasets_to_rch
dbrakenhoff Mar 9, 2023
c364c13
improve gwt
dbrakenhoff Mar 9, 2023
f63b1a5
gwt output
dbrakenhoff Mar 9, 2023
dd2fbaa
add method to set default transport params
dbrakenhoff Mar 9, 2023
9a589d4
simplify IMS call
dbrakenhoff Mar 9, 2023
349eda9
add kwargs to plot surface water
dbrakenhoff Mar 9, 2023
44c7ba9
update nb
dbrakenhoff Mar 9, 2023
9e88d39
improve gwt
dbrakenhoff Mar 10, 2023
9845707
add freshwater and point water head conversion functions
dbrakenhoff Mar 10, 2023
e0dfdc8
docstring
dbrakenhoff Mar 10, 2023
8d5496c
add descriptions and improve nb
dbrakenhoff Mar 10, 2023
6ffa697
isort and black
dbrakenhoff Mar 10, 2023
7b6e603
codacy
dbrakenhoff Mar 10, 2023
fdbc942
clear nb output
dbrakenhoff Mar 10, 2023
7c56889
testing is smart 8-)
dbrakenhoff Mar 10, 2023
9fadc97
codacy
dbrakenhoff Mar 10, 2023
443f4bb
codacy
dbrakenhoff Mar 10, 2023
42319f8
fix comments by @OnnoEbbens
dbrakenhoff Mar 10, 2023
1daa0a3
fix comments by @OnnoEbbens
dbrakenhoff Mar 10, 2023
d867c4f
whitespace
dbrakenhoff Mar 13, 2023
c2bb7a0
fix for #150
OnnoEbbens Mar 13, 2023
2a2e805
codacy
dbrakenhoff Mar 13, 2023
098013c
Merge pull request #148 from ArtesiaWater/gwt
dbrakenhoff Mar 13, 2023
06c4372
_get_hds should work with only a filename
OnnoEbbens Mar 20, 2023
f3b1ef3
Add option for outlets to lakes
OnnoEbbens Mar 20, 2023
1510129
add lakes to Schoonhoven example
OnnoEbbens Mar 20, 2023
6ac29f3
fix when getting headobj from gwf
OnnoEbbens Mar 20, 2023
71f5c7e
Merge branch 'dev' into lake
OnnoEbbens Mar 23, 2023
18f4569
fix two errors in tests
OnnoEbbens Mar 23, 2023
5749fcb
logging -> logger
OnnoEbbens Mar 23, 2023
3c371cb
codacy fix
OnnoEbbens Mar 23, 2023
c4f61e2
minor change to improve performance
OnnoEbbens Mar 24, 2023
b3dc0fc
processed comments
OnnoEbbens Mar 24, 2023
187472c
Merge pull request #154 from ArtesiaWater/lake
OnnoEbbens Mar 27, 2023
8d6031f
Add Meteobase ASCII read function (#159)
martinvonk Apr 11, 2023
4ff4430
Improve split layers ds and many other improvements (#156)
rubencalje Apr 11, 2023
2a6c5bc
Fixes issue #157
rubencalje Apr 11, 2023
26ea770
Changed data_kind in inactive test
rubencalje Apr 11, 2023
2bdce42
filename was not used in add_season_timeseries
rubencalje Apr 11, 2023
9528e2b
Update version.py
rubencalje Apr 11, 2023
a461e69
Minor changes to documentation
rubencalje Apr 12, 2023
7386579
condacy stuff
rubencalje Apr 12, 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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ cython_debug/

# vscode
.vscode
.code-workspace
*.code-workspace

# nlmod specific
nlmod/bin/
flowchartnlmod.pptx
tests/data/
docs/examples/*/
docs/examples/*/
!docs/examples/data/
!docs/examples/data/chloride_hbossche.nc
13 changes: 5 additions & 8 deletions docs/examples/00_model_from_scratch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"nlmod.util.get_color_logger('INFO');"
"nlmod.util.get_color_logger(\"INFO\");"
]
},
{
Expand Down Expand Up @@ -94,7 +94,6 @@
" extent,\n",
" delr=dx,\n",
" delc=dy,\n",
" layer=len(kh),\n",
" top=top,\n",
" botm=botm,\n",
" kh=kh,\n",
Expand All @@ -118,9 +117,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds = nlmod.time.set_ds_time(\n",
" ds, time=[pd.Timestamp.today()], steady_state=True\n",
")\n"
"ds = nlmod.time.set_ds_time(ds, time=pd.Timestamp.today())"
]
},
{
Expand All @@ -143,7 +140,7 @@
"dis = nlmod.gwf.dis(ds, gwf)\n",
"npf = nlmod.gwf.npf(ds, gwf)\n",
"ic = nlmod.gwf.ic(ds, gwf, starting_head=1.0)\n",
"oc = nlmod.gwf.oc(ds, gwf, save_head=True)\n"
"oc = nlmod.gwf.oc(ds, gwf, save_head=True)"
]
},
{
Expand All @@ -163,7 +160,7 @@
"wells.index.name = \"well no.\"\n",
"wells.loc[0] = 100, -50, -5, -10, -100.0\n",
"wells.loc[1] = 200, 150, -20, -30, -300.0\n",
"wells\n"
"wells"
]
},
{
Expand Down Expand Up @@ -210,7 +207,7 @@
"metadata": {},
"outputs": [],
"source": [
"riv_data = nlmod.gwf.surface_water.rivdata_from_xylist( \n",
"riv_data = nlmod.gwf.surface_water.rivdata_from_xylist(\n",
" gwf, xyriv, riv_layer, riv_stage, riv_cond, riv_botm\n",
")\n",
"\n",
Expand Down
24 changes: 9 additions & 15 deletions docs/examples/01_basic_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"import flopy\n",
"import geopandas as gpd\n",
"import matplotlib.pyplot as plt\n",
"import nlmod\n"
"import nlmod"
]
},
{
Expand All @@ -35,7 +35,7 @@
"source": [
"print(f\"nlmod version: {nlmod.__version__}\")\n",
"\n",
"nlmod.util.get_color_logger('INFO');"
"nlmod.util.get_color_logger(\"INFO\");"
]
},
{
Expand Down Expand Up @@ -94,9 +94,7 @@
")\n",
"\n",
"# create a model ds by changing grid of layer_model\n",
"ds = nlmod.to_model_ds(\n",
" layer_model, model_name, model_ws, delr=delr, delc=delc\n",
")\n",
"ds = nlmod.to_model_ds(layer_model, model_name, model_ws, delr=delr, delc=delc)\n",
"\n",
"# add time discretisation\n",
"ds = nlmod.time.set_ds_time(\n",
Expand Down Expand Up @@ -135,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 @@ -153,7 +151,7 @@
"ds.update(rws_ds)\n",
"\n",
"# build ghb package\n",
"ghb = nlmod.gwf.ghb(ds, gwf, da_name)\n"
"ghb = nlmod.gwf.ghb(ds, gwf, da_name)"
]
},
{
Expand All @@ -179,7 +177,7 @@
"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, chd=\"edge_mask\", head=\"starting_head\")\n"
"chd = nlmod.gwf.chd(ds, gwf, chd=\"edge_mask\", head=\"starting_head\")"
]
},
{
Expand All @@ -189,14 +187,12 @@
"outputs": [],
"source": [
"# download knmi recharge data\n",
"knmi_ds = nlmod.read.knmi.get_recharge(\n",
" ds, cachedir=ds.cachedir, cachename=\"recharge\"\n",
")\n",
"knmi_ds = nlmod.read.knmi.get_recharge(ds, cachedir=ds.cachedir, cachename=\"recharge\")\n",
"# update model dataset\n",
"ds.update(knmi_ds)\n",
"\n",
"# create recharge package\n",
"rch = nlmod.gwf.rch(ds, gwf)\n"
"rch = nlmod.gwf.rch(ds, gwf)"
]
},
{
Expand Down Expand Up @@ -231,9 +227,7 @@
"metadata": {},
"outputs": [],
"source": [
"nlmod.sim.write_and_run(\n",
" sim, ds, write_ds=True, nb_path=\"01_basic_model.ipynb\"\n",
")"
"nlmod.sim.write_and_run(sim, ds, write_ds=True, nb_path=\"01_basic_model.ipynb\")"
]
},
{
Expand Down
50 changes: 18 additions & 32 deletions docs/examples/02_surface_water.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"source": [
"print(f\"nlmod version: {nlmod.__version__}\")\n",
"\n",
"nlmod.util.get_color_logger('INFO');"
"nlmod.util.get_color_logger(\"INFO\");"
]
},
{
Expand Down Expand Up @@ -92,7 +92,7 @@
"source": [
"fname_ahn = os.path.join(cachedir, \"ahn.tif\")\n",
"if not os.path.isfile(fname_ahn):\n",
" ahn = nlmod.read.ahn.get_ahn4(extent, identifier='AHN4_DTM_5m')\n",
" ahn = nlmod.read.ahn.get_ahn4(extent, identifier=\"AHN4_DTM_5m\")\n",
" ahn.rio.to_raster(fname_ahn)\n",
"ahn = rioxarray.open_rasterio(fname_ahn, mask_and_scale=True)"
]
Expand Down Expand Up @@ -122,7 +122,7 @@
"metadata": {},
"source": [
"#### Add minimum surface height around surface water bodies\n",
"Get the minimum surface level in 1 meter around surface water levels and add these data to the column 'ahn_min'."
"Get the minimum surface level in 5 meter around surface water levels and add these data to the column 'ahn_min'."
]
},
{
Expand All @@ -132,18 +132,7 @@
"metadata": {},
"outputs": [],
"source": [
"# use geocube\n",
"gc = make_geocube(\n",
" vector_data=bgt.buffer(5.0).reset_index().rename_geometry('geometry'),\n",
" measurements=[\"index\"],\n",
" like=ahn, # ensure the data are on the same grid\n",
" rasterize_function=partial(rasterize_image, all_touched=True),\n",
")\n",
"gc['ahn'] = ahn\n",
"\n",
"ahn_min = gc.groupby('index').min()['ahn'].to_pandas()\n",
"ahn_min.index = ahn_min.index.astype(int)\n",
"bgt['ahn_min'] = ahn_min"
"bgt = nlmod.gwf.add_min_ahn_to_gdf(bgt, ahn, buffer=5.0, column='ahn_min')"
]
},
{
Expand Down Expand Up @@ -182,7 +171,7 @@
"metadata": {},
"outputs": [],
"source": [
"pg = nlmod.gwf.surface_water.download_level_areas(bgt, extent=extent)"
"la = nlmod.gwf.surface_water.download_level_areas(bgt, extent=extent, raise_exceptions=False)"
]
},
{
Expand All @@ -203,8 +192,8 @@
"source": [
"f, ax = nlmod.plot.get_map(extent)\n",
"bgt.plot(color=\"k\", ax=ax)\n",
"for wb in pg:\n",
" pg[wb].plot(\"summer_stage\", ax=ax, vmin=-3, vmax=1, zorder=0)"
"for wb in la:\n",
" la[wb].plot(\"summer_stage\", ax=ax, vmin=-3, vmax=1, zorder=0)"
]
},
{
Expand All @@ -223,7 +212,7 @@
"metadata": {},
"outputs": [],
"source": [
"bgt = nlmod.gwf.surface_water.add_stages_from_waterboards(bgt, pg=pg)"
"bgt = nlmod.gwf.surface_water.add_stages_from_waterboards(bgt, la=la)"
]
},
{
Expand Down Expand Up @@ -349,7 +338,9 @@
"outputs": [],
"source": [
"# layer model\n",
"layer_model = nlmod.read.get_regis(extent, cachedir=cachedir, cachename=\"layer_model.nc\")\n",
"layer_model = nlmod.read.get_regis(\n",
" extent, cachedir=cachedir, cachename=\"layer_model.nc\"\n",
")\n",
"layer_model"
]
},
Expand All @@ -361,9 +352,7 @@
"outputs": [],
"source": [
"# create a model ds by changing grid of layer_model\n",
"ds = nlmod.to_model_ds(\n",
" layer_model, model_name, model_ws, delr=delr, delc=delc\n",
")\n",
"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",
Expand Down Expand Up @@ -502,12 +491,13 @@
"outputs": [],
"source": [
"fig, ax = plt.subplots(1, 1, figsize=(10, 8))\n",
"sfw_grid.loc[mask].plot(column=\"identificatie\", legend=True, ax=ax,\n",
" legend_kwds={\"loc\": \"upper left\"})\n",
"sfw_grid.loc[mask].plot(\n",
" column=\"identificatie\", legend=True, ax=ax, legend_kwds={\"loc\": \"upper left\"}\n",
")\n",
"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)\n",
"ax.set_ylim(ylim)\n",
"ax.set_title(f\"Surface water shapes in cell: {cid}\");"
]
Expand Down Expand Up @@ -581,9 +571,7 @@
"metadata": {},
"outputs": [],
"source": [
"celldata = nlmod.gwf.surface_water.aggregate(\n",
" sfw_grid, \"area_weighted\"\n",
")"
"celldata = nlmod.gwf.surface_water.aggregate(sfw_grid, \"area_weighted\")"
]
},
{
Expand Down Expand Up @@ -723,9 +711,7 @@
"metadata": {},
"outputs": [],
"source": [
"nlmod.sim.write_and_run(\n",
" sim, ds, write_ds=True, nb_path=\"02_surface_water.ipynb\"\n",
")"
"nlmod.sim.write_and_run(sim, ds, write_ds=True, nb_path=\"02_surface_water.ipynb\")"
]
},
{
Expand Down
24 changes: 10 additions & 14 deletions docs/examples/03_local_grid_refinement.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"metadata": {},
"outputs": [],
"source": [
"print(f'nlmod version: {nlmod.__version__}')\n",
"print(f\"nlmod version: {nlmod.__version__}\")\n",
"\n",
"nlmod.util.get_color_logger('INFO');"
"nlmod.util.get_color_logger(\"INFO\");"
]
},
{
Expand Down Expand Up @@ -91,9 +91,7 @@
")\n",
"\n",
"# create a model ds by changing grid of layer_model\n",
"ds = nlmod.to_model_ds(\n",
" layer_model, model_name, model_ws, delr=delr, delc=delc\n",
")\n",
"ds = nlmod.to_model_ds(layer_model, model_name, model_ws, delr=delr, delc=delc)\n",
"\n",
"# add time discretisation\n",
"ds = nlmod.time.set_ds_time(\n",
Expand Down Expand Up @@ -122,9 +120,7 @@
"outputs": [],
"source": [
"# use gridgen to create vertex grid\n",
"ds = nlmod.grid.refine(\n",
" ds, refinement_features=[(refine_shp_fname, \"line\", levels)]\n",
")\n",
"ds = nlmod.grid.refine(ds, refinement_features=[(refine_shp_fname, \"line\", levels)])\n",
"\n",
"if add_northsea:\n",
" ds = nlmod.read.rws.add_northsea(ds, cachedir=cachedir)"
Expand Down Expand Up @@ -194,9 +190,7 @@
"outputs": [],
"source": [
"# add knmi recharge to the model datasets\n",
"knmi_ds = nlmod.read.knmi.get_recharge(\n",
" ds, cachedir=ds.cachedir, cachename=\"recharge\"\n",
")\n",
"knmi_ds = nlmod.read.knmi.get_recharge(ds, cachedir=ds.cachedir, cachename=\"recharge\")\n",
"ds.update(knmi_ds)\n",
"\n",
"# create recharge package\n",
Expand Down Expand Up @@ -321,13 +315,15 @@
"metadata": {},
"outputs": [],
"source": [
"fname = os.path.join(ds.figdir, 'results.nc')\n",
"fname = os.path.join(ds.figdir, \"results.nc\")\n",
"nlmod.gis.ds_to_ugrid_nc_file(ds, fname)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/x-python"
},
"source": [
"## Compare with measurements\n",
"We can download the BRO groundwater observation data and compare the model results with this data."
Expand Down
Loading