Skip to content

Commit

Permalink
Bugfix when using pyet method to calculate PET (Deltares#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
shartgring committed Aug 1, 2024
1 parent 4a3d6a5 commit a707d44
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ New
---
- Further automate release mechanism. (#1019)


Changed
-------

Fixed
-----
- Bugfix related to use of pyet in Penman-Monteith PET calculation. (#918)

Deprecated
----------
Expand Down
2 changes: 1 addition & 1 deletion hydromt/workflows/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def pm_fao56(
if var == "temp_dew":
avp = pyet.calc_e0(tmean=temp_dew)
elif var == "rh":
avp = pyet.calc_e0(tmax=temp_max, tmin=temp_min, rh=temp_dew)
avp = pyet.calc_ea(tmax=temp_max, tmin=temp_min, rh=temp_dew)

# Net radiation
dates = pyet.utils.get_index(kin)
Expand Down
15 changes: 11 additions & 4 deletions tests/test_forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ def test_pet(data_catalog):
et_data = data_catalog.get_rasterdataset("era5_daily_zarr")
dem = data_catalog.get_rasterdataset("era5_orography").squeeze("time", drop=True)

peto = pet(et_data, et_data, dem, method="penman-monteith_tdew")

assert peto.raster.shape == dem.raster.shape
np.testing.assert_almost_equal(peto.mean(), 0.57746, decimal=4)
peto_tdew = pet(et_data, et_data, dem, method="penman-monteith_tdew")
assert peto_tdew.raster.shape == dem.raster.shape
np.testing.assert_almost_equal(peto_tdew.mean(), 0.57746, decimal=4)

# Convert to relative humidity using simple approach
# as relative humidity is not provided in ERA5 data
# Lawrence (2005) dx.doi.org/10.1175/BAMS-86-2-225
et_data["rh"] = 5 * et_data["temp_dew"] + 100 - 5 * et_data["temp"]
peto_rh = pet(et_data, et_data, dem, method="penman-monteith_rh_simple")
assert peto_rh.raster.shape == dem.raster.shape
np.testing.assert_almost_equal(peto_rh.mean(), 0.51279, decimal=4)

0 comments on commit a707d44

Please sign in to comment.