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.6.0 #192

Merged
merged 122 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
2e942b5
Update dev version
rubencalje Apr 12, 2023
fdbb2f8
Remove dependency on mfpymake
rubencalje Apr 12, 2023
4224213
make surface water methods more robust
rubencalje Apr 12, 2023
2ad644c
Remove warnings when no surface water data is available in extent
rubencalje Apr 12, 2023
4c585f5
Update setup.py
martinvonk Apr 14, 2023
e8e601e
Add information about webservices Vechtstromen
rubencalje Apr 17, 2023
f4fa303
Add information about webservices Rijn en IJssel
rubencalje Apr 17, 2023
76c44a1
typo
dbrakenhoff Apr 17, 2023
e9b8e0f
update ci
dbrakenhoff Apr 17, 2023
4fd79da
Add index of wetercourses of Vechtstromen
rubencalje Apr 17, 2023
18a9bf3
Update dependencies in setup.py, readme and docs
rubencalje Apr 18, 2023
236437e
add methods:
dbrakenhoff May 1, 2023
ebab4b8
add modelgrid_to_ds function
dbrakenhoff May 1, 2023
22798da
code formatting
dbrakenhoff May 1, 2023
f5c909c
improve x, y-origin calculation
dbrakenhoff May 1, 2023
6bd3d3e
docstring and code formatting improvements
dbrakenhoff May 1, 2023
e227c95
minor update nb (black)
dbrakenhoff May 1, 2023
f09e4a6
update reqs
dbrakenhoff May 1, 2023
d6302c8
codacy suggestion
dbrakenhoff May 1, 2023
cc98281
move to pyproject.toml
dbrakenhoff May 1, 2023
125c8ed
forgot to include linting in ci install
dbrakenhoff May 1, 2023
6a853f5
fix
dbrakenhoff May 1, 2023
9978392
set correct netcdf version for gh actions
dbrakenhoff May 1, 2023
b61b20d
fix nb
dbrakenhoff May 2, 2023
77970e8
fix reading ascii file header if key is not in header
martinvonk May 2, 2023
17bd391
try to fix 'no such kernel' error in rtd
OnnoEbbens May 3, 2023
7bf05e7
revert change because of weird error
OnnoEbbens May 3, 2023
69cdafd
Minor change in surface_water.py
rubencalje May 3, 2023
7eacd18
some improvements:
dbrakenhoff May 8, 2023
2756593
set gridgen_ws
dbrakenhoff May 8, 2023
1f9b276
improve dealing with ssm packages
dbrakenhoff May 8, 2023
2a527b9
Knmi stations (#174)
rubencalje May 8, 2023
eab2d35
Knmi stations (#174)
rubencalje May 8, 2023
607d748
Merge branch 'dev' into ds_from_modelgrids
rubencalje May 8, 2023
b662e4b
Merge pull request #169 from ArtesiaWater/ds_from_modelgrids
dbrakenhoff May 9, 2023
b8e227e
add methods:
dbrakenhoff May 1, 2023
c0770dd
add modelgrid_to_ds function
dbrakenhoff May 1, 2023
1b6488b
code formatting
dbrakenhoff May 1, 2023
224f8ba
improve x, y-origin calculation
dbrakenhoff May 1, 2023
8576c3c
codacy suggestion
dbrakenhoff May 1, 2023
8d242ca
some improvements:
dbrakenhoff May 8, 2023
c4ca68d
set gridgen_ws
dbrakenhoff May 8, 2023
f7b65ed
improve dealing with ssm packages
dbrakenhoff May 8, 2023
0de78bb
fix reading ascii file header if key is not in header
martinvonk May 2, 2023
ad39be6
Minor change in surface_water.py
rubencalje May 3, 2023
f1c920e
Knmi stations (#174)
rubencalje May 8, 2023
f931206
Knmi stations (#174)
rubencalje May 8, 2023
ae08bd1
update pyproject toml
dbrakenhoff May 9, 2023
d7d7f16
codacy
dbrakenhoff May 9, 2023
cbf54e6
Merge remote-tracking branch 'origin/dev' into pyproject_toml2
dbrakenhoff May 9, 2023
fc5839a
merge again...
dbrakenhoff May 9, 2023
9a970d9
modify dependency grouping for rtd
dbrakenhoff May 9, 2023
e42e066
add ipython
dbrakenhoff May 9, 2023
a9f6299
attempt to remove metadata
dbrakenhoff May 9, 2023
d271581
attempt to remove metadata
dbrakenhoff May 9, 2023
2bc181c
attempt to remove metadata
dbrakenhoff May 9, 2023
5312c0f
add ipykernel
dbrakenhoff May 9, 2023
1ef997a
Merge pull request #170 from ArtesiaWater/pyproject_toml2
dbrakenhoff May 10, 2023
79c4fe1
Address @rubencalje comments
dbrakenhoff May 10, 2023
8418eea
add animate map func
dbrakenhoff May 11, 2023
8c34e1f
formatting
dbrakenhoff May 11, 2023
131156e
Merge pull request #176 from ArtesiaWater/animate
dbrakenhoff May 12, 2023
0b328cd
Use the provisonal version of modpath (#177)
rubencalje May 12, 2023
1229e2f
Update dev version
rubencalje May 13, 2023
1967697
add method to get time coordinate from gwf/gwt
dbrakenhoff May 15, 2023
1c7be69
add budget output reader function
dbrakenhoff May 15, 2023
eb6bfaa
rename get cellbudget file method
dbrakenhoff May 15, 2023
21a5604
use new ds_time_from_model func to get time coordinates
dbrakenhoff May 15, 2023
648a9d2
use new ds_time_from_model func to get time coordinates
dbrakenhoff May 15, 2023
3f1d037
isort+black
dbrakenhoff May 15, 2023
bc843bc
modpath bug is fixed, so set start_date_time in simulation
dbrakenhoff May 15, 2023
f7653ed
add improved plotting submodule
dbrakenhoff May 15, 2023
a7443ee
black
dbrakenhoff May 15, 2023
60ab0f6
use time units from groundwater model object
dbrakenhoff May 15, 2023
c143a59
rename cbf to cbc
dbrakenhoff May 15, 2023
0773ed1
Merge pull request #178 from ArtesiaWater/time-coord-outputs
dbrakenhoff May 15, 2023
70af375
fix init
dbrakenhoff May 15, 2023
8cbda23
Merge pull request #179 from ArtesiaWater/improve-plotting
dbrakenhoff May 15, 2023
b7bf72d
Minor fixes to meteobase
bdestombe May 23, 2023
646a548
Write crs to meteodata
bdestombe May 24, 2023
de43745
Set nodata values to nan
bdestombe May 24, 2023
187e19a
Add units to meteobase data
bdestombe May 24, 2023
1c736ad
Minor bug prevents using meteobase <py3.9
bdestombe May 24, 2023
a85e412
Suppress false codecov warning
bdestombe May 24, 2023
d55865c
set x/y coordinates local for structured grid in case angrot!=0
dbrakenhoff May 25, 2023
18d7331
add "sum" and "first" methods to aggregate_values function
dbrakenhoff May 25, 2023
cf1aa30
add functions to obtain time index for xarray
dbrakenhoff May 25, 2023
1860e7e
improve gwf output
dbrakenhoff May 25, 2023
b5f3728
improve well tools
dbrakenhoff May 25, 2023
7d3d76d
improve flopy plotting
dbrakenhoff May 25, 2023
ba11748
improve dataset plotting
dbrakenhoff May 25, 2023
8b6f67e
black + isort
dbrakenhoff May 25, 2023
a1e79e2
make meteobase changes a bit more robust
martinvonk May 25, 2023
d4691ec
accidentally removed return
dbrakenhoff May 25, 2023
ea654a7
Merge pull request #182 from ArtesiaWater/meteobase
martinvonk May 25, 2023
c91f705
Reading data from KNMI Data Platform (#166)
martinvonk May 26, 2023
275641f
Delete pytest.ini
rubencalje May 26, 2023
ca3e471
make h5netcdf optional
martinvonk May 26, 2023
9d179cb
update pytest.ini_options in pyproject.toml
martinvonk May 26, 2023
4e1b474
remove deprecated functions
dbrakenhoff Jun 2, 2023
c6cdecc
refactor gwf/gwt output
dbrakenhoff Jun 2, 2023
06e524e
improve plotting
dbrakenhoff Jun 2, 2023
4a2d4d1
add download_mfbinaries to nlmod root
dbrakenhoff Jun 2, 2023
fbc611b
improve DatasetCrossSection
dbrakenhoff Jun 2, 2023
0602780
move dcs to plot
OnnoEbbens Jun 2, 2023
0eec828
Merge branch 'nhzz' of github.com:ArtesiaWater/nlmod into nhzz
OnnoEbbens Jun 2, 2023
e6d723f
black, isort, codacy
dbrakenhoff Jun 2, 2023
8e30f3c
fix test
dbrakenhoff Jun 2, 2023
1b5c4fb
fix imports
OnnoEbbens Jun 3, 2023
d275258
Fix 2 Codacy errors
OnnoEbbens Jun 3, 2023
6be8251
Merge pull request #183 from ArtesiaWater/nhzz
OnnoEbbens Jun 5, 2023
070a03c
Improve waterboard data (Scheldestromen and Hollandse Delta)
rubencalje Jun 5, 2023
06ff3d8
Fix some plot imports
rubencalje Jun 5, 2023
e218e01
Flip MeteoBase data (#185)
bdestombe Jun 6, 2023
7b63db0
Deprecate nlmod facet plot method (#189)
dbrakenhoff Jun 7, 2023
b5e58e5
fix for #186 (#187)
OnnoEbbens Jun 7, 2023
80019b0
Update modules.rst
rubencalje Jun 7, 2023
813df78
Handling data when building flopy packages from model dataset (#188)
dbrakenhoff Jun 7, 2023
c89c505
Remove 06_compare_layermodels.ipynb (#191)
rubencalje Jun 7, 2023
68db768
add test for lake (#184)
OnnoEbbens Jun 7, 2023
d8a8502
Merge branch 'main' into dev
rubencalje Jun 7, 2023
3610637
Process comments from @dbrakenhoff
rubencalje Jun 7, 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
25 changes: 9 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,40 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install codecov
pip install pytest-cov
pip install pytest-dependency
pip install codacy-coverage
pip install mfpymake
pip install -e .

pip install -e .[ci]

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=80 --statistics

- name: Download executables needed for tests
shell: bash -l {0}
run: |
python -c "import nlmod; nlmod.util.download_mfbinaries()"

- name: Run notebooks
if: ${{ github.event_name == 'push' }}
run: |
py.test ./tests -m "not notebooks"

- name: Run tests only
if: ${{ github.event_name == 'pull_request' }}
run: |
py.test ./tests -m "not notebooks"


- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@master
with:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ cython_debug/
*.code-workspace

# nlmod specific
nlmod/bin/
nlmod/bin/*
!nlmod/bin/
!nlmod/bin/mp7_2_002_provisional
flowchartnlmod.pptx
tests/data/
docs/examples/*/
Expand Down
8 changes: 6 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ sphinx:

# Optionally declare the Python requirements required to build your docs
python:
system_packages: true
install:
- requirements: docs/requirements.txt
- method: setuptools
- method: pip
path: .
extra_requirements:
- nbtest
- rtd

20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# nlmod

<img src="docs/_static/logo_10000_2.png" width="256"/>

[![nlmod](https://github.com/ArtesiaWater/nlmod/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ArtesiaWater/nlmod/actions/workflows/ci.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/6fadea550ea04ea28b6ccde88fc56f35)](https://www.codacy.com/gh/ArtesiaWater/nlmod/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=ArtesiaWater/nlmod&amp;utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/6fadea550ea04ea28b6ccde88fc56f35)](https://www.codacy.com/gh/ArtesiaWater/nlmod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ArtesiaWater/nlmod&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/6fadea550ea04ea28b6ccde88fc56f35)](https://www.codacy.com/gh/ArtesiaWater/nlmod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ArtesiaWater/nlmod&utm_campaign=Badge_Coverage)
[![PyPI version](https://badge.fury.io/py/nlmod.svg)](https://badge.fury.io/py/nlmod)
[![Documentation Status](https://readthedocs.org/projects/nlmod/badge/?version=stable)](https://nlmod.readthedocs.io/en/stable/?badge=stable)

Python package with functions to process, build and visualise MODFLOW models in the Netherlands.
Python package with functions to process, build and visualise MODFLOW models in the Netherlands.

The functions in nlmod have four main objectives:

1. Create and adapt the temporal and spatial discretization of a MODFLOW model using an xarray Dataset (`nlmod.dims`).
2. Download and read data from external sources, project this data on the modelgrid and add this data to an xarray Dataset (`nlmod.read`).
3. Use data in an xarray Dataset to build modflow packages using FloPy (`nlmod.gwf` for Modflow 6 and `nlmod.modpath` for Modpath).
Expand All @@ -23,16 +25,18 @@ Install the module with pip:

`pip install nlmod`

`nlmod` has many dependencies `xarray`, `flopy`, `rasterio`, `rioxarray`, `owslib`, `hydropandas`, `netcdf4`, `pyshp`, `rtree`, `openpyxl` and `matplotlib`.
`nlmod` has many required dependencies: `flopy`, `xarray`, `netcdf4`, `rasterio`, `rioxarray`, `affine`, `geopandas`, `owslib`, `hydropandas`, `shapely`, `pyshp`, `rtree`, `matplotlib`, `dask` and `colorama`. On top of that there are some optional dependecies, only needed (and imported) in a single method. Examples of this are `bottleneck` (used in calculate_gxg), `geocube` (used in add_min_ahn_to_gdf), `h5netcdf` (used for hdf5 files backend in xarray). To install the nlmod with the optional dependencies use:

When using pip the dependencies are automatically installed. Some dependencies are notoriously hard to install on certain platforms.
Please see the [dependencies](https://github.com/ArtesiaWater/hydropandas#dependencies) section of the `hydropandas` package for more information on how to install these packages manually.
`pip install nlmod[full]`

When using pip the dependencies are automatically installed. Some dependencies are notoriously hard to install on certain platforms.
Please see the [dependencies](https://github.com/ArtesiaWater/hydropandas#dependencies) section of the `hydropandas` package for more information on how to install these packages manually.

## Getting started

If you are using nlmod for the first time you need to download the MODFLOW executables. You can easily download these executables by running this Python code:

import nlmod
nlmod.util.download_mfbinaries()
import nlmod
nlmod.download_mfbinaries()

After you've downloaded the executables you can run the Jupyter Notebooks in the examples folder. These notebooks illustrate how you to use the nlmod package.
After you've downloaded the executables you can run the Jupyter Notebooks in the examples folder. These notebooks illustrate how you to use the nlmod package.
46 changes: 33 additions & 13 deletions docs/examples/00_model_from_scratch.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -35,6 +36,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -49,10 +51,11 @@
"outputs": [],
"source": [
"if not nlmod.util.check_presence_mfbinaries():\n",
" nlmod.util.download_mfbinaries()"
" nlmod.download_mfbinaries()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -78,6 +81,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -105,6 +109,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -121,6 +126,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -144,6 +150,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -173,6 +180,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -215,6 +223,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -231,6 +240,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -247,6 +257,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -262,20 +273,21 @@
"fig, ax = plt.subplots(1, 1, figsize=(10, 8))\n",
"\n",
"pc = nlmod.plot.data_array(\n",
" head.sel(layer=1).isel(time=0),\n",
" head.sel(layer=0).isel(time=0),\n",
" ds=ds,\n",
" cmap=\"RdYlBu\",\n",
" ax=ax,\n",
" edgecolor=\"k\",\n",
")\n",
"nlmod.plot.modelgrid(ds, ax=ax, alpha=0.5, lw=0.5)\n",
"ax.axis(extent)\n",
"cbar = ax.figure.colorbar(pc, shrink=1.0)\n",
"cbar.set_label(\"head [m NAP]\")\n",
"ax.set_title(\"head layer 1\")\n",
"ax.set_title(\"head first layer\")\n",
"fig.tight_layout()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -288,17 +300,25 @@
"metadata": {},
"outputs": [],
"source": [
"fig, axes = nlmod.plot.facet_plot(\n",
" gwf,\n",
" head,\n",
" lbl=\"head [m NAP]\",\n",
" plot_dim=\"layer\",\n",
" period=0,\n",
"fg = head.plot(\n",
" x=\"x\",\n",
" y=\"y\",\n",
" col=\"layer\",\n",
" col_wrap=3,\n",
" cmap=\"RdYlBu\",\n",
" plot_bc={\"WEL\": {}},\n",
" plot_grid=True,\n",
")"
" subplot_kws={\"aspect\": \"equal\"},\n",
")\n",
"\n",
"for iax in fg.axs.flat:\n",
" nlmod.plot.modelgrid(ds, ax=iax, alpha=0.5, lw=0.5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/01_basic_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -49,7 +50,7 @@
"- a structured grid based on the subsurface models [Regis](https://www.dinoloket.nl/regis-ii-het-hydrogeologische-model) and [Geotop](https://www.dinoloket.nl/detaillering-van-de-bovenste-lagen-met-geotop). The Regis layers that are not present within the extent are removed. In this case we use 'MSz1' as the bottom layer of the model. Use `nlmod.read.regis.get_layer_names()` to get all the layer names of Regis. All Regis layers below this layer are not used in the model. Geotop is used to replace the holoceen layer in Regis because there is no kh or kv defined for the holoceen in Regis. Part of the model is in the North sea. Regis and Geotop have no data there. Therefore the Regis and Geotop layers are extrapolated from the shore and the seabed is added using bathymetry data from [Jarkus](https://www.openearth.nl/rws-bathymetry/2018.html).\n",
"- starting heads of 1 in every cell.\n",
"- the model is a steady state model of a single time step.\n",
"- big surface water bodies (Northsea, IJsselmeer, Markermeer, Noordzeekanaal) within the extent are added as a general head boundary. The surface water bodies are obtained from a [shapefile](..\\data\\opp_water.shp).\n",
"- big surface water bodies (Northsea, IJsselmeer, Markermeer, Noordzeekanaal) within the extent are added as a general head boundary. The surface water bodies are obtained from a [shapefile](..\\data\\shapes\\opp_water.shp).\n",
"- surface drainage is added using [ahn](https://www.ahn.nl) data and a default conductance of $1000 m^2/d$\n",
"- recharge is added using data from the [knmi](https://www.knmi.nl/nederland-nu/klimatologie/daggegevens) using the following steps:~~\n",
" 1. Check for each cell which KNMI weather and/or rainfall station is closest.\n",
Expand Down Expand Up @@ -151,7 +152,7 @@
"ds.update(rws_ds)\n",
"\n",
"# build ghb package\n",
"ghb = nlmod.gwf.ghb(ds, gwf, da_name)"
"ghb = nlmod.gwf.ghb(ds, gwf, bhead=f\"{da_name}_stage\", cond=f\"{da_name}_cond\")"
]
},
{
Expand All @@ -177,7 +178,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\")"
"chd = nlmod.gwf.chd(ds, gwf, mask=\"edge_mask\", head=\"starting_head\")"
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions docs/examples/02_surface_water.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"metadata": {},
"outputs": [],
"source": [
"bgt = nlmod.gwf.add_min_ahn_to_gdf(bgt, ahn, buffer=5.0, column='ahn_min')"
"bgt = nlmod.gwf.add_min_ahn_to_gdf(bgt, ahn, buffer=5.0, column=\"ahn_min\")"
]
},
{
Expand Down Expand Up @@ -171,7 +171,9 @@
"metadata": {},
"outputs": [],
"source": [
"la = nlmod.gwf.surface_water.download_level_areas(bgt, extent=extent, raise_exceptions=False)"
"la = nlmod.gwf.surface_water.download_level_areas(\n",
" bgt, extent=extent, raise_exceptions=False\n",
")"
]
},
{
Expand Down
Loading