diff --git a/docs/api.rst b/docs/api.rst index 5416d263..fcd1337a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -65,8 +65,6 @@ Attributes WflowModel.config WflowModel.grid WflowModel.geoms - WflowModel.staticmaps - WflowModel.staticgeoms WflowModel.forcing WflowModel.states WflowModel.results diff --git a/docs/changelog.rst b/docs/changelog.rst index 1059a085..d3516884 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,12 +6,12 @@ All notable changes to this project will be documented in this page. The format is based on `Keep a Changelog`_, and this project adheres to `Semantic Versioning`_. -Unreleased -========== +v0.6.0 (7 June 2024) +==================== Added ----- -- If applicable, basins geometry based on the higher resolution DEM is stored seperately under **basins_highres** `PR #266 ` +- If applicable, basins geometry based on the higher resolution DEM is stored seperately under **basins_highres** `PR #266 `_ - New function **setup_1dmodel_connection** to connect wflow to 1D river model (eg Delft3D FM 1D, HEC-RAS, etc.) `PR #210 `_ - New setup method for the **KsatHorFrac** parameter **setup_ksathorfarc** to up-downscale existing ksathorfrac maps. `PR #255 `_ - new function **setup_pet_forcing** to reproject existing pet data rather than computing from other meteo data. PR #257 @@ -22,7 +22,7 @@ Added - new utils method **get_grid_from_config** to get the right wflow staticmaps variable based on the TOML configuration (e.g. detects name in netcdf, value, scale and offset). Only applied now to prepare cold states (e.g. not yet in read_grid). PR #252 - Added support for the "GLCNMO" land-use dataset, with a default parameter mapping table (similar to the existing tables). PR #272 - Added the `alpha_h1` parameter (based on land use maps). This parameter represents whether root water uptake reduction at soil water pressure head h1 occurs or not. By default, it is set to 0.0 for all "non-natural" vegetation (crops) and to 1.0 for all "natural vegetation" PR #272 -- Parameter for output filename in **write_grid** (`output_fn`). PR #278 +- Parameter for output filename in **write_grid** (`fn_out`). PR #278 - New function **setup_laimaps_from_lulc_mapping** to set leaf area index (LAI) climatology maps per month based on landuse mapping. PR #273 Changed @@ -40,8 +40,14 @@ Fixed - Removed building a wflow model without a config file in the build notebook. - Deprecated np.bool and earlier error message for subbasin delination. PR #263 -v0.5.0 (February 2024) -====================== +Deprecated +---------- +- **clip_staticmaps** in favour of **clip_grid** +- **read_staticmaps** and **write_staticmaps**, superseded by **read_grid** and **write_grid** +- **read_staticgeoms** and **write_staticgeoms**, superseded by **read_geoms** and **write_geoms** + +v0.5.0 (13 February 2024) +========================= Better handling of nodata and a switch from ini to yaml for configuration. Added @@ -70,16 +76,16 @@ Documentation ------------- - Extra information for most of the setup methods of **WflowModel** and **WflowSedimentModel** -v0.4.1 (November 2023) -====================== +v0.4.1 (22 November 2023) +========================= Small update Fixed ----- - Make HydroMT-Wflow **v0.4.0** conda installable -v0.4.0 (November 2023) -====================== +v0.4.0 (21 November 2023) +========================= Small overhaul of internal methods and stability fixes. This version works with HydroMT **v0.9.1** onwards. Changed @@ -95,8 +101,8 @@ Fixed ----- - Mainly stability fixes -v0.3.0 (July 2023) -================== +v0.3.0 (27 July 2023) +===================== Various new features and bugfixes in support of Wflow.jl v0.7.1. This version works with HydroMT v0.8.0. Added diff --git a/hydromt_wflow/__init__.py b/hydromt_wflow/__init__.py index 207a3b18..cab361ff 100644 --- a/hydromt_wflow/__init__.py +++ b/hydromt_wflow/__init__.py @@ -1,17 +1,6 @@ """hydroMT plugin for wflow models.""" -from os.path import abspath, dirname, join - -__version__ = "0.5.1.dev0" - -try: - import pcraster as pcr - - HAS_PCRASTER = True -except ImportError: - HAS_PCRASTER = False - -DATADIR = join(dirname(abspath(__file__)), "data") +__version__ = "0.6.0" from .utils import * from .wflow import * diff --git a/hydromt_wflow/pcrm.py b/hydromt_wflow/pcrm.py index 0a068779..35aa3559 100644 --- a/hydromt_wflow/pcrm.py +++ b/hydromt_wflow/pcrm.py @@ -14,6 +14,13 @@ from pyflwdir import core_conversion, core_d8, core_ldd from pyproj import CRS +try: + import pcraster as pcr + + HAS_PCRASTER = True +except ImportError: + HAS_PCRASTER = False + logger = logging.getLogger(__name__) # specify pcraster map types @@ -141,8 +148,6 @@ def write_map( """ import tempfile - import pcraster as pcr - with tempfile.TemporaryDirectory() as tmpdir: # deal with pcr clone map if clone_path is None: diff --git a/hydromt_wflow/utils.py b/hydromt_wflow/utils.py index e8af1887..3dc41a31 100644 --- a/hydromt_wflow/utils.py +++ b/hydromt_wflow/utils.py @@ -1,5 +1,5 @@ """Some utilities from the Wflow plugin.""" -from os.path import abspath, join +from os.path import abspath, dirname, join from pathlib import Path from typing import Dict, Optional, Union @@ -9,6 +9,8 @@ from hydromt.vector import GeoDataArray from hydromt.workflows.grid import grid_from_constant +DATADIR = join(dirname(abspath(__file__)), "data") + __all__ = ["read_csv_results", "get_config", "get_grid_from_config"] diff --git a/hydromt_wflow/wflow.py b/hydromt_wflow/wflow.py index a9f16d98..22dae600 100644 --- a/hydromt_wflow/wflow.py +++ b/hydromt_wflow/wflow.py @@ -28,7 +28,8 @@ from pyflwdir import core_conversion, core_d8, core_ldd from shapely.geometry import box -from . import DATADIR, utils, workflows +from . import utils, workflows +from .utils import DATADIR __all__ = ["WflowModel"] @@ -110,9 +111,6 @@ def __init__( self._tables = dict() self._flwdir = None self.data_catalog.from_yml(self._CATALOGS) - # To be deprecated from v0.6.0 onwards - self._staticmaps = None - self._staticgeoms = None # COMPONENTS def setup_basemaps( @@ -3189,13 +3187,11 @@ def read_grid(self, **kwargs): and ``dir_input``. If not found uses the default path ``staticmaps.nc`` in the root folder. - If the file is not found, will try to read from the old PCRaster format if map - files are found in the ``staticmaps`` folder in the root folder using - read_staticmaps_pcr. + For reading old PCRaster maps, see the pcrm submodule. See Also -------- - read_staticmaps_pcr + pcrm.read_staticmaps_pcr """ fn_default = "staticmaps.nc" fn = self.get_config( @@ -3225,16 +3221,6 @@ def read_grid(self, **kwargs): if ds.raster.res[1] > 0: ds = ds.raster.flipud() self.set_grid(ds) - elif len(glob.glob(join(self.root, "staticmaps", "*.map"))) > 0: - self.read_staticmaps_pcr() - - def read_staticmaps(self, **kwargs): - """Read staticmaps. DEPRECATED for read_grid.""" - self.logger.warning( - "read_staticmaps is deprecated. Use 'read_grid' instead. " - "Will be removed in hydromt_wflow v0.6.0" - ) - self.read_grid(**kwargs) def write_grid( self, @@ -3304,14 +3290,6 @@ def write_grid( ds_out[v] = ds_out[v].where(mask, ds_out[v].raster.nodata) ds_out.to_netcdf(fn, encoding=encoding) - def write_staticmaps(self): - """Write staticmaps: DEPRECATED for write_grid.""" - self.logger.warning( - "write_staticmaps is deprecated. Use 'write_grid' instead. " - "Will be removed in hydromt_wflow v0.6.0" - ) - self.write_grid() - def read_geoms( self, geom_fn: str = "staticgeoms", @@ -3337,17 +3315,6 @@ def read_geoms( if name != "region": self.set_geoms(gpd.read_file(fn), name=name) - def read_staticgeoms( - self, - geom_fn: str = "staticgeoms", - ): - """Read static geometries: DEPRECATED for read_geoms.""" - self.logger.warning( - "read_staticgeoms is deprecated. Use 'read_geoms' instead. " - "Will be removed in hydromt_wflow v0.6.0" - ) - self.read_geoms(geom_fn) - def write_geoms( self, geom_fn: str = "staticgeoms", @@ -3377,17 +3344,6 @@ def write_geoms( fn_out = join(self.root, geom_fn, f"{name}.geojson") gdf.to_file(fn_out, driver="GeoJSON") - def write_staticgeoms( - self, - geom_fn: str = "staticgeoms", - ): - """Write static geometries: DEPRECATED for write_geoms.""" - self.logger.warning( - "write_staticgeoms is deprecated. Use 'write_geoms' instead. " - "Will be removed in hydromt_wflow v0.6.0" - ) - self.write_geoms(geom_fn) - def read_forcing(self): """ Read forcing. @@ -3926,32 +3882,6 @@ def rivers(self): gdf = None return gdf - @property - def staticgeoms(self): - """Return static geometries. - - Note: deprecated and will be removed in hydromt_wflow v0.6.0. Use - :py:attr:`geoms` instead. - """ - self.logger.warning( - "staticgeoms is deprecated. Call 'geoms' instead. " - "Will be removed in hydromt_wflow v0.6.0" - ) - return self.geoms - - @property - def staticmaps(self): - """Return staticmaps. - - Note: deprecated and will be removed in hydromt_wflow v0.6.0. Use - :py:attr:`grid` instead. - """ - self.logger.warning( - "staticmaps is deprecated. Call 'grid' instead. " - "Will be removed in hydromt_wflow v0.6.0" - ) - return self.grid - ## WFLOW specific modification (clip for now) methods def clip_grid( @@ -4107,20 +4037,6 @@ def clip_grid( if self.get_config("state.lateral.river.lake") is not None: del self.config["state"]["lateral"]["river"]["lake"] - def clip_staticmaps( - self, - region, - buffer=0, - align=None, - crs=4326, - ): - """Clip staticmaps to subbasin.""" - self.logger.warning( - "clip_staticmaps is deprecated. Use 'clip_grid' instead. " - "Will be removed in hydromt_wflow v0.6.0" - ) - self.clip_grid(region, buffer, align, crs) - def clip_forcing(self, crs=4326, **kwargs): """Return clippped forcing for subbasin. diff --git a/hydromt_wflow/wflow_sediment.py b/hydromt_wflow/wflow_sediment.py index 747a75e3..608b196b 100644 --- a/hydromt_wflow/wflow_sediment.py +++ b/hydromt_wflow/wflow_sediment.py @@ -11,7 +11,7 @@ from hydromt_wflow.wflow import WflowModel -from . import DATADIR +from .utils import DATADIR from .workflows import landuse, soilgrids_sediment __all__ = ["WflowSedimentModel"] diff --git a/hydromt_wflow/workflows/river.py b/hydromt_wflow/workflows/river.py index fc426476..a534661c 100644 --- a/hydromt_wflow/workflows/river.py +++ b/hydromt_wflow/workflows/river.py @@ -10,7 +10,7 @@ from hydromt import flw, gis_utils, stats, workflows from scipy.optimize import curve_fit -from hydromt_wflow import DATADIR # global var +from hydromt_wflow.utils import DATADIR # global var logger = logging.getLogger(__name__) diff --git a/pyproject.toml b/pyproject.toml index 0066f713..58a879c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ authors = [ dependencies = [ "dask", "geopandas>=0.10", - "hydromt>=0.9.3,<0.10", + "hydromt>=0.9.4,<0.11", "netcdf4", "numpy", "pandas",