Releases: Ouranosinc/xclim
v0.55.1
v0.55.0
Contributors to this version: Juliette Lavoie (@juliettelavoie), Trevor James Smith (@Zeitsperre), Sascha Hofmann (@saschahofmann), Pascal Bourgault (@aulemahal), Éric Dupuis (@coxipi), Baptiste Hamon (@baptistehamon), Sarah Gammon (@SarahG-579462).
Breaking changes
- Missing value method "WMO" was modified to remove the criterion that the timeseries needs to be continuous (without holes). (PR/2058).
Announcements
xclim
now officially supports Python 3.13 (usingnumba
v0.61.0). (GH/2022, PR/2054).xclim
version 0.55.0 will be the last version to support Python 3.10. The next version will require Python 3.11 or higher. (PR/2054).
New indicators
- Added
xclim.land.holiday_snow_days
to compute the number of days with snow on the ground during holidays ("Christmas Days"). (GH/2029, PR/2030). - Added
xclim.land.holiday_snow_and_snowfall_days
to compute the number of days with snow on the ground and measurable snowfall during holidays ("Perfect Christmas Days"). (GH/2029, PR/2030). - Added
xclim.atmos.vapor_pressure_deficit
to compute the vapor pressure deficit from temperature and relative humidity. (GH/1917, PR/2072).
New features and enhancements
- New function
ensemble.partition.general_partition
. (PR/2035). - Added a new
xclim.indices.generic.bivariate_count_occurrences
function to count instances where operations and performed and validated for two variables. (PR/2030). xclim.testing.helpers.test_timeseries
now accepts acalendar
argument that is forwarded toxr.cftime_range
. (PR/2019).- New
xclim.indices.fao_allen98
, exporting the FAO-56 Penman-Monteith equation for potential evapotranspiration (GH/2004, PR/2067). - Missing values method "pct" and "at_least_n" now accept a new "subfreq" option that allows to compute the missing mask in two steps. When given, the algorithm is applied at this "subfreq" resampling frequency first and then the result is resampled at the target indicator frequency. In the output, a period is invalid if any of its subgroup where flagged as invalid by the chosen method. (PR/2058, GH/1820).
scipy.stats.rv_continuous
instances can now be given directly as thedist
argument instandardized_precipitation_index
andstandardized_precipitation_evapotranspiration_index
indicators. This includeslmoments3
distributions when specifyingmethod="PWM"
. (GH/2043, PR/2045).- Time selection in
xclim.core.calendar.select_time
and the**indexer
argument of indicators now supports day-of-year bounds given as DataArrays with spatial and/or temporal dimensions. (GH/1987, PR/2055). - Maximum Spacing Estimation method for distribution fitting has been added to
xclim.indices.stats.fit
(GH/2078, PR/2077)
Bug fixes
- Fixed a bug in
xclim.sdba.Grouper.get_index
that didn't correctly interpolate seasonal values (GH/2014, PR/2019). - Fixed a bug where
xclim.indicators.atmos.potential_evapotranspiration
would return wrong results whenhurs
was provided in%
(PR/2067). - Fixed the default "op" argument of
xclim.atmos.growing_season_end
(GH/2056, PR/2080). - Removed the useless "thresh" argument from
xclim.atmos.precip_accumulation
(GH/1763, PR/2080).
Internal changes
- Adjusted the
TestOfficialYaml
test to use a dynamic method for finding the installed location ofxclim
. (PR/2028). - Adjusted two tests for better handling when running in Windows environments. (PR/2057).
- Refactor of the
xclim.core.missing
module, usage of theMissing
objects has been broken. (PR/2058, PR/2055, PR/2076, GH/1820, GH/2000).- Objects are initialized with their options and then called with the data, input frequency, target frequency and indexer.
- Subclasses receive non-resampled DataArray in their
is_missing
methods. - Subclasses receive the array of valid timesteps
valid
instead ofnull
, the invalid ones. MissingWMO
now usesxclim.indices.helpers.resample_map
which should greatly improve performance in a dask context.
- There is now a warning stating that
fitkwargs
are not employed when using thelmoments3
distribution. One exception is the use of'floc'
which is allowed with the gamma distribution.'floc'
is used to shift the distribution before computing fitting parameters with thelmoments3
distribution sinceloc=0
is always assumed in the library. (GH/2043, PR/2045). xclim
now tracks energy usage and carbon emissions ("last run", "average", and "total") during CI workflows using theeco-ci-energy-estimation
GitHub Action. (PR/2046).
v0.54.0
Contributors to this version: Trevor James Smith (@Zeitsperre), Pascal Bourgault (@aulemahal), Éric Dupuis (@coxipi), Sascha Hofmann (@saschahofmann).
New features and enhancements
- Python 3.9 coding conventions have been dropped in favour of Python 3.10+ conventions. (PR/1988).
xclim.indices.chill_unit
now accepts a new argumentpositive_only
to compute the daily positive chill units. (PR/2003).
Breaking changes
- The minimum required version of
dask
has been increased to2024.8.1
. (GH/1992, PR/1991). - The docstrings of many
xclim
modules, classes, methods, and functions have been slightly adjusted to ensure stricter compliance with establishednumpy
docstring conventions. (PR/1988). - Using different time for
ref
andhist
is now explicitly forbidden in many bias adjustment methods (e.g.EmpiricalQuantileMapping
). Methods that combineref
,hist
, andsim
in the samemap_groups
also require that time arrays be equal in size. (GH/1903, PR/1995, PR/2013). xclim
now uses asrc
layout for the codebase. Structure-dependent functions, documentation, and build commands have been adapted to reflect these changes. Developers will need to reinstallxclim
usingpip install -e .
. (PR/1971).- The call signature of
xclim.indices.hot_spell_magnitude
originally asked for anop
argument that was not used. This argument has been removed. (PR/2018).
Bug fixes
- Fixed pickling issue with
xclim.sdba.Grouper
and other classes for usage withdask>=2024.11
. (GH/1992, PR/1993). - Fixed an issue with
nimbus
that was causing URL path components to be improperly joined. (PR/1997). base_kws_vars
inMBCn
is now copied inside theadjust
function so that in-place changes do not change the dict globally. (PR/1999).- Fixed a bug in the logic of
xclim.testing.utils.load_registry
that impacted the ability to load aregistry.txt
from a non-default repository. (PR/2001).
Internal changes
- Changed French translations with word "pluvieux" to "avec précipitations". (GH/1960, PR/1994).
- Nan values in
OTC
anddOTC
are only dropped and replaced at the lowest level so that the size of time arrays never changes onxarray
levels. (PR/1995, PR/2013) streamflow
entry replaced with"q"
invariables.yml
. (GH/1912, PR/1996).- In order to address
Error 403
(forbidden) requests when retrieving data from GitHub via ReadTheDocs, thenimbus
class has been modified to use an overloadedfetch
method that appends a modified User-Agent header to the request. (PR/2001). - Addressed a very rare race condition that can happen if
pytest
is tearing down the test environment when running across multiple workers. (PR/1863). - The
numpydoc
linting tool has been added to the development dependencies, linting checks, and thepre-commit
configuration. (PR/1988). - Added a more robust
yamllint
configuration to ensure that all YAML files are linted consistently. (PR/1971). - Addressed a very rare singular matrix error that can happen in
test_loess_smoothing_nan
. (PR/2015). - Addressed a handful of typing and call signature issues in the
xclim
codebase. (PR/2018).
CI changes
- Added the
green-coding-solutions/eco-ci-energy-estimation
GitHub Action to the workflows to establish energy and carbon usage of CI activity. (PR/1863). - Various workflow security fixes: (PR/2023)
- Simplified the
bump-version.yml
version string parsing to harden against template injection. - Further de-escalated privileges for most workflows.
- Simplified the
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).