Skip to content

Commit

Permalink
Merge branch 'main' into bugfixes-maps
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer authored Oct 18, 2024
2 parents eaec995 + dca452d commit 1ea728e
Show file tree
Hide file tree
Showing 16 changed files with 431 additions and 26 deletions.
400 changes: 400 additions & 0 deletions docs/_static/hydromt-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/_static/hydromt-logo.jpg
Binary file not shown.
10 changes: 8 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The format is based on `Keep a Changelog`_, and this project adheres to
Unreleased
==========
This version includes many code updates to accomodate for newer versions of dependencies.
This makes the code more robust and future-proof.
The only upper bound left is hydromt<1.

Added
-----
Expand All @@ -21,15 +21,21 @@ Changed
-------
- Change default spacing in setup_channels from ``None`` to ``np.inf``. (PR #133)
- Added ``maxdist`` variable to setup_rivers and setup_channels. (PR #153)
- Renamed ``manhole_defaults_fn`` to ``manholes_defaults_fn`` in ``setup_manholes`` for consistency. (PR #187)
- No data values in maps from ``setup_maps_from_rasterdataset`` are now handled as -999.0. (PR #161)

Fixed
-----
- Bugfixing of reading of frictions (global), crosssections and boundaries when update. (PR #81)
- Fixing bug related to changes to pandas TimeDelta formatting, see also https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#other-deprecations. (PR #129)
- Support for xugrid>=0.9.0, meshkernel>=4.3.0, hydromt>=0.10,<1, pandas>=2. (PR #129)
- Fixing setup_links1d2d for 2d to 1d direction. (PR #133)
- Support for hydrolib-core>=0.8.0. (PR #139)
- Add support for Python 3.12. (PR #149)
- Fix writing of structures with newer (geo)pandas versions. (PR #151)
- Several bugfixes related to processing of cross-sections (PR #153)
- Support for geopandas v1 (PR #158)
- Support for latest version hydromt artifact data. (PR #160)
- Avoid sediment section in mdu so generated models can run in Delft3D FM Suite 2024.03 1D2D. (PR #184)

v0.2.0 (20 November 2023)
=========================
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def remove_dir_content(path: str) -> None:
# a list of builtin themes.
#
html_theme = "pydata_sphinx_theme"
html_logo = "_static/hydromt-logo.jpg"
html_logo = "_static/hydromt-icon.svg"
html_favicon = "_static/hydromt-icon.svg"
autodoc_member_order = "bysource" # overwrite default alphabetical sort
autoclass_content = "both"

Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/dflowfm_build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Settings to build or update a Delft3DFM model are managed in a configuration fil
every option from each :ref:`model method <model_methods>` can be changed by the user
in its corresponding section.

Note that the order in which the components are listed in the yml/ini file is important:
Note that the order in which the components are listed in the yml file is important:


- When setting up a 1D model, one of the `setup_rivers`, `setup_channels` and `setup_pipes` should always be run first to determine the model topology.
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/dflowfm_model_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The main interactions are available from the HydroMT Command Line Interface and
HydroMT in order to build or update Delft3D FM models.

When building or updating a model from command line a model setup
:ref:`configuration <model_config>` (.yml/.ini file) with model methods and options and, optionally,
:ref:`configuration <model_config>` (.yml file) with model methods and options and, optionally,
a `data sources <https://deltares.github.io/hydromt/latest/user_guide/data_prepare_cat.html>`_ (.yml) file should be prepared.

.. _model_methods:
Expand Down
6 changes: 3 additions & 3 deletions examples/build_1d2dmodel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"\n",
"More information on how to write a data catalog yml file can be found in the [HydroMT core docs](https://deltares.github.io/hydromt/latest/user_guide/data_prepare_cat.html) \n",
"\n",
"> **NOTE**: In HydroMT-Delft3D FM, an additionnal data catalog with all default parameters values is always used [parameters_data.yml](https://github.com/Deltares/hydromt_delft3dfm/tree/main/hydromt_delft3dfm/data/parameters_data.yml). It contains default values for 1D network elements and structures as well as default 2D landuse paramter mapping tables."
"> **NOTE**: In HydroMT-Delft3D FM, an additional data catalog with all default parameters values is always used [parameters_data.yml](https://github.com/Deltares/hydromt_delft3dfm/tree/main/hydromt_delft3dfm/data/parameters_data.yml). It contains default values for 1D network elements and structures as well as default 2D landuse parameter mapping tables."
]
},
{
Expand All @@ -109,7 +109,7 @@
"id": "fb8282c9",
"metadata": {},
"source": [
"The HydroMT configuration file contains the model setup configuration and determines which methods are used to prepare the different components of a Delft3D FM model and in which order and optionally sets non-default arguments for each method. This configuration is passed to HydroMT using `-i <path_to_configuration_file>`. The supported format are either YAML or INI. We have prepared several example yml-files which are available in the model repository [examples folder](https://github.com/Deltares/hydromt_delft3dfm/tree/main/examples) and from the [docs (building a model)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_build). \n",
"The HydroMT configuration file contains the model setup configuration and determines which methods are used to prepare the different components of a Delft3D FM model and in which order and optionally sets non-default arguments for each method. This configuration is passed to HydroMT using `-i <path_to_configuration_file>`. We have prepared several example yml-files which are available in the model repository [examples folder](https://github.com/Deltares/hydromt_delft3dfm/tree/main/examples) and from the [docs (building a model)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_build). \n",
"\n",
"Each section, before indent, (e.g. setup_rivers_from_dem) corresponds to a model method. All model methods are explained in the [docs (model components)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_model_setup.html). The `global` section contains direct model initialisation properties."
]
Expand Down Expand Up @@ -146,7 +146,7 @@
"\n",
"- [setup_rivers_from_dem](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_rivers_from_dem.html): We will derive the 1D rivers lines based on the *MERIT Hydro DEM* and that intersects with the region bounding box [12.4331, 46.4661, 12.5212, 46.5369]. River roughness will be a Manning constant of 25.0 and we will use data from *rivers_lin2019* database to prepare rectangular cross-sections. \n",
"- [setup_pipes](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_pipes.html): We will add pipes by assuming that they are located under the roads, with a standard length of 50 meters. The roads are defined in the *grip_roads* data and the standard length are defined in the argument spacing. Roughness will be a WhiteColeBrook constant of 0.003 and we will use a circular cross-sections of 0.5m. The pipes invert levels will be derived from the *MERIT Hydro DEM* assuming a constant depth of the pipe underground of 2 meters. \n",
"- [setup_manholes](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_manholes.html): For a pipe network, manholes are present at pipe connections. Here we do not have specific input data locations for our pipes, so manholes will be generated based on a set of standards specified in manhole_defaults_fn.\n",
"- [setup_manholes](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_manholes.html): For a pipe network, manholes are present at pipe connections. Here we do not have specific input data locations for our pipes, so manholes will be generated based on a set of standards specified in manholes_defaults_fn.\n",
"- [setup_1dboundary](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_1dboundary.html): Finally as a default, we will apply both upstream and downstream boundaries of our rivers with a constant waterlevel of -2.0 meter a.s.l\n",
"\n",
"- [setup_mesh2d](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_mesh2d.html): we will prepare a regular grid for the region bounding box [12.4331, 46.4661, 12.5212, 46.5369] of *500***500* meters resolution.\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/build_1dmodel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"\n",
"More information on how to write a data catalog yml file can be found in the [HydroMT core docs](https://deltares.github.io/hydromt/latest/user_guide/data_prepare_cat.html) \n",
"\n",
"> **NOTE**: In HydroMT-Delft3D FM, an additionnal data catalog with all default parameters values is always used [parameters_data.yml](https://github.com/Deltares/hydromt_delft3dfm/tree/main/hydromt_delft3dfm/data/parameters_data.yml). It contains default values for 1D network elements and structures as well as default 2D landuse paramter mapping tables."
"> **NOTE**: In HydroMT-Delft3D FM, an additional data catalog with all default parameters values is always used [parameters_data.yml](https://github.com/Deltares/hydromt_delft3dfm/tree/main/hydromt_delft3dfm/data/parameters_data.yml). It contains default values for 1D network elements and structures as well as default 2D landuse parameter mapping tables."
]
},
{
Expand All @@ -107,7 +107,7 @@
"id": "fb8282c9",
"metadata": {},
"source": [
"The HydroMT configuration file contains the model setup configuration and determines which methods are used to prepare the different components of a Delft3D FM model and in which order and optionally sets non-default arguments for each method. This configuration is passed to HydroMT using `-i <path_to_configuration_file>`. The supported format are either YAML or INI. We have prepared several example yml-files which are available in the model repository [examples folder](https://github.com/Deltares/hydromt_delft3dfm/tree/main/examples) and from the [docs (building a model)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_build). \n",
"The HydroMT configuration file contains the model setup configuration and determines which methods are used to prepare the different components of a Delft3D FM model and in which order and optionally sets non-default arguments for each method. This configuration is passed to HydroMT using `-i <path_to_configuration_file>`. We have prepared several example yml-files which are available in the model repository [examples folder](https://github.com/Deltares/hydromt_delft3dfm/tree/main/examples) and from the [docs (building a model)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_build). \n",
"\n",
"Each section, before indent, (e.g. setup_rivers_from_dem) corresponds to a model method. All model methods are explained in the [docs (model components)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_model_setup.html). The `global` section contains direct model initialisation properties."
]
Expand Down Expand Up @@ -143,7 +143,7 @@
"- [global](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.html#hydromt_delft3dfm.DFlowFMModel): Our model will be defined in the projected CRS WGS84 EPSG 3857. TO ensure the 1D network is connected, we will allow snapping of 25 meters using argument network_snap_offset. The 1D computational grid for the open water system will be created at 40 meters distance using argument openwater_computation_node_distance. \n",
"- [setup_rivers_from_dem](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_rivers_from_dem.html): We will derive the 1D rivers lines based on the *MERIT Hydro DEM* and that intersects with the region bounding box [12.4331, 46.4661, 12.5212, 46.5369]. River roughness will be a Manning constant of 25.0 and we will use data from *rivers_lin2019* database to prepare rectangular cross-sections. \n",
"- [setup_pipes](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_pipes.html): We will add pipes by assuming that they are located under the roads, with a standard length of 50 meters. The roads are defined in the *grip_roads* data and the standard length are defined in the argument spacing. Roughness will be a WhiteColeBrook constant of 0.003 and we will use a circular cross-sections of 0.5m. The pipes invert levels will be derived from the *MERIT Hydro DEM* assuming a constant depth of the pipe underground of 2 meters. \n",
"- [setup_manholes](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_manholes.html): For a pipe network, manholes are present at pipe connections. Here we do not have specific input data locations for our pipes, so manholes will be generated based on a set of standards specified in manhole_defaults_fn.\n",
"- [setup_manholes](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_manholes.html): For a pipe network, manholes are present at pipe connections. Here we do not have specific input data locations for our pipes, so manholes will be generated based on a set of standards specified in manholes_defaults_fn.\n",
"- [setup_1dboundary](https://deltares.github.io/hydromt_delft3dfm/latest/_generated/hydromt_delft3dfm.DFlowFMModel.setup_1dboundary.html): Finally as a default, we will apply both upstream and downstream boundaries of our rivers with a constant waterlevel of -2.0 meter a.s.l\n",
"\n",
"Feel free to use the links of each components to know more about how each function works and what are all the available settings."
Expand Down
4 changes: 2 additions & 2 deletions examples/build_2dmodel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"\n",
"More information on how to write a data catalog yml file can be found in the [HydroMT core docs](https://deltares.github.io/hydromt/latest/user_guide/data_prepare_cat.html) \n",
"\n",
"> **NOTE**: In HydroMT-Delft3D FM, an additionnal data catalog with all default parameters values is always used [parameters_data.yml](https://github.com/Deltares/hydromt_delft3dfm/tree/main/hydromt_delft3dfm/data/parameters_data.yml). It contains default values for 1D network elements and structures as well as default 2D landuse paramter mapping tables."
"> **NOTE**: In HydroMT-Delft3D FM, an additional data catalog with all default parameters values is always used [parameters_data.yml](https://github.com/Deltares/hydromt_delft3dfm/tree/main/hydromt_delft3dfm/data/parameters_data.yml). It contains default values for 1D network elements and structures as well as default 2D landuse parameter mapping tables."
]
},
{
Expand All @@ -107,7 +107,7 @@
"id": "fb8282c9",
"metadata": {},
"source": [
"The HydroMT configuration file contains the model setup configuration and determines which methods are used to prepare the different components of a Delft3D FM model and in which order and optionally sets non-default arguments for each method. This configuration is passed to HydroMT using `-i <path_to_configuration_file>`. The supported format are either YAML or INI. We have prepared several example yml-files which are available in the model repository [examples folder](https://github.com/Deltares/hydromt_delft3dfm/tree/main/examples) and from the [docs (building a model)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_build). \n",
"The HydroMT configuration file contains the model setup configuration and determines which methods are used to prepare the different components of a Delft3D FM model and in which order and optionally sets non-default arguments for each method. This configuration is passed to HydroMT using `-i <path_to_configuration_file>`. We have prepared several example yml-files which are available in the model repository [examples folder](https://github.com/Deltares/hydromt_delft3dfm/tree/main/examples) and from the [docs (building a model)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_build). \n",
"\n",
"Each section, before indent, (e.g. setup_mesh2d) corresponds to a model method. All model methods are explained in the [docs (model components)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_model_setup.html). The `global` section contains direct model initialisation properties."
]
Expand Down
2 changes: 1 addition & 1 deletion examples/dflowfm_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ setup_pipes:

setup_manholes:
manholes_fn:
manhole_defaults_fn: manholes_defaults
manholes_defaults_fn: manholes_defaults
dem_fn: merit_hydro
bedlevel_shift: 0.5

Expand Down
2 changes: 1 addition & 1 deletion examples/dflowfm_build1d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ setup_pipes:

setup_manholes:
manholes_fn:
manhole_defaults_fn: manholes_defaults
manholes_defaults_fn: manholes_defaults
dem_fn: merit_hydro
bedlevel_shift: 0.5

Expand Down
2 changes: 1 addition & 1 deletion examples/plot_dflowfm_mesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"# Get the different types of branches in mesh1d\n",
"rivers = mod.rivers\n",
"pipes = mod.pipes\n",
"# Additionnal geometry and structures\n",
"# Additional geometry and structures\n",
"manholes = mod.geoms[\"manholes\"]\n",
"crosssections = mod.geoms[\"crosssections\"]\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/update_refine_2dgrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"source": [
"Updating a bedlevel or infiltration capacity map is an easy step with the command line but sometimes, for example with forcing or grid refinement, you need to update several things at the same time. This is possible by preparing a **configuration file** that includes every methods and settings that you want to do during your update.\n",
"\n",
"The configuration-file contains the model setup configuration and determines which methods are updated and in which sequence and sets optional arguments for each method. This configuration is passed to hydromt using `-i <path_to_ini_file>`. The supported format are either YAML or INI.\n",
"The configuration-file contains the model setup configuration and determines which methods are updated and in which sequence and sets optional arguments for each method. This configuration is passed to hydromt using `-i <path_to_configuration_file>`.\n",
"\n",
"Each section, before indent, (e.g. setup_mesh2d_refine) corresponds with a model method which are explained in the [docs (model methods)](https://deltares.github.io/hydromt_delft3dfm/latest/user_guide/dflowfm_model_setup.html).\n",
"\n",
Expand Down
10 changes: 5 additions & 5 deletions hydromt_delft3dfm/dflowfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ def _setup_crosssections(
def setup_manholes(
self,
manholes_fn: str = None,
manhole_defaults_fn: str = "manholes_defaults",
manholes_defaults_fn: str = "manholes_defaults",
bedlevel_shift: float = -0.5,
dem_fn: str = None,
snap_offset: float = 1e-3,
Expand All @@ -1330,7 +1330,7 @@ def setup_manholes(
Can only be used after all branches are setup.
The manholes are generated based on a set of standards specified in
``manhole_defaults_fn`` (default) and can be overwritten with manholes
``manholes_defaults_fn`` (default) and can be overwritten with manholes
read from ``manholes_fn``.
Use ``manholes_fn`` to set the manholes from a dataset of point locations.
Expand All @@ -1339,7 +1339,7 @@ def setup_manholes(
Manhole attributes ["area", "streetstoragearea", "storagetype", "streetlevel"]
are either taken from ``manholes_fn`` or filled in using defaults in
``manhole_defaults_fn``.
``manholes_defaults_fn``.
Manhole attribute ["bedlevel"] is always generated from invert levels of the
pipe/tunnel network plus a shift defined in ``bedlevel_shift``. This is needed
for numerical stability.
Expand Down Expand Up @@ -1414,7 +1414,7 @@ def setup_manholes(
self.set_branches(branches)

# add manhole attributes from defaults
defaults = self.data_catalog.get_dataframe(manhole_defaults_fn)
defaults = self.data_catalog.get_dataframe(manholes_defaults_fn)

# add defaults
manholes = workflows.update_data_columns_attributes(manholes, defaults)
Expand Down Expand Up @@ -3729,7 +3729,7 @@ def set_mesh(

def set_link1d2d(
self,
link1d2d: xr.Dataset(),
link1d2d: xr.Dataset,
):
"""
Add or replace the link1d2d in the model mesh.
Expand Down
4 changes: 1 addition & 3 deletions hydromt_delft3dfm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ def write_branches_gui(
return branchgui_fn


def read_crosssections(
gdf: gpd.GeoDataFrame, fm_model: FMModel
) -> tuple((gpd.GeoDataFrame, gpd.GeoDataFrame)):
def read_crosssections(gdf: gpd.GeoDataFrame, fm_model: FMModel) -> gpd.GeoDataFrame:
"""
Read crosssections from hydrolib-core crsloc and crsdef objects and add to branches.
Expand Down
Loading

0 comments on commit 1ea728e

Please sign in to comment.