Releases: Ouranosinc/xclim
Releases · Ouranosinc/xclim
v0.24.0
New indicators
days_over_precip_thresh
,fraction_over_precip_thresh
,liquid_precip_ratio
,warm_spell_duration_index
, all from eponymous indices.maximum_consecutive_warm_days
from indicemaximum_consecutive_tx_days
.
Breaking changes
-
Numerous changes to
xclim.core.calendar.percentile_doy
:per
now accepts a sequence as well as a scalar and as such the output has a percentiles axis.per
argument is now expected to between 0-100 (not 0-1).- input data must have a daily (or coarser) time frequency.
-
Change in unit handling paradigm for indices, which as a result will lead to some indices returning values with different units. Note that related
Indicator
objects remain unchanged and will return units consistent with CF Convention. If you are concerned with code stability, please useIndicator
objects. The change was necessary to resolve inconsistencies with xarray'skeep_attrs=True
context.- Indice functions now return output units that preserve consistency with input units. That is, feeding inputs in Celsius will yield outputs in Celsius instead of casting to Kelvin. In all cases the dimensionality is preserved.
- Indice functions now accept non-daily data, but daily frequency is assumed by default if the frequency cannot be inferred.
-
Removed the explicitly-installed
netCDF4
python library from the base installation, as this is never explicitly used (now only installed in thedocs
recipe for sdba documented example). -
Removed
xclim.core.checks
, which was deprecated since v0.18.
New features and enhancements
- Indicator now have docstrings generated from their metadata.
- Units and fixed choices set are parsed from indice docstrings into
Indicator.parameters
. - Units of indices using the
declare_units
decorator are stored inindice.in_units
andindice.out_units
. - Changes to
Indicator.format
andIndicator.json
to ensure the resulting json really is serializable.
Internal changes
- Leave
missing_options
undefined inland.fit
indicator to allow control viaset_options
. - Modified
xclim.core.calendar.percentile_doy
to improve performance. - New
xclim.core.calendar.compare_offsets
for comparing offset strings. - New
xclim.indices.generic.get_op
to retrieve a function from a string representation of that operator. - The CI pipeline has been migrated from Travis CI to GitHub Actions. All stages are still built using
tox
. - Indice functions must always set the units (the
declare_units
decorator does no check anymore). - New
xclim.core.units.rate2amout
to convert rates like precipitation to amounts. xclim.core.units.pint2cfunits
now removes ' * ' symbols and changesΔ°
todelta_deg
.- New
xclim.core.units.to_agg_units
andxclim.core.units.infer_sampling_units
for unit handling involving aggregation operations along the time dimension. - Added an indicators API page to the docs and links to there from the
Climate Indicators
page.
Bug fixes
- The unit handling change resolved a bug that prevented the use of
xr.set_options(keep_attrs=True)
with indices.
v0.23.0
Breaking changes
- Renamed indicator
atmos.degree_days_depassment_date
toatmos.degree_days_exceedance_date
. - In
degree_days_exceedance_date
: renamed argumentstart_date
toafter_date
. - Added cfchecks for Pr+Tas-based indicators.
- Refactored test suite to now be available as part of the standard library installation (
xclim.testing.tests
). - Running
pytest
withxdoctest
now requires therootdir
to point attests
location (pytest --rootdir xclim/testing/tests/ --xdoctest xclim
). - Development checks now require working jupyter notebooks (assessed via the
pytest --nbval
command).
New indicators
rain_approximation
andsnowfall_approximation
for computingprlp
andprsn
frompr
andtas
(ortasmin
ortasmax
) according to some threshold and method.solid_precip_accumulation
andliquid_precip_accumulation
now accept athresh
parameter to control the binary snow/rain temperature threshold.first_snowfall
andlast_snowfall
to compute the date of first/last snowfall exceeding a threshold in a period.
New features and enhancements
- New
kind
entry in theparameters
property of indicators, differentiating between [optional] variables and parameters. - The git pre-commit hooks (
pre-commit run --all
) now clean the jupyter notebooks withnbstripout
call.
Bug fixes
- Fixed a bug in
indices.run_length.lazy_indexing
that occurred with 1D coords and 0D indexes when using the dask backend. - Fixed a bug with default frequency handling affecting
fit
indicator. - Set missing method to 'skip' for
freq_analysis
indicator. - Fixed a bug in
ensembles._ens_align_datasets
that occurred when inputs are.nc
filepaths but files lack a time dimension.
Internal changes
core.cfchecks.check_valid
now accepts a sequence of strings as itsexpected
argument.- Clean up in the tests to speed up testing. Addition of a marker to include "slow" tests when desired (
-m slow
). - Fixes in the tests to support
sklearn>=0.24
,clisops>=0.5
and build xarray@master against python 3.7. - Moved the testing suite to within xclim and simplified
tox
to manage its own tempdir. - Indicator class now has a
default_freq
method.
v0.22.0
Breaking changes
- Statistical functions (
frequency_analysis
,fa
,fit
,parametric_quantile
) are now solely accessible viaindices.stats
.
New indicators
atmos.degree_days_depassment_date
, the day of year when the degree days sum exceeds a threshold.
New features and enhancements
- Added unique titles to
atmos
calculations employing wrapped_partials. xclim.core.calendar.convert_calendar
now accepts amissing
argument.- Added
xclim.core.calendar.date_range
andxclim.core.calendar.date_range_like
wrapping pandas'date_range
and xarray'scftime_range
. xclim.core.calendar.get_calendar
now accepts many different types of data, including datetime object directly.- New module
xclim.analog
and methodxclim.analog.spatial_analogs
to compute spatial analogs. - Indicators can now accept dataset in their new
ds
call argument. Variable arguments (that use theDataArray
annotation) can now be given with strings that correspond to variable names in the dataset, and default to their own name. - Clarification to
frequency_analysis
notebook. - Now officially supporting PEP596 (Python3.9).
- New methods
xclim.ensembles.change_significance
andxclim.ensembles.knutti_sedlacek
to qualify climate change agreement among members of an ensemble.
Bug fixes
- Fixed bug that prevented the use of
xclim.core.missing.MissingBase
and subclasses with an indexer and a cftime datetime coordinate. - Fixed issues with metadata handling in statistical indices.
- Various small fixes to the documentation (re-establishment of some internally and externally linked documents).
Internal changes
- Passing
align_on
toxclim.core.calendar.convert_calendar
without using '360_day' calendars will not raise a warning anymore. - Added formatting utilities for metadata attributes (
update_cell_methods
,prefix_attrs
andunprefix_attrs
). xclim/ensembles.py
moved toxclim/ensembles/*.py
, splitting stats/creation, reduction and robustness methods.- With the help of the
mypy
library, added several typing fixes to better identify inputs/outputs, and reduce object type mutations. - Fixed some doctests in
ensembles
andset_options
. clisops
v0.4.0+ is now an optional requirements for non-Windows builds.- New
xclim.core.units.str2pint
method to convert quantity strings to quantity objects. Main improvement is to make "3 degC days" a valid string that converts to "3 K days".
v0.21.0
Breaking changes
- Statistical functions (
frequency_analysis
,fa
,fit
,parametric_quantile
) moved fromindices.generic
toindices.stats
to make them more visible.
New features and enhancements
- New xclim.testing.open_dataset method to read data from the remote testdata repo.
- Added a notebook,
ensembles-advanced.ipynb
, to the documentation detailing ensemble reduction techniques and showing how to make use of built-in figure-generating commands. - Added a notebook,
frequency_analysis.ipynb
, with examples showcasing frequency analysis capabilities.
Bug fixes
- Fixed a bug in the attributes of
frost_season_length
. indices.run_length
methods using dates now respect the array's calendar.- Worked around an xarray bug in sdba.QuantileDeltaMapping when multidimensional arrays are used with linear or cubic interpolation.
v0.20.0
Breaking changes
xclim.subset
has been deprecated and now relies onclisops
to perform specialized spatio-temporal subsetting.
Install withpip install xclim[gis]
in order to retain the same functionality.- The python library
pandoc
is no longer listed as a docs build requirement. Documentation still requires a current
version ofpandoc
binaries installed at system-level. - ANUCLIM indices have seen their
input_freq
parameter renamed tosrc_timestep
for clarity. - A clean-up and harmonization of the indicators metadata has changed some of the indicator identifiers, long_names, abstracts and titles.
xclim.atmos.drought_code
andfire_weather_indexes
now have indentifiers "dc" and "fwi" (lowercase version of the previous identifiers). xc.indices.run_length.run_length_with_dates
becomesxc.indices.run_length.season_length
. Its argumentdate
is now optional and the default changes from "07-01" toNone
.xc.indices.consecutive_frost_days
becomesxc.indices.maximum_consecutive_frost_days
.- Changed the
history
indicator output attribute toxclim_history
in order to respect CF conventions.
New indicators
atmos.max_pr_intensity
acting on hourly data.atmos.wind_vector_from_speed
, also thewind_speed_from_vector
now also returns the "wind from direction".- Richards-Baker flow flashiness indicator (
xclim.land.rb_flashiness_index
). atmos.max_daily_temperature_range
.atmos.cold_spell_frequency
.atmos.tg_min
andatmos.tg_max
.atmos.frost_season_length
,atmos.first_day_above
. Also,atmos.consecutive_frost_days
now takes athresh
argument (default : 0 degC).
New features and enhancements
sdba.loess
submodule implementing LOESS smoothing tools used insdba.detrending.LoessDetrend
.- xclim now depends on clisops for subsetting, offloading several heavy GIS dependencies. This improves
maintainability and reduces the size of a "vanilla" xclim installation considerably. - New
generic.parametric_quantile
function taking parameters estimated bygeneric.fit
as an input. - Add support for using probability weighted moments method in
generic.fit
function. Requires the
lmoments3
package, which is not included in dependencies because it is unmaintained. Install manually if needed. - Implemented
_fit_start
utility function providing initial conditions for statistical distribution parameters estimation, reducing the likelihood of poor fits. - Added support for indicators based on hourly (1H) inputs, and a first hourly indicator called
max_pr_intensity
returning hourly precipitation intensity. - Indicator instances can be retrieved through their class with the
get_instance()
class method.
This allows the use ofxclim.core.indicator.registry
as an instance registry. - Indicators now have a
realm
attribute. It must be given when creating indicators outside xclim. - Better docstring parsing for indicators: parameters description, annotation and default value are accessible in the json output and
Indicator.parameters
. - New command line interface
xclim
for simple indicator computing tasks. - New
sdba.processing.jitter_over_thresh
for variables with a upper bound. - Added
op
parameter toxclim.indices.daily_temperature_range
to allow resample reduce operations other than mean core.formatting.AttrFormatter
(and thus, locale dictionaries) can now use glob-like pattern for matching values to translate.
Bug fixes
- The ICCLIM module was identified as
icclim
in the documentation but the module available underICCLIM
. Nowicclim == ICCLIM
andICCLIM will be deprecated in a future release
.
Internal changes
xclim.subset
now attempts to load and expose the functions ofclisops.core.subset
. This is an API workaround preserving backwards compatibility.- Code styling now conforms to the latest release of black (v0.20.8).
- New
IndicatorRegistrar
class that takes care of adding indicator classes and instances to the
appropriate registries.Indicator
now inherits from it.
v0.19.0
Breaking changes
- Refactoring of the
Indicator
class. Thecfprobe
method has been renamed tocfcheck
and thevalidate
method has been renamed todatacheck
. More importantly, instantiatingIndicator
creates a new subclass on
the fly and stores it in a registry, allowing users to subclass existing indicators easily. The algorithm for
missing values is identified by its registered name, e.g. "any", "pct", etc, along with itsmissing_options
. - xclim now requires xarray >= 0.16, ensuring that xclim.sdba is fully functional.
- The dev requirements now include
xdoctest
-- a rewrite of the standard library module,doctest
. xclim.core.locales.get_local_attrs
now uses the indicator's class name instead of the indicator itself and no
longer accepts thefill_missing
keyword. Behaviour is now the same as passingFalse
.Indicator.cf_attrs
is now a list of dictionaries.Indicator.json
puts all the metadata attributes in the key "outputs" (a list of dicts).
All variable metadata (names inIndicator._cf_names
) might be strings or lists of strings when accessed as object attributes.- Passing doctests are now strictly enforced as a build requirement in the Travis CI testing ensemble.
New features and enhancements
- New
ensembles.kkz_reduce_ensemble
method to select subsets of an ensemble based on the KKZ algorithm. - Create new Indicator
Daily
,Daily2D
subclasses for indicators using daily input data. - The
Indicator
class now supports outputing multiple indices for the same inputs. xclim.core.units.declare_units
now works with indices outputting multiple DataArrays.- Doctests now make use of the
xdoctest_namespace
in order to more easily access mdoules and tesdata.
Bug fixes
- Fix
generic.fit
dimension ordering. This caused errors when "time" was not the first dimension in a DataArray.
Internal changes
datachecks.check_daily
now usesxr.infer_freq
.- Indicator subclasses
Tas
,Tasmin
,Tasmax
,Pr
andStreamflow
now inherit fromDaily
. - Indicator subclasses
TasminTasmax
andPrTas
now inherit fromDaily2D
. - Docstring style now enforced using the
pydocstyle
withnumpy
doctsring conventions. - Doctests are now performed for all docstring
Examples
usingxdoctest
. Failing examples must be explicitly skipped otherwise build will now fail. - Indicator methods
update_attrs
andformat
are now classmethods, attrs to update must be passed. - Indicators definitions without an accompanying translation (presently French) will cause build failures.
- Major refactoring of the internal marchinery of
Indicator
to support multiple outputs.
v0.18.0
0.18.x (2020-06-26)
- Optimization options for
xclim.sdba
: different grouping for the normalization steps of DQM and save training or fitting datasets to temporary files. xclim.sdba.detrending
objects can now act on groups.- Replaced
dask[complete]
withdask[array]
in basic installation and addeddistributed
todocs
build dependencies. xclim.core.locales
now supported in Windows build environments.ensembles.ensemble_percentiles
modified to compute along apercentiles
dimension by default, instead of creating different variables.- Added indicator
first_day_below
and run length helperfirst_run_after_date
. - Added ANUCLIM model climate indices mappings.
- Renamed
areacella
toareacello
in sea ice tests. - Sea ice extent and area outputs now have units of m2 to comply with CF-Convention.
- Split
checks.py
intocfchecks.py
,datachecks.py
andmissing.py
. This change will only affect users creating custom indices using utilities previously located inchecks.py
. - Changed signature of
daily_freeze_thaw_cycles
,daily_temperature_range
,daily_temperature_range_variability
andextreme_temperature_range
to take (tasmin, tasmax) instead of (tasmax, tasmin) and match signature of other similar multivariate indices. - Added
FromContext
subclass ofMissingBase
to have a uniform API for missing value operations. - Remove logging commands that captured all xclim warnings. Remove deprecated xr.set_options calls.
v0.17.0
0.17.x (2020-05-15)
- Added support for operations on dimensionless variables (
units = '1'
) - Moved
xclim.locales
toxclim.core.locales
in a batch of internal changes aimed to removed most potential cyclic imports cases. - Missing checks and input validation refactored with addition of custom missing class registration (
xclim.core.checks.register_missing_method
) and simple validation method decorator (xclim.core.checks.check
). - New
xclim.set_options
context to control the missing checks, input validation and locales. - New
xclim.sdba
module for statistical downscaling and bias-adjustment of climate data. - Added
convert_calendar
andinterp_calendar
to help in the conversion between calendars. - Added
at_least_n_valid
function, indentifying null calculations based on minimum threshold. - Added support for
freq=None
in missing calculations. - Fixed outdated code examples in the docs and docstrings.
- Doctests are now run as part of the test suite.
v0.16.0
0.16.0 (2020-04-23)
- Added
vectorize
flag tosubset_shape
andcreate_mask_vectorize
function based onshapely.vectorize
as default backend for mask creation. - Removed
start_yr
andend_yr
flags from subsetting functions. - Add multi gridpoints support in
subset.subset_gridpoint
. - Better
wrapped_partial
for more meaningful inspection. - Add indices for relative humidity, specific humidity and saturation vapor pressure with a few choices of method.
- Allow lazy units conversion.
- CRS definitions of projected DataSets are now written to file according to Climate and Forecast-convention standards.
- Add utilities to merge attributes and update history in xclim.core.formatting.
- Ensembles : Allow alignment of datasets with same frequency but different offsets.
- Bug fixes in run_length for run-with-dates methods when the date is not found in the run.
- Remove deepcopy from subset.subset_shape to improve memory usage.
- Add
missing_wmo
function, identifying null calculations based on criteria from WMO. - Add
missing_pct
function, identifying null calculations based on percentage of missing values.
v0.15.0
0.15.x (2020-03-12)
- Improvement in FWI: Vectorization of DC, DMC and FFMC with numba and small code refactoring for better maintainability.
- Added example notebook for creating a catalog of selected indices
- Added
growing_season_end
,last_spring_frost
,dry_days
,hot_spell_frequency
,hot_spell_max_length
, andmaximum_consecutive_frost_free_days
indices. - Dropped use of
fiona.crs
class in lieu of the newer pyproj CRS handler forsubset_shape
operations. - Completed first phase of internal reorganization of xclim.
- Internationalization of xclim : add
locales
submodule for localized metadata. - Add feature to retrieve coordinate values instead of index in
run_length.first_run
. Addrun_length.last_run
. - Fix bug in subset_gridpoint to work on lat/lon coords of any dimension when they are not a dimension of the data.