Skip to content

Commit

Permalink
python 39 support (#323)
Browse files Browse the repository at this point in the history
* python 39 support and test

* prepare release

* drop python 39 support
  • Loading branch information
hboisgon authored Jan 29, 2025
1 parent c497316 commit fdefeb0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
17 changes: 7 additions & 10 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
========================
Expand Down
2 changes: 1 addition & 1 deletion hydromt_wflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""hydroMT plugin for wflow models."""

__version__ = "0.7.1dev0"
__version__ = "0.7.1"

from .naming import *
from .utils import *
Expand Down
9 changes: 5 additions & 4 deletions hydromt_wflow/pcrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <root/staticmaps> and parse to xarray.
Expand All @@ -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
Expand Down Expand Up @@ -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 <root/staticmaps> in PCRaster maps format.
Expand All @@ -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.
"""
Expand Down
19 changes: 11 additions & 8 deletions hydromt_wflow/wflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions hydromt_wflow/workflows/demand.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fdefeb0

Please sign in to comment.