Skip to content

Commit

Permalink
fix mrt and utci
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal committed Oct 13, 2023
1 parent 34fb116 commit 133fb2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ v0.46.0 (unreleased)
--------------------
Contributors to this version: Éric Dupuis (:user:`coxipi`), Trevor James Smith (:user:`Zeitsperre`), David Huard (:user:`huard`).

Announcements
^^^^^^^^^^^^^
* The default mechanism for computing the Mean Radiant Temperature, a part of the Universal Thermal Climate Index (UTCI) was broken in xclim 0.44 and 0.45. This has been fixed by changing the default.

New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Add ``wind_power_potential`` to estimate the potential for wind power production given wind speed at the turbine hub height and turbine specifications, along with ``wind_profile`` to estimate the wind speed at different heights based on wind speed at a reference height. (:issue:`1458`, :pull:`1471`)
Expand All @@ -22,6 +26,7 @@ Bug fixes
* Optimization of indicators ``huglin_index`` and ``biologically_effective_degree_days`` when used with dask and flox. As a side effect, the indice functions (i.e. under ``xc.indices``) no longer mask incomplete periods. The indicators' output is unchanged under the default "check_missing" setting (:issue:`1494`, :pull:`1495`).
* Fixed ``xclim.indices.run_length.lazy_indexing`` which would sometimes trigger the loading of auxiliary coordinates. (:issue:`1483`, :pull:`1484`).
* Fixed a bug in the `pytest` configuration that could prevent testing data caching from occurring in systems where the platform-dependent cache directory is not found in the user's home. (:issue:`1468`, :pull:`1473`).
* Remove nonsensical `stat='average'` option for ``mean_radiant_temperature``. (:issue:`1496`, :pull:`1501`).

Breaking changes
^^^^^^^^^^^^^^^^
Expand Down
24 changes: 7 additions & 17 deletions xclim/indices/_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ def universal_thermal_climate_index(
rsus: xr.DataArray = None,
rlds: xr.DataArray = None,
rlus: xr.DataArray = None,
stat: str = "average",
stat: str = "sunlit",
mask_invalid: bool = True,
) -> xr.DataArray:
r"""Universal thermal climate index (UTCI).
Expand Down Expand Up @@ -1801,12 +1801,10 @@ def universal_thermal_climate_index(
rlus : xr.DataArray, optional
Surface Upwelling Longwave Radiation
This is necessary if mrt is not None.
stat : {'average', 'instant', 'sunlit'}
Which statistic to apply. If "average", the average of the cosine of the
solar zenith angle is calculated. If "instant", the instantaneous cosine
stat : {'instant', 'sunlit'}
Which statistic to apply. If "instant", the instantaneous cosine
of the solar zenith angle is calculated. If "sunlit", the cosine of the
solar zenith angle is calculated during the sunlit period of each interval.
If "instant", the instantaneous cosine of the solar zenith angle is calculated.
This is necessary if mrt is not None.
mask_invalid: bool
If True (default), UTCI values are NaN where any of the inputs are outside
Expand Down Expand Up @@ -1923,7 +1921,7 @@ def mean_radiant_temperature(
rsus: xr.DataArray,
rlds: xr.DataArray,
rlus: xr.DataArray,
stat: str = "average",
stat: str = "sunlit",
) -> xr.DataArray:
r"""Mean radiant temperature.
Expand All @@ -1939,12 +1937,10 @@ def mean_radiant_temperature(
Surface Downwelling Longwave Radiation
rlus : xr.DataArray
Surface Upwelling Longwave Radiation
stat : {'average', 'instant', 'sunlit'}
Which statistic to apply. If "average", the average of the cosine of the
solar zenith angle is calculated. If "instant", the instantaneous cosine
stat : {'instant', 'sunlit'}
Which statistic to apply. If "instant", the instantaneous cosine
of the solar zenith angle is calculated. If "sunlit", the cosine of the
solar zenith angle is calculated during the sunlit period of each interval.
If "instant", the instantaneous cosine of the solar zenith angle is calculated.
Returns
-------
Expand Down Expand Up @@ -1987,15 +1983,9 @@ def mean_radiant_temperature(
)
csza_i = csza.copy()
csza_s = csza.copy()
elif stat == "average":
csza = cosine_of_solar_zenith_angle(
dates, dec, lat, stat="average", sunlit=False
)
csza_i = csza.copy()
csza_s = csza.copy()
else:
raise NotImplementedError(
"Argument 'stat' must be one of 'average', 'instant' or 'sunlit'."
"Argument 'stat' must be one of 'instant' or 'sunlit'."
)

fdir_ratio = _fdir_ratio(dates, csza_i, csza_s, rsds)
Expand Down

0 comments on commit 133fb2b

Please sign in to comment.