Releases: Ouranosinc/xclim
v0.53.2
Contributors to this version: Éric Dupuis (@coxipi), Pascal Bourgault (@aulemahal), Trevor James Smith (@Zeitsperre).
Breaking changes
- Due to a regression affecting symmetry of
polyfit
andpolyval
inxarray
,xclim
now requiresxarray>=2023.11.0,!=2024.10.0
(see: pydata/xarray PR/9691). (PR/1978).
Bug fixes
- Fixed a bug where the units could be changed before a conversion of the magnitudes could occur. Conversion of units for multivariate
DataArray
is now properly handled insdba.TrainAdjust
andsdba.Adjust
. (PR/1972). - Fixed a units formatting bug with indicators that output "delta" Celsius degrees. (PR/1973).
- Corrected the
"choices"
of parameterop
in the docstring offrost_free_spell_max_length
. (PR/1977). - Reorganised how
Indicator
subclasses can be added arguments to the call signature. Injecting such arguments now works. Forxclim
's subclasses, this bug only affected theindexer
argument of indicators subclassingxc.core.indicator.IndexingIndicator
. (PR/1981). - All-nan slices are now treated correctly in method
ExtremeValues
. (GH/1982, PR/1983).
v0.53.1
Contributors to this version: Trevor James Smith (@Zeitsperre).
Internal changes
- Fixed a few missing dependencies in the documentation build recipe that were causing errors in the CI workflow on ReadTheDocs. (PR/1970).
v0.53.0
Contributors to this version: Adrien Lamarche (@LamAdr), Trevor James Smith (@Zeitsperre), Éric Dupuis (@coxipi), Pascal Bourgault (@aulemahal), Sascha Hofmann (@saschahofmann), David Huard (@huard).
Announcements
xclim
has now adopted the Scientific Python SPEC 0 conventions for its suggested dependency support schedule. (GH/1914, PR/1915).xclim
has dropped support for Python 3.9 and adopted Python 3.10+ code styling conventions. (GH/1914, PR/1915).
New indicators
- New
heat_spell_frequency
,heat_spell_max_length
andheat_spell_total_length
: spell length statistics on a bivariate condition that uses the average over a window by default. (PR/1885, PR/1778). - New
hot_spell_max_magnitude
: yields the magnitude of the most intensive heat wave. (PR/1926). - New
chill_portion
andchill_unit
: chill portion based on the Dynamic Model and chill unit based on the Utah model indicators. (GH/1753, PR/1909). - New
water_cycle_intensity
: yields the sum of precipitation and actual evapotranspiration. (GH/410, PR/1947).
New features and enhancements
- New generic
xclim.indices.generic.spell_mask
that returns a mask of which days are part of a spell. Supports multivariate conditions and weights. Used in new generic indexxclim.indices.generic.bivariate_spell_length_statistics
that extendsspell_length_statistics
to two variables. (PR/1885). - Indicator parameters can now be assigned a new name, different from the argument name in the compute function. (PR/1885).
- Add attribute
units_metadata
to outputs representing a difference between temperatures. This is needed to disambiguate temperature differences from absolute temperature. Changes affect indicatorsdaily_temperature_range
,daily_temperature_range_variability
,extreme_temperature_range
,interday_diurnal_temperature_range
, and all degree-day indicators. Implemented using a newpint2cfattrs
function to convert pint units to a dictionary of CF attributes.units2pint
is also modified to supportunits_metadata
attributes in DataArrays. Some SDBA properties and measures previously returning units ofdelta_degC
will now return the original input DataArray units accompanied with theunits_metadata
attribute. (GH/1822, PR/1830). xclim.indices.run_length.windowed_max_run_sum
accumulates positive values across runs and yields the maximum valued run. (PR/1926).- Helper function
xclim.indices.helpers.make_hourly_temperature
to estimate hourly temperatures from daily min and max temperatures. (PR/1909). - New global option
resample_map_blocks
to wrap allresample().map()
code inside axr.map_blocks
to lower the number of dask tasks. Uses utilityxclim.indices.helpers.resample_map
and requiresflox
to ensure the chunking allows such block-mapping. Defaults to False. (PR/1848). xclim.indices.run_length.runs_with_holes
allows to input a condition that must be met for a run to start and a second condition that must be met for the run to stop. (PR/1778).- New generic compute function
xclim.indices.generic.thresholded_events
that finds events based on a threshold condition and returns basic stats for each. See also:xclim.indices.run_length.find_events
. (PR/1778). xclim.core.units.rate2amount
andxclim.core.units.amount2rate
can now also accept quantities (pint objects or strings), in which case thedim
argument must be thetime
coordinate through which we can find the sampling rate. (PR/1778).xclim.indices.stats.standardized_index
now supports a weekly resampling frequency. Only "standard" calendars usingnumpy
'sdatetime64
dtype are supported for this mode. (GH/1892, PR/1952)
Bug fixes
- Fixed
rate2amount
andamount2rate
for sub-daily frequencies. (GH/1962, PR/1963). - Added the liquid water equivalent thickness ("[length]") to amount ("[mass]/[area]") transformation to the
hydro
context (the inverse operation was already there). (PR/1963). - Fixed a small inefficiency in
_otc_adjust
, and thestandardize
method ofOTC/dOTC
is now applied on individual variable. (PR/1890, PR/1896). - Removed deprecated cells in the tutorial notebook
sdba.ipynb
. (PR/1895).
Breaking changes
platformdirs
is no longer a direct dependency ofxclim
, butpooch
is required to use many of the new testing functions (installable viapip install pooch
orpip install 'xclim[dev]'
). (PR/1889).- The following previously-deprecated functions have now been removed from
xclim
:xclim.core.calendar.convert_calendar
,xclim.core.calendar.date_range
,xclim.core.calendar.date_range_like
,xclim.core.calendar.interp_calendar
,xclim.core.calendar.days_in_year
,xclim.core.calendar.datetime_to_decimal_year
. For guidance on how to migrate to alternatives, see the version 0.50.0 Breaking changes. (GH/1010, PR/1845). - The
transform
argument ofOTC/dOTC
classes (and child functions) has been changed tonormalization
, andnumIterMax
has been changed tonum_iter_max
inxclim.core.utils.optimal_transport
(PR/1896). xclim
now requiresnumpy >=1.23.0
andscikit-learn >=1.1.0
, as well as (optionally)ipython >=8.5.0
,nbsphinx >=0.9.5
, andmatplotlib >=3.6.0
. (GH/1914, PR/1915).
Internal changes
- The
Ouranosinc/xclim-testdata
repository has been restructured for better organization and to make better use ofpooch
and data registries for testing data fetching (see: xclim-testdata PR/29). (PR/1889). - The
xclim.testing
module has been refactored to make use ofpooch
with file registries. Several testing functions have been removed as a result: (PR/1889)xclim.testing.utils.open_dataset
now uses apooch
instance to deliver locally-stored datasets. Its call signature has also changed.xclim
now accepts more environment variables to control the behaviour of the testing setup functions. These includeXCLIM_TESTDATA_BRANCH
,XCLIM_TESTDATA_REPO_URL
, andXCLIM_TESTDATA_CACHE_DIR
.xclim.testing.utils.get_file
,xclim.testing.utils.get_local_testdata
,xclim.testing.utils.list_datasets
, andxclim.testing.utils.file_md5_checksum
have been removed.xclim.testing.utils.nimbus
replaces much of this functionality. See thexclim
documentation for more information.
- Many tests focused on evaluating the normal operation of remote file access tools under
xclim.testing
have been removed. (PR/1889). - Setup and teardown functions that were found under
tests/conftest.py
have been optimised to reduce redundant calls when runningpytest xclim
. Some obsoletepytest
fixtures have also been removed. (PR/1889). - Many
DeprecationWarning
andFutureWarning
messages emitted fromxarray
andpint
have been addressed. (GH/1719, PR/1881). - The code base has been adjusted to address many
pylint
-related warnings and errors. In some cases,casting
was used to redefine somenumpy
andxarray
objects. (GH/1719, PR/1881). xclim.core
now uses absolute imports for clarity and some objects commonly used in the module have been moved to hidden submodules. (GH/1719, PR/1881).xclim.core.indicator.Parameter
has a new attributecompute_name
while ``xclim.core.indicator.Indicat...
v0.52.2
Contributors to this version: Pascal Bourgault (@aulemahal).
Bug fixes
- Fixed
decimal_year
import, fixed functionsrate2amount
,amount2rate
,time_bnds
andstack_periods
forxarray
version 2024.09.0. Removeddatetime_to_decimal_year
as the mirroredxarray
function was replaced byds.time.dt.decimal_year
. (PR/1920).
v0.52.1
Contributors to this version: Trevor James Smith (@Zeitsperre).
Bug fixes
- Adjusted the required base version of
pyarrow
to bev10.0.1
to address an environment resolution error on conda-forge. (PR/1918).
v0.52.0
Contributors to this version: David Huard (@huard), Trevor James Smith (@Zeitsperre), Hui-Min Wang (@Hem-W), Éric Dupuis (@coxipi), Sarah Gammon (@SarahG-579462), Pascal Bourgault (@aulemahal), Juliette Lavoie (@juliettelavoie), Adrien Lamarche (@LamAdr).
Announcements
xclim
now supports bothnumpy
versions>=1.20
and>=2.0
. (GH/1785, PR/1814, PR/1870).xclim
now needscf_xarray>=0.9.3
but continues to support older versions ofpint
(<0.24
) for compatibility reasons. (PR/1870).
New features and enhancements
xclim.sdba.nbutils.quantile
and its child functions are now faster. If thefastnanquantile
library is installed, it is used as the backend for the computation of quantiles and yields even faster results. This dependency is now listed in thexclim[extras]
recipe. (GH/1255, PR/1513).- New multivariate bias adjustment class
MBCn
, giving a faster and more accurate implementation of theMBCn
algorithm. (GH/1551, PR/1580). - New multivariate bias adjustment classes
OTC
anddOTC
. Requires thePOT
library which can be installed via thexclim[extras]
recipe. (PR/1787). xclim
is now compatible withpytest
versions>=8.0.0
. (PR/1632).
Breaking changes
- As of
cf_xarray>=0.9.3
, dimensionless quantities now use the"1"
units attribute as specified by the CF conventions, previously an empty string was returned. (PR/1814). - The definitions of the
frost_free_season_start
andfrost_free_season_end
have been slightly changed to be coherent with thefrost_free_season_length
andxclim
's notion ofseason
in general. Indicator and indices signature have been adapted to the new conventions. (PR/1845). - Season length indicators have been modified to return
0
for all cases where a proper season was not found, but the data is valid. Previously, anan
was given if neither a start nor an end were found, even if the data was valid, and a0
was given if an end was found but without a valid start. (PR/1845).
Bug fixes
- Fixed the indexer bug in the
xclim.indices.standardized_index_fit_params
when multiple or non-array indexers are specified and fitted parameters are reloaded from netCDF. (GH/1842, PR/1843). - Addressed a bug found in
wet_spell_*
indicators that was contributing to erroneous results. A new generic spell length statistic function (xclim.indices.generic.spell_length_statistics
) is now used in wet and dry spells indicators. (GH/1834, PR/1838). - Syntax for
nan
andinf
was adapted to supportnumpy>=2.0
. (PR/1814, GH/1785). - The type in
jitter
now works with modern version ofdask
(>=2024.8.0
). (PR/1864).
Internal changes
- Changed the French translation of "wet days" from "jours mouillés" to "jours pluvieux". (GH/1825, PR/1826).
- In order to adapt to changes in
pytest
, the doctest fixtures have been split from the main testing suite and doctests are now run using$ python -c 'from xclim.testing.utils import run_doctests; run_doctests()'
. (PR/1632). tox
has been reconfigured to run doctests in a separate environment (tox -e doctests
). (PR/1632).- Added
xclim.indices.generic.season
to make season start, end, and length indices. Added astat
argument toxclim.indices.run_length.season
to avoid returning a dataset. (PR/1845).
CI changes
pip-tools
(pip-compile
) has been used to generate a lock file with hashes for the CI dependencies. (PR/1841).- The
main.yml
workflow has been updated to use simpler trigger logic. (PR/1841). - A workflow bug has been fixed that was causing multiple duplicate comments to be made on Pull Requests originating from forks. (PR/1841).
- The
upstream.yml
workflow was adapted to not install upstream Python dependencies using hashes (as it is impossible to install directly from GitHub sources using--require-hashes
). (PR/1859). - The
tox-gh
configuration has been set to handle the environment configurations on GitHub Workflows. The tox.ini file is also a bit more organized/consistent. (PR/1859).
v0.51.0
Contributors to this version: Trevor James Smith (@Zeitsperre), Pascal Bourgault (@aulemahal).
New features and enhancements
- Added the
op
keyword to thegrowing_season_{start|end}
indices and indicators, allowing for customizable threshold operators usingindices.generic.compare()
. (GH/1794, PR/1796). xclim
now separates the optional dependencies intodev
anddocs
recipes. Both can be installed with theall
option ($ python -m pip install xclim[all]
). (PR/1806).
Bug fixes
- Units of degree-days computations with Fahrenheit input fixed to yield "°R d". Added a new
xclim.core.units.ensure_absolute_temperature
method to convert from delta to absolute temperatures. (GH/1789, PR/1804). - Clarified a typo in the docstring formula for
xclim.indices.growing_season_length
. (PR/1796).
Internal changes
netcdf4
has been pinned below v1.7 for test stability reasons. (PR/1791).flake8-bandit
-like checks have been enabled viaruff
, with fixes for a few security-related issues. (PR/1806).xclim.testing.utils
now employs more secure URL auditing checks. (PR/1806).CHANGES.rst
has been renamed toCHANGELOG.rst
, adhering to suggestions from the keepachangelog v.1.1.0 specifications. (PR/1823).
CI changes
- GitHub repository now uses Rulesets for branch protection. (PR/1790).
- Version bumping and project triage is now handled by the Ouranos Helper GitHub App. (PR/1790).
bump-my-version
has been updated to v0.23.0. (PR/1790).- The Ouranos Helper GitHub App now provides verified commits. (GH/1811, PR/1812).
- Added the deptry package to the
dev
linter tools and linting workflows for performing dependency analyses. (PR/1806). - Several linting tools have been updated to the latest versions and pinned. (PR/1806).
v0.50.0
Contributors to this version: Trevor James Smith (@Zeitsperre), Éric Dupuis (@coxipi).
New features and enhancements
- New properties: Bivariate Spell Length (
xclim.sdba.properties.bivariate_spell_length
), Generalized Spell Lengths with an argument forwindow
, and Specific Spell Lengths withwindow
fixed to '1' (xclim.sdba.properties.threshold_count
,xclim.sdba.properties.bivariate_threshold_count
). (PR/1758). - New option
normalize
insdba.measures.taylordiagram
to obtain normalized Taylor Diagrams (divide standard deviations by standard deviation of the reference). (PR/1764).
Breaking changes
pint
has been pinned below v0.24 untilxclim
can be updated to support the latest version. (GH/1771, PR/1772).numpy
has been pinned below v2.0.0 untilxclim
can be updated to support the latest version. (PR/1783).- Calendar utilities that have an equivalent in
xarray
have been deprecated and will be removed inxclim
v0.51.0. (GH/1010, PR/1761). This concerns the following members ofxclim.core.calendar
:convert_calendar
: UseDataset.convert_calendar
,DataArray.convert_calendar
orxr.coding.calendar_ops.convert_calendar
instead.- If your code passes
target
as an array, first convert the source to the target's calendar and then reindex the result totarget
. - If you were using the
doy=True
option, replace it withxc.core.calendar.convert_doy(source, target_cal).convert_calendar(target_cal)
. "default"
is no longer a valid calendar name for any xclim functions and will not be returned byget_calendar
. Xarray has ause_cftime
argument, xclim exposes it when the distinction is needed.
- If your code passes
date_range
: Usexarray.date_range
instead.date_range_like
: Usexarray.date_range_like
instead.interp_calendar
: UseDataset.interp_calendar
orxarray.coding.calendar_ops.interp_calendar
instead.days_in_year
: Usexarray.coding.calendar_ops._days_in_year
instead.datetime_to_decimal_year
: Usexarray.coding.calendar_ops._datetime_to_decimal_year
instead.
Internal changes
- Synchronized tooling versions across
pyproject.toml
andtox.ini
and pinned them to the latest stable releases in GitHub Workflows. (PR/1744). - Fixed a few small spelling and grammar issues that were causing errors with
codespell
. Now ignoringSVG
files. (PR/1769). - Temporarily skipping the
test_hawkins_sutton_smoke
test due to strange behaviour withxarray
. (PR/1769). - Fixed some previously uncaught errors raised from recent versions of
pylint
andcodespell
. (PR/1772). - Set the
doctest
examples to all useh5netcdf
with worker-separated caches to load datasets. (PR/1772).
Bug fixes
v0.49.0
Contributors to this version: Trevor James Smith (@Zeitsperre), Pascal Bourgault (@aulemahal), Juliette Lavoie (@juliettelavoie), David Huard (@huard), Gabriel Rondeau-Genesse (@RondeauG), Javier Diez-Sierra (@JavierDiezSierra), Sarah Gammon (@SarahG-579462), Éric Dupuis (@coxipi).
Announcements
New features and enhancements
- Indicator
xclim.atmos.potential_evapotranspiration
and indicexclim.indices.potential_evapotranspiration
now accept a new value (DA02
) for argumentmethod
implementing potential evapotranspiration based on Droogers and Allen (2002). (GH/1710, PR/1723). - The documentation now uses the furo theme for Sphinx. This theme supports native "light" and "dark" modes, adaptive screen resolution, as well as provides a better navigation layout for pages housing long lists of entries (e.g.
indices
). (GH/1693, PR/1731). xclim.ensembles.ensemble_percentiles
now takes amethod
argument, accepting one of:'interpolated_inverted_cdf'
,'hazen'
,'weibull'
,'linear'
(default),'median_unbiased'
, or'normal_unbiased'
. (GH/1694, PR/1732).- Distributions with negative values are directly fitted without need for an offset for distributions such as
'gamma'
and'fisk'
inxclim.indices.standardized_precipitation_evapotranspiration_index
. (GH/1477 PR/1720). xclim.indices.stats_fit_start
gives an estimate of theloc
parameter for'gamma'
and'fisk'
distributions. (GH/1477 PR/1720).
New indicators
- New
snw_season_length
andsnd_season_length
computing the duration between the start and the end of the snow season, both defined as the first day of a continuous period with snow above/under a threshold. Previous versions of these indicators were renamedsnw_days_above
andsnd_days_above
to better reflect what they computed : the number of days with snow above a given threshold (with no notion of continuity). (GH/1703, PR/1708). - Added
xclim.atmos.duff_moisture_code
, part of the Canadian Forest Fire Weather Index System. It was already an output of thexclim.atmos.cffwis_indices
, but now has its own standalone indicator. (GH/1698, PR/1712).
Breaking changes
- The previously deprecated functions
xclim.sdba.processing.construct_moving_yearly_window
andxclim.sdba.processing.unpack_moving_yearly_window
have been removed. These functions have been replaced byxclim.core.calendar.stack_periods
andxclim.core.calendar.unstack_periods
. (PR/1717). - The previously deprecated function
xclim.ensembles.change_significance
has been removed. (PR/1737). - Indicators
snw_season_length
andsnd_season_length
have been modified. (GH/1703, PR/1708). - The
'hargeaves85'
/'hg85'
method for thepotential_evapotranspiration
indicator and indice has been modified for precision and consistency with recent academic literature. (GH/1710, PR/1723). - The
__getitem__
method ofxclim.core.indicator.Parameter
instances has been removed. Accessing members ofParameters
now uniquely uses dot notation. (PR/1721). - The obsolete function wrapper for generating Indicators
xclim.core.utils.wrapped_partial
has been removed. (PR/1721). - The default documentation theme has changed from
sphinx-rtd-theme
tofuro
; Several modifications to the documentation configuration and CSS overrides have been made to accommodate the changes.furo
is now adocs
dependency. (GH/1693, PR/1731). - Estimation of parameters using
_fit_start
forgamma
andfisk
has been changed and can affect the results obtained with full-fledged (e.g. "ML") methods. (GH/1477 PR/1720). - Method
APP
inxclim.indices.standardized_precipitation_index
andxclim.indices.standardized_precipitation_evapotranspiration_index
now requires the user to impose aloc
parameter throughfitkwargs['floc']
. (GH/1477, PR/1720). - Zero inflated distributions used in
xclim.stats.standardized_index
now appropriately use the probability of zeroes in the calibration data and not the entire dataset. (GH/1477 PR/1720).
Bug fixes
- Fixed a bug in
sdba
'smap_groups
that prevented passing DataArrays with cftime coordinates if thesdba_encode_cf
option was'True'
. (GH/1673, PR/1674). - Fixed bug in
sdba
where a loaded training dataset could not be used for adjustment. (GH/1678, PR/1679). - Fixed bug with loess smoothing for an array full of NaNs. (PR/1699).
- Fixed and adapted
time_bnds
to the newest xarray. (PR/1700). - Fixed "agreement fraction" in
robustness_fractions
to distinguish between negative change and no change. Added "negative" and "changed negative" fractions (GH/1690, PR/1711). make_criteria
now skips columns with NaNs across all realizations. (PR/1713).- Fixed bug where
QuantileDeltaMapping
adjustment was failing for seasonal grouping. (GH/1704, PR/1716). - The codebase has been adjusted to address several (~400)
mypy
-related errors attributable to inaccurate function call signatures and variable name shadowing. (GH/1719, PR/1721). xclim.core.formatting.generate_indicator_docstring
has been modified to ensure that thenumpy
-docstrings of all Indicators are consistent in their formatting. (PR/1731).- Fixed documentation example for frequency adaptation with
sdba
. (GH/1740, PR/1742).
Internal changes
- Added "doymin" and "doymax" to the possible operations of
generic.stats
. Fixed a warning issue whenop
was "integral". (PR/1672). - Reorganized GitHub CI build matrices to run the doctests more consistently. (PR/1709).
- Removed the experimental
numba
andllvm
dependency installation steps in thetox.ini
file. Addednumba@main
to the upstream dependencies. (PR/1709). - Added the
tox-gh
dependency to the development installation recipe. This will soon be required for running thetox
test ensemble on GitHub Workflows. (PR/1709). - Added the
vulture
static code analysis tool for finding dead code to the development dependency list and linters (makefile, tox and pre-commit hooks). (PR/1717). - Added error message when using
xclim.indices.stats.dist_method
withnnlf
and included note in docstring. (GH/1683, PR/1714). - PEP8 rule
N802
is now enabled in theruff
formatter. Function names should follow Snake case, with rare exceptions. (PR/1721). - Linting dependencies have been updated to the latest versions and made consistent across
environment.yml
,pyproject.toml
andtox.ini
files. (PR/1717). - Code styling for the documentation now uses
sas
("light" theme) andlightbulb
("dark" theme) in order to ensure adequate contrast for code blocks. ([PR/1731](https://github.com/Ouranosinc/x...
v0.48.2
Contributors to this version: Juliette Lavoie (@juliettelavoie).
Bug fixes
- Add
measure
to YAML validation schema (for building sdba properties) and allow skipping the YAML validation when building modules. (PR/1664).