From 8675b68390a45d40d9e5971c4a0c59940d303b02 Mon Sep 17 00:00:00 2001 From: JoostBuitink <44062204+JoostBuitink@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:58:16 +0100 Subject: [PATCH] updated changelog; added test --- docs/changelog.rst | 1 + tests/conftest.py | 3 ++- tests/test_model_methods.py | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 49fc0287..ab8b247b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,7 @@ Fixed - **setup_config_output_timeseries**: bugfix for reducer. - update hydromt configuration files from ini to yml format. PR #230 - remove or update calls to check if source in self.data_catalog `Issue #501 `_ +- Included NoDataStrategy from hydromt-core: setup functions for lakes, reservoirs, glaciers, and gauges are skipped when no data is found withing the model region (same behavior as before) PR #229 Deprecated ---------- diff --git a/tests/conftest.py b/tests/conftest.py index 5fa672ab..a2fffd92 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """add global fixtures.""" + import logging import platform from os.path import abspath, dirname, join @@ -72,7 +73,7 @@ def example_wflow_results(): @pytest.fixture() def clipped_wflow_model(): root = join(EXAMPLEDIR, "wflow_piave_clip") - mod = WflowModel(root=root, mode="r") + mod = WflowModel(root=root, mode="r", data_libs="artifact_data") return mod diff --git a/tests/test_model_methods.py b/tests/test_model_methods.py index 758ac001..0a87288f 100644 --- a/tests/test_model_methods.py +++ b/tests/test_model_methods.py @@ -516,3 +516,18 @@ def test_setup_floodplains_2d(elevtn_map, example_wflow_model, floodplain1d_test .raster.mask_nodata() .equals(floodplain1d_testdata[f"{mapname}_D4"]) ) + + +def test_skip_nodata_reservoir(clipped_wflow_model): + # Using the clipped_wflow_model as the reservoirs are not in this model + clipped_wflow_model.setup_reservoirs( + reservoirs_fn="hydro_reservoirs", + min_area=0.0, + ) + assert clipped_wflow_model.config["model"]["reservoirs"] == False + # Get names for two reservoir layers + for mapname in ["resareas", "reslocs"]: + # Check if layers are indeed not present in the model + assert ( + clipped_wflow_model._MAPS[mapname] not in clipped_wflow_model.grid.data_vars + )