diff --git a/docs/changelog.rst b/docs/changelog.rst index dbc3cbbd..ec4f7dc9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,21 +6,18 @@ 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.7.1 (29 January 2025) +======================== +Officially drop support for python 3.9. Added ----- -- **setup_ksatver_vegetation**: method to calculate KsatVer_vegetation to account for biologically-enhanced soil structure in KsatVer. +- **setup_ksatver_vegetation**: method to calculate KsatVer_vegetation to account for biologically-enhanced soil structure in KsatVer. PR #313 - **setup_lulcmaps_from_vector**: method to prepare LULC map and params from a vector input rather than raster. PR #320 -Changed -------- -- - -Fixed ------ -- +Deprecated +---------- +- Support for python 3.9 (already not supported in previous releases). v0.7.0 (8 November 2024) ======================== diff --git a/hydromt_wflow/__init__.py b/hydromt_wflow/__init__.py index e4ba09b8..e437b49a 100644 --- a/hydromt_wflow/__init__.py +++ b/hydromt_wflow/__init__.py @@ -1,6 +1,6 @@ """hydroMT plugin for wflow models.""" -__version__ = "0.7.1dev0" +__version__ = "0.7.1" from .naming import * from .utils import * diff --git a/hydromt_wflow/pcrm.py b/hydromt_wflow/pcrm.py index 95d5ae99..4d7a990d 100644 --- a/hydromt_wflow/pcrm.py +++ b/hydromt_wflow/pcrm.py @@ -5,6 +5,7 @@ import tempfile from os.path import basename, dirname, isdir, isfile, join from pathlib import Path +from typing import Union import numpy as np import pandas as pd @@ -187,7 +188,7 @@ def write_map( def read_staticmaps_pcr( - root: Path | str, crs: int = 4326, obj: object = None, **kwargs + root: Union[Path, str], crs: int = 4326, obj: object = None, **kwargs ): """ Read pcraster staticmaps at and parse to xarray. @@ -196,7 +197,7 @@ def read_staticmaps_pcr( Parameters ---------- - root : Path | str + root : Path, str Path to the root directory of the model. Assumes this folder contains a staticmaps folder with the pcraster maps. crs : int, optional @@ -256,7 +257,7 @@ def read_staticmaps_pcr( def write_staticmaps_pcr( staticmaps: xr.Dataset, - root: Path | str, + root: Union[Path, str], ): """ Write staticmaps at in PCRaster maps format. @@ -265,7 +266,7 @@ def write_staticmaps_pcr( ---------- staticmaps : xr.Dataset Dataset with the staticmaps. - root : Path | str + root : Path, str Path to the root directory of the model. A staticmaps folder will be created in this folder with the pcraster maps. """ diff --git a/hydromt_wflow/wflow.py b/hydromt_wflow/wflow.py index 5a77face..d4dc729e 100644 --- a/hydromt_wflow/wflow.py +++ b/hydromt_wflow/wflow.py @@ -2209,7 +2209,7 @@ def setup_soilmaps( def setup_ksathorfrac( self, ksat_fn: Union[str, xr.DataArray], - variable: str | None = None, + variable: Optional[str] = None, resampling_method: str = "average", ): """Set KsatHorFrac parameter values from a predetermined map. @@ -2220,9 +2220,9 @@ def setup_ksathorfrac( Parameters ---------- - ksat_fn : str, optional + ksat_fn : str, xr.DataArray The identifier of the KsatHorFrac dataset in the data catalog. - variable : str | None, optional + variable : str, optional The variable name for the ksathorfrac map to use in ``ksat_fn`` in case \ ``ksat_fn`` contains several variables. By default None. resampling_method : str, optional @@ -4255,7 +4255,7 @@ def read_grid(self, **kwargs): def write_grid( self, - fn_out: Path | str = None, + fn_out: Optional[Union[Path, str]] = None, ): """ Write grid to wflow static data file. @@ -4266,7 +4266,7 @@ def write_grid( Parameters ---------- - fn_out : Path | str, optional + fn_out : Path, str, optional Name or path to the outgoing grid file (including extension). This is the path/name relative to the root folder and if present the ``dir_input`` folder. @@ -4426,7 +4426,7 @@ def read_geoms( def write_geoms( self, geoms_fn: str = "staticgeoms", - precision: int | None = None, + precision: Optional[int] = None, ): """ Write geoms in GeoJSON format. @@ -4440,6 +4440,9 @@ def write_geoms( geoms_fn : str, optional Folder name/path where the static geometries are stored relative to the model root and ``dir_input`` if any. By default "staticgeoms". + precision : int, optional + Decimal precision to write the geometries. By default None to use 1 decimal + for projected crs and 6 for non-projected crs. """ # to write use self.geoms[var].to_file() if not self._write: @@ -4648,10 +4651,10 @@ def write_forcing( # only correct dates in toml for standard calendars: if not hasattr(da.indexes["time"], "to_datetimeindex"): times = da.time.values - if (start < pd.to_datetime(times[0])) | (start not in times): + if (start < pd.to_datetime(times[0])) or (start not in times): start = pd.to_datetime(times[0]) correct_times = True - if (end > pd.to_datetime(times[-1])) | (end not in times): + if (end > pd.to_datetime(times[-1])) or (end not in times): end = pd.to_datetime(times[-1]) correct_times = True # merge, process and write forcing diff --git a/hydromt_wflow/workflows/demand.py b/hydromt_wflow/workflows/demand.py index e0702904..354d4bf5 100644 --- a/hydromt_wflow/workflows/demand.py +++ b/hydromt_wflow/workflows/demand.py @@ -1,7 +1,7 @@ """Workflow for water demand.""" import logging -from typing import List, Optional, Tuple +from typing import List, Optional, Tuple, Union import geopandas as gpd import numpy as np @@ -438,7 +438,7 @@ def classify_pixels( da_irr: xr.DataArray, da_crop_model: xr.DataArray, threshold: float, - nodata_value: float | int = -9999, + nodata_value: Union[float, int] = -9999, ): """Classifies pixels based on a (fractional) threshold. @@ -453,7 +453,7 @@ def classify_pixels( Layer of the masked cropland in wflow model threshold: float Threshold above which pixels are classified as irrigated - nodata_value: float | int = -9999 + nodata_value: float, int = -9999 Value to be used for nodata Returns diff --git a/pyproject.toml b/pyproject.toml index 729eca1d..3ddd6c88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,13 +19,13 @@ dependencies = [ "pandas", "pyflwdir>=0.5.7", "pyproj", - "rioxarray", + "rioxarray<=0.17.0", # pin because of xarray pin "scipy", "shapely", "toml", "xarray<=2024.3.0", # pin xarray to avoid issues with time resampling and NaN interpolation ] -requires-python = ">=3.9" +requires-python = ">=3.10" readme = "README.rst" classifiers = [ "Development Status :: 4 - Beta", @@ -98,7 +98,7 @@ deps_not_in_conda = [ [tool.black] line-length = 88 -target-version = ['py39'] +target-version = ['py310', 'py311'] [tool.ruff] line-length = 88