v0.58.0
Contributors to this version: Sebastian Lehner (@seblehner), Trevor James Smith (@Zeitsperre), Pascal Bourgault (@aulemahal), Éric Dupuis (@coxipi), Baptiste Hamon (@baptistehamon).
New indicators and features
- New indicator
xclim.atmos.antecedent_precipitation_indexcomputes theantecedent_precipitation_index(weighted summation of daily precipitation amounts for a given window). (GH/2166, PR/2184). - Argument
indexeradded to indicatorsmax_n_day_precipitation_amount,max_pr_intensity, andblowing_snow. (GH/2187, PR/2190). - Argument
windowadded to indicatorrain_on_frozen_ground_days. (PR/2190). - New helper
xclim.indices.generic.season_length_from_boundariestakesseason_startandseason_endas input and givesseason_length. This is used when starts and ends are computed with different resampling frequencies:days_sinceare used to compute temporal lengths in this case. (PR/2189). - Allow
invalid_valuesas argument forrelative_humidity_from_dewpoint. (GH/2202, PR/2203). - New thermodynamic conversion indicators (GH/2165, PR/2206):
xclim.convert.vapor_pressureto compute the partial pressure of water vapor from specific humidity and total pressure.xclim.convert.dewpoint_from_specific_humidityto compute the dewpoint temperature from specific humidity and total pressure.
- All functions using saturation vapour pressure can now compute it with a smooth transition between saturation over ice and saturation over water. The transition is controlled by the
interp_power,ice_threshandwater_threshparameters. (GH/2165, PR/2206).- New methods
"buck81"and"aerk96"and new method"ECMWF"which is"buck81"on water and"aerk96"on ice. - Saturation vapor pressure calculations were reorganized.
xclim.indices.converters.ESAT_FORMULAS_COEFFICIENTSnow stores the August-Roche-Magnus formula's coefficients.
- New methods
- New indicator
xclim.atmos.hot_daysas counterpart toxclim.atmos.frost_days. (GH/2194, PR/2213). - New helper indices for computing the day-length coefficient for viticulture growing seasons based on several approaches:
xclim.indices.helpers.gladstones_day_length_coefficient: Based on the Gladstones (1992, 2011) method.xclim.indices.helpers.huglin_day_length_coefficient: Based on the Huglin (1978, 1998) method.xclim.indices.helpers.jones_day_length_coefficient: Based on the approach outlined in Hall and Jones (2010).
- The
xclim.indices.helpers.day_lengthfunction now accepts aninfill_polar_daysargument to control whether polar days or polar nights are filled with NaNs (infill_polar_days=False; default behaviour) or with a day length of 0 or 24 hours, depending on the date (infill_polar_days=True). (GH/2201, PR/2207). - The indices for
uas_vas_to_sfcwind,sfcwind_to_uas_vas,rle_1d, andcffwis_indicesnow provide their outputs via theNamedTupleformat. This provides a method for accessing indice outputs using variable names in addition to positional indexing. (PR/2224). - The new
xclim.indicators.convertmodule is now available to provide a distinct API for conversion-focused indicators. This module is intended to regroup all conversion-based indicators that were previously scattered across different indicato realms. This module is also accessible viaxclim.convert. (GH/1289, PR/2224). - New methods
dai_annualanddai_seasonalforxclim.convert.snowfall_approximationandxclim.convert.rain_approximation, taken from :cite:t:dai_snowfall_2008. Indicator also take new argumentlandmaskto switch between the land and ocean formulations. (PR/2208, GH/1752).
Breaking changes
- The
"jones"method for calculating'k'inxclim.indices.huglin_indexandxclim.indices.biologically_effective_degree_daysnow require daily data computed at annual frequencies (freq="YS"|"YS-JAN"|"YS-JUL"). The previous behaviour for non-annual frequencies was undefined. (GH/2201, PR/2207).- The
"jones"method now sets a floor value for"k"where it is not allowed to be less than1.0. This is to avoid values below1.0for"k"which were previously allowed inxclimbut not supported by the source literature. - Incomplete growing seasons (where the values of
"k"for all latitudes during the growing season are all below1.0) will now raiseValueError. This is to ensure that the expected output is consistent with the literature.
- The
- The
"gladstones"method for calculating'k'inxclim.indices.biologically_effective_degree_daysnow uses a dedicated function based on a dynamic day_length compared to a reference latitude (40 degrees). The previous implementation of the"gladstones"method was based off an approximation found in Hall and Jones (2010). (GH/2201, PR/2207).- The
"gladstones"approximation is now available as a separate helper function:xclim.indices.helpers.jones_day_length_coefficientwithmethod="gladstones".
- The
- The
"icclim"method for calculating'k'inxclim.indices.huglin_indexhas been renamed the"huglin"method. The"icclim"method was identical to the implementation proposed in Huglin (1978). (GH/2201, PR/2207). - The
xclim.indices._conversionsubmodule has been refactored into the newxclim.indices.convertersmodule. Directly importing functions from the older location will still work but will emit aDeprecationWarning. This workaround will be removed in a future release. (GH/1289, PR/2224). - The
xclim.indicators.atmosandxclim.indicators.landsubmodules have been refactored to move all conversion-based indicators to the newxclim.indices.convertersmodule. This change is intended to improve code organization and clarity. Directly importing indicators that were previously accessible viaatmosandlandwill still work but will emit aDeprecationWarning. This workaround will be removed in a future release. (GH/1289, PR/2224). xclim.indicators.atmos.tghas been refactored toxclim.indicators.convert.mean_temperature_from_max_and_min. Importingtgfromxclim.indices.atmosorxclim.indicators.convertwill still work but will emit aDeprecationWarning. This workaround will be removed in a future release. (GH/1289, PR/2224).
Internal changes
- Modified internal logic for
xclim.testing.utils.default_testdata_cacheto support mocking ofpooch. (PR/2188). - The
xclim.indices.helpersmodule now uses an__all__variable to explicitly define the public API of the module. (PR/2207). - Viticulture indices are more heavily tested and employ type guarding to ensure that parameters passed are those of the expected types. (PR/2207).
- Fixed some tests relying on floating-point imprecision. Avoid numbagg on sensitive fitting tests. (PR/2228).
- Conversion indicators have been split from
tests/test_atmos.pyinto newtests/test_converters.py. This is to ensure that conversion indicators are tested separately from other atmospheric indicators. (GH/1289, PR/2224). xclim.testing.utils.show_versionsnow uses theimportlib.metadatalibrary to more accurately gather dependency information. (PR/2229).- Replaced the deprecated
"time.week"grouping strings withda.time.dt.isocalendar().weekinxclim.indices.stats.standardized_indexfunctions. (PR/2230). xclim.indices.run_length.lazy_indexingmoved to utils. (GH/2107, PR/2231).- Updated the command-line configuration to address
DeprecationWarningmessages introduced inclickv8.2.0 (changes remain compatible withclickv8.1.0). (GH/2212, PR/2233).
Bug fixes
- Increase the tolerance in the tests of
xclim.indices.standardized_groundwater_index(the standardized indices are sensitive to package versions because of the parameter optimization inscipy). (GH/2183, PR/2193). - In
xclim.indices._conversion.humidexandxclim.indices._conversion.vapor_pressure_deficit, add a converter to ensurehurshas'%'units. (PR/2209). - Indices relying on
units.to_agg_units(src, out, 'count')will not raise on a non-inferrable frequency and instead use the common default of "D", as their docstring implies. (GH/2215, PR/2217). - Fix
spell_length_statisticsand related functions for cases wherethreshis a DataArray. (GH/2216, PR/2218). - Addressed a noisy warning emitted by
numpyin thexclim.indices.statswhen performing a fit over data with missing values. (PR/2224). - In the Canadian Forest Fire Weather Index System, values of 0 for both the Duff-Moisture code (DMC) and the Drought code (DC) will yield a 0 Build-Up index (BUI) instead of failing with division by zero error. (GH/2145, PR/2225).
xclim.indices.generic.{doymax|doymin}now work with dask arrays. (GH/2107, PR/2231).