xclim.indicators.atmos package

Atmospheric Indicators

While the compute module stores the computing functions, this module defines Indicator classes and instances that include a number of functionalities, such as input validation, unit conversion, output meta-data handling, and missing value masking.

The concept followed here is to define Indicator subclasses for each input variable, then create instances for each indicator.

xclim.indicators.atmos.antecedent_precipitation_index(pr='pr', *, window=7, p_exp=0.935, ds=None)

Antecedent Precipitation Index.

Calculate the running weighted sum of daily precipitation values given a window and weighting exponent. This index serves as an indicator for soil moisture.

Based on function antecedent_precipitation_index().

Parameters:
  • pr (str or DataArray) – Daily precipitation data. Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Window for the days of precipitation data to be weighted and summed, default is 7. Default: 7.

  • p_exp (number) – Weighting exponent, default is 0.935. Default: 0.935.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – Antecedent Precipitation Index. With additional attributes: cell_methods: time: sum over days, description: Weighted moving sum of daily precipitation totals with a {window}-day window. Weights are an exponential decay of base {p_exp}.

Return type:

xarray.DataArray

References

Li, Wei, and Li [2021], Schröter, Kunz, Elmer, Mühr, and Merz [2015]

xclim.indicators.atmos.aridity_index(pr='pr', evspsblpot='evspsblpot', *, freq='YS', ds=None, **indexer)

Aridity index.

The ratio of total precipitation over potential evapotranspiration. Classification based on the Aridity Index (AI).

This indicator will check for missing values according to the method “from_context”. Based on function aridity_index().

Parameters:
  • pr (str or DataArray) – Precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • evspsblpot (str or DataArray) – Potential evapotranspiration. Default: ‘evspsblpot’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. A monthly or yearly frequency is expected. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray – Aridity Index. With additional attributes: description: The ratio of total precipitation over potential evapotranspiration.Classification based on the Aridity Index (AI).

Return type:

xarray.DataArray

Notes

  • The range in the aridity index define different environment categories (percentage of global land area covered)
    • Hyperarid (7.5%): AI < 0.05

    • Arid (12.1%): 0.05 ≤ AI < 0.20

    • Semi-Arid (17.7%): 0.20 ≤ AI < 0.50

    • Dry subhumid (9.9%): 0.50 ≤ AI < 0.65

    • Humid (52.8%): AI ≥ 0.65

  • In North America, higher aridity index values can be associated with colder climates due to lower evapotranspiration, even when precipitation is limited or occurring as snow.

References

:cite:cts:’zomer_2022’

xclim.indicators.atmos.australian_hardiness_zones(tasmin='tasmin', *, window=30, freq='YS', ds=None)

Australian hardiness zones

A climate indice based on a multi-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The Australian National Botanical Gardens (ANBG) classification scheme divides categories into 5-degree Celsius zones, starting from -15 degrees Celsius and ending at 20 degrees Celsius.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function hardiness_zones(). With injected parameters: method=anbg.

Parameters:
  • tasmin (str or DataArray) – Minimum temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • window (number) – The length of the averaging window, in years. Default: 30.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [dimensionless] – Hardiness zones. With additional attributes: description: A climate indice based on a {window}-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The Australian National Botanical Gardens (ANBG) classification scheme divides categories into 5-degree Celsius zones, starting from -15 degrees Celsius and ending at 20 degrees Celsius.

Return type:

xarray.DataArray

References

Dawson [1991], USDA Agricultural Research Service [2012]

xclim.indicators.atmos.biologically_effective_degree_days(tasmin='tasmin', tasmax='tasmax', lat='lat', *, thresh_tasmin='10 degC', method='gladstones', cap_value=1.0, low_dtr='10 degC', high_dtr='13 degC', max_daily_degree_days='9 degC', start_date='04-01', end_date='11-01', freq='YS', ds=None)

Biologically effective degree days

Considers daily minimum and maximum temperature with a given base threshold between 1 April and 31 October, with a maximum daily value for cumulative degree days (typically 9°C), and integrates modification coefficients for latitudes between 40°N and 50°N as well as for swings in daily temperature range. Metric originally published in Gladstones (1992).

This indicator will check for missing values according to the method “from_context”. Based on function biologically_effective_degree_days().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • lat (str or DataArray) – Latitude coordinate. If None and method is not “icclim”, a CF-conformant “latitude” field must be available within the passed DataArray. Default: ‘lat’. [Required units : []]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The minimum temperature threshold. Default: ‘10 degC’. [Required units : [temperature]]

  • method ({‘jones’, ‘icclim’, ‘huglin’, ‘gladstones’, ‘interpolated’}) – The formula to use for the daily temperature range and latitude coefficient. The “gladstones” method uses a temperature range adjustment and a latitude coefficient based on Gladstones [2011]. End_date should be “11-01” for the Northern Hemisphere. The “huglin” method uses a temperature range adjustment and a stepwise latitude coefficient for values between 40° and 50° based on Huglin [1978]. End_date should be “11-01” for the Northern Hemisphere. The “icclim” method does not implement daily temperature range and nor a latitude coefficient based on Project team ECA&D and KNMI [2013]. End date should be “10-01” for the Northern Hemisphere. The “interpolated” method uses a temperature range adjustment and a smoothed curve latitude coefficient for values between 40° and 50° based on Huglin [1978]. The “jones” method uses a temperature range adjustment and integrates axial tilt, latitude, and day-of-year based on Hall and Jones [2010]. End_date should be “11-01” for the Northern Hemisphere. Default: ‘gladstones’.

  • cap_value (number) – The value to use for the latitude coefficient for latitudes north of 50°N or south of 50°S. Only applicable for methods “huglin” and “interpolated”. Default: 1.0.

  • low_dtr (quantity (string or DataArray, with units)) – The lower bound for daily temperature range adjustment. Default: ‘10 degC’. [Required units : [temperature]]

  • high_dtr (quantity (string or DataArray, with units)) – The higher bound for daily temperature range adjustment. Default: ‘13 degC’. [Required units : [temperature]]

  • max_daily_degree_days (quantity (string or DataArray, with units)) – The maximum number of biologically effective degrees days that can be summed daily. Default: ‘9 degC’. [Required units : [temperature]]

  • start_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = April, south = October). Default: ‘04-01’.

  • end_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = October, south = April). This date is non-inclusive. Default: ‘11-01’.

  • freq (offset alias (string)) – Resampling frequency (For Southern Hemisphere, should be “YS-JUL”). Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [K days] – Integral of mean daily temperature above {thresh_tasmin}, with maximum value of {max_daily_degree_days}, multiplied by day-length coefficient and temperature range modifier based on {method} method for days between {start_date} and {end_date}. With additional attributes: description: Heat-summation index for agroclimatic suitability estimation, developed specifically for viticulture. Computed with {method} formula (Summation of min((max((Tn + Tx)/2 - {thresh_tasmin}, 0) * k) + TR_adj, Dmax), where coefficient `k` is a latitude-based day-length for days between {start_date} and {end_date}), coefficient `TR_adj` is a modifier accounting for large temperature swings, and `Dmax` is the maximum possibleamount of degree days that can be gained within a day ({max_daily_degree_days}).

Return type:

xarray.DataArray

Notes

Lat coordinate must be provided if method is “gladstones”, “gladstones_simple”, or “huglin”; The “icclim” method for BEDD here differs from the approach detailed in the Heliothermal Index of Huglin (HI) by not considering the latitude coefficient.

The tasmax ceiling of 19°C is assumed to be the maximum temperature beyond which no further gains from warmer daily temperatures occur. Index originally published in Gladstones [1992].

Let \(TX_{i}\) and \(TN_{i}\) be the daily maximum and minimum temperature at day \(i\), \(lat\) the latitude of the point of interest, \(degdays_{max}\) the maximum amount of degrees that can be summed per day (typically, 9). Then the sum of daily biologically effective growing degree day (BEDD) units between 1 April and 31 October is:

\[BEDD_i = \sum_{i=\text{April 1}}^{\text{October 31}} min\left( \left( max\left( \frac{TX_i + TN_i)}{2} - 10, 0 \right) * k \right) + TR_{adj}, degdays_{max} \right)\]
\[\begin{split}TR_{adj} = f(TX_{i}, TN_{i}) = \begin{cases} 0.25(TX_{i} - TN_{i} - 13), & \text{if } (TX_{i} - TN_{i}) > 13 \\ 0, & \text{if } 10 < (TX_{i} - TN_{i}) < 13\\ 0.25(TX_{i} - TN_{i} - 10), & \text{if } (TX_{i} - TN_{i}) < 10 \\ \end{cases}\end{split}\]
\[k = f(lat) = 1 + \left( \frac{\left| lat \right|}{50} * 0.06, \text{if }40 < |lat| <50, \text{else } 0\right)\]

An alternative version of the BEDD (method=”icclim”) does not consider \(TR_{adj}\) and \(k\) and employs a different end date (30 September) [Project team ECA&D and KNMI, 2013]. The simplified formula is as follows:

\[BEDD_i = \sum_{i=\text{April 1}}^{ \text{September 30} } min\left( max\left( \frac{TX_i + TN_i)}{2} - 10, 0 \right), degdays_{max} \right)\]

References

Gladstones [1992], Hall and Jones [2010], Huglin and Schneider [1998], Project team ECA&D and KNMI [2013]

xclim.indicators.atmos.calm_days(sfcWind='sfcWind', *, thresh='2 m s-1', freq='MS', ds=None, **indexer)

Calm days

Number of days with surface wind speed below threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘2 m s-1’. [Required units : ([speed])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘MS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days with surface wind speed below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with surface wind speed below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.cffwis_indices(tas='tas', pr='pr', sfcWind='sfcWind', hurs='hurs', lat='lat', snd=None, ffmc0=None, dmc0=None, dc0=None, season_mask=None, *, season_method=None, overwintering=False, dry_start=None, initial_start_up=True, ds=None, **params)

Canadian Fire Weather Index System indices.

Computes the six (6) fire weather indexes, as defined by the Canadian Forest Service: - The Drought Code - The Duff-Moisture Code - The Fine Fuel Moisture Code - The Initial Spread Index - The Build Up Index - The Fire Weather Index.

Based on function cffwis_indices().

Parameters:
  • tas (str or DataArray) – Noon temperature. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Rain fall in open over previous 24 hours, at noon. Default: ‘pr’. [Required units : [precipitation]]

  • sfcWind (str or DataArray) – Noon wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • hurs (str or DataArray) – Noon relative humidity. Default: ‘hurs’. [Required units : []]

  • lat (str or DataArray) – Latitude coordinate. Default: ‘lat’. [Required units : []]

  • snd (str or DataArray, optional) – Noon snow depth, only used if season_method=’LA08’ is passed. Default: None. [Required units : [length]]

  • ffmc0 (str or DataArray, optional) – Initial values of the fine fuel moisture code. Default: None. [Required units : []]

  • dmc0 (str or DataArray, optional) – Initial values of the Duff moisture code. Default: None. [Required units : []]

  • dc0 (str or DataArray, optional) – Initial values of the drought code. Default: None. [Required units : []]

  • season_mask (str or DataArray, optional) – Boolean mask, True where/when the fire season is active. Default: None. [Required units : []]

  • season_method ({None, ‘LA08’, ‘GFWED’, ‘WF93’}) – How to compute the start-up and shutdown of the fire season. If “None”, no start-ups or shutdowns are computed, similar to the R fire function. Ignored if season_mask is given. Default: None.

  • overwintering (boolean) – Whether to activate DC overwintering or not. If True, either season_method or season_mask must be given. Default: False.

  • dry_start ({None, ‘GFWED’, ‘CFS’}) – Whether to activate the DC and DMC “dry start” mechanism or not, see fire_weather_ufunc(). Default: None.

  • initial_start_up (boolean) – If True (default), gridpoints where the fire season is active on the first timestep go through a start_up phase for that time step. Otherwise, previous codes must be given as a continuing fire season is assumed for those points. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • params – Any other keyword parameters as defined in fire_weather_ufunc() and in default_params.

Returns:

  • dc (xarray.DataArray, [dimensionless]) – drought_code, Drought Code. With additional attributes: description: Numeric rating of the average moisture content of deep, compact organic layers.

  • dmc (xarray.DataArray, [dimensionless]) – duff_moisture_code, Duff Moisture Code. With additional attributes: description: Numeric rating of the average moisture content of loosely compacted organic layers of moderate depth.

  • ffmc (xarray.DataArray, [dimensionless]) – fine_fuel_moisture_code, Fine Fuel Moisture Code. With additional attributes: description: Numeric rating of the average moisture content of litter and other cured fine fuels.

  • isi (xarray.DataArray, [dimensionless]) – initial_spread_index, Initial Spread Index. With additional attributes: description: Numeric rating of the expected rate of fire spread.

  • bui (xarray.DataArray, [dimensionless]) – buildup_index, Buildup Index. With additional attributes: description: Numeric rating of the total amount of fuel available for combustion.

  • fwi (xarray.DataArray, [dimensionless]) – fire_weather_index, Fire Weather Index. With additional attributes: description: Numeric rating of fire intensity.

Return type:

tuple[xarray.DataArray, xarray.DataArray, xarray.DataArray, xarray.DataArray, xarray.DataArray, xarray.DataArray]

Notes

See Natural Resources Canada [n.d.], the xclim.compute.fire module documentation, and the docstring of fire_weather_ufunc() for more information. This algorithm follows the official R code released by the CFS, which contains revisions from the original 1982 Fortran code.

References

Wang, Anderson, and Suddaby [2015]

xclim.indicators.atmos.chill_portions(tas='tas', *, freq='YS', ds=None, **indexer)

Chill portions

Chill portions are a measure to estimate the bud breaking potential of different crops. The constants and functions are taken from Luedeling et al. (2009) which formalises the method described in Fishman et al. (1987). The model computes the accumulation of cold temperatures in a two-step process. First, cold temperatures contribute to an intermediate product that is transformed to a chill portion once it exceeds a certain concentration. The intermediate product can be broken down at higher temperatures but the final product is stable even at higher temperature. Thus the dynamic model is more accurate than other chill models like the Chilling hours or Utah model, especially in moderate climates like Israel, California or Spain.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function chill_portions().

Parameters:
  • tas (str or DataArray) – Hourly temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.compute.generic.select_time().

Returns:

xarray.DataArray, [unitless] – Chill portions after the Dynamic Model. With additional attributes: cell_methods: time: sum, description: Chill portions are a measure to estimate the bud breaking potential of different crops. The constants and functions are taken from Luedeling et al. (2009) which formalises the method described in Fishman et al. (1987).

Return type:

xarray.DataArray

Notes

Typically, this indicator is computed for a period of the year. You can use the **indexer arguments of select_time in combination with the freq argument to select e.g. a winter period:

cp = chill_portions(tas, date_bounds=("09-01", "03-30"), freq="YS-JUL")

Note that incomplete periods will lead to NaNs.

References

Fishman, Erez, and Couvillon [1987], Luedeling [2012]

xclim.indicators.atmos.chill_units(tas='tas', *, positive_only=False, freq='YS', ds=None, **indexer)

Chill units

Chill units are a measure to estimate the bud breaking potential of different crop based on Richardson et al. [1974]. The Utah model assigns a weight to each hour depending on the temperature recognising that high temperatures can actual decrease, the potential for bud breaking. Providing positive_only=True will ignore days with negative chill units.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function chill_units().

Parameters:
  • tas (str or DataArray) – Hourly temperature. Default: ‘tas’. [Required units : [temperature]]

  • positive_only (boolean) – If True, only positive daily chill units are aggregated. Default: False.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Chill units after the Utah Model. With additional attributes: cell_methods: time: sum, description: Chill units are a measure to estimate the bud breaking potential of different crops based on the Utah model developed in Richardson et al. (1974). The Utah model assigns a weight to each hour depending on the temperature recognising that high temperatures can actually decrease the potential for bud breaking.

Return type:

xarray.DataArray

References

Richardson, Seeley, and Walker [1974]

xclim.indicators.atmos.cold_and_dry_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Cold and dry days

Number of days with temperature below a given percentile and precipitation below a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function cold_and_dry_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – First quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – First quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature is below {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is below {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos.cold_and_wet_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Cold and wet days

Number of days with temperature below a given percentile and precipitation above a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function cold_and_wet_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – First quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – Third quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature is below {tas_per_thresh}th percentile and precipitation is above {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is below {tas_per_thresh}th percentile and precipitation is above {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos.cold_spell_days(tas='tas', *, window=5, condition='<', thresh, freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell days

The number of days that are part of a cold spell. A cold spell is defined as a minimum number of consecutive days with mean daily temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=sum, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 5.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Required. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – cold_spell_days, Total number of days constituting events of at least {window} consecutive days where the mean daily temperature is below {thresh}. With additional attributes: description: {freq} number of days that are part of a cold spell. A cold spell is defined as {window} or more consecutive days with mean daily temperature below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.cold_spell_duration_index(tasmin='tasmin', tasmin_per='tasmin_per', *, window=6, freq='YS', resample_before_rl=True, bootstrap=False, condition='<', ds=None)

Cold Spell Duration Index (CSDI)

Number of days part of a percentile-defined cold spell. A cold spell occurs when the daily minimum temperature is below a given percentile for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function cold_spell_duration_index().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmin_per (str or DataArray) – The nth percentile of daily minimum temperature with dayofyear coordinate. Default: ‘tasmin_per’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperature below threshold to qualify as a cold spell. Default: 6.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Keep bootstrap to False when there is no common period, as bootstrapping is computationally expensive, and it might provide the wrong results. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – cold_spell_duration_index, Total number of days constituting events of at least {window} consecutive days where the daily minimum temperature is below the {tasmin_per_thresh}th percentile. With additional attributes: description: {freq} number of days with at least {window} consecutive days where the daily minimum temperature is below the {tasmin_per_thresh}th percentile. A {tasmin_per_window} day(s) window, centred on each calendar day in the {tasmin_per_period} period, is used to compute the {tasmin_per_thresh}th percentile(s).

Return type:

xarray.DataArray

Notes

Let \(TN_i\) be the minimum daily temperature for the day of the year \(i\) and \(TN10_i\) the 10th percentile of the minimum daily temperature over the 1961-1990 period for day of the year \(i\), the cold spell duration index over period \(\phi\) is defined as:

\[\sum_{i \in \phi} \prod_{j=i}^{i+6} \left[ TN_j < TN10_j \right]\]

where \([P]\) is 1 if \(P\) is true, and 0 if false.

References

From the Expert Team on Climate Change Detection, Monitoring and Indices (ETCCDMI; [Zhang et al., 2011]).

xclim.indicators.atmos.cold_spell_frequency(tas='tas', *, window=5, condition='<', thresh='-10 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell frequency

The frequency of cold periods of N days or more, during which the temperature over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=count, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 5.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of cold periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is below {thresh}.. With additional attributes: description: The {freq} number of cold periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.cold_spell_max_length(tas='tas', *, window=1, condition='<', thresh='-10 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell maximum length

The maximum length of a cold period of N days or more, during which the temperature over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=max, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 1.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a cold period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is under {thresh}.. With additional attributes: description: The maximum {freq} number of consecutive days in a cold period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.cold_spell_total_length(tas='tas', *, window=3, condition='<', thresh='-10 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell total length

The total length of cold periods of N days or more, during which the temperature over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=sum, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in cold periods of {window} day(s) or more, during which thetemperature within windows of {window} day(s) is under {thresh}.. With additional attributes: description: The {freq} number of days in cold periods of {window} day(s) or more, during which the temperature within windows of {window} day(s) is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.consecutive_frost_days(tasmin='tasmin', *, condition='<', thresh='0 degC', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Consecutive frost days

Maximum number of consecutive days where the daily minimum temperature is below a given threshold

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=max, statistic=max, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_below_threshold, Maximum number of consecutive days where minimum daily temperature is {condition} {thresh}. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum number of consecutive days where minimum daily temperature is {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.cool_night_index(tasmin='tasmin', lat=None, *, freq='YS', ds=None)

Cool night index

A night coolness variable which takes into account the mean minimum night temperatures during the month when ripening usually occurs beyond the ripening period.

This indicator will check for missing values according to the method “from_context”. Based on function cool_night_index().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • lat (str or DataArray, optional) – Latitude coordinate as an array, float or string. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: None.

  • freq ({‘YS-JAN’, ‘YS’}) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [degC] – Mean minimum temperature in late summer. With additional attributes: cell_methods: time: mean over days, description: Mean minimum temperature for September (Northern hemisphere) or March (Southern hemisphere).

Return type:

xarray.DataArray

Notes

Given that this index only examines September and March months, it is possible to send in DataArrays containing only these timesteps. Users should be aware that due to the missing values checks in wrapped Indicators, datasets that are missing several months will be flagged as invalid. This check can be ignored by setting the following context:

with xclim.set_options(check_missing="skip"):
    cni = cool_night_index(tasmin)

References

Tonietto and Carbonneau [2004]

xclim.indicators.atmos.cooling_degree_days(tas='tas', *, thresh='18.0 degC', freq='YS', ds=None, **indexer)

Cooling degree days

The cumulative degree days for days when the mean daily temperature is above a given threshold and buildings must be air conditioned.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=>.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘18.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for mean daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative cooling degree days (mean temperature above {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos.cooling_degree_days_approximation(tasmax='tasmax', tasmin='tasmin', tas='tas', *, thresh='18.0 degC', freq='YS', ds=None, **indexer)

Cooling degree days approximation

The cumulative degree days for days when temperatures are above a given threshold and buildings must be air conditioned. This method integrates mean, minimum, and maximum temperatures, accounting for asymmetry in the distributions of temperatures throughout the diurnal cycle.

This indicator will check for missing values according to the method “from_context”. Based on function degree_days_above_approximation().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Temperature threshold above which degree days are accumulated. Default: ‘18.0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for daily temperatures above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative cooling degree days (temperature above {thresh}) using a combination of minimum, maximum, and mean daily temperatures.

Return type:

xarray.DataArray

Notes

For each day, the integrated quantity depends on where the threshold lies in relation to the 3 temperature statistics.

  • thresh > tasmax : 0

  • tasmax >= thresh > tas : (tasmax - thresh) / 4

  • tas >= thresh > tasmin : (tasmax - thresh) / 2 - (thresh - tasmin) / 4,

  • `` tasmin > thresh`` : (tas - thresh).

References

Spinoni, Vogt, Barbosa, Dosio, McCormick, Bigano, and Füssel [2018]

xclim.indicators.atmos.corn_heat_units(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='4.44 degC', thresh_tasmax='10 degC', ds=None)

Corn heat units

A temperature-based index used to estimate the development of corn crops. Corn growth occurs when the daily minimum and maximum temperatures exceed given thresholds.

Based on function corn_heat_units().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The minimum temperature threshold needed for corn growth. Default: ‘4.44 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The maximum temperature threshold needed for corn growth. Default: ‘10 degC’. [Required units : [temperature]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [unitless] – Corn heat units (Tmin > {thresh_tasmin} and Tmax > {thresh_tasmax}). With additional attributes: description: Temperature-based index used to estimate the development of corn crops. Corn growth occurs when the minimum and maximum daily temperatures both exceed {thresh_tasmin} and {thresh_tasmax}, respectively.

Return type:

xarray.DataArray

Notes

Formula used in calculating the Corn Heat Units for the Agroclimatic Atlas of Quebec [Audet et al., 2012].

The thresholds of 4.44°C for minimum temperatures and 10°C for maximum temperatures were selected following the assumption that no growth occurs below these values.

Let \(TX_{i}\) and \(TN_{i}\) be the daily maximum and minimum temperature at day \(i\). Then the daily corn heat unit is:

\[CHU_i = \frac{YX_{i} + YN_{i}}{2}\]

with

\[\begin{split}\begin{aligned} YX_i &= 3.33(TX_i - 10) - 0.084(TX_i - 10)^2, &\text{if } TX_i > 10^\circ\mathrm{C} \\ YN_i &= 1.8(TN_i - 4.44), &\text{if } TN_i > 4.44^\circ\mathrm{C} \end{aligned}\end{split}\]

Where \(YX_{i}\) and \(YN_{i}\) is 0 when \(TX_i \leq 10°C\) and \(TN_i \leq 4.44°C\), respectively.

References

Audet, Côté, Bachand, and Mailhot [2012], Bootsma, Tremblay, and Filion [1999]

xclim.indicators.atmos.daily_freezethaw_cycles(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', condition_tasmin='<=', condition_tasmax='>', freq='YS', resample_before_rl=True, ds=None, **indexer)

Daily freeze-thaw cycles

The number of days with a freeze-thaw cycle. A freeze-thaw cycle is defined as a day where maximum daily temperature is above a given threshold and minimum daily temperature is at or below a given threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: window=1, statistic=sum.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • condition_tasmin ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation for tasmin. Default: “<=”. Default: ‘<=’.

  • condition_tasmax ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation for tasmax. Default: “>”. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [days] – Number of days where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin}. With additional attributes: description: {freq} number of days with a diurnal freeze-thaw cycle, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin}.

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos.daily_pr_intensity(pr='pr', *, condition='>=', thresh='1 mm/day', freq='YS', ds=None, **indexer)

Simple Daily Intensity Index

Average precipitation for days with daily precipitation above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function thresholded_statistics(). With injected parameters: statistic=mean, constrain=(‘>’, ‘>=’), out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold, should have the same dimensionality as data. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm d-1] – lwe_precipitation_rate, Average precipitation during days with daily precipitation over {thresh} (Simple Daily Intensity Index: SDII). With additional attributes: description: {freq} Simple Daily Intensity Index (SDII) or {freq} average precipitation for days with daily precipitation over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.daily_temperature_range(tasmin='tasmin', tasmax='tasmax', *, statistic='mean', freq='YS', ds=None, **indexer)

Mean of daily temperature range

The average difference between the daily maximum and minimum temperatures.

This indicator will check for missing values according to the method “from_context”. Based on function difference_statistics(). With injected parameters: absolute=False.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • statistic ({‘min’, ‘sum’, ‘max’, ‘mean’}) – The statistic to compute over the difference between the two variables. Default: ‘mean’.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean diurnal temperature range. With additional attributes: cell_methods: time range within days time: mean over days, description: {freq} mean diurnal temperature range.

Return type:

xarray.DataArray

xclim.indicators.atmos.daily_temperature_range_variability(tasmin='tasmin', tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Variability of daily temperature range

The average day-to-day variation in daily temperature range.

This indicator will check for missing values according to the method “from_context”. Based on function interday_difference_statistics(). With injected parameters: statistic=mean, absolute=False.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after differentiating along time.

Returns:

xarray.DataArray, [K] – air_temperature, Mean diurnal temperature range variability. With additional attributes: cell_methods: time range within days time: difference over days time: mean over days, description: {freq} mean diurnal temperature range variability, defined as the average day-to-day variation in daily temperature range for the given time period.

Return type:

xarray.DataArray

xclim.indicators.atmos.day_to_day_temperature_variability(tas='tas', *, freq='YS', ds=None, **indexer)

Day-to-day temperature variability

Computes the standard deviation of the variable within each sub-period (e.g. month), then averages those standard deviations over the main resampling period (e.g. year). This provides a measure of typical day-to-day variability as described in Kotz et al. [2021].

This indicator will check for missing values according to the method “from_context”. Based on function day_to_day_variability(). With injected parameters: subfreq=MS.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency used to average the sub-period standard deviations. Default is "YS" (yearly). Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – Mean of the day-to-day temperature variability. With additional attributes: cell_methods: time: standard_deviation within months time: mean over months, description: {freq} mean of the day-to-day variability computed as the {subfreq} standard deviation

Return type:

xarray.DataArray

References

Kotz, Wenz, Stechemesser, Kalkuhl, and Levermann [2021]

xclim.indicators.atmos.days_over_precip_doy_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Number of days with precipitation above a given daily percentile

Number of days in a period where precipitation is above a given daily percentile and a fixed threshold.

This indicator will check for missing values according to the method “from_context”. Based on function days_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_daily_threshold, Number of days with daily precipitation flux above the {pr_per_thresh}th percentile of {pr_per_period}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with precipitation above the {pr_per_thresh}th daily percentile. Only days with at least {thresh} are counted. A {pr_per_window} day(s) window, centered on each calendar day in the {pr_per_period} period, is used to compute the {pr_per_thresh}th percentile(s).

Return type:

xarray.DataArray

xclim.indicators.atmos.days_over_precip_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Number of days with precipitation above a given percentile

Number of days in a period where precipitation is above a given percentile, calculated over a given period and a fixed threshold.

This indicator will check for missing values according to the method “from_context”. Based on function days_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Number of days with precipitation flux above the {pr_per_thresh}th percentile of {pr_per_period}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with precipitation above the {pr_per_thresh}th percentile of {pr_per_period} period. Only days with at least {thresh} are counted.

Return type:

xarray.DataArray

xclim.indicators.atmos.days_with_snow(prsn='prsn', *, freq='YS-JUL', ds=None, low='0 kg m-2 s-1', high='1E6 kg m-2 s-1', **indexer)

Days with snowfall

Number of days with snow between a lower and upper limit.

This indicator will check for missing values according to the method “from_context”. Based on function count_domain_occurrences(). With injected parameters: low_condition=>, high_condition=<=.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • freq (offset alias (string)) – Resampling frequency defining the periods defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • low (quantity (string or DataArray, with units)) – Minimum value. Default: ‘0 kg m-2 s-1’. [Required units : ([mass]/([area]*[time]))]

  • high (quantity (string or DataArray, with units)) – Maximum value. Default: ‘1E6 kg m-2 s-1’. [Required units : ([mass]/([area]*[time]))]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days with snowfall between {low} and {high} thresholds. With additional attributes: description: {freq} number of days with snowfall larger than {low} and smaller or equal to {high}.

Return type:

xarray.DataArray

xclim.indicators.atmos.degree_days_exceedance_date(tas='tas', *, thresh='0 degC', sum_thresh='25 K days', condition='>', after_date=None, never_reached=None, freq='YS', ds=None)

Degree day exceedance date

The day of the year when the sum of degree days exceeds a threshold, occurring after a given date. Degree days are calculated above or below a given temperature threshold.

This indicator will check for missing values according to the method “from_context”. Based on function degree_days_exceedance_date().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold temperature on which to base degree-days evaluation. Default: ‘0 degC’. [Required units : [temperature]]

  • sum_thresh (quantity (string or DataArray, with units)) – Threshold of the degree days sum. Default: ‘25 K days’. [Required units : K days]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – If equivalent to ‘>’, degree days are computed as tas - thresh and if equivalent to ‘<’, they are computed as thresh - tas. Default: ‘>’.

  • after_date (date (string, MM-DD)) – Date at which to start the cumulative sum. In “MM-DD” format, defaults to the start of the sampling period. Default: None.

  • never_reached (date (string, MM-DD)) – What to do when sum_thresh is never exceeded. If an int, the value to assign as a day-of-year. If a string, must be in “MM-DD” format, the day-of-year of that date is assigned. Default (None) assigns “NaN”. Default: None.

  • freq (offset alias (string)) – Resampling frequency. If after_date is given, freq should be annual. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Day of year when the integral of mean daily temperature {condition} {thresh} exceeds {sum_thresh}. With additional attributes: description: <function <lambda> at 0x7c95fe5313a0>

Return type:

xarray.DataArray

Notes

Let \(TG_{ij}\) be the daily mean temperature at day \(i\) of period \(j\), \(T\) is the reference threshold and \(ST\) is the sum threshold. Then, starting at day :math:i_0:, the degree days exceedance date is the first day \(k\) such that:

\[\begin{split}\begin{cases} ST < \sum_{i=i_0}^{k} \max(TG_{ij} - T, 0) & \text{if $condition$ is '>' | '>='} \\ ST < \sum_{i=i_0}^{k} \max(T - TG_{ij}, 0) & \text{if $condition$ is '<' | '<='} \end{cases}\end{split}\]

The resulting \(k\) is expressed as a day of year.

Cumulated degree days have numerous applications including plant and insect phenology. See: https://en.wikipedia.org/wiki/Growing_degree-day for examples (Wikipedia Contributors [2021]).

xclim.indicators.atmos.drought_code(tas='tas', pr='pr', lat='lat', snd=None, dc0=None, season_mask=None, *, season_method=None, overwintering=False, dry_start=None, initial_start_up=True, ds=None, **params)

Daily drought code

The Drought Index is part of the Canadian Forest-Weather Index system. It is a numerical code that estimates the average moisture content of organic layers.

Based on function drought_code().

Parameters:
  • tas (str or DataArray) – Noon temperature. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Rain fall in open over previous 24 hours, at noon. Default: ‘pr’. [Required units : [precipitation]]

  • lat (str or DataArray) – Latitude coordinate. Default: ‘lat’. [Required units : []]

  • snd (str or DataArray, optional) – Noon snow depth. Default: None. [Required units : [length]]

  • dc0 (str or DataArray, optional) – Initial values of the drought code. Default: None. [Required units : []]

  • season_mask (str or DataArray, optional) – Boolean mask, True where/when the fire season is active. Default: None. [Required units : []]

  • season_method ({None, ‘LA08’, ‘GFWED’, ‘WF93’}) – How to compute the start-up and shutdown of the fire season. If “None”, no start-ups or shutdowns are computed, similar to the R fire function. Ignored if season_mask is given. Default: None.

  • overwintering (boolean) – Whether to activate DC overwintering or not. If True, either season_method or season_mask must be given. Default: False.

  • dry_start ({None, ‘GFWED’, ‘CFS’}) – Whether to activate the DC and DMC “dry start” mechanism and which method to use. See fire_weather_ufunc(). Default: None.

  • initial_start_up (boolean) – If True (default), grid points where the fire season is active on the first timestep go through a start_up phase for that time step. Otherwise, previous codes must be given as a continuing fire season is assumed for those points. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • params – Any other keyword parameters as defined in xclim.compute.fire.fire_weather_ufunc and in default_params.

Returns:

xarray.DataArray, [dimensionless] – Drought Code. With additional attributes: description: Numerical code estimating the average moisture content of organic layers.

Return type:

xarray.DataArray

Notes

See Natural Resources Canada [n.d.], the xclim.compute.fire module documentation, and the docstring of fire_weather_ufunc() for more information. This algorithm follows the official R code released by the CFS, which contains revisions from the original 1982 Fortran code.

References

Wang, Anderson, and Suddaby [2015]

xclim.indicators.atmos.dry_days(pr='pr', *, condition='<', thresh='0.2 mm/d', freq='YS', ds=None, **indexer)

Number of dry days

The number of days with daily precipitation under a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0.2 mm/d’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_below_threshold, Number of dry days. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with daily precipitation under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.dry_spell_frequency(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Dry spell frequency

The frequency of dry periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=<, statistic=count, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – An amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of dry periods of at least {window} days. With additional attributes: description: The {freq} number of dry periods of at least {window} days. A period is dry if its {window_statistic} precipitation on a window of {window} days is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.dry_spell_max_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Dry spell maximum length

The maximum length of a dry period of N days or more, during which the accumulated or maximum precipitation over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=<, statistic=max, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – An amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a dry period of at least {window} days. With additional attributes: description: The maximum {freq} number of consecutive days in a dry period of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.dry_spell_total_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Dry spell total length

The total length of dry periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=<, statistic=sum, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – An amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in dry periods of at least {window} days.. With additional attributes: description: The {freq} number of days in dry periods of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.dryness_index(pr='pr', evspsblpot='evspsblpot', lat=None, *, wo='200 mm', freq='YS', ds=None)

Dryness index

The dryness index is a characterization of the water component in winegrowing regions which considers the precipitation and evapotranspiration factors without deduction for surface runoff or drainage. Metric originally published in Riou et al. (1994).

This indicator will check for missing values according to the method “from_context”. Based on function dryness_index().

Parameters:
  • pr (str or DataArray) – Precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • evspsblpot (str or DataArray) – Potential evapotranspiration. Default: ‘evspsblpot’. [Required units : [precipitation]]

  • lat (str or DataArray, optional) – Latitude coordinate as an array, float or string. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: None.

  • wo (quantity (string or DataArray, with units)) – The initial soil water reserve accessible to root systems [length]. Default: 200 mm. Default: ‘200 mm’. [Required units : [length]]

  • freq ({‘YS-JAN’, ‘YS’}) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – Growing season humidity. With additional attributes: description: Estimation of growing season humidity (precipitation minus adjusted evapotranspiration) for the period of April to September (Northern Hemisphere) or October to March (Southern Hemisphere), with initial soil moisture content set to {wo} and an adjustment based on monthly precipitation and evapotranspiration limits.

Return type:

xarray.DataArray

Notes

Given that this index only examines monthly total accumulations for six-month periods depending on the hemisphere, it is possible to send in DataArrays containing only these timesteps. Users should be aware that due to the missing values checks in wrapped Indicators, datasets that are missing several months will be flagged as invalid. This check can be ignored by setting the following context:

with xclim.set_options(check_missing="skip"):
    di = dryness_index(pr, evspsblpot)

Let \(Wo\) be the initial useful soil water reserve (typically “200 mm”), \(P\) be precipitation, \(T_{v}\) be the potential transpiration in the vineyard, and \(E_{s}\) be the direct evaporation from the soil. Then the Dryness Index, or the estimate of soil water reserve at the end of a period (1 April to 30 September in the Northern Hemispherere or 1 October to 31 March in the Southern Hemisphere), can be given by the following formulae:

\[W = \sum_{\text{April 1}}^{\text{September 30}} \left( Wo + P - T_{v} - E_{s} \right)\]

or (for the Southern Hemisphere):

\[W = \sum_{\text{October 1}}^{\text{March 31}} \left( Wo + P - T_{v} - E_{s} \right)\]

Where \(T_{v}\) and \(E_{s}\) are given by the following formulae:

\[T_{v} = ETP * k\]

and

\[E_{s} = \frac{ETP}{N}\left( 1 - k \right) * JPm\]

Where \(ETP\) is evapotranspiration, \(N\) is the number of days in the given month. \(k\) is the coefficient for radiative absorption given by the vine plant architecture, and \(JPm\) is the number of days of effective evaporation from the soil per month, both provided by the following formulae:

\[\begin{split}k = \begin{cases} 0.1, & \text{if month = April (NH) or October (SH)} \\ 0.3, & \text{if month = May (NH) or November (SH)} \\ 0.5, & \text{if month = June - September (NH) or December - March (SH)} \\ \end{cases}\end{split}\]
\[JPm = \max\left( P / 5, N \right)\]

References

Riou [1994], Tonietto and Carbonneau [2004]

xclim.indicators.atmos.duff_moisture_code(tas='tas', pr='pr', hurs='hurs', lat='lat', snd=None, dmc0=None, season_mask=None, *, season_method=None, dry_start=None, initial_start_up=True, ds=None, **params)

Duff moisture code (FWI component).

The duff moisture code is part of the Canadian Forest Fire Weather Index System. It is a numeric rating of the average moisture content of loosely compacted organic layers of moderate depth.

Based on function duff_moisture_code().

Parameters:
  • tas (str or DataArray) – Noon temperature. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Rain fall in open over previous 24 hours, at noon. Default: ‘pr’. [Required units : [precipitation]]

  • hurs (str or DataArray) – Noon relative humidity. Default: ‘hurs’. [Required units : []]

  • lat (str or DataArray) – Latitude coordinate. Default: ‘lat’. [Required units : []]

  • snd (str or DataArray, optional) – Noon snow depth. Default: None. [Required units : [length]]

  • dmc0 (str or DataArray, optional) – Initial values of the duff moisture code. Default: None. [Required units : []]

  • season_mask (str or DataArray, optional) – Boolean mask, True where/when the fire season is active. Default: None. [Required units : []]

  • season_method ({None, ‘LA08’, ‘GFWED’, ‘WF93’}) – How to compute the start-up and shutdown of the fire season. If “None”, no start-ups or shutdowns are computed, similar to the R fire function. Ignored if season_mask is given. Default: None.

  • dry_start ({None, ‘GFWED’, ‘CFS’}) – Whether to activate the DC and DMC “dry start” mechanism and which method to use. See fire_weather_ufunc(). Default: None.

  • initial_start_up (boolean) – If True (default), grid points where the fire season is active on the first timestep go through a start_up phase for that time step. Otherwise, previous codes must be given as a continuing fire season is assumed for those points. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • params – Any other keyword parameters as defined in xclim.compute.fire.fire_weather_ufunc and in default_params.

Returns:

xarray.DataArray, [dimensionless] – Duff Moisture Code. With additional attributes: description: Numeric rating of the average moisture content of loosely compacted organic layers of moderate depth.

Return type:

xarray.DataArray

Notes

See Natural Resources Canada [n.d.], the xclim.compute.fire module documentation, and the docstring of fire_weather_ufunc() for more information. This algorithm follows the official R code released by the Canadian Forestry Service, which contains revisions from the original 1982 Fortran code.

References

Wang, Anderson, and Suddaby [2015]

xclim.indicators.atmos.extreme_temperature_range(tasmin='tasmin', tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Extreme temperature range

The maximum of the maximum temperature minus the minimum of the minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function extreme_range().

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Intra-period extreme temperature range. With additional attributes: description: {freq} range between the maximum of daily maximum temperature and the minimum of dailyminimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.fire_season(tas='tas', snd=None, *, method='WF93', freq=None, temp_start_thresh='12 degC', temp_end_thresh='5 degC', temp_condition_days=3, snow_condition_days=3, snow_thresh='0.01 m', ds=None)

Fire season mask.

Binary mask of the active fire season, defined by conditions on consecutive daily temperatures and, optionally, snow depths.

Based on function fire_season().

Parameters:
  • tas (str or DataArray) – Daily surface temperature, cffdrs recommends using maximum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • snd (str or DataArray, optional) – Snow depth, used with method == ‘LA08’. Default: None. [Required units : [length]]

  • method ({‘LA08’, ‘GFWED’, ‘WF93’}) – Which method to use. “LA08” and “GFWED” need the snow depth. Default: ‘WF93’.

  • freq (offset alias (string)) – If given only the longest fire season for each period defined by this frequency, Every “seasons” are returned if None, including the short shoulder seasons. Default: None.

  • temp_start_thresh (quantity (string or DataArray, with units)) – Minimal temperature needed to start the season. Must be scalar. Default: ‘12 degC’. [Required units : [temperature]]

  • temp_end_thresh (quantity (string or DataArray, with units)) – Maximal temperature needed to end the season. Must be scalar. Default: ‘5 degC’. [Required units : [temperature]]

  • temp_condition_days (number) – Number of days with temperature above or below the thresholds to trigger a start or an end of the fire season. Default: 3.

  • snow_condition_days (number) – Parameters for the fire season determination. See fire_season(). Temperature is in degC, snow in m. The snow_thresh parameters is also used when dry_start is set to “GFWED”. Default: 3.

  • snow_thresh (quantity (string or DataArray, with units)) – Minimal snow depth level to end a fire season, only used with method “LA08”. Must be scalar. Default: ‘0.01 m’. [Required units : [length]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray – Fire season mask.. With additional attributes: description: Fire season mask, computed with method {method}.

Return type:

xarray.DataArray

References

Lawson and Armitage [2008], Wotton and Flannigan [1993]

xclim.indicators.atmos.first_day_tg_above(tas='tas', *, condition='>', thresh='0 degC', freq='YS', window=1, ds=None, after_date='01-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of mean temperature above {thresh}. With additional attributes: description: First day of year with mean temperature above {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.first_day_tg_below(tas='tas', *, condition='<', thresh='0 degC', freq='YS', window=1, ds=None, after_date='07-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of mean temperature below {thresh}. With additional attributes: description: First day of year with mean temperature below {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.first_day_tn_above(tasmin='tasmin', *, condition='>', thresh='0 degC', freq='YS', window=1, ds=None, after_date='01-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of minimum temperature above {thresh}. With additional attributes: description: First day of year with minimum temperature above {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.first_day_tn_below(tasmin='tasmin', *, condition='<', thresh='0 degC', freq='YS', window=1, ds=None, after_date='07-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of minimum temperature below {thresh}. With additional attributes: description: First day of year with minimum temperature below {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.first_day_tx_above(tasmax='tasmax', *, condition='>', thresh='0 degC', freq='YS', window=1, ds=None, after_date='01-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of maximum temperature above {thresh}. With additional attributes: description: First day of year with maximum temperature above {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.first_day_tx_below(tasmax='tasmax', *, condition='<', thresh='0 degC', freq='YS', window=1, ds=None, after_date='07-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of maximum temperature below {thresh}. With additional attributes: description: First day of year with maximum temperature below {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.first_snowfall(prsn='prsn', *, thresh='1 mm/d', freq='YS-JUL', ds=None, **indexer)

First day where snowfall exceeded a given threshold

The first day where snowfall exceeded a given threshold during a time period (the threshold can be given as a snowfall flux or a liquid water equivalent snowfall rate).

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: condition=>=, date=None, which=first, window=1, constrain=None.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘1 mm/d’. [Required units : ([mass]/([area]*[time]))]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Date of first day where snowfall exceeded {thresh}. With additional attributes: description: {freq} first day where snowfall exceeded {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.fraction_over_precip_doy_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Fraction of precipitation due to wet days with daily precipitation over a given daily percentile.

The percentage of the total precipitation over a period occurring for days when the precipitation is above a threshold defining wet days and above a given percentile for that day.

This indicator will check for missing values according to the method “from_context”. Based on function fraction_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Fraction of precipitation due to days with daily precipitation above {pr_per_thresh}th daily percentile. With additional attributes: description: {freq} fraction of total precipitation due to days with precipitation above {pr_per_thresh}th daily percentile. Only days with at least {thresh} are included in the total. A {pr_per_window} day(s) window, centered on each calendar day in the {pr_per_period} period, is used to compute the {pr_per_thresh}th percentile(s).

Return type:

xarray.DataArray

xclim.indicators.atmos.fraction_over_precip_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Fraction of precipitation due to wet days with daily precipitation over a given percentile.

The percentage of the total precipitation over a period occurring for days when the precipitation is above a threshold defining wet days and above a given percentile for that day.

This indicator will check for missing values according to the method “from_context”. Based on function fraction_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Fraction of precipitation due to days with precipitation above {pr_per_thresh}th daily percentile. With additional attributes: description: {freq} fraction of total precipitation due to days with precipitation above {pr_per_thresh}th percentile of {pr_per_period} period. Only days with at least {thresh} are included in the total.

Return type:

xarray.DataArray

xclim.indicators.atmos.freezethaw_spell_frequency(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', window=1, condition_tasmin='<=', condition_tasmax='>', freq='YS', resample_before_rl=True, ds=None, **indexer)

Freeze-thaw spell frequency

Frequency of daily freeze-thaw spells. A freeze-thaw spell is defined as a number of consecutive days where maximum daily temperatures are above a given threshold and minimum daily temperatures are at or below a given threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: statistic=count.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • window (number) – The minimal length of spells to be included in the statistics. Default: 1.

  • condition_tasmin ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation for tasmin. Default: “<=”. Default: ‘<=’.

  • condition_tasmax ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation for tasmax. Default: “>”. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [time] – Frequency of events where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).. With additional attributes: description: {freq} number of freeze-thaw spells, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos.freezethaw_spell_max_length(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', window=1, condition_tasmin='<=', condition_tasmax='>', freq='YS', resample_before_rl=True, ds=None, **indexer)

Maximal length of freeze-thaw spells

Maximal length of daily freeze-thaw spells. A freeze-thaw spell is defined as a number of consecutive days where maximum daily temperatures are above a given threshold and minimum daily temperatures are at or below a threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: statistic=max.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • window (number) – The minimal length of spells to be included in the statistics. Default: 1.

  • condition_tasmin ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation for tasmin. Default: “<=”. Default: ‘<=’.

  • condition_tasmax ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation for tasmax. Default: “>”. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [days] – Maximal length of events where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).. With additional attributes: description: {freq} maximal length of freeze-thaw spells, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos.freezethaw_spell_mean_length(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', window=1, freq='YS', resample_before_rl=True, ds=None, **indexer)

Freeze-thaw spell mean length

Average length of daily freeze-thaw spells. A freeze-thaw spell is defined as a number of consecutive days where maximum daily temperatures are above a given threshold and minimum daily temperatures are at or below a given threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: statistic=mean, condition_tasmin=<=, condition_tasmax=>.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • window (number) – The minimal length of spells to be included in the statistics. Default: 1.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [days] – Average length of events where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).. With additional attributes: description: {freq} average length of freeze-thaw spells, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos.freezing_degree_days(tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Freezing degree days

The cumulative degree days for days when the average temperature is below a given threshold, typically 0°C.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=<.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_deficit_wrt_time, Cumulative sum of temperature degrees for mean daily temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} freezing degree days (mean temperature below {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos.freshet_start(tas='tas', *, condition='>', thresh='0 degC', freq='YS', window=5, ds=None, after_date='01-01', **indexer)

Day of year of spring freshet start

Day of year of the spring freshet start, defined as the first day when the temperature exceeds a certain threshold for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 5.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day where temperature threshold of {thresh} is exceeded for at least {window} days. With additional attributes: description: Day of year of the spring freshet start, defined as the first day a temperature threshold of {thresh} is exceeded for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.frost_days(tasmin='tasmin', *, thresh='0 °C', freq='YS', ds=None, **indexer)

Frost days

Number of days where the daily minimum temperature is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days where the daily minimum temperature is below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the daily minimum temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.frost_free_season_end(tasmin='tasmin', *, condition='>=', thresh='0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Frost free season end

First day when the temperature is below a given threshold for a given number of consecutive days after a median calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=end, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day, after {mid_date}, following a period of {window} days with minimum daily temperature below {thresh}. With additional attributes: description: Day of the year of the end of the frost-free season, defined as the interval between the first set of {window} days when the minimum daily temperature is at or above {thresh} and the first set (after {mid_date}) of {window} days when it is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.frost_free_season_length(tasmin='tasmin', *, condition='>=', thresh='0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Frost free season length

Duration of the frost free season, defined as the period when the minimum daily temperature is above 0°C without a freezing window of N days, with freezing occurring after a median calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=length, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} after {mid_date}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos.frost_free_season_start(tasmin='tasmin', *, condition='>=', thresh='0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Frost free season start

First day when minimum daily temperature exceeds a given threshold for a given number of consecutive days

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=start, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day following a period of {window} days with minimum daily temperature at or above {thresh}. With additional attributes: description: Day of the year of the beginning of the frost-free season, defined as the {window}th consecutive day when minimum daily temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.frost_free_spell_max_length(tasmin='tasmin', *, window=1, condition='>=', thresh='0 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Frost free spell maximum length

The maximum length of a frost free period of N days or more, during which the minimum temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 1.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a frost free period of {window} day(s) or more, during which the minimum temperature within windows of {window} day(s) is above {thresh}.. With additional attributes: description: The maximum {freq} number of consecutive days in a frost free period of {window} day(s) or more, during which the minimum temperature within windows of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.frost_season_length(tasmin='tasmin', *, condition='<', thresh='0 degC', window=5, freq='YS-JUL', mid_date='01-01', ds=None, **indexer)

Frost season length

Duration of the freezing season, defined as the period when the daily minimum temperature is below 0°C without a thawing window of days, with the thaw occurring after a median calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=length, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘01-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} after {mid_date}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos.griffiths_drought_factor(pr='pr', smd='smd', *, limiting_func='xlim', ds=None)

Griffiths drought factor based on the soil moisture deficit.

The drought factor is a numeric indicator of the forest fire fuel availability in the deep litter bed. It is often used in the calculation of the McArthur Forest Fire Danger Index. The method implemented here follows Finkele et al. [2006].

Based on function griffiths_drought_factor().

Parameters:
  • pr (str or DataArray) – Total rainfall over previous 24 hours [mm/day]. Default: ‘pr’. [Required units : [precipitation]]

  • smd (str or DataArray) – Daily soil moisture deficit (often KBDI) [mm/day]. Default: ‘smd’. [Required units : [precipitation]]

  • limiting_func ({‘xlim’, ‘discrete’}) – How to limit the values of the drought factor. If “xlim” (default), use equation (14) in Finkele et al. [2006]. If “discrete”, use equation Eq (13) in Finkele et al. [2006], but with the lower limit of each category bound adjusted to match the upper limit of the previous bound. Default: ‘xlim’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray – griffiths_drought_factor, Griffiths Drought Factor. With additional attributes: description: Numeric indicator of the forest fire fuel availability in the deep litter bed

Return type:

xarray.DataArray

Notes

Calculation of the Griffiths drought factor depends on the rainfall over the previous 20 days. Thus, the first non-NaN time point in the drought factor returned by this function corresponds to the 20th day of the input data.

References

Finkele, Mills, Beard, and Jones [2006], Griffiths [1999], Holgate, Van DIjk, Cary, and Yebra [2017]

xclim.indicators.atmos.growing_degree_days(tas='tas', *, thresh='4.0 degC', freq='YS', ds=None, **indexer)

Growing degree days

The cumulative degree days for days when the average temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=>.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘4.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for mean daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} growing degree days (mean temperature above {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos.growing_season_end(tas='tas', *, condition='>=', thresh='5.0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Growing season end

The first day when the temperature is below a certain threshold for a certain number of consecutive days after a given calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=end, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘5.0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day of the first series of {window} days with mean daily temperature {condition} {thresh}, occurring after {mid_date}. With additional attributes: description: Day of year of end of growing season, defined as the first day of consistent inferior threshold temperature of {thresh} after a run of {window} days superior to threshold temperature, occurring after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos.growing_season_length(tas='tas', *, condition='>=', thresh='5.0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Growing season length

Number of days between the first occurrence of a series of days with a daily average temperature above a threshold and the first occurrence of a series of days with a daily average temperature below that same threshold, occurring after a given calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=length, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘5.0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – growing_season_length, Number of days between the first occurrence of at least {window} consecutive days with mean daily temperature over {thresh} and the first occurrence of at least {window} consecutive days with mean daily temperature below {thresh}, occurring after {mid_date}. With additional attributes: description: {freq} number of days between the first occurrence of at least {window} consecutive days with mean daily temperature over {thresh} and the first occurrence of at least {window} consecutive days with mean daily temperature below {thresh}, occurring after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos.growing_season_start(tas='tas', *, condition='>=', thresh='5.0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Growing season start

The first day when the temperature exceeds a certain threshold for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=start, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘5.0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day of the first series of {window} days with mean daily temperature {condition} {thresh}. With additional attributes: description: Day of the year marking the beginning of the growing season, defined as the first day of the first series of {window} days with mean daily temperature {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.heat_spell_frequency(tasmin='tasmin', tasmax='tasmax', *, window=3, freq='YS', min_gap=1, resample_before_rl=True, ds=None, win_reducer='mean', thresh_tasmin='20 °C', thresh_tasmax='33 °C', **indexer)

Heat spell frequency

Number of heat spells. A heat spell occurs when rolling averages of daily minimum and maximumtemperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: condition=>=, statistic=count, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • win_reducer ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘mean’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for tasmin Default: ‘20 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for tasmax Default: ‘33 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of heat spells. With additional attributes: description: {freq} number of heat spells events. A heat spell occurs when the {window}-day averages of daily minimum and maximum temperatures each exceed {thresh_tasmin} and {thresh_tasmax}. All days of the {window}-day period are considered part of the spell. Gaps of fewer than {min_gap} day(s) are allowed within a spell.

Return type:

xarray.DataArray

xclim.indicators.atmos.heat_spell_max_length(tasmin='tasmin', tasmax='tasmax', *, window=3, freq='YS', min_gap=1, resample_before_rl=True, ds=None, win_reducer='mean', thresh_tasmin='20 °C', thresh_tasmax='33 °C', **indexer)

Heat spell maximum length

The longest heat spell of a period. A heat spell occurs when rolling averages of daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: condition=>=, statistic=max, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • win_reducer ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘mean’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for tasmin Default: ‘20 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for tasmax Default: ‘33 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Longest heat spell. With additional attributes: description: {freq} maximum length of heat spells. A heat spell occurs when the {window}-day averages of daily minimum and maximum temperatures each exceed {thresh_tasmin} and {thresh_tasmax}. All days of the {window}-day period are considered part of the spell. Gaps of fewer than {min_gap} day(s) are allowed within a spell.

Return type:

xarray.DataArray

xclim.indicators.atmos.heat_spell_total_length(tasmin='tasmin', tasmax='tasmax', *, window=3, freq='YS', min_gap=1, resample_before_rl=True, ds=None, win_reducer='mean', thresh_tasmin='20 °C', thresh_tasmax='33 °C', **indexer)

Heat spell total length

Total length of heat spells. A heat spell occurs when rolling averages of daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: condition=>=, statistic=sum, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • win_reducer ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘mean’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for tasmin Default: ‘20 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for tasmax Default: ‘33 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Total length of heat spells.. With additional attributes: description: {freq} total length of heat spell events. A heat spell occurs when the {window}-day  averages of daily minimum and maximum temperatures each exceed {thresh_tasmin} and {thresh_tasmax}.  All days of the {window}-day period are considered part of the spell. Gaps of fewer than {min_gap} day(s) are allowed within a spell.

Return type:

xarray.DataArray

xclim.indicators.atmos.heat_wave_frequency(tasmin='tasmin', tasmax='tasmax', *, window=3, condition='>', freq='YS', resample_before_rl=True, ds=None, thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Heat wave frequency

Number of heat waves. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: window_statistic=min, statistic=count, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold to test against for data1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold to test against for data2. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Total number of series of at least {window} consecutive days with daily minimum temperature above {thresh_tasmin} and daily maximum temperature above {thresh_tasmax}. With additional attributes: description: {freq} number of heat wave events within a given period. A heat wave occurs when daily minimum and maximum temperatures exceed {thresh_tasmin} and {thresh_tasmax}, respectively, over at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.heat_wave_index(tasmax='tasmax', *, thresh='25 degC', window=5, freq='YS', op='>', resample_before_rl=True, ds=None)

Heat wave index

Number of days that constitute heatwave events. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function hot_spell_total_length().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a hot spell. Default: ‘25 degC’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperatures below the threshold to qualify as a hot spell. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • op ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – Total number of days constituting events of at least {window} consecutive days with daily maximum temperature above {thresh}. With additional attributes: description: {freq} total number of days that are part of a heatwave within a given period. A heat wave occurs when daily maximum temperatures exceed {thresh} over at least {window} days.

Return type:

xarray.DataArray

Notes

The threshold on tasmax follows the one used in heat waves. A day temperature threshold between 30° and 35°C was selected by Health Canada professionals, following a temperature–mortality analysis. This absolute temperature threshold characterize the occurrence of hot weather events that can result in adverse health outcomes for Canadian communities [Casati et al., 2013].

In Robinson [2001] where heat waves are also considered, the corresponding parameters would be thresh=39.44, window=2 (103F).

xclim.indicators.atmos.heat_wave_max_length(tasmin='tasmin', tasmax='tasmax', *, window=3, condition='>', freq='YS', resample_before_rl=True, ds=None, thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Heat wave maximum length

Maximal duration of heat waves. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: window_statistic=min, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold to test against for data1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold to test against for data2. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Longest series of at least {window} consecutive days with daily minimum temperature above {thresh_tasmin} and daily maximum temperature above {thresh_tasmax}. With additional attributes: description: {freq} maximum length of heat wave events occurring within a given period. A heat wave occurs when daily minimum and maximum temperatures exceed {thresh_tasmin} and {thresh_tasmax}, respectively, over at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.heat_wave_total_length(tasmin='tasmin', tasmax='tasmax', *, window=3, condition='>', freq='YS', resample_before_rl=True, ds=None, thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Heat wave total length

Total length of heat waves. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: window_statistic=min, statistic=sum, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold to test against for data1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold to test against for data2. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Total length of events of at least {window} consecutive days with daily minimum temperature above {thresh_tasmin} and daily maximum temperature above {thresh_tasmax}. With additional attributes: description: {freq} total length of heat wave events occurring within a given period. A heat wave occurs when daily minimum and maximum temperatures exceed {thresh_tasmin} and {thresh_tasmax}, respectively, over at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos.heating_degree_days(tas='tas', *, thresh='17.0 degC', freq='YS', ds=None, **indexer)

Heating degree days

The cumulative degree days for days when the mean daily temperature is below a given threshold and buildings must be heated.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=<.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘17.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_deficit_wrt_time, Cumulative sum of temperature degrees for mean daily temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative heating degree days (mean temperature below {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos.heating_degree_days_approximation(tasmax='tasmax', tasmin='tasmin', tas='tas', *, thresh='17.0 degC', freq='YS', ds=None, **indexer)

Heating degree days approximation

The cumulative degree days for days where temperatures are below a given threshold and buildings must be heated. This method integrates mean, minimum, and maximum temperatures, accounting for asymmetry in the distributions of temperatures throughout the diurnal cycle.

This indicator will check for missing values according to the method “from_context”. Based on function degree_days_below_approximation().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Temperature threshold below which degree days are accumulated. Default: ‘17.0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_deficit_wrt_time, Cumulative sum of temperature degrees for daily temperatures below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative heating degree days (temperature below {thresh}) using a combination of minimum, maximum, and mean daily temperatures.

Return type:

xarray.DataArray

Notes

For each day, the integrated quantity depends on where the threshold lies in relation to the 3 temperature statistics.

  • thresh > tasmax : (thresh - tas)

  • tasmax >= thresh > tas : (thresh - tasmin) / 2 - (tasmax - thresh) / 4

  • tas >= thresh > tasmin : (thresh - tasmin) / 4

  • tasmin > thresh : 0.

References

Spinoni, Vogt, Barbosa, Dosio, McCormick, Bigano, and Füssel [2018]

xclim.indicators.atmos.high_precip_low_temp(pr='pr', tas='tas', *, freq='YS', ds=None, pr_thresh='0.4 mm/d', tas_thresh='-0.2 degC', **indexer)

Days with precipitation and cold temperature

Number of days with precipitation above a given threshold and temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_count_occurrences(). With injected parameters: condition1=>=, condition2=<, var_reducer=all, constrain1=None, constrain2=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • pr_thresh (quantity (string or DataArray, with units)) – Threshold for data variable 1. Default: ‘0.4 mm/d’. [Required units : ([precipitation])]

  • tas_thresh (quantity (string or DataArray, with units)) – Threshold for data variable 2. If None, thresh1 is used. Default: ‘-0.2 degC’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Days with precipitation at or above {pr_thresh} and temperature below {tas_thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with precipitation at or above {pr_thresh} and temperature below {tas_thresh}.

Return type:

xarray.DataArray

Notes

Sampling length is derived from data1.

xclim.indicators.atmos.hot_days(tasmax='tasmax', *, thresh='25 °C', freq='YS', ds=None, **indexer)

Hot days

Number of days where the daily maximum temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=>, constrain=>.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘25 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days where the daily maximum temperature is above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the daily maximum temperature is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.hot_spell_frequency(tasmax='tasmax', *, window=3, condition='>', thresh='30 °C', freq='YS', resample_before_rl=True, ds=None, **indexer)

Hot spell frequency

The frequency of hot periods of N days or more, during which the temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=min, statistic=count, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘30 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of hot periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is above {thresh}.. With additional attributes: description: The {freq} number of hot periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.hot_spell_max_length(tasmax='tasmax', *, window=1, condition='>', thresh='30 °C', freq='YS', resample_before_rl=True, ds=None, **indexer)

Hot spell maximum length

The maximum length of a hot period of N days or more, during which the temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=min, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 1.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘30 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a hot period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is above {thresh}.. With additional attributes: description: The maximum {freq} number of consecutive days in a hot period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.hot_spell_max_magnitude(tasmax='tasmax', *, thresh='25.0 degC', window=3, freq='YS', resample_before_rl=True, ds=None)

Hot spell maximum magnitude

Magnitude of the most intensive heat wave per {freq}. A heat wave occurs when daily maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function hot_spell_max_magnitude().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold temperature on which to designate a heatwave. Default: ‘25.0 degC’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperature above the threshold to qualify as a heatwave. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [K d] – Maximum cumulative difference between daily maximum temperature and {thresh} for days within a heat wave. A heat wave is defined as a series of at least {window} consecutive days with daily maximum temperature above {thresh}.. With additional attributes: description: Magnitude of the most intensive heat wave per {freq}. The magnitude is the cumulative exceedance of daily maximum temperature over {thresh}. A heat wave is defined as a series of at least {window} consecutive days with daily maximum temperature above {thresh}

Return type:

xarray.DataArray

References

Russo, Dosio, Graversen, Sillmann, Carrao, Dunbar, Singleton, Montagna, Barbola, and Vogt [2014], Zhang, She, Zhang, Wang, Chen, and Hao [2022].

xclim.indicators.atmos.hot_spell_total_length(tasmax='tasmax', *, window=3, condition='>', thresh='30 °C', freq='YS', resample_before_rl=True, ds=None, **indexer)

Hot spell total length

The total length of hot periods of N days or more, during which the temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=min, statistic=sum, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘30 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in hot periods of {window} day(s) or more, during which thetemperature within windows of {window} day(s) is above {thresh}.. With additional attributes: description: The {freq} number of days in hot periods of {window} day(s) or more, during which the temperature within windows of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.huglin_index(tas='tas', tasmax='tasmax', lat='lat', *, thresh='10 degC', method='jones', cap_value=1.0, start_date='04-01', end_date='10-01', freq='YS', ds=None)

Huglin heliothermal index

Heat-summation index for agroclimatic suitability estimation, developed specifically for viticulture. Considers daily minimum and maximum temperature with a given base threshold, typically between 1 April and 30September, and integrates a day-length coefficient calculation for higher latitudes. Metric originally published in Huglin (1978). Day-length coefficient based on Hall & Jones (2010).

This indicator will check for missing values according to the method “from_context”. Based on function huglin_index().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • lat (str or DataArray) – Latitude coordinate. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: ‘lat’. [Required units : []]

  • thresh (quantity (string or DataArray, with units)) – The temperature threshold. Default: “10 degC”. Default: ‘10 degC’. [Required units : [temperature]]

  • method ({‘jones’, ‘huglin’, ‘interpolated’}) – The formula to use for the latitude coefficient calculation. The “huglin” method uses a stepwise latitude coefficient for values between 40° and 50° based on Huglin [1978]. The “interpolated” method uses a smoothed curve latitude coefficient for values based on the intervals set in Huglin [1978]. The “jones” method integrates axial tilt, latitude, and day-of-year based on Hall and Jones [2010]. Default: ‘jones’.

  • cap_value (number) – The value to use for the latitude coefficient when latitude is above 50°N or below 50°S. Only applicable for methods “huglin” and “interpolated” (default: 1.0). Default: 1.0.

  • start_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = April, south = October). Default: ‘04-01’.

  • end_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = October, south = April). This date is non-inclusive. Default: ‘10-01’.

  • freq ({‘YS-JAN’, ‘YS’, ‘YS-JUL’}) – Resampling frequency (default: “YS”; For Southern Hemisphere, should be “YS-JUL”). Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [unitless] – Integral of mean daily temperature above {thresh} multiplied by day-length coefficient with {method} method for days between {start_date} and {end_date}. With additional attributes: description: Heat-summation index for agroclimatic suitability estimation, developed specifically for viticulture, computed with {method} formula (Summation of ((Tn + Tx)/2 - {thresh}) * k), where coefficient `k` is a latitude-based day-length for days between {start_date} and {end_date}.

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) and \(TG_{i}\) be the daily maximum and mean temperature at day \(i\) and \(T_{thresh}\) the base threshold needed for heat summation (typically, 10 degC). A day-length multiplication, \(k\), based on latitude, \(lat\), is also considered. Then the heliothermal index for dates between 1 April and 30 September is:

\[HI = \sum_{i=\text{April 1}}^{\text{September 30}} \left(\frac{TX_i + TG_i}{2} - T_{thresh} \right) * k\]

There are a few methods provided for calculating the day-length multiplication factor (\(k\)) based on latitude:

  • For the “huglin” and “interpolated” methods, values for k increase from 1.0 at 40°N or 40°S to 1.06 at 50°N or 50°S, where the interpolated method uses a smoothed curve and the huglin method uses a stepwise function. Values above 50°N or below 50°S are set via the cap_value variable, with 1.0 set as default. See: xclim.compute.helpers.huglin_day_length_latitude_coefficient() for more information.

  • For the “jones” method, A more robust day-length calculation based on latitude, calendar, day-of-year, and obliquity is used. The current implementation requires an annual frequency for consistent results. See: xclim.compute.generic.jones_day_length_coefficient() or Hall and Jones [2010] for more information.

For compatibility with the original ICCLIM implementation [Project team ECA&D and KNMI, 2013], end_date should be set to 11-01 with method=”huglin”.

References

Hall and Jones [2010], Huglin [1978]

xclim.indicators.atmos.ice_days(tasmax='tasmax', *, thresh='0 °C', freq='YS', ds=None, **indexer)

Ice days

Number of days where the daily maximum temperature is below 0°C

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with maximum daily temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the maximum daily temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.jetstream_metric_woollings(ua='ua', *, ds=None)

Strength and latitude of jetstream

Identify latitude and strength of maximum smoothed zonal wind speed in the region from 15 to 75°N and -60 to 0°E, using the formula outlined in [Woollings et al., 2010]. Wind is smoothened using a Lanczos filter approach.

Based on function jetstream_metric_woollings().

Parameters:
  • ua (str or DataArray) – Eastward wind component (u) at between 750 and 950 hPa. Default: ‘ua’. [Required units : [speed]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

  • jetlat (xarray.DataArray, [degrees_north]) – Latitude of maximum smoothed zonal wind speed. With additional attributes: description: Daily latitude of maximum Lanczos smoothed zonal wind speed.

  • jetstr (xarray.DataArray, [m s-1]) – Maximum strength of smoothed zonal wind speed. With additional attributes: description: Daily maximum strength of Lanczos smoothed zonal wind speed.

Return type:

tuple[xarray.DataArray, xarray.DataArray]

References

Woollings, Hannachi, and Hoskins [2010]

xclim.indicators.atmos.keetch_byram_drought_index(pr='pr', tasmax='tasmax', pr_annual='pr_annual', kbdi0=None, *, ds=None)

Keetch-Byram drought index (KBDI) for soil moisture deficit.

The KBDI indicates the amount of water necessary to bring the soil moisture content back to field capacity. It is often used in the calculation of the McArthur Forest Fire Danger Index. The method implemented here follows Finkele et al. [2006] but limits the maximum KBDI to 203.2 mm, rather than 200 mm, in order to align best with the majority of the literature.

Based on function keetch_byram_drought_index().

Parameters:
  • pr (str or DataArray) – Total rainfall over previous 24 hours [mm/day]. Default: ‘pr’. [Required units : [precipitation]]

  • tasmax (str or DataArray) – Maximum temperature near the surface over previous 24 hours [degC]. Default: ‘tasmax’. [Required units : [temperature]]

  • pr_annual (str or DataArray) – Mean (over years) annual accumulated rainfall [mm/year]. Default: ‘pr_annual’. [Required units : [precipitation]]

  • kbdi0 (str or DataArray, optional) – Previous KBDI values used to initialise the KBDI calculation [mm/day]. Defaults to 0. Default: None. [Required units : [precipitation]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm/day] – keetch_byram_drought_index, Keetch-Byran Drought Index. With additional attributes: description: Amount of water necessary to bring the soil moisture content back to field capacity

Return type:

xarray.DataArray

Notes

This method implements the method described in Finkele et al. [2006] (section 2.1.1) for calculating the KBDI with one small difference: in Finkele et al. [2006] the maximum KBDI is limited to 200 mm to represent the maximum field capacity of the soil (8 inches according to Keetch and Byram [1968]). However, it is more common in the literature to limit the KBDI to 203.2 mm which is a more accurate conversion from inches to mm. In this function, the KBDI is limited to 203.2 mm.

References

Dolling, Chu, and Fujioka [2005], Finkele, Mills, Beard, and Jones [2006], Holgate, Van DIjk, Cary, and Yebra [2017], Keetch and Byram [1968]

xclim.indicators.atmos.last_snowfall(prsn='prsn', *, thresh='1 mm/d', freq='YS-JUL', ds=None, **indexer)

Last day where snowfall exceeded a given threshold

The last day where snowfall exceeded a given threshold during a time period (the threshold can be given as a snowfall flux or a liquid water equivalent snowfall rate).

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: condition=>=, date=None, which=last, window=1, constrain=None.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘1 mm/d’. [Required units : ([mass]/([area]*[time]))]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Date of last day where snowfall exceeded {thresh}. With additional attributes: description: {freq} last day where snowfall exceeded {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.last_spring_frost(tasmin='tasmin', *, condition='<', thresh='0°C', freq='YS', window=1, ds=None, before_date='07-01', **indexer)

Last spring frost

The last day when minimum temperature is below a given threshold for a certain number of days, limited by a final calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=last, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0°C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • before_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Last day of minimum daily temperature below a threshold of {thresh} for at least {window} days before a given date ({before_date}). With additional attributes: description: Day of year of last spring frost, defined as the last day a minimum temperature remains below a threshold of {thresh} for at least {window} days before a given date ({before_date}).

Return type:

xarray.DataArray

xclim.indicators.atmos.late_frost_days(tasmin='tasmin', *, thresh='0 °C', freq='YS', ds=None, **indexer)

Late frost days

Number of days where the daily minimum temperature is below a given threshold between a givenstart date and a given end date.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days where the daily minimum temperature is below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the daily minimum temperature is below {thresh}over the period {indexer}.

Return type:

xarray.DataArray

xclim.indicators.atmos.latitude_temperature_index(tas='tas', lat='lat', *, freq='YS', ds=None)

Latitude temperature index

A climate indice based on mean temperature of the warmest month and a latitude-based coefficient to account for longer day-length favouring growing conditions. Developed specifically for viticulture. Mean temperature of warmest month multiplied by the difference of latitude factor coefficient minus latitude. Metric originally published in Jackson, D. I., & Cherry, N. J. (1988).

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function latitude_temperature_index(). With injected parameters: lat_factor=60.

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • lat (str or DataArray) – Latitude coordinate. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: ‘lat’. [Required units : []]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [unitless] – Mean temperature of warmest month multiplied by the difference of {lat_factor} minus latitude. With additional attributes: description: A climate indice based on mean temperature of the warmest month and a latitude-based coefficient to account for longer day-length favouring growing conditions. Developed specifically for viticulture. Mean temperature of warmest month multiplied by the difference of {lat_factor} minus latitude.

Return type:

xarray.DataArray

Notes

The latitude factor of 75 is provided for examining the poleward expansion of wine-growing climates under scenarios of climate change [Kenny and Shao, 1992]. For comparing 20th century/observed historical records, the original scale factor of 60 is more appropriate [Jackson and Cherry, 1988].

Let \(Tn_{j}\) be the average temperature for a given month \(j\), \(lat_{f}\) be the latitude factor, and \(lat\) be the latitude of the area of interest. Then the Latitude-Temperature Index (\(LTI\)) is:

\[LTI = max(TN_{j}: j = 1..12)(lat_f - | lat | )\]

References

Jackson and Cherry [1988], Kenny and Shao [1992]

xclim.indicators.atmos.liquid_precip_accumulation(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Total accumulated liquid precipitation.

Total accumulated liquid precipitation. Precipitation is considered liquid when the average daily temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_accumulation(). With injected parameters: phase=liquid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_liquid_precipitation_amount, Total accumulated precipitation when temperature is above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} total {phase} precipitation, estimated as precipitation when temperature is above {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} = \sum_{i=a}^{b} PR_i\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos.liquid_precip_average(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Averaged liquid precipitation.

Averaged liquid precipitation. Precipitation is considered liquid when the average daily temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_average(). With injected parameters: phase=liquid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_average_of_liquid_precipitation_amount, Averaged precipitation when temperature is above {thresh}. With additional attributes: cell_methods: time: mean over days, description: {freq} mean {phase} precipitation, estimated as precipitation when temperature is above {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} =\frac{ \sum_{i=a}^{b} PR_i }{b - a + 1}\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos.liquid_precip_ratio(pr='pr', tas='tas', prra=None, *, thresh='0 degC', freq='QS-DEC', ds=None, **indexer)

Fraction of liquid to total precipitation

The ratio of total liquid precipitation over the total precipitation. Liquid precipitation is approximated from total precipitation on days where temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function liquid_precip_ratio(). With injected parameters: prsn=None.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • prra (str or DataArray, optional) – Mean daily liquid precipitation flux. Default: None.

  • thresh (quantity (string or DataArray, with units)) – Threshold temperature under which precipitation is assumed to be solid. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘QS-DEC’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Fraction of liquid to total precipitation (temperature above {thresh}). With additional attributes: description: The {freq} ratio of rainfall to total precipitation. Rainfall is estimated as precipitation on days where temperature is above {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation on day \(i\), and \(PRSN_i\) the mean daily solid precipitation. For a period \(j\) starting on day \(a\) and ending on day \(b\):

\[PR_{j} = \sum_{i=a}^{b} PR_i\]
\[PR^{\mathrm{liquid}}_{j} = \sum_{i=a}^{b} (PR_i - PRSN_i)\]

The liquid precipitation ratio is then:

\[R_j = \frac{PR^{\mathrm{liquid}}_{j}}{PR_j}\]
xclim.indicators.atmos.max_1day_precipitation_amount(pr='pr', *, freq='YS', ds=None, **indexer)

Maximum 1-day total precipitation

Maximum total daily precipitation for a given period.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm/day] – lwe_thickness_of_precipitation_amount, Maximum 1-day total precipitation. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum 1-day total precipitation

Return type:

xarray.DataArray

xclim.indicators.atmos.max_daily_temperature_range(tasmin='tasmin', tasmax='tasmax', *, statistic='max', freq='YS', ds=None, **indexer)

Maximum of daily temperature range

The maximum difference between the daily maximum and minimum temperatures.

This indicator will check for missing values according to the method “from_context”. Based on function difference_statistics(). With injected parameters: absolute=False.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • statistic ({‘min’, ‘sum’, ‘max’, ‘mean’}) – The statistic to compute over the difference between the two variables. Default: ‘max’.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum diurnal temperature range. With additional attributes: cell_methods: time range within days time: max over days, description: {freq} maximum diurnal temperature range.

Return type:

xarray.DataArray

xclim.indicators.atmos.max_n_day_precipitation_amount(pr='pr', *, window, freq='YS', ds=None, **indexer)

maximum n-day total precipitation

Maximum of the moving sum of daily precipitation for a given period.

This indicator will check for missing values according to the method “from_context”. Based on function running_statistics(). With injected parameters: window_statistic=integral, statistic=max, window_center=True, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Size of the rolling window. Required.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Resampling is done after the running statistic. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Time selection is done after applying the running statistic.

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_precipitation_amount, maximum {window}-day total precipitation amount. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum {window}-day total precipitation amount.

Return type:

xarray.DataArray

xclim.indicators.atmos.max_pr_intensity(pr='pr', *, window=1, freq='YS', ds=None, **indexer)

Maximum precipitation intensity over time window

Maximum precipitation intensity over a given rolling time window.

This indicator will check for missing values according to the method “from_context”. Based on function running_statistics(). With injected parameters: window_statistic=mean, statistic=max, window_center=False, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Size of the rolling window. Default: 1.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Resampling is done after the running statistic. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Time selection is done after applying the running statistic.

Returns:

xarray.DataArray, [mm h-1] – precipitation, Maximum precipitation intensity over rolling {window}h time window. With additional attributes: cell_methods: time: max, description: {freq} maximum precipitation intensity over rolling {window}h time window.

Return type:

xarray.DataArray

xclim.indicators.atmos.maximum_consecutive_dry_days(pr='pr', *, condition='<', thresh='1 mm/day', freq='YS', min_gap=1, resample_before_rl=True, ds=None, **indexer)

Maximum consecutive dry days

The longest number of consecutive days where daily precipitation below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=max, statistic=max, constrain=(‘<’, ‘<=’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_below_threshold, Maximum consecutive days with daily precipitation {condition} {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} maximum number of consecutive days with daily precipitation {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.maximum_consecutive_frost_free_days(tasmin='tasmin', *, condition='>', thresh='0 degC', freq='YS', resample_before_rl=True, ds=None, **indexer)

Maximum consecutive frost free days

Maximum number of consecutive frost-free days: where the daily minimum temperature is above or equal to given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=min, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Maximum number of consecutive days with minimum temperature {condition} {thresh}. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum number of consecutive days with minimum daily temperature {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.maximum_consecutive_warm_days(tasmax='tasmax', *, thresh='25 °C', freq='YS', op='>', resample_before_rl=True, ds=None)

Maximum consecutive warm days

Maximum number of consecutive days where the maximum daily temperature exceeds a certain threshold.

This indicator will check for missing values according to the method “from_context”. Based on function hot_spell_max_length(). With injected parameters: window=1.

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a hot spell. Default: ‘25 °C’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • op ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Maximum number of consecutive days with #maximum daily temperature {op} {thresh}. With additional attributes: cell_methods: time: maximum over days, description: {freq} longest spell of consecutive days with maximum daily temperature {op} {thresh}.

Return type:

xarray.DataArray

Notes

The threshold on tasmax follows the one used in heat waves. A day temperature threshold between 30° and 35°C was selected by Health Canada professionals, following a temperature–mortality analysis. This absolute temperature threshold characterizes the occurrence of hot weather events that can result in adverse health outcomes for Canadian communities [Casati et al., 2013].

In Robinson [2001] where heat waves are also considered, the corresponding parameters would be thresh=39.44, window=2 (103F).

References

Casati, Yagouti, and Chaumont [2013], Robinson [2001]

xclim.indicators.atmos.maximum_consecutive_wet_days(pr='pr', *, condition='>=', thresh='1 mm/day', freq='YS', min_gap=1, resample_before_rl=True, ds=None, **indexer)

Maximum consecutive wet days

The longest number of consecutive days where daily precipitation is at or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=max, statistic=max, constrain=(‘>=’, ‘>’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Maximum consecutive days with daily precipitation {condition} {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} maximum number of consecutive days with daily precipitation {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.mcarthur_forest_fire_danger_index(drought_factor='drought_factor', tasmax='tasmax', hurs='hurs', sfcWind='sfcWind', *, ds=None)

McArthur forest fire danger index (FFDI) Mark 5.

The FFDI is a numeric indicator of the potential danger of a forest fire.

Based on function mcarthur_forest_fire_danger_index().

Parameters:
  • drought_factor (str or DataArray) – The drought factor, often the daily Griffiths drought factor (see griffiths_drought_factor()). Default: ‘drought_factor’. [Required units : []]

  • tasmax (str or DataArray) – The daily maximum temperature near the surface, or similar. Different applications have used different inputs here, including the previous/current day’s maximum daily temperature at a height of 2m, and the daily mean temperature at a height of 2m. Default: ‘tasmax’. [Required units : [temperature]]

  • hurs (str or DataArray) – The relative humidity near the surface and near the time of the maximum daily temperature, or similar. Different applications have used different inputs here, including the mid-afternoon relative humidity at a height of 2m, and the daily mean relative humidity at a height of 2m. Default: ‘hurs’. [Required units : []]

  • sfcWind (str or DataArray) – The wind speed near the surface and near the time of the maximum daily temperature, or similar. Different applications have used different inputs here, including the mid-afternoon wind speed at a height of 10m, and the daily mean wind speed at a height of 10m. Default: ‘sfcWind’. [Required units : [speed]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray – mcarthur_forest_fire_danger_index, McArthur Forest Fire Danger Index. With additional attributes: description: Numeric rating of the potential danger of a forest fire

Return type:

xarray.DataArray

References

Dowdy [2018], Holgate, Van DIjk, Cary, and Yebra [2017], Noble, Gill, and Bary [1980]

xclim.indicators.atmos.precip_accumulation(pr='pr', *, freq='YS', ds=None)

Total accumulated precipitation (solid and liquid)

Total accumulated precipitation.

This indicator will check for missing values according to the method “from_context”. Based on function precip_accumulation(). With injected parameters: tas=None, phase=None, thresh=None.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_precipitation_amount, Total accumulated precipitation. With additional attributes: cell_methods: time: sum over days, description: {freq} total precipitation.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} = \sum_{i=a}^{b} PR_i\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos.precip_average(pr='pr', *, thresh='0 degC', freq='YS', ds=None)

Averaged precipitation (solid and liquid)

Averaged precipitation.

This indicator will check for missing values according to the method “from_context”. Based on function precip_average(). With injected parameters: tas=None, phase=None.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – lwe_average_of_precipitation_amount, Averaged precipitation. With additional attributes: cell_methods: time: mean over days, description: {freq} mean precipitation.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} =\frac{ \sum_{i=a}^{b} PR_i }{b - a + 1}\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos.precipitation_concentration_index(pr='pr', *, freq='YS', subfreq='MS', ds=None)

Precipitation Concentration Index.

A measure of the unevenness of precipitation distribution within a period. Computed as the ratio of the sum of squared sub-period totals to the square of the sum of sub-period totals, multiplied by 100 [Oliver, 1980].

This indicator will check for missing values according to the method “from_context”. Based on function precipitation_concentration_index().

Parameters:
  • pr (str or DataArray) – Precipitation flux or rate, with units convertible to a precipitation unit (e.g. "mm/day"). Default: ‘pr’.

  • freq (offset alias (string)) – Resampling frequency for the output (main period). Default is "YS" (yearly). Default: ‘YS’.

  • subfreq (str) – Resampling frequency for computing sub-period totals. Default is "MS" (monthly). Default: ‘MS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [%] – Precipitation Concentration Index. With additional attributes: description: A measure of the unevenness of the {freq} distribution of precipitations. Computed as the ratio of the sum of squared {subfreq} totals to the square of the sum of {subfreq} totals, multiplied by 100

Return type:

xarray.DataArray

Notes

The precipitation concentration index (PCI) can be calculated as follows:

\[PCI = \frac{\sum_{i=1}^{n} p_i^2}{\left(\sum_{i=1}^{n} p_i\right)^2} \times 100\]

where \(p_i\) is the precipitation total for sub-period \(i\) and \(n\) is the number of sub-periods per main period.

A PCI of 8.3 (i.e. \(100/n\)) indicates perfectly uniform precipitation. Higher values indicate increasing concentration. Values above ~20 indicate a highly irregular or seasonal distribution.

References

Oliver [1980]

xclim.indicators.atmos.rain_on_frozen_ground_days(pr='pr', tas='tas', *, thresh='1 mm/d', window=7, freq='YS', ds=None, **indexer)

Number of rain on frozen ground days

The number of days with rain above a given threshold after a series of seven days with average daily temperature below 0°C. Precipitation is assumed to be rain when the daily average temperature is above 0°C.

This indicator will check for missing values according to the method “from_context”. Based on function rain_on_frozen_ground_days().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation threshold to consider a day as a rain event. Default: ‘1 mm/d’. [Required units : [precipitation]]

  • window (number) – Minimum number of days below freezing temperature needed to consider the ground frozen. Default: 7.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Number of rain on frozen ground days (mean daily temperature > 0℃ and precipitation > {thresh}). With additional attributes: description: {freq} number of days with rain above {thresh} after a series of seven days with average daily temperature below 0℃. Precipitation is assumed to be rain when the daily average temperature is above 0℃.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation and \(TG_i\) be the mean daily temperature of day \(i\). Then for a period \(j\), rain on frozen grounds days are counted where:

\[PR_{i} > Threshold [mm]\]

and where

\[TG_{i} ≤ 0℃\]

is true for continuous periods where \(i ≥ window\)

xclim.indicators.atmos.rain_season(pr='pr', *, thresh_wet_start='25.0 mm', window_wet_start=3, window_not_dry_start=30, thresh_dry_start='1.0 mm', window_dry_start=7, method_dry_start='per_day', date_min_start='05-01', date_max_start='12-31', thresh_dry_end='0.0 mm', window_dry_end=20, method_dry_end='per_day', date_min_end='09-01', date_max_end='12-31', freq='YS-JAN', ds=None)

Rain season

Start time, end time and length of the rain season, notably useful for West Africa (sivakumar, 1998). The rain season starts with a period of abundant rainfall, followed by a period without prolonged dry sequences, which must happen before a given date. The rain season stops during a dry period happening after a given date.

This indicator will check for missing values according to the method “from_context”. Based on function rain_season().

Parameters:
  • pr (str or DataArray) – Precipitation data. Default: ‘pr’. [Required units : [precipitation]]

  • thresh_wet_start (quantity (string or DataArray, with units)) – Accumulated precipitation threshold associated with window_wet_start. Default: ‘25.0 mm’. [Required units : [length]]

  • window_wet_start (number) – Number of days when accumulated precipitation is above thresh_wet_start. Defines the first condition to start the rain season. Default: 3.

  • window_not_dry_start (number) – Number of days, after window_wet_start days, during which no dry period must be found as a second and last condition to start the rain season. A dry sequence is defined with thresh_dry_start, window_dry_start and method_dry_start. Default: 30.

  • thresh_dry_start (quantity (string or DataArray, with units)) – Threshold length defining a dry day in the sequence related to window_dry_start. Default: ‘1.0 mm’. [Required units : [length]]

  • window_dry_start (number) – Number of days used to define a dry sequence in the start of the season. Daily precipitations lower than thresh_dry_start during window_dry_start days are considered a dry sequence. The precipitations must be lower than thresh_dry_start for either every day in the sequence (method_dry_start == “per_day”) or for the total (method_dry_start == “total”). Default: 7.

  • method_dry_start ({‘per_day’, ‘total’}) – Method used to define a dry sequence associated with window_dry_start. The threshold thresh_dry_start is either compared to every daily precipitation (method_dry_start == “per_day”) or to total precipitations (method_dry_start == “total”) in the sequence window_dry_start days. Default: ‘per_day’.

  • date_min_start (date (string, MM-DD)) – First day of year when season can start (“mm-dd”). Default: ‘05-01’.

  • date_max_start (date (string, MM-DD)) – Last day of year when season can start (“mm-dd”). Default: ‘12-31’.

  • thresh_dry_end (quantity (string or DataArray, with units)) – Threshold length defining a dry day in the sequence related to window_dry_end. Default: ‘0.0 mm’. [Required units : [length]]

  • window_dry_end (number) – Number of days used to define a dry sequence in the end of the season. Daily precipitations lower than thresh_dry_end during window_dry_end days are considered a dry sequence. The precipitations must be lower than thresh_dry_end for either every day in the sequence (method_dry_end == “per_day”) or for the total (method_dry_end == “total”). Default: 20.

  • method_dry_end ({‘per_day’, ‘total’}) – Method used to define a dry sequence associated with window_dry_end. The threshold thresh_dry_end is either compared to every daily precipitation (method_dry_end == “per_day”) or to total precipitations (method_dry_end == “total”) in the sequence window_dry days. Default: ‘per_day’.

  • date_min_end (date (string, MM-DD)) – First day of year when season can end (“mm-dd”). Default: ‘09-01’.

  • date_max_end (date (string, MM-DD)) – Last day of year when season can end (“mm-dd”). Default: ‘12-31’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JAN’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

  • rain_season_start (xarray.DataArray, [dimensionless]) – Start of the rain season. With additional attributes: description: First step of a run where i) a sequence of {window_wet_start} days accumulated {thresh_wet_start} of precipitations ii) followed by a sequence of {window_not_dry_start} days with no dry sequence, i.e. a sequence of {window_dry_start} days with at least {thresh_dry_start} {method_dry_start}. The start of the season is on the last day of the first sequence i) and must be between {date_min_start} and {date_max_start}.

  • rain_season_end (xarray.DataArray, [dimensionless]) – End of the rain season. With additional attributes: description: Last day in a dry sequence after the start of the season, i.e. a sequence of {window_dry_end} days with at least {thresh_dry_end} {method_dry_end}. It must be between {date_min_end} and {date_max_end}.

  • rain_season_length (xarray.DataArray, [days]) – Length of the rain season. With additional attributes: description: Number of steps of the original series in the season, between 'start' and 'end'.

Return type:

tuple[xarray.DataArray, xarray.DataArray, xarray.DataArray]

Notes

The rain season starts at the end of a period of raining (a total precipitation of thresh_wet_start over window_wet_start days). This must be directly followed by a period of window_not_dry_start days with no dry sequence. The dry sequence is a period of window_dry_start days where precipitations are below thresh_dry_start (either the total precipitations over the period, or the daily precipitations, depending on method_dry_start). The rain season stops when a dry sequence happens (the dry sequence is defined as in the start sequence, but with parameters window_dry_end, thresh_dry_end and method_dry_end). The dates on which the season can start are constrained by date_min_start`and `date_max_start (and similarly for the end of the season).

References

Sivakumar [1988]

xclim.indicators.atmos.rprctot(pr='pr', prc='prc', *, thresh='1.0 mm/day', freq='YS', op='>=', ds=None, **indexer)

Proportion of accumulated precipitation arising from convective processes

The proportion of total precipitation due to convective processes. Only days with surpassing a minimum precipitation flux are considered.

This indicator will check for missing values according to the method “from_context”. Based on function rprctot().

Parameters:
  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • prc (str or DataArray) – Daily convective precipitation. Default: ‘prc’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1.0 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • op ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>=”. Default: ‘>=’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Proportion of accumulated precipitation arising from convective processeswith precipitation of at least {thresh}. With additional attributes: cell_methods: time: sum, description: {freq} proportion of accumulated precipitation arising from convective processes with precipitation of at least {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.sfcWind_max(sfcWind='sfcWind', *, freq='YS', ds=None, **indexer)

Maximum near-surface mean wind speed

Maximum of daily mean near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Maximum daily mean wind speed. With additional attributes: cell_methods: time: max over days, description: {freq} maximum of daily mean wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos.sfcWind_mean(sfcWind='sfcWind', *, freq='YS', ds=None, **indexer)

Mean near-surface wind speed

Mean of daily near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Mean daily mean wind speed. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily mean wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos.sfcWind_min(sfcWind='sfcWind', *, freq='YS', ds=None, **indexer)

Minimum near-surface mean wind speed

Minimum of daily mean near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Minimum daily mean wind speed. With additional attributes: cell_methods: time: min over days, description: {freq} minimum of daily mean wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos.sfcWindmax_max(sfcWindmax='sfcWindmax', *, freq='YS', ds=None, **indexer)

Maximum near-surface maximum wind speed

Maximum of daily maximum near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • sfcWindmax (str or DataArray) – Surface maximum wind speed. Default: ‘sfcWindmax’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Maximum daily maximum wind speed. With additional attributes: cell_methods: time: max over days, description: {freq} maximum of daily maximum wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos.sfcWindmax_mean(sfcWindmax='sfcWindmax', *, freq='YS', ds=None, **indexer)

Mean near-surface maximum wind speed

Mean of daily maximum near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • sfcWindmax (str or DataArray) – Surface maximum wind speed. Default: ‘sfcWindmax’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Mean daily maximum wind speed. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily maximum wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos.sfcWindmax_min(sfcWindmax='sfcWindmax', *, freq='YS', ds=None, **indexer)

Minimum near-surface maximum wind speed

Minimum of daily maximum near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • sfcWindmax (str or DataArray) – Surface maximum wind speed. Default: ‘sfcWindmax’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Minimum daily maximum wind speed. With additional attributes: cell_methods: time: min over days, description: {freq} minimum of daily maximum wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos.snowfall_frequency(prsn='prsn', *, thresh='1 mm/day', freq='YS-JUL', ds=None, **indexer)

Snowfall frequency

Percentage of days with snowfall above a given threshold (either a snowfall flux or a liquid water equivalent snowfall rate).

This indicator will check for missing values according to the method “from_context”. Based on function snowfall_frequency().

Parameters:
  • prsn (str or DataArray) – Snowfall flux. Default: ‘prsn’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Threshold snowfall flux or liquid water equivalent snowfall rate (default: 1 mm/day). Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [%] – Percentage of days with snowfall above {thresh} threshold. With additional attributes: description: {freq} percentage of days with snowfall larger than {thresh}.

Return type:

xarray.DataArray

Notes

The 1 mm/day liquid water equivalent snowfall rate threshold in Frei, Kotlarski, Liniger, and Schär [2018] corresponds to the 1 cm/day snowfall rate threshold in CBCL [2020] using a snow density of 100 kg/m**3.

If the threshold and prsn differ by a density (i.e. [length/time] vs. [mass/area/time]), a liquid water equivalent snowfall rate is assumed, and the threshold is converted using a 1000 kg m-3 density.

References

Frei, Kotlarski, Liniger, and Schär [2018].

xclim.indicators.atmos.snowfall_intensity(prsn='prsn', *, thresh='1 mm/d', freq='YS-JUL', ds=None, **indexer)

Snowfall intensity

Mean daily liquid water equivalent snowfall rate above threshold (either a snowfall flux or a liquid water equivalent snowfall rate)

This indicator will check for missing values according to the method “from_context”. Based on function thresholded_statistics(). With injected parameters: condition=>=, statistic=mean, constrain=None, out_units=None.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • thresh (quantity (string or DataArray, with units)) – Threshold, should have the same dimensionality as data. Default: ‘1 mm/d’. [Required units : ([mass]/([area]*[time]))]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm/day] – Mean daily snowfall above {thresh} threshold. With additional attributes: description: {freq} mean daily snowfall larger than {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.solid_precip_accumulation(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Total accumulated solid precipitation.

Total accumulated solid precipitation. Precipitation is considered solid when the average daily temperature is at or below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_accumulation(). With injected parameters: phase=solid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_snowfall_amount, Total accumulated solid precipitation. With additional attributes: cell_methods: time: sum over days, description: {freq} total solid precipitation, estimated as precipitation when temperature at or below {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} = \sum_{i=a}^{b} PR_i\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos.solid_precip_average(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Averaged solid precipitation.

Averaged solid precipitation. Precipitation is considered solid when the average daily temperature is at or below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_average(). With injected parameters: phase=solid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_average_of_snowfall_amount, Averaged solid precipitation. With additional attributes: cell_methods: time: mean over days, description: {freq} mean solid precipitation, estimated as precipitation when temperature at or below {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} =\frac{ \sum_{i=a}^{b} PR_i }{b - a + 1}\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos.standardized_precipitation_evapotranspiration_index(wb='wb', *, freq='MS', window=1, dist='gamma', method='ML', fitkwargs=None, cal_start=None, cal_end=None, params=None, ds=None, **indexer)

Standardized Precipitation Evapotranspiration Index (SPEI)

Water budget (precipitation - evapotranspiration) over a moving window, normalized such that the SPEI averages to 0 for the calibration data. The window unit X is the minimal time period defined by the resampling frequency.

This indicator will check for missing values according to the method “from_context”. Based on function standardized_precipitation_evapotranspiration_index().

Parameters:
  • wb (str or DataArray) – Daily water budget (pr - pet). Default: ‘wb’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. A monthly or daily frequency is expected. Option None assumes that the desired resampling has already been applied input dataset and will skip the resampling step. Default: ‘MS’.

  • window (number) – Averaging window length relative to the resampling frequency. For example, if freq=”MS”, i.e. a monthly resampling, the window is an integer number of months. Default: 1.

  • dist ({‘fisk’, ‘gamma’, ‘genextreme’, ‘lognorm’}) – Name of the univariate distribution, or a callable rv_continuous (see scipy.stats). Default: ‘gamma’.

  • method ({‘ML’, ‘PWM’, ‘APP’}) – Name of the fitting method, such as ML (maximum likelihood), APP (approximate). The approximate method uses a deterministic function that does not involve any optimization, which can be sensitive to noise. PWM should be used with a lmoments3 distribution. Default: ‘ML’.

  • fitkwargs (dict) – Kwargs passed to xclim.compute.stats.fit used to impose values of certains parameters (floc, fscale). If method is PWM, fitkwargs should be empty, except for floc with dist`=`gamma which is allowed. Default: None.

  • cal_start (date (string, YYYY-MM-DD)) – Start date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period begins at the start of the input dataset. Default: None.

  • cal_end (date (string, YYYY-MM-DD)) – End date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period finishes at the end of the input dataset. Default: None.

  • params (quantity (string or DataArray, with units)) – Fit parameters. The params can be computed using xclim.compute.stats.standardized_index_fit_params in advance. The output can be given here as input, and it overrides other options. Default: None. [Required units : []]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.compute.generic.select_time().

Returns:

xarray.DataArray – spei, Standardized precipitation evapotranspiration index (SPEI). With additional attributes: description: Water budget (precipitation minus evapotranspiration) over a moving {window}-X window, normalized such that SPEI averages to 0 for calibration data. The window unit `X` is the minimal time period defined by the resampling frequency {freq}.

Return type:

xarray.DataArray

xclim.indicators.atmos.standardized_precipitation_index(pr='pr', *, freq='MS', window=1, dist='gamma', method='ML', fitkwargs=None, cal_start=None, cal_end=None, params=None, prob_zero_interpolation='upper', plotting_position_zero='ecdf', ds=None, **indexer)

Standardized Precipitation Index (SPI)

Precipitation over a moving window, normalized such that SPI averages to 0 for the calibration data. The window unit X is the minimal time period defined by the resampling frequency.

This indicator will check for missing values according to the method “from_context”. Based on function standardized_precipitation_index().

Parameters:
  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. A monthly or daily frequency is expected. Option None assumes that the desired resampling has already been applied input dataset and will skip the resampling step. Default: ‘MS’.

  • window (number) – Averaging window length relative to the resampling frequency. For example, if freq=”MS”, i.e. a monthly resampling, the window is an integer number of months. Default: 1.

  • dist ({‘fisk’, ‘gamma’, ‘genextreme’, ‘lognorm’}) – Name of the univariate distribution, or a callable rv_continuous (see scipy.stats). Default: ‘gamma’.

  • method ({‘ML’, ‘PWM’, ‘APP’}) – Name of the fitting method, such as ML (maximum likelihood), APP (approximate). The approximate method uses a deterministic function that does not involve any optimization, which can be sensitive to noise. PWM should be used with a lmoments3 distribution. Default: ‘ML’.

  • fitkwargs (dict) – Kwargs passed to xclim.compute.stats.fit used to impose values of certains parameters (floc, fscale). If method is PWM, fitkwargs should be empty, except for floc with dist`=`gamma which is allowed. Default: None.

  • cal_start (date (string, YYYY-MM-DD)) – Start date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period begins at the start of the input dataset. Default: None.

  • cal_end (date (string, YYYY-MM-DD)) – End date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period finishes at the end of the input dataset. Default: None.

  • params (quantity (string or DataArray, with units)) – Fit parameters. The params can be computed using xclim.compute.stats.standardized_index_fit_params in advance. The output can be given here as input, and it overrides other options. Default: None. [Required units : []]

  • prob_zero_interpolation ({‘upper’, ‘center’}) – Interpolation method used to assign a probability to zero values (only used if zero_inflated is True). When the data contain multiple zeros, the admissible plotting position interval spans from the first zero rank to the last zero rank. This parameter selects a representative probability within that interval. The default method “upper” assigns the upper bound of the zero-rank interval. The “center” method assigns the midpoint of the zero-rank interval. If a float in [0, 1] is provided, it is used as a linear interpolation factor between the lower (0) and upper (1) zero-rank plotting positions. Default: ‘upper’.

  • plotting_position_zero ({‘ecdf’, ‘weibull’}) – Method used to assign a probability to a rank for the zeros (only used if zero_inflated is True). “ecdf” (default option) is the empirical cumulative distribution and divides the number or zeros by the total number of observations. “weibull” implements the unbiased version, dividing by the total number of observation plus one. A tuple consisting of two coefficients in [0,1] to relate the number of zeros and the total number of observations. “ecdf” corresponds to (0,1) and “weibull” to (0,0). See scipy.stats.mstats.plotting_positions() Default: ‘ecdf’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.compute.generic.select_time().

Returns:

xarray.DataArray, [unitless] – spi, Standardized Precipitation Index (SPI). With additional attributes: description: Precipitations over a moving {window}-X window, normalized such that SPI averages to 0 for calibration data. The window unit `X` is the minimal time period defined by resampling frequency {freq}.

Return type:

xarray.DataArray

Notes

  • N-month SPI / N-day SPI is determined by choosing the window = N and the appropriate frequency freq.

  • Supported statistical distributions are: [“gamma”, “fisk”], where “fisk” is scipy’s implementation of a log-logistic distribution

  • Supported frequencies are daily (“D”), weekly (“W”), and monthly (“MS”).

  • Weekly frequency will only work if the input array has a “standard” (non-cftime) calendar.

  • If params is given as input, it overrides the cal_start, cal_end, freq and window, dist and method options.

  • “APP” method only supports two-parameter distributions. Parameter loc needs to be fixed to use method APP.

  • The results from climate_indices library can be reproduced with method = “APP” and fitwkargs = {“floc”: 0}, except for the maximum and minimum values allowed which are greater in xclim ±8.21, . See xclim.compute.stats.standardized_index

References

McKee, Doesken, and Kleist [1993], Stagge, Tallaksen, Gudmundsson, Van Loon, and Stahl [2015]

xclim.indicators.atmos.tg10p(tas='tas', tas_per='tas_per', *, freq='YS', bootstrap=False, condition='<', ds=None, **indexer)

Days with mean temperature below the 10th percentile

Number of days with mean temperature below the 10th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tg10p().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • tas_per (str or DataArray) – 10th percentile of daily mean temperature. Default: ‘tas_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with mean temperature below the 10th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with mean temperature below the 10th percentile. A {tas_per_window} day(s) window, centered on each calendar day in the {tas_per_period} period, is used to compute the 10th percentile.

Return type:

xarray.DataArray

Notes

The 10th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos.tg90p(tas='tas', tas_per='tas_per', *, freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Days with mean temperature above the 90th percentile

Number of days with mean temperature above the 90th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tg90p().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • tas_per (str or DataArray) – 90th percentile of daily mean temperature. Default: ‘tas_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days with mean temperature above the 90th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with mean temperature above the 90th percentile. A {tas_per_window} day(s) window, centered on each calendar day in the {tas_per_period} period, is used to compute the 90th percentile.

Return type:

xarray.DataArray

Notes

The 90th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos.tg_days_above(tas='tas', *, condition='>', thresh='10 °C', freq='YS', ds=None, **indexer)

Number of days with mean temperature above a given threshold

The number of days with mean temperature above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, The number of days with mean temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily mean temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.tg_days_below(tas='tas', *, condition='<', thresh='10 °C', freq='YS', ds=None, **indexer)

Number of days with mean temperature below a given threshold

The number of days with mean temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_below_threshold, The number of days with mean temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily mean temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.tg_max(tas='tas', *, freq='YS', ds=None, **indexer)

Maximum of mean temperature

Maximum of daily mean temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum daily mean temperature. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum of daily mean temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tg_mean(tas='tas', *, freq='YS', ds=None, **indexer)

Mean temperature

Mean of daily mean temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean daily mean temperature. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily mean temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tg_min(tas='tas', *, freq='YS', ds=None, **indexer)

Minimum of mean temperature

Minimum of daily mean temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Minimum daily mean temperature. With additional attributes: cell_methods: time: minimum over days, description: {freq} minimum of daily mean temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.thawing_degree_days(tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Thawing degree days

The cumulative degree days for days when the average temperature is above a given threshold, typically 0°C.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=>.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for mean daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} thawing degree days (mean temperature above {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos.tn10p(tasmin='tasmin', tasmin_per='tasmin_per', *, freq='YS', bootstrap=False, condition='<', ds=None, **indexer)

Days with minimum temperature below the 10th percentile

Number of days with minimum temperature below the 10th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tn10p().

Parameters:
  • tasmin (str or DataArray) – Mean daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmin_per (str or DataArray) – 10th percentile of daily minimum temperature. Default: ‘tasmin_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with minimum temperature below the 10th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with minimum temperature below the 10th percentile. A {tasmin_per_window} day(s) window, centered on each calendar day in the {tasmin_per_period} period, is used to compute the 10th percentile.

Return type:

xarray.DataArray

Notes

The 10th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos.tn90p(tasmin='tasmin', tasmin_per='tasmin_per', *, freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Days with minimum temperature above the 90th percentile

Number of days with minimum temperature above the 90th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tn90p().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmin_per (str or DataArray) – 90th percentile of daily minimum temperature. Default: ‘tasmin_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days with minimum temperature above the 90th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with minimum temperature above the 90th percentile. A {tasmin_per_window} day(s) window, centered on each calendar day in the {tasmin_per_period} period, is used to compute the 90th percentile.

Return type:

xarray.DataArray

Notes

The 90th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos.tn_days_above(tasmin='tasmin', *, condition='>', thresh='20 °C', freq='YS', ds=None, **indexer)

Number of days with minimum temperature above a given threshold

The number of days with minimum temperature above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘20 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, The number of days with minimum temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily minimum temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.tn_days_below(tasmin='tasmin', *, condition='<', thresh='-10 °C', freq='YS', ds=None, **indexer)

Number of days with minimum temperature below a given threshold

The number of days with minimum temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_below_threshold, The number of days with minimum temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily minimum temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.tn_max(tasmin='tasmin', *, freq='YS', ds=None, **indexer)

Maximum of minimum temperature

Maximum of daily minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum daily minimum temperature. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum of daily minimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tn_mean(tasmin='tasmin', *, freq='YS', ds=None, **indexer)

Mean of minimum temperature

Mean of daily minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean daily minimum temperature. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily minimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tn_min(tasmin='tasmin', *, freq='YS', ds=None, **indexer)

Minimum temperature

Minimum of daily minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Minimum daily minimum temperature. With additional attributes: cell_methods: time: minimum over days, description: {freq} minimum of daily minimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tropical_nights(tasmin='tasmin', *, condition='>', thresh='20.0 degC', freq='YS', ds=None, **indexer)

Tropical nights

Number of days where minimum temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘20.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, Number of days with minimum daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of Tropical Nights, defined as days with minimum daily temperature above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.tx10p(tasmax='tasmax', tasmax_per='tasmax_per', *, freq='YS', bootstrap=False, condition='<', ds=None, **indexer)

Days with maximum temperature below the 10th percentile

Number of days with maximum temperature below the 10th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tx10p().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmax_per (str or DataArray) – 10th percentile of daily maximum temperature. Default: ‘tasmax_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with maximum temperature below the 10th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with maximum temperature below the 10th percentile. A {tasmax_per_window} day(s) window, centered on each calendar day in the {tasmax_per_period} period, is used to compute the 10th percentile.

Return type:

xarray.DataArray

Notes

The 10th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos.tx90p(tasmax='tasmax', tasmax_per='tasmax_per', *, freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Days with maximum temperature above the 90th percentile

Number of days with maximum temperature above the 90th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tx90p().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmax_per (str or DataArray) – 90th percentile of daily maximum temperature. Default: ‘tasmax_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days with maximum temperature above the 90th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with maximum temperature above the 90th percentile. A {tasmax_per_window} day(s) window, centered on each calendar day in the {tasmax_per_period} period, is used to compute the 90th percentile.

Return type:

xarray.DataArray

Notes

The 90th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos.tx_days_above(tasmax='tasmax', *, condition='>', thresh='25 °C', freq='YS', ds=None, **indexer)

Number of days with maximum temperature above a given threshold

The number of days with maximum temperature above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘25 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, The number of days with maximum temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily maximum temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.tx_days_below(tasmax='tasmax', *, condition='<', thresh='25 °C', freq='YS', ds=None, **indexer)

Number of days with maximum temperature below a given threshold

The number of days with maximum temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘25 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_below_threshold, The number of days with maximum temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily max temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.tx_max(tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Maximum temperature

Maximum of daily maximum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum daily maximum temperature. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum of daily maximum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tx_mean(tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Mean of maximum temperature

Mean of daily maximum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean daily maximum temperature. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily maximum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tx_min(tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Minimum of maximum temperature

Minimum of daily maximum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Minimum daily maximum temperature. With additional attributes: cell_methods: time: minimum over days, description: {freq} minimum of daily maximum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos.tx_tn_days_above(tasmin='tasmin', tasmax='tasmax', *, freq='YS', ds=None, condition='>', thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Number of days with daily minimum and maximum temperatures exceeding thresholds

Number of days with daily maximum and minimum temperatures above given thresholds.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_count_occurrences(). With injected parameters: condition2=None, var_reducer=all, constrain1=(‘>’, ‘>=’), constrain2=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator for data variable 1. Default: ‘>’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for data variable 1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for data variable 2. If None, thresh1 is used. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, Number of days with daily minimum above {thresh_tasmin} and daily maximum temperatures above {thresh_tasmax}. With additional attributes: description: {freq} number of days where daily maximum temperature exceeds {thresh_tasmax} and minimum temperature exceeds {thresh_tasmin}.

Return type:

xarray.DataArray

Notes

Sampling length is derived from data1.

xclim.indicators.atmos.usda_hardiness_zones(tasmin='tasmin', *, window=30, freq='YS', ds=None)

USDA hardiness zones

A climate indice based on a multi-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The USDA classificationscheme divides categories into 10 degree Fahrenheit zones, with 5-degree Fahrenheit half-zones, starting from -65 degrees Fahrenheit and ending at 65 degrees Fahrenheit.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function hardiness_zones(). With injected parameters: method=usda.

Parameters:
  • tasmin (str or DataArray) – Minimum temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • window (number) – The length of the averaging window, in years. Default: 30.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [dimensionless] – Hardiness zones. With additional attributes: description: A climate indice based on a {window}-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The USDA classificationscheme divides categories into 10 degree Fahrenheit zones, with 5-degree Fahrenheit half-zones, starting from -65 degrees Fahrenheit and ending at 65 degrees Fahrenheit.

Return type:

xarray.DataArray

References

Dawson [1991], USDA Agricultural Research Service [2012]

xclim.indicators.atmos.warm_and_dry_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Warm and dry days

Number of days with temperature above a given percentile and precipitation below a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function warm_and_dry_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – Third quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – First quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature is above {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is above {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos.warm_and_wet_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Warm and wet days

Number of days with temperature above a given percentile and precipitation above a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function warm_and_wet_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – Third quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – Third quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature above {tas_per_thresh}th percentile and precipitation above {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is above {tas_per_thresh}th percentile and precipitation is above {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos.warm_spell_duration_index(tasmax='tasmax', tasmax_per='tasmax_per', *, window=6, freq='YS', resample_before_rl=True, bootstrap=False, condition='>', ds=None)

Warm spell duration index

Number of days part of a percentile-defined warm spell. A warm spell occurs when the maximum daily temperature is above a given percentile for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function warm_spell_duration_index().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmax_per (str or DataArray) – Percentile(s) of daily maximum temperature. Default: ‘tasmax_per’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperature above threshold to qualify as a warm spell. Default: 6.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, Number of days with at least {window} consecutive days where the maximum daily temperature is above the {tasmax_per_thresh}th percentile(s). With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with at least {window} consecutive days where the maximum daily temperature is above the {tasmax_per_thresh}th percentile(s). A {tasmax_per_window} day(s) window, centred on each calendar day in the {tasmax_per_period} period, is used to compute the {tasmax_per_thresh}th percentile(s).

Return type:

xarray.DataArray

References

From the Expert Team on Climate Change Detection, Monitoring and Indices (ETCCDMI; [Zhang et al., 2011]). Used in Alexander, Zhang, Peterson, Caesar, Gleason, Klein Tank, Haylock, Collins, Trewin, Rahimzadeh, Tagipour, Rupa Kumar, Revadekar, Griffiths, Vincent, Stephenson, Burn, Aguilar, Brunet, Taylor, New, Zhai, Rusticucci, and Vazquez-Aguirre [2006]

xclim.indicators.atmos.water_cycle_intensity(pr='pr', evspsbl='evspsbl', *, freq='YS', ds=None, **indexer)

Water cycle intensity

The sum of precipitation and actual evapotranspiration.

This indicator will check for missing values according to the method “from_context”. Based on function water_cycle_intensity().

Parameters:
  • pr (str or DataArray) – Precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • evspsbl (str or DataArray) – Actual evapotranspiration flux. Default: ‘evspsbl’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – Water cycle intensity. With additional attributes: cell_methods: time: sum over days, description: The {freq} water cycle intensity, defined as the sum of precipitation and actual evapotranspiration.

Return type:

xarray.DataArray

References

Huntington, Weiskel, Wolock, and McCabe [2018]

xclim.indicators.atmos.wet_precip_accumulation(pr='pr', *, thresh='1 mm/day', freq='YS', ds=None, **indexer)

Total accumulated precipitation (solid and liquid) during wet days

Total accumulated precipitation on days with precipitation. A day is considered to have precipitation if the precipitation is greater than or equal to a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function thresholded_statistics(). With injected parameters: condition=>=, statistic=integral, constrain=None, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Threshold, should have the same dimensionality as data. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_precipitation_amount, Total accumulated precipitation over days where precipitation exceeds {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} total precipitation over wet days, defined as days where precipitation exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.wet_spell_frequency(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Wet spell frequency

The frequency of wet periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is equal or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=>=, statistic=count, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – A threshold amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of wet periods of at least {window} days.. With additional attributes: description: The {freq} number of wet periods of at least {window} days, during which the {window_statistic} precipitation on a window of {window} days is equal or over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.wet_spell_max_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Wet spell maximum length

The maximum length of a wet period of N days or more, during which the accumulated or maximum precipitation over a given time window of days is equal or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=>=, statistic=max, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – A threshold amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a wet period of at least {window} days.. With additional attributes: description: The maximum {freq} number of consecutive days in a wet period of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is equal or over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.wet_spell_total_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Wet spell total length

The total length of wet periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is equal or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=>=, statistic=sum, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – A threshold amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in wet periods of at least {window} days. With additional attributes: description: The {freq} number of days in wet periods of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is equal or over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.wetdays(pr='pr', *, condition='>=', thresh='1 mm/d', freq='YS', ds=None, **indexer)

Number of wet days

The number of days with daily precipitation at or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>=’, ‘>’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘1 mm/d’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Number of days with daily precipitation at or above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with daily precipitation at or above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.wetdays_prop(pr='pr', *, thresh='1.0 mm/day', freq='YS', condition='>=', ds=None, **indexer)

Proportion of wet days

The proportion of days with daily precipitation at or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function wetdays_prop().

Parameters:
  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1.0 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>=”. Default: ‘>=’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [1] – Proportion of days with precipitation at or above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} proportion of days with precipitation at or above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos.windy_days(sfcWind='sfcWind', *, thresh='10.8 m s-1', freq='MS', ds=None, **indexer)

Windy days

Number of days with surface wind speed at or above threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=>=, constrain=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘10.8 m s-1’. [Required units : ([speed])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘MS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_wind_speed_above_threshold, Number of days with surface wind speed at or above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with surface wind speed at or above {thresh}.

Return type:

xarray.DataArray

Submodules

xclim.indicators.atmos._precip module

Precipitation indicator definitions.

xclim.indicators.atmos._precip.antecedent_precipitation_index(pr='pr', *, window=7, p_exp=0.935, ds=None)

Antecedent Precipitation Index.

Calculate the running weighted sum of daily precipitation values given a window and weighting exponent. This index serves as an indicator for soil moisture.

Based on function antecedent_precipitation_index().

Parameters:
  • pr (str or DataArray) – Daily precipitation data. Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Window for the days of precipitation data to be weighted and summed, default is 7. Default: 7.

  • p_exp (number) – Weighting exponent, default is 0.935. Default: 0.935.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – Antecedent Precipitation Index. With additional attributes: cell_methods: time: sum over days, description: Weighted moving sum of daily precipitation totals with a {window}-day window. Weights are an exponential decay of base {p_exp}.

Return type:

xarray.DataArray

References

Li, Wei, and Li [2021], Schröter, Kunz, Elmer, Mühr, and Merz [2015]

xclim.indicators.atmos._precip.aridity_index(pr='pr', evspsblpot='evspsblpot', *, freq='YS', ds=None, **indexer)

Aridity index.

The ratio of total precipitation over potential evapotranspiration. Classification based on the Aridity Index (AI).

This indicator will check for missing values according to the method “from_context”. Based on function aridity_index().

Parameters:
  • pr (str or DataArray) – Precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • evspsblpot (str or DataArray) – Potential evapotranspiration. Default: ‘evspsblpot’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. A monthly or yearly frequency is expected. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray – Aridity Index. With additional attributes: description: The ratio of total precipitation over potential evapotranspiration.Classification based on the Aridity Index (AI).

Return type:

xarray.DataArray

Notes

  • The range in the aridity index define different environment categories (percentage of global land area covered)
    • Hyperarid (7.5%): AI < 0.05

    • Arid (12.1%): 0.05 ≤ AI < 0.20

    • Semi-Arid (17.7%): 0.20 ≤ AI < 0.50

    • Dry subhumid (9.9%): 0.50 ≤ AI < 0.65

    • Humid (52.8%): AI ≥ 0.65

  • In North America, higher aridity index values can be associated with colder climates due to lower evapotranspiration, even when precipitation is limited or occurring as snow.

References

:cite:cts:’zomer_2022’

xclim.indicators.atmos._precip.cffwis_indices(tas='tas', pr='pr', sfcWind='sfcWind', hurs='hurs', lat='lat', snd=None, ffmc0=None, dmc0=None, dc0=None, season_mask=None, *, season_method=None, overwintering=False, dry_start=None, initial_start_up=True, ds=None, **params)

Canadian Fire Weather Index System indices.

Computes the six (6) fire weather indexes, as defined by the Canadian Forest Service: - The Drought Code - The Duff-Moisture Code - The Fine Fuel Moisture Code - The Initial Spread Index - The Build Up Index - The Fire Weather Index.

Based on function cffwis_indices().

Parameters:
  • tas (str or DataArray) – Noon temperature. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Rain fall in open over previous 24 hours, at noon. Default: ‘pr’. [Required units : [precipitation]]

  • sfcWind (str or DataArray) – Noon wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • hurs (str or DataArray) – Noon relative humidity. Default: ‘hurs’. [Required units : []]

  • lat (str or DataArray) – Latitude coordinate. Default: ‘lat’. [Required units : []]

  • snd (str or DataArray, optional) – Noon snow depth, only used if season_method=’LA08’ is passed. Default: None. [Required units : [length]]

  • ffmc0 (str or DataArray, optional) – Initial values of the fine fuel moisture code. Default: None. [Required units : []]

  • dmc0 (str or DataArray, optional) – Initial values of the Duff moisture code. Default: None. [Required units : []]

  • dc0 (str or DataArray, optional) – Initial values of the drought code. Default: None. [Required units : []]

  • season_mask (str or DataArray, optional) – Boolean mask, True where/when the fire season is active. Default: None. [Required units : []]

  • season_method ({None, ‘LA08’, ‘GFWED’, ‘WF93’}) – How to compute the start-up and shutdown of the fire season. If “None”, no start-ups or shutdowns are computed, similar to the R fire function. Ignored if season_mask is given. Default: None.

  • overwintering (boolean) – Whether to activate DC overwintering or not. If True, either season_method or season_mask must be given. Default: False.

  • dry_start ({None, ‘GFWED’, ‘CFS’}) – Whether to activate the DC and DMC “dry start” mechanism or not, see fire_weather_ufunc(). Default: None.

  • initial_start_up (boolean) – If True (default), gridpoints where the fire season is active on the first timestep go through a start_up phase for that time step. Otherwise, previous codes must be given as a continuing fire season is assumed for those points. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • params – Any other keyword parameters as defined in fire_weather_ufunc() and in default_params.

Returns:

  • dc (xarray.DataArray, [dimensionless]) – drought_code, Drought Code. With additional attributes: description: Numeric rating of the average moisture content of deep, compact organic layers.

  • dmc (xarray.DataArray, [dimensionless]) – duff_moisture_code, Duff Moisture Code. With additional attributes: description: Numeric rating of the average moisture content of loosely compacted organic layers of moderate depth.

  • ffmc (xarray.DataArray, [dimensionless]) – fine_fuel_moisture_code, Fine Fuel Moisture Code. With additional attributes: description: Numeric rating of the average moisture content of litter and other cured fine fuels.

  • isi (xarray.DataArray, [dimensionless]) – initial_spread_index, Initial Spread Index. With additional attributes: description: Numeric rating of the expected rate of fire spread.

  • bui (xarray.DataArray, [dimensionless]) – buildup_index, Buildup Index. With additional attributes: description: Numeric rating of the total amount of fuel available for combustion.

  • fwi (xarray.DataArray, [dimensionless]) – fire_weather_index, Fire Weather Index. With additional attributes: description: Numeric rating of fire intensity.

Return type:

tuple[xarray.DataArray, xarray.DataArray, xarray.DataArray, xarray.DataArray, xarray.DataArray, xarray.DataArray]

Notes

See Natural Resources Canada [n.d.], the xclim.compute.fire module documentation, and the docstring of fire_weather_ufunc() for more information. This algorithm follows the official R code released by the CFS, which contains revisions from the original 1982 Fortran code.

References

Wang, Anderson, and Suddaby [2015]

xclim.indicators.atmos._precip.cold_and_dry_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Cold and dry days

Number of days with temperature below a given percentile and precipitation below a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function cold_and_dry_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – First quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – First quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature is below {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is below {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos._precip.cold_and_wet_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Cold and wet days

Number of days with temperature below a given percentile and precipitation above a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function cold_and_wet_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – First quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – Third quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature is below {tas_per_thresh}th percentile and precipitation is above {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is below {tas_per_thresh}th percentile and precipitation is above {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos._precip.daily_pr_intensity(pr='pr', *, condition='>=', thresh='1 mm/day', freq='YS', ds=None, **indexer)

Simple Daily Intensity Index

Average precipitation for days with daily precipitation above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function thresholded_statistics(). With injected parameters: statistic=mean, constrain=(‘>’, ‘>=’), out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold, should have the same dimensionality as data. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm d-1] – lwe_precipitation_rate, Average precipitation during days with daily precipitation over {thresh} (Simple Daily Intensity Index: SDII). With additional attributes: description: {freq} Simple Daily Intensity Index (SDII) or {freq} average precipitation for days with daily precipitation over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.days_over_precip_doy_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Number of days with precipitation above a given daily percentile

Number of days in a period where precipitation is above a given daily percentile and a fixed threshold.

This indicator will check for missing values according to the method “from_context”. Based on function days_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_daily_threshold, Number of days with daily precipitation flux above the {pr_per_thresh}th percentile of {pr_per_period}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with precipitation above the {pr_per_thresh}th daily percentile. Only days with at least {thresh} are counted. A {pr_per_window} day(s) window, centered on each calendar day in the {pr_per_period} period, is used to compute the {pr_per_thresh}th percentile(s).

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.days_over_precip_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Number of days with precipitation above a given percentile

Number of days in a period where precipitation is above a given percentile, calculated over a given period and a fixed threshold.

This indicator will check for missing values according to the method “from_context”. Based on function days_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Number of days with precipitation flux above the {pr_per_thresh}th percentile of {pr_per_period}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with precipitation above the {pr_per_thresh}th percentile of {pr_per_period} period. Only days with at least {thresh} are counted.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.days_with_snow(prsn='prsn', *, freq='YS-JUL', ds=None, low='0 kg m-2 s-1', high='1E6 kg m-2 s-1', **indexer)

Days with snowfall

Number of days with snow between a lower and upper limit.

This indicator will check for missing values according to the method “from_context”. Based on function count_domain_occurrences(). With injected parameters: low_condition=>, high_condition=<=.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • freq (offset alias (string)) – Resampling frequency defining the periods defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • low (quantity (string or DataArray, with units)) – Minimum value. Default: ‘0 kg m-2 s-1’. [Required units : ([mass]/([area]*[time]))]

  • high (quantity (string or DataArray, with units)) – Maximum value. Default: ‘1E6 kg m-2 s-1’. [Required units : ([mass]/([area]*[time]))]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days with snowfall between {low} and {high} thresholds. With additional attributes: description: {freq} number of days with snowfall larger than {low} and smaller or equal to {high}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.drought_code(tas='tas', pr='pr', lat='lat', snd=None, dc0=None, season_mask=None, *, season_method=None, overwintering=False, dry_start=None, initial_start_up=True, ds=None, **params)

Daily drought code

The Drought Index is part of the Canadian Forest-Weather Index system. It is a numerical code that estimates the average moisture content of organic layers.

Based on function drought_code().

Parameters:
  • tas (str or DataArray) – Noon temperature. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Rain fall in open over previous 24 hours, at noon. Default: ‘pr’. [Required units : [precipitation]]

  • lat (str or DataArray) – Latitude coordinate. Default: ‘lat’. [Required units : []]

  • snd (str or DataArray, optional) – Noon snow depth. Default: None. [Required units : [length]]

  • dc0 (str or DataArray, optional) – Initial values of the drought code. Default: None. [Required units : []]

  • season_mask (str or DataArray, optional) – Boolean mask, True where/when the fire season is active. Default: None. [Required units : []]

  • season_method ({None, ‘LA08’, ‘GFWED’, ‘WF93’}) – How to compute the start-up and shutdown of the fire season. If “None”, no start-ups or shutdowns are computed, similar to the R fire function. Ignored if season_mask is given. Default: None.

  • overwintering (boolean) – Whether to activate DC overwintering or not. If True, either season_method or season_mask must be given. Default: False.

  • dry_start ({None, ‘GFWED’, ‘CFS’}) – Whether to activate the DC and DMC “dry start” mechanism and which method to use. See fire_weather_ufunc(). Default: None.

  • initial_start_up (boolean) – If True (default), grid points where the fire season is active on the first timestep go through a start_up phase for that time step. Otherwise, previous codes must be given as a continuing fire season is assumed for those points. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • params – Any other keyword parameters as defined in xclim.compute.fire.fire_weather_ufunc and in default_params.

Returns:

xarray.DataArray, [dimensionless] – Drought Code. With additional attributes: description: Numerical code estimating the average moisture content of organic layers.

Return type:

xarray.DataArray

Notes

See Natural Resources Canada [n.d.], the xclim.compute.fire module documentation, and the docstring of fire_weather_ufunc() for more information. This algorithm follows the official R code released by the CFS, which contains revisions from the original 1982 Fortran code.

References

Wang, Anderson, and Suddaby [2015]

xclim.indicators.atmos._precip.dry_days(pr='pr', *, condition='<', thresh='0.2 mm/d', freq='YS', ds=None, **indexer)

Number of dry days

The number of days with daily precipitation under a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0.2 mm/d’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_below_threshold, Number of dry days. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with daily precipitation under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.dry_spell_frequency(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Dry spell frequency

The frequency of dry periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=<, statistic=count, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – An amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of dry periods of at least {window} days. With additional attributes: description: The {freq} number of dry periods of at least {window} days. A period is dry if its {window_statistic} precipitation on a window of {window} days is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.dry_spell_max_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Dry spell maximum length

The maximum length of a dry period of N days or more, during which the accumulated or maximum precipitation over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=<, statistic=max, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – An amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a dry period of at least {window} days. With additional attributes: description: The maximum {freq} number of consecutive days in a dry period of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.dry_spell_total_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Dry spell total length

The total length of dry periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=<, statistic=sum, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – An amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in dry periods of at least {window} days.. With additional attributes: description: The {freq} number of days in dry periods of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.dryness_index(pr='pr', evspsblpot='evspsblpot', lat=None, *, wo='200 mm', freq='YS', ds=None)

Dryness index

The dryness index is a characterization of the water component in winegrowing regions which considers the precipitation and evapotranspiration factors without deduction for surface runoff or drainage. Metric originally published in Riou et al. (1994).

This indicator will check for missing values according to the method “from_context”. Based on function dryness_index().

Parameters:
  • pr (str or DataArray) – Precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • evspsblpot (str or DataArray) – Potential evapotranspiration. Default: ‘evspsblpot’. [Required units : [precipitation]]

  • lat (str or DataArray, optional) – Latitude coordinate as an array, float or string. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: None.

  • wo (quantity (string or DataArray, with units)) – The initial soil water reserve accessible to root systems [length]. Default: 200 mm. Default: ‘200 mm’. [Required units : [length]]

  • freq ({‘YS-JAN’, ‘YS’}) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – Growing season humidity. With additional attributes: description: Estimation of growing season humidity (precipitation minus adjusted evapotranspiration) for the period of April to September (Northern Hemisphere) or October to March (Southern Hemisphere), with initial soil moisture content set to {wo} and an adjustment based on monthly precipitation and evapotranspiration limits.

Return type:

xarray.DataArray

Notes

Given that this index only examines monthly total accumulations for six-month periods depending on the hemisphere, it is possible to send in DataArrays containing only these timesteps. Users should be aware that due to the missing values checks in wrapped Indicators, datasets that are missing several months will be flagged as invalid. This check can be ignored by setting the following context:

with xclim.set_options(check_missing="skip"):
    di = dryness_index(pr, evspsblpot)

Let \(Wo\) be the initial useful soil water reserve (typically “200 mm”), \(P\) be precipitation, \(T_{v}\) be the potential transpiration in the vineyard, and \(E_{s}\) be the direct evaporation from the soil. Then the Dryness Index, or the estimate of soil water reserve at the end of a period (1 April to 30 September in the Northern Hemispherere or 1 October to 31 March in the Southern Hemisphere), can be given by the following formulae:

\[W = \sum_{\text{April 1}}^{\text{September 30}} \left( Wo + P - T_{v} - E_{s} \right)\]

or (for the Southern Hemisphere):

\[W = \sum_{\text{October 1}}^{\text{March 31}} \left( Wo + P - T_{v} - E_{s} \right)\]

Where \(T_{v}\) and \(E_{s}\) are given by the following formulae:

\[T_{v} = ETP * k\]

and

\[E_{s} = \frac{ETP}{N}\left( 1 - k \right) * JPm\]

Where \(ETP\) is evapotranspiration, \(N\) is the number of days in the given month. \(k\) is the coefficient for radiative absorption given by the vine plant architecture, and \(JPm\) is the number of days of effective evaporation from the soil per month, both provided by the following formulae:

\[\begin{split}k = \begin{cases} 0.1, & \text{if month = April (NH) or October (SH)} \\ 0.3, & \text{if month = May (NH) or November (SH)} \\ 0.5, & \text{if month = June - September (NH) or December - March (SH)} \\ \end{cases}\end{split}\]
\[JPm = \max\left( P / 5, N \right)\]

References

Riou [1994], Tonietto and Carbonneau [2004]

xclim.indicators.atmos._precip.duff_moisture_code(tas='tas', pr='pr', hurs='hurs', lat='lat', snd=None, dmc0=None, season_mask=None, *, season_method=None, dry_start=None, initial_start_up=True, ds=None, **params)

Duff moisture code (FWI component).

The duff moisture code is part of the Canadian Forest Fire Weather Index System. It is a numeric rating of the average moisture content of loosely compacted organic layers of moderate depth.

Based on function duff_moisture_code().

Parameters:
  • tas (str or DataArray) – Noon temperature. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Rain fall in open over previous 24 hours, at noon. Default: ‘pr’. [Required units : [precipitation]]

  • hurs (str or DataArray) – Noon relative humidity. Default: ‘hurs’. [Required units : []]

  • lat (str or DataArray) – Latitude coordinate. Default: ‘lat’. [Required units : []]

  • snd (str or DataArray, optional) – Noon snow depth. Default: None. [Required units : [length]]

  • dmc0 (str or DataArray, optional) – Initial values of the duff moisture code. Default: None. [Required units : []]

  • season_mask (str or DataArray, optional) – Boolean mask, True where/when the fire season is active. Default: None. [Required units : []]

  • season_method ({None, ‘LA08’, ‘GFWED’, ‘WF93’}) – How to compute the start-up and shutdown of the fire season. If “None”, no start-ups or shutdowns are computed, similar to the R fire function. Ignored if season_mask is given. Default: None.

  • dry_start ({None, ‘GFWED’, ‘CFS’}) – Whether to activate the DC and DMC “dry start” mechanism and which method to use. See fire_weather_ufunc(). Default: None.

  • initial_start_up (boolean) – If True (default), grid points where the fire season is active on the first timestep go through a start_up phase for that time step. Otherwise, previous codes must be given as a continuing fire season is assumed for those points. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • params – Any other keyword parameters as defined in xclim.compute.fire.fire_weather_ufunc and in default_params.

Returns:

xarray.DataArray, [dimensionless] – Duff Moisture Code. With additional attributes: description: Numeric rating of the average moisture content of loosely compacted organic layers of moderate depth.

Return type:

xarray.DataArray

Notes

See Natural Resources Canada [n.d.], the xclim.compute.fire module documentation, and the docstring of fire_weather_ufunc() for more information. This algorithm follows the official R code released by the Canadian Forestry Service, which contains revisions from the original 1982 Fortran code.

References

Wang, Anderson, and Suddaby [2015]

xclim.indicators.atmos._precip.first_snowfall(prsn='prsn', *, thresh='1 mm/d', freq='YS-JUL', ds=None, **indexer)

First day where snowfall exceeded a given threshold

The first day where snowfall exceeded a given threshold during a time period (the threshold can be given as a snowfall flux or a liquid water equivalent snowfall rate).

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: condition=>=, date=None, which=first, window=1, constrain=None.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘1 mm/d’. [Required units : ([mass]/([area]*[time]))]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Date of first day where snowfall exceeded {thresh}. With additional attributes: description: {freq} first day where snowfall exceeded {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.fraction_over_precip_doy_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Fraction of precipitation due to wet days with daily precipitation over a given daily percentile.

The percentage of the total precipitation over a period occurring for days when the precipitation is above a threshold defining wet days and above a given percentile for that day.

This indicator will check for missing values according to the method “from_context”. Based on function fraction_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Fraction of precipitation due to days with daily precipitation above {pr_per_thresh}th daily percentile. With additional attributes: description: {freq} fraction of total precipitation due to days with precipitation above {pr_per_thresh}th daily percentile. Only days with at least {thresh} are included in the total. A {pr_per_window} day(s) window, centered on each calendar day in the {pr_per_period} period, is used to compute the {pr_per_thresh}th percentile(s).

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.fraction_over_precip_thresh(pr='pr', pr_per='pr_per', *, thresh='1 mm/day', freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Fraction of precipitation due to wet days with daily precipitation over a given percentile.

The percentage of the total precipitation over a period occurring for days when the precipitation is above a threshold defining wet days and above a given percentile for that day.

This indicator will check for missing values according to the method “from_context”. Based on function fraction_over_precip_thresh().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • pr_per (str or DataArray) – Percentile of wet day precipitation flux. Either computed daily (one value per day of year) or computed over a period (one value per spatial point). Default: ‘pr_per’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Fraction of precipitation due to days with precipitation above {pr_per_thresh}th daily percentile. With additional attributes: description: {freq} fraction of total precipitation due to days with precipitation above {pr_per_thresh}th percentile of {pr_per_period} period. Only days with at least {thresh} are included in the total.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.griffiths_drought_factor(pr='pr', smd='smd', *, limiting_func='xlim', ds=None)

Griffiths drought factor based on the soil moisture deficit.

The drought factor is a numeric indicator of the forest fire fuel availability in the deep litter bed. It is often used in the calculation of the McArthur Forest Fire Danger Index. The method implemented here follows Finkele et al. [2006].

Based on function griffiths_drought_factor().

Parameters:
  • pr (str or DataArray) – Total rainfall over previous 24 hours [mm/day]. Default: ‘pr’. [Required units : [precipitation]]

  • smd (str or DataArray) – Daily soil moisture deficit (often KBDI) [mm/day]. Default: ‘smd’. [Required units : [precipitation]]

  • limiting_func ({‘xlim’, ‘discrete’}) – How to limit the values of the drought factor. If “xlim” (default), use equation (14) in Finkele et al. [2006]. If “discrete”, use equation Eq (13) in Finkele et al. [2006], but with the lower limit of each category bound adjusted to match the upper limit of the previous bound. Default: ‘xlim’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray – griffiths_drought_factor, Griffiths Drought Factor. With additional attributes: description: Numeric indicator of the forest fire fuel availability in the deep litter bed

Return type:

xarray.DataArray

Notes

Calculation of the Griffiths drought factor depends on the rainfall over the previous 20 days. Thus, the first non-NaN time point in the drought factor returned by this function corresponds to the 20th day of the input data.

References

Finkele, Mills, Beard, and Jones [2006], Griffiths [1999], Holgate, Van DIjk, Cary, and Yebra [2017]

xclim.indicators.atmos._precip.high_precip_low_temp(pr='pr', tas='tas', *, freq='YS', ds=None, pr_thresh='0.4 mm/d', tas_thresh='-0.2 degC', **indexer)

Days with precipitation and cold temperature

Number of days with precipitation above a given threshold and temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_count_occurrences(). With injected parameters: condition1=>=, condition2=<, var_reducer=all, constrain1=None, constrain2=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • pr_thresh (quantity (string or DataArray, with units)) – Threshold for data variable 1. Default: ‘0.4 mm/d’. [Required units : ([precipitation])]

  • tas_thresh (quantity (string or DataArray, with units)) – Threshold for data variable 2. If None, thresh1 is used. Default: ‘-0.2 degC’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Days with precipitation at or above {pr_thresh} and temperature below {tas_thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with precipitation at or above {pr_thresh} and temperature below {tas_thresh}.

Return type:

xarray.DataArray

Notes

Sampling length is derived from data1.

xclim.indicators.atmos._precip.keetch_byram_drought_index(pr='pr', tasmax='tasmax', pr_annual='pr_annual', kbdi0=None, *, ds=None)

Keetch-Byram drought index (KBDI) for soil moisture deficit.

The KBDI indicates the amount of water necessary to bring the soil moisture content back to field capacity. It is often used in the calculation of the McArthur Forest Fire Danger Index. The method implemented here follows Finkele et al. [2006] but limits the maximum KBDI to 203.2 mm, rather than 200 mm, in order to align best with the majority of the literature.

Based on function keetch_byram_drought_index().

Parameters:
  • pr (str or DataArray) – Total rainfall over previous 24 hours [mm/day]. Default: ‘pr’. [Required units : [precipitation]]

  • tasmax (str or DataArray) – Maximum temperature near the surface over previous 24 hours [degC]. Default: ‘tasmax’. [Required units : [temperature]]

  • pr_annual (str or DataArray) – Mean (over years) annual accumulated rainfall [mm/year]. Default: ‘pr_annual’. [Required units : [precipitation]]

  • kbdi0 (str or DataArray, optional) – Previous KBDI values used to initialise the KBDI calculation [mm/day]. Defaults to 0. Default: None. [Required units : [precipitation]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm/day] – keetch_byram_drought_index, Keetch-Byran Drought Index. With additional attributes: description: Amount of water necessary to bring the soil moisture content back to field capacity

Return type:

xarray.DataArray

Notes

This method implements the method described in Finkele et al. [2006] (section 2.1.1) for calculating the KBDI with one small difference: in Finkele et al. [2006] the maximum KBDI is limited to 200 mm to represent the maximum field capacity of the soil (8 inches according to Keetch and Byram [1968]). However, it is more common in the literature to limit the KBDI to 203.2 mm which is a more accurate conversion from inches to mm. In this function, the KBDI is limited to 203.2 mm.

References

Dolling, Chu, and Fujioka [2005], Finkele, Mills, Beard, and Jones [2006], Holgate, Van DIjk, Cary, and Yebra [2017], Keetch and Byram [1968]

xclim.indicators.atmos._precip.last_snowfall(prsn='prsn', *, thresh='1 mm/d', freq='YS-JUL', ds=None, **indexer)

Last day where snowfall exceeded a given threshold

The last day where snowfall exceeded a given threshold during a time period (the threshold can be given as a snowfall flux or a liquid water equivalent snowfall rate).

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: condition=>=, date=None, which=last, window=1, constrain=None.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘1 mm/d’. [Required units : ([mass]/([area]*[time]))]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Date of last day where snowfall exceeded {thresh}. With additional attributes: description: {freq} last day where snowfall exceeded {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.liquid_precip_accumulation(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Total accumulated liquid precipitation.

Total accumulated liquid precipitation. Precipitation is considered liquid when the average daily temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_accumulation(). With injected parameters: phase=liquid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_liquid_precipitation_amount, Total accumulated precipitation when temperature is above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} total {phase} precipitation, estimated as precipitation when temperature is above {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} = \sum_{i=a}^{b} PR_i\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos._precip.liquid_precip_average(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Averaged liquid precipitation.

Averaged liquid precipitation. Precipitation is considered liquid when the average daily temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_average(). With injected parameters: phase=liquid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_average_of_liquid_precipitation_amount, Averaged precipitation when temperature is above {thresh}. With additional attributes: cell_methods: time: mean over days, description: {freq} mean {phase} precipitation, estimated as precipitation when temperature is above {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} =\frac{ \sum_{i=a}^{b} PR_i }{b - a + 1}\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos._precip.liquid_precip_ratio(pr='pr', tas='tas', prra=None, *, thresh='0 degC', freq='QS-DEC', ds=None, **indexer)

Fraction of liquid to total precipitation

The ratio of total liquid precipitation over the total precipitation. Liquid precipitation is approximated from total precipitation on days where temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function liquid_precip_ratio(). With injected parameters: prsn=None.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • prra (str or DataArray, optional) – Mean daily liquid precipitation flux. Default: None.

  • thresh (quantity (string or DataArray, with units)) – Threshold temperature under which precipitation is assumed to be solid. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘QS-DEC’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Fraction of liquid to total precipitation (temperature above {thresh}). With additional attributes: description: The {freq} ratio of rainfall to total precipitation. Rainfall is estimated as precipitation on days where temperature is above {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation on day \(i\), and \(PRSN_i\) the mean daily solid precipitation. For a period \(j\) starting on day \(a\) and ending on day \(b\):

\[PR_{j} = \sum_{i=a}^{b} PR_i\]
\[PR^{\mathrm{liquid}}_{j} = \sum_{i=a}^{b} (PR_i - PRSN_i)\]

The liquid precipitation ratio is then:

\[R_j = \frac{PR^{\mathrm{liquid}}_{j}}{PR_j}\]
xclim.indicators.atmos._precip.max_1day_precipitation_amount(pr='pr', *, freq='YS', ds=None, **indexer)

Maximum 1-day total precipitation

Maximum total daily precipitation for a given period.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm/day] – lwe_thickness_of_precipitation_amount, Maximum 1-day total precipitation. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum 1-day total precipitation

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.max_n_day_precipitation_amount(pr='pr', *, window, freq='YS', ds=None, **indexer)

maximum n-day total precipitation

Maximum of the moving sum of daily precipitation for a given period.

This indicator will check for missing values according to the method “from_context”. Based on function running_statistics(). With injected parameters: window_statistic=integral, statistic=max, window_center=True, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Size of the rolling window. Required.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Resampling is done after the running statistic. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Time selection is done after applying the running statistic.

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_precipitation_amount, maximum {window}-day total precipitation amount. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum {window}-day total precipitation amount.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.max_pr_intensity(pr='pr', *, window=1, freq='YS', ds=None, **indexer)

Maximum precipitation intensity over time window

Maximum precipitation intensity over a given rolling time window.

This indicator will check for missing values according to the method “from_context”. Based on function running_statistics(). With injected parameters: window_statistic=mean, statistic=max, window_center=False, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Size of the rolling window. Default: 1.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Resampling is done after the running statistic. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Time selection is done after applying the running statistic.

Returns:

xarray.DataArray, [mm h-1] – precipitation, Maximum precipitation intensity over rolling {window}h time window. With additional attributes: cell_methods: time: max, description: {freq} maximum precipitation intensity over rolling {window}h time window.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.maximum_consecutive_dry_days(pr='pr', *, condition='<', thresh='1 mm/day', freq='YS', min_gap=1, resample_before_rl=True, ds=None, **indexer)

Maximum consecutive dry days

The longest number of consecutive days where daily precipitation below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=max, statistic=max, constrain=(‘<’, ‘<=’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_below_threshold, Maximum consecutive days with daily precipitation {condition} {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} maximum number of consecutive days with daily precipitation {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.maximum_consecutive_wet_days(pr='pr', *, condition='>=', thresh='1 mm/day', freq='YS', min_gap=1, resample_before_rl=True, ds=None, **indexer)

Maximum consecutive wet days

The longest number of consecutive days where daily precipitation is at or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=max, statistic=max, constrain=(‘>=’, ‘>’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Maximum consecutive days with daily precipitation {condition} {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} maximum number of consecutive days with daily precipitation {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.mcarthur_forest_fire_danger_index(drought_factor='drought_factor', tasmax='tasmax', hurs='hurs', sfcWind='sfcWind', *, ds=None)

McArthur forest fire danger index (FFDI) Mark 5.

The FFDI is a numeric indicator of the potential danger of a forest fire.

Based on function mcarthur_forest_fire_danger_index().

Parameters:
  • drought_factor (str or DataArray) – The drought factor, often the daily Griffiths drought factor (see griffiths_drought_factor()). Default: ‘drought_factor’. [Required units : []]

  • tasmax (str or DataArray) – The daily maximum temperature near the surface, or similar. Different applications have used different inputs here, including the previous/current day’s maximum daily temperature at a height of 2m, and the daily mean temperature at a height of 2m. Default: ‘tasmax’. [Required units : [temperature]]

  • hurs (str or DataArray) – The relative humidity near the surface and near the time of the maximum daily temperature, or similar. Different applications have used different inputs here, including the mid-afternoon relative humidity at a height of 2m, and the daily mean relative humidity at a height of 2m. Default: ‘hurs’. [Required units : []]

  • sfcWind (str or DataArray) – The wind speed near the surface and near the time of the maximum daily temperature, or similar. Different applications have used different inputs here, including the mid-afternoon wind speed at a height of 10m, and the daily mean wind speed at a height of 10m. Default: ‘sfcWind’. [Required units : [speed]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray – mcarthur_forest_fire_danger_index, McArthur Forest Fire Danger Index. With additional attributes: description: Numeric rating of the potential danger of a forest fire

Return type:

xarray.DataArray

References

Dowdy [2018], Holgate, Van DIjk, Cary, and Yebra [2017], Noble, Gill, and Bary [1980]

xclim.indicators.atmos._precip.precip_accumulation(pr='pr', *, freq='YS', ds=None)

Total accumulated precipitation (solid and liquid)

Total accumulated precipitation.

This indicator will check for missing values according to the method “from_context”. Based on function precip_accumulation(). With injected parameters: tas=None, phase=None, thresh=None.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_precipitation_amount, Total accumulated precipitation. With additional attributes: cell_methods: time: sum over days, description: {freq} total precipitation.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} = \sum_{i=a}^{b} PR_i\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos._precip.precip_average(pr='pr', *, thresh='0 degC', freq='YS', ds=None)

Averaged precipitation (solid and liquid)

Averaged precipitation.

This indicator will check for missing values according to the method “from_context”. Based on function precip_average(). With injected parameters: tas=None, phase=None.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [mm] – lwe_average_of_precipitation_amount, Averaged precipitation. With additional attributes: cell_methods: time: mean over days, description: {freq} mean precipitation.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} =\frac{ \sum_{i=a}^{b} PR_i }{b - a + 1}\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos._precip.precipitation_concentration_index(pr='pr', *, freq='YS', subfreq='MS', ds=None)

Precipitation Concentration Index.

A measure of the unevenness of precipitation distribution within a period. Computed as the ratio of the sum of squared sub-period totals to the square of the sum of sub-period totals, multiplied by 100 [Oliver, 1980].

This indicator will check for missing values according to the method “from_context”. Based on function precipitation_concentration_index().

Parameters:
  • pr (str or DataArray) – Precipitation flux or rate, with units convertible to a precipitation unit (e.g. "mm/day"). Default: ‘pr’.

  • freq (offset alias (string)) – Resampling frequency for the output (main period). Default is "YS" (yearly). Default: ‘YS’.

  • subfreq (str) – Resampling frequency for computing sub-period totals. Default is "MS" (monthly). Default: ‘MS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [%] – Precipitation Concentration Index. With additional attributes: description: A measure of the unevenness of the {freq} distribution of precipitations. Computed as the ratio of the sum of squared {subfreq} totals to the square of the sum of {subfreq} totals, multiplied by 100

Return type:

xarray.DataArray

Notes

The precipitation concentration index (PCI) can be calculated as follows:

\[PCI = \frac{\sum_{i=1}^{n} p_i^2}{\left(\sum_{i=1}^{n} p_i\right)^2} \times 100\]

where \(p_i\) is the precipitation total for sub-period \(i\) and \(n\) is the number of sub-periods per main period.

A PCI of 8.3 (i.e. \(100/n\)) indicates perfectly uniform precipitation. Higher values indicate increasing concentration. Values above ~20 indicate a highly irregular or seasonal distribution.

References

Oliver [1980]

xclim.indicators.atmos._precip.rain_on_frozen_ground_days(pr='pr', tas='tas', *, thresh='1 mm/d', window=7, freq='YS', ds=None, **indexer)

Number of rain on frozen ground days

The number of days with rain above a given threshold after a series of seven days with average daily temperature below 0°C. Precipitation is assumed to be rain when the daily average temperature is above 0°C.

This indicator will check for missing values according to the method “from_context”. Based on function rain_on_frozen_ground_days().

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation threshold to consider a day as a rain event. Default: ‘1 mm/d’. [Required units : [precipitation]]

  • window (number) – Minimum number of days below freezing temperature needed to consider the ground frozen. Default: 7.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Number of rain on frozen ground days (mean daily temperature > 0℃ and precipitation > {thresh}). With additional attributes: description: {freq} number of days with rain above {thresh} after a series of seven days with average daily temperature below 0℃. Precipitation is assumed to be rain when the daily average temperature is above 0℃.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation and \(TG_i\) be the mean daily temperature of day \(i\). Then for a period \(j\), rain on frozen grounds days are counted where:

\[PR_{i} > Threshold [mm]\]

and where

\[TG_{i} ≤ 0℃\]

is true for continuous periods where \(i ≥ window\)

xclim.indicators.atmos._precip.rain_season(pr='pr', *, thresh_wet_start='25.0 mm', window_wet_start=3, window_not_dry_start=30, thresh_dry_start='1.0 mm', window_dry_start=7, method_dry_start='per_day', date_min_start='05-01', date_max_start='12-31', thresh_dry_end='0.0 mm', window_dry_end=20, method_dry_end='per_day', date_min_end='09-01', date_max_end='12-31', freq='YS-JAN', ds=None)

Rain season

Start time, end time and length of the rain season, notably useful for West Africa (sivakumar, 1998). The rain season starts with a period of abundant rainfall, followed by a period without prolonged dry sequences, which must happen before a given date. The rain season stops during a dry period happening after a given date.

This indicator will check for missing values according to the method “from_context”. Based on function rain_season().

Parameters:
  • pr (str or DataArray) – Precipitation data. Default: ‘pr’. [Required units : [precipitation]]

  • thresh_wet_start (quantity (string or DataArray, with units)) – Accumulated precipitation threshold associated with window_wet_start. Default: ‘25.0 mm’. [Required units : [length]]

  • window_wet_start (number) – Number of days when accumulated precipitation is above thresh_wet_start. Defines the first condition to start the rain season. Default: 3.

  • window_not_dry_start (number) – Number of days, after window_wet_start days, during which no dry period must be found as a second and last condition to start the rain season. A dry sequence is defined with thresh_dry_start, window_dry_start and method_dry_start. Default: 30.

  • thresh_dry_start (quantity (string or DataArray, with units)) – Threshold length defining a dry day in the sequence related to window_dry_start. Default: ‘1.0 mm’. [Required units : [length]]

  • window_dry_start (number) – Number of days used to define a dry sequence in the start of the season. Daily precipitations lower than thresh_dry_start during window_dry_start days are considered a dry sequence. The precipitations must be lower than thresh_dry_start for either every day in the sequence (method_dry_start == “per_day”) or for the total (method_dry_start == “total”). Default: 7.

  • method_dry_start ({‘per_day’, ‘total’}) – Method used to define a dry sequence associated with window_dry_start. The threshold thresh_dry_start is either compared to every daily precipitation (method_dry_start == “per_day”) or to total precipitations (method_dry_start == “total”) in the sequence window_dry_start days. Default: ‘per_day’.

  • date_min_start (date (string, MM-DD)) – First day of year when season can start (“mm-dd”). Default: ‘05-01’.

  • date_max_start (date (string, MM-DD)) – Last day of year when season can start (“mm-dd”). Default: ‘12-31’.

  • thresh_dry_end (quantity (string or DataArray, with units)) – Threshold length defining a dry day in the sequence related to window_dry_end. Default: ‘0.0 mm’. [Required units : [length]]

  • window_dry_end (number) – Number of days used to define a dry sequence in the end of the season. Daily precipitations lower than thresh_dry_end during window_dry_end days are considered a dry sequence. The precipitations must be lower than thresh_dry_end for either every day in the sequence (method_dry_end == “per_day”) or for the total (method_dry_end == “total”). Default: 20.

  • method_dry_end ({‘per_day’, ‘total’}) – Method used to define a dry sequence associated with window_dry_end. The threshold thresh_dry_end is either compared to every daily precipitation (method_dry_end == “per_day”) or to total precipitations (method_dry_end == “total”) in the sequence window_dry days. Default: ‘per_day’.

  • date_min_end (date (string, MM-DD)) – First day of year when season can end (“mm-dd”). Default: ‘09-01’.

  • date_max_end (date (string, MM-DD)) – Last day of year when season can end (“mm-dd”). Default: ‘12-31’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JAN’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

  • rain_season_start (xarray.DataArray, [dimensionless]) – Start of the rain season. With additional attributes: description: First step of a run where i) a sequence of {window_wet_start} days accumulated {thresh_wet_start} of precipitations ii) followed by a sequence of {window_not_dry_start} days with no dry sequence, i.e. a sequence of {window_dry_start} days with at least {thresh_dry_start} {method_dry_start}. The start of the season is on the last day of the first sequence i) and must be between {date_min_start} and {date_max_start}.

  • rain_season_end (xarray.DataArray, [dimensionless]) – End of the rain season. With additional attributes: description: Last day in a dry sequence after the start of the season, i.e. a sequence of {window_dry_end} days with at least {thresh_dry_end} {method_dry_end}. It must be between {date_min_end} and {date_max_end}.

  • rain_season_length (xarray.DataArray, [days]) – Length of the rain season. With additional attributes: description: Number of steps of the original series in the season, between 'start' and 'end'.

Return type:

tuple[xarray.DataArray, xarray.DataArray, xarray.DataArray]

Notes

The rain season starts at the end of a period of raining (a total precipitation of thresh_wet_start over window_wet_start days). This must be directly followed by a period of window_not_dry_start days with no dry sequence. The dry sequence is a period of window_dry_start days where precipitations are below thresh_dry_start (either the total precipitations over the period, or the daily precipitations, depending on method_dry_start). The rain season stops when a dry sequence happens (the dry sequence is defined as in the start sequence, but with parameters window_dry_end, thresh_dry_end and method_dry_end). The dates on which the season can start are constrained by date_min_start`and `date_max_start (and similarly for the end of the season).

References

Sivakumar [1988]

xclim.indicators.atmos._precip.rprctot(pr='pr', prc='prc', *, thresh='1.0 mm/day', freq='YS', op='>=', ds=None, **indexer)

Proportion of accumulated precipitation arising from convective processes

The proportion of total precipitation due to convective processes. Only days with surpassing a minimum precipitation flux are considered.

This indicator will check for missing values according to the method “from_context”. Based on function rprctot().

Parameters:
  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • prc (str or DataArray) – Daily convective precipitation. Default: ‘prc’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1.0 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • op ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>=”. Default: ‘>=’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Proportion of accumulated precipitation arising from convective processeswith precipitation of at least {thresh}. With additional attributes: cell_methods: time: sum, description: {freq} proportion of accumulated precipitation arising from convective processes with precipitation of at least {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.snowfall_frequency(prsn='prsn', *, thresh='1 mm/day', freq='YS-JUL', ds=None, **indexer)

Snowfall frequency

Percentage of days with snowfall above a given threshold (either a snowfall flux or a liquid water equivalent snowfall rate).

This indicator will check for missing values according to the method “from_context”. Based on function snowfall_frequency().

Parameters:
  • prsn (str or DataArray) – Snowfall flux. Default: ‘prsn’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Threshold snowfall flux or liquid water equivalent snowfall rate (default: 1 mm/day). Default: ‘1 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [%] – Percentage of days with snowfall above {thresh} threshold. With additional attributes: description: {freq} percentage of days with snowfall larger than {thresh}.

Return type:

xarray.DataArray

Notes

The 1 mm/day liquid water equivalent snowfall rate threshold in Frei, Kotlarski, Liniger, and Schär [2018] corresponds to the 1 cm/day snowfall rate threshold in CBCL [2020] using a snow density of 100 kg/m**3.

If the threshold and prsn differ by a density (i.e. [length/time] vs. [mass/area/time]), a liquid water equivalent snowfall rate is assumed, and the threshold is converted using a 1000 kg m-3 density.

References

Frei, Kotlarski, Liniger, and Schär [2018].

xclim.indicators.atmos._precip.snowfall_intensity(prsn='prsn', *, thresh='1 mm/d', freq='YS-JUL', ds=None, **indexer)

Snowfall intensity

Mean daily liquid water equivalent snowfall rate above threshold (either a snowfall flux or a liquid water equivalent snowfall rate)

This indicator will check for missing values according to the method “from_context”. Based on function thresholded_statistics(). With injected parameters: condition=>=, statistic=mean, constrain=None, out_units=None.

Parameters:
  • prsn (str or DataArray) – Surface snowfall flux. Default: ‘prsn’. [Required units : [mass]/([area]*[time])]

  • thresh (quantity (string or DataArray, with units)) – Threshold, should have the same dimensionality as data. Default: ‘1 mm/d’. [Required units : ([mass]/([area]*[time]))]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS-JUL’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm/day] – Mean daily snowfall above {thresh} threshold. With additional attributes: description: {freq} mean daily snowfall larger than {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.solid_precip_accumulation(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Total accumulated solid precipitation.

Total accumulated solid precipitation. Precipitation is considered solid when the average daily temperature is at or below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_accumulation(). With injected parameters: phase=solid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_snowfall_amount, Total accumulated solid precipitation. With additional attributes: cell_methods: time: sum over days, description: {freq} total solid precipitation, estimated as precipitation when temperature at or below {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} = \sum_{i=a}^{b} PR_i\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos._precip.solid_precip_average(pr='pr', tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Averaged solid precipitation.

Averaged solid precipitation. Precipitation is considered solid when the average daily temperature is at or below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function precip_average(). With injected parameters: phase=solid.

Parameters:
  • pr (str or DataArray) – Mean daily precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • tas (str or DataArray) – Mean, maximum or minimum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold of tas over which the precipication is assumed to be liquid rain. Default: ‘0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_average_of_snowfall_amount, Averaged solid precipitation. With additional attributes: cell_methods: time: mean over days, description: {freq} mean solid precipitation, estimated as precipitation when temperature at or below {thresh}.

Return type:

xarray.DataArray

Notes

Let \(PR_i\) be the mean daily precipitation of day \(i\), then for a period \(j\) starting at day \(a\) and finishing on day \(b\):

\[PR_{ij} =\frac{ \sum_{i=a}^{b} PR_i }{b - a + 1}\]

If tas and phase are given, the corresponding phase precipitation is estimated before computing the accumulation, using one of snowfall_approximation or rain_approximation with the binary method.

xclim.indicators.atmos._precip.standardized_precipitation_evapotranspiration_index(wb='wb', *, freq='MS', window=1, dist='gamma', method='ML', fitkwargs=None, cal_start=None, cal_end=None, params=None, ds=None, **indexer)

Standardized Precipitation Evapotranspiration Index (SPEI)

Water budget (precipitation - evapotranspiration) over a moving window, normalized such that the SPEI averages to 0 for the calibration data. The window unit X is the minimal time period defined by the resampling frequency.

This indicator will check for missing values according to the method “from_context”. Based on function standardized_precipitation_evapotranspiration_index().

Parameters:
  • wb (str or DataArray) – Daily water budget (pr - pet). Default: ‘wb’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. A monthly or daily frequency is expected. Option None assumes that the desired resampling has already been applied input dataset and will skip the resampling step. Default: ‘MS’.

  • window (number) – Averaging window length relative to the resampling frequency. For example, if freq=”MS”, i.e. a monthly resampling, the window is an integer number of months. Default: 1.

  • dist ({‘fisk’, ‘gamma’, ‘genextreme’, ‘lognorm’}) – Name of the univariate distribution, or a callable rv_continuous (see scipy.stats). Default: ‘gamma’.

  • method ({‘ML’, ‘PWM’, ‘APP’}) – Name of the fitting method, such as ML (maximum likelihood), APP (approximate). The approximate method uses a deterministic function that does not involve any optimization, which can be sensitive to noise. PWM should be used with a lmoments3 distribution. Default: ‘ML’.

  • fitkwargs (dict) – Kwargs passed to xclim.compute.stats.fit used to impose values of certains parameters (floc, fscale). If method is PWM, fitkwargs should be empty, except for floc with dist`=`gamma which is allowed. Default: None.

  • cal_start (date (string, YYYY-MM-DD)) – Start date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period begins at the start of the input dataset. Default: None.

  • cal_end (date (string, YYYY-MM-DD)) – End date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period finishes at the end of the input dataset. Default: None.

  • params (quantity (string or DataArray, with units)) – Fit parameters. The params can be computed using xclim.compute.stats.standardized_index_fit_params in advance. The output can be given here as input, and it overrides other options. Default: None. [Required units : []]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.compute.generic.select_time().

Returns:

xarray.DataArray – spei, Standardized precipitation evapotranspiration index (SPEI). With additional attributes: description: Water budget (precipitation minus evapotranspiration) over a moving {window}-X window, normalized such that SPEI averages to 0 for calibration data. The window unit `X` is the minimal time period defined by the resampling frequency {freq}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.standardized_precipitation_index(pr='pr', *, freq='MS', window=1, dist='gamma', method='ML', fitkwargs=None, cal_start=None, cal_end=None, params=None, prob_zero_interpolation='upper', plotting_position_zero='ecdf', ds=None, **indexer)

Standardized Precipitation Index (SPI)

Precipitation over a moving window, normalized such that SPI averages to 0 for the calibration data. The window unit X is the minimal time period defined by the resampling frequency.

This indicator will check for missing values according to the method “from_context”. Based on function standardized_precipitation_index().

Parameters:
  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. A monthly or daily frequency is expected. Option None assumes that the desired resampling has already been applied input dataset and will skip the resampling step. Default: ‘MS’.

  • window (number) – Averaging window length relative to the resampling frequency. For example, if freq=”MS”, i.e. a monthly resampling, the window is an integer number of months. Default: 1.

  • dist ({‘fisk’, ‘gamma’, ‘genextreme’, ‘lognorm’}) – Name of the univariate distribution, or a callable rv_continuous (see scipy.stats). Default: ‘gamma’.

  • method ({‘ML’, ‘PWM’, ‘APP’}) – Name of the fitting method, such as ML (maximum likelihood), APP (approximate). The approximate method uses a deterministic function that does not involve any optimization, which can be sensitive to noise. PWM should be used with a lmoments3 distribution. Default: ‘ML’.

  • fitkwargs (dict) – Kwargs passed to xclim.compute.stats.fit used to impose values of certains parameters (floc, fscale). If method is PWM, fitkwargs should be empty, except for floc with dist`=`gamma which is allowed. Default: None.

  • cal_start (date (string, YYYY-MM-DD)) – Start date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period begins at the start of the input dataset. Default: None.

  • cal_end (date (string, YYYY-MM-DD)) – End date of the calibration period. A DateStr is expected, that is a str in format “YYYY-MM-DD”. Default option None means that the calibration period finishes at the end of the input dataset. Default: None.

  • params (quantity (string or DataArray, with units)) – Fit parameters. The params can be computed using xclim.compute.stats.standardized_index_fit_params in advance. The output can be given here as input, and it overrides other options. Default: None. [Required units : []]

  • prob_zero_interpolation ({‘upper’, ‘center’}) – Interpolation method used to assign a probability to zero values (only used if zero_inflated is True). When the data contain multiple zeros, the admissible plotting position interval spans from the first zero rank to the last zero rank. This parameter selects a representative probability within that interval. The default method “upper” assigns the upper bound of the zero-rank interval. The “center” method assigns the midpoint of the zero-rank interval. If a float in [0, 1] is provided, it is used as a linear interpolation factor between the lower (0) and upper (1) zero-rank plotting positions. Default: ‘upper’.

  • plotting_position_zero ({‘ecdf’, ‘weibull’}) – Method used to assign a probability to a rank for the zeros (only used if zero_inflated is True). “ecdf” (default option) is the empirical cumulative distribution and divides the number or zeros by the total number of observations. “weibull” implements the unbiased version, dividing by the total number of observation plus one. A tuple consisting of two coefficients in [0,1] to relate the number of zeros and the total number of observations. “ecdf” corresponds to (0,1) and “weibull” to (0,0). See scipy.stats.mstats.plotting_positions() Default: ‘ecdf’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.compute.generic.select_time().

Returns:

xarray.DataArray, [unitless] – spi, Standardized Precipitation Index (SPI). With additional attributes: description: Precipitations over a moving {window}-X window, normalized such that SPI averages to 0 for calibration data. The window unit `X` is the minimal time period defined by resampling frequency {freq}.

Return type:

xarray.DataArray

Notes

  • N-month SPI / N-day SPI is determined by choosing the window = N and the appropriate frequency freq.

  • Supported statistical distributions are: [“gamma”, “fisk”], where “fisk” is scipy’s implementation of a log-logistic distribution

  • Supported frequencies are daily (“D”), weekly (“W”), and monthly (“MS”).

  • Weekly frequency will only work if the input array has a “standard” (non-cftime) calendar.

  • If params is given as input, it overrides the cal_start, cal_end, freq and window, dist and method options.

  • “APP” method only supports two-parameter distributions. Parameter loc needs to be fixed to use method APP.

  • The results from climate_indices library can be reproduced with method = “APP” and fitwkargs = {“floc”: 0}, except for the maximum and minimum values allowed which are greater in xclim ±8.21, . See xclim.compute.stats.standardized_index

References

McKee, Doesken, and Kleist [1993], Stagge, Tallaksen, Gudmundsson, Van Loon, and Stahl [2015]

xclim.indicators.atmos._precip.warm_and_dry_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Warm and dry days

Number of days with temperature above a given percentile and precipitation below a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function warm_and_dry_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – Third quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – First quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature is above {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is above {tas_per_thresh}th percentile and precipitation is below {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos._precip.warm_and_wet_days(tas='tas', pr='pr', tas_per='tas_per', pr_per='pr_per', *, freq='YS', ds=None, **indexer)

Warm and wet days

Number of days with temperature above a given percentile and precipitation above a given percentile.

This indicator will check for missing values according to the method “from_context”. Based on function warm_and_wet_days().

Parameters:
  • tas (str or DataArray) – Mean daily temperature values. Default: ‘tas’. [Required units : [temperature]]

  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • tas_per (str or DataArray) – Third quartile of daily mean temperature computed by month. Default: ‘tas_per’. [Required units : [temperature]]

  • pr_per (str or DataArray) – Third quartile of daily total precipitation computed by month. Default: ‘pr_per’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days where temperature above {tas_per_thresh}th percentile and precipitation above {pr_per_thresh}th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where temperature is above {tas_per_thresh}th percentile and precipitation is above {pr_per_thresh}th percentile.

Return type:

xarray.DataArray

Notes

Bootstrapping is not available for quartiles because it would make no significant difference to bootstrap percentiles so far from the extremes.

Formula to be written (Beniston [2009]).

References

Beniston [2009]

xclim.indicators.atmos._precip.water_cycle_intensity(pr='pr', evspsbl='evspsbl', *, freq='YS', ds=None, **indexer)

Water cycle intensity

The sum of precipitation and actual evapotranspiration.

This indicator will check for missing values according to the method “from_context”. Based on function water_cycle_intensity().

Parameters:
  • pr (str or DataArray) – Precipitation flux. Default: ‘pr’. [Required units : [precipitation]]

  • evspsbl (str or DataArray) – Actual evapotranspiration flux. Default: ‘evspsbl’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – Water cycle intensity. With additional attributes: cell_methods: time: sum over days, description: The {freq} water cycle intensity, defined as the sum of precipitation and actual evapotranspiration.

Return type:

xarray.DataArray

References

Huntington, Weiskel, Wolock, and McCabe [2018]

xclim.indicators.atmos._precip.wet_precip_accumulation(pr='pr', *, thresh='1 mm/day', freq='YS', ds=None, **indexer)

Total accumulated precipitation (solid and liquid) during wet days

Total accumulated precipitation on days with precipitation. A day is considered to have precipitation if the precipitation is greater than or equal to a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function thresholded_statistics(). With injected parameters: condition=>=, statistic=integral, constrain=None, out_units=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Threshold, should have the same dimensionality as data. Default: ‘1 mm/day’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [mm] – lwe_thickness_of_precipitation_amount, Total accumulated precipitation over days where precipitation exceeds {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} total precipitation over wet days, defined as days where precipitation exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.wet_spell_frequency(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Wet spell frequency

The frequency of wet periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is equal or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=>=, statistic=count, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – A threshold amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of wet periods of at least {window} days.. With additional attributes: description: The {freq} number of wet periods of at least {window} days, during which the {window_statistic} precipitation on a window of {window} days is equal or over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.wet_spell_max_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Wet spell maximum length

The maximum length of a wet period of N days or more, during which the accumulated or maximum precipitation over a given time window of days is equal or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=>=, statistic=max, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – A threshold amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a wet period of at least {window} days.. With additional attributes: description: The maximum {freq} number of consecutive days in a wet period of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is equal or over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.wet_spell_total_length(pr='pr', *, window=3, window_statistic='sum', thresh='1 mm', freq='YS', resample_before_rl=True, ds=None, **indexer)

Wet spell total length

The total length of wet periods of N days or more, during which the accumulated or maximum precipitation over a given time window of days is equal or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: condition=>=, statistic=sum, min_gap=1, constrain=None.

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • window (number) – Minimum length of a spell. Default: 3.

  • window_statistic ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘sum’.

  • thresh (quantity (string or DataArray, with units)) – A threshold amount of precipitation (not a flux or rate). Default: ‘1 mm’. [Required units : ([mass]/[area])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in wet periods of at least {window} days. With additional attributes: description: The {freq} number of days in wet periods of at least {window} days, during which the {window_statistic} precipitation within windows of {window} days is equal or over {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.wetdays(pr='pr', *, condition='>=', thresh='1 mm/d', freq='YS', ds=None, **indexer)

Number of wet days

The number of days with daily precipitation at or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>=’, ‘>’).

Parameters:
  • pr (str or DataArray) – Surface precipitation flux (all phases). Default: ‘pr’. [Required units : [precipitation]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘1 mm/d’. [Required units : ([precipitation])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_lwe_thickness_of_precipitation_amount_above_threshold, Number of days with daily precipitation at or above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with daily precipitation at or above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._precip.wetdays_prop(pr='pr', *, thresh='1.0 mm/day', freq='YS', condition='>=', ds=None, **indexer)

Proportion of wet days

The proportion of days with daily precipitation at or above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function wetdays_prop().

Parameters:
  • pr (str or DataArray) – Daily precipitation. Default: ‘pr’. [Required units : [precipitation]]

  • thresh (quantity (string or DataArray, with units)) – Precipitation value over which a day is considered wet. Default: ‘1.0 mm/day’. [Required units : [precipitation]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>=”. Default: ‘>=’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [1] – Proportion of days with precipitation at or above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} proportion of days with precipitation at or above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._synoptic module

Synoptic indicator definitions.

xclim.indicators.atmos._synoptic.jetstream_metric_woollings(ua='ua', *, ds=None)

Strength and latitude of jetstream

Identify latitude and strength of maximum smoothed zonal wind speed in the region from 15 to 75°N and -60 to 0°E, using the formula outlined in [Woollings et al., 2010]. Wind is smoothened using a Lanczos filter approach.

Based on function jetstream_metric_woollings().

Parameters:
  • ua (str or DataArray) – Eastward wind component (u) at between 750 and 950 hPa. Default: ‘ua’. [Required units : [speed]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

  • jetlat (xarray.DataArray, [degrees_north]) – Latitude of maximum smoothed zonal wind speed. With additional attributes: description: Daily latitude of maximum Lanczos smoothed zonal wind speed.

  • jetstr (xarray.DataArray, [m s-1]) – Maximum strength of smoothed zonal wind speed. With additional attributes: description: Daily maximum strength of Lanczos smoothed zonal wind speed.

Return type:

tuple[xarray.DataArray, xarray.DataArray]

References

Woollings, Hannachi, and Hoskins [2010]

xclim.indicators.atmos._temperature module

Temperature indicator definitions.

xclim.indicators.atmos._temperature.australian_hardiness_zones(tasmin='tasmin', *, window=30, freq='YS', ds=None)

Australian hardiness zones

A climate indice based on a multi-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The Australian National Botanical Gardens (ANBG) classification scheme divides categories into 5-degree Celsius zones, starting from -15 degrees Celsius and ending at 20 degrees Celsius.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function hardiness_zones(). With injected parameters: method=anbg.

Parameters:
  • tasmin (str or DataArray) – Minimum temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • window (number) – The length of the averaging window, in years. Default: 30.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [dimensionless] – Hardiness zones. With additional attributes: description: A climate indice based on a {window}-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The Australian National Botanical Gardens (ANBG) classification scheme divides categories into 5-degree Celsius zones, starting from -15 degrees Celsius and ending at 20 degrees Celsius.

Return type:

xarray.DataArray

References

Dawson [1991], USDA Agricultural Research Service [2012]

xclim.indicators.atmos._temperature.biologically_effective_degree_days(tasmin='tasmin', tasmax='tasmax', lat='lat', *, thresh_tasmin='10 degC', method='gladstones', cap_value=1.0, low_dtr='10 degC', high_dtr='13 degC', max_daily_degree_days='9 degC', start_date='04-01', end_date='11-01', freq='YS', ds=None)

Biologically effective degree days

Considers daily minimum and maximum temperature with a given base threshold between 1 April and 31 October, with a maximum daily value for cumulative degree days (typically 9°C), and integrates modification coefficients for latitudes between 40°N and 50°N as well as for swings in daily temperature range. Metric originally published in Gladstones (1992).

This indicator will check for missing values according to the method “from_context”. Based on function biologically_effective_degree_days().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • lat (str or DataArray) – Latitude coordinate. If None and method is not “icclim”, a CF-conformant “latitude” field must be available within the passed DataArray. Default: ‘lat’. [Required units : []]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The minimum temperature threshold. Default: ‘10 degC’. [Required units : [temperature]]

  • method ({‘jones’, ‘icclim’, ‘huglin’, ‘gladstones’, ‘interpolated’}) – The formula to use for the daily temperature range and latitude coefficient. The “gladstones” method uses a temperature range adjustment and a latitude coefficient based on Gladstones [2011]. End_date should be “11-01” for the Northern Hemisphere. The “huglin” method uses a temperature range adjustment and a stepwise latitude coefficient for values between 40° and 50° based on Huglin [1978]. End_date should be “11-01” for the Northern Hemisphere. The “icclim” method does not implement daily temperature range and nor a latitude coefficient based on Project team ECA&D and KNMI [2013]. End date should be “10-01” for the Northern Hemisphere. The “interpolated” method uses a temperature range adjustment and a smoothed curve latitude coefficient for values between 40° and 50° based on Huglin [1978]. The “jones” method uses a temperature range adjustment and integrates axial tilt, latitude, and day-of-year based on Hall and Jones [2010]. End_date should be “11-01” for the Northern Hemisphere. Default: ‘gladstones’.

  • cap_value (number) – The value to use for the latitude coefficient for latitudes north of 50°N or south of 50°S. Only applicable for methods “huglin” and “interpolated”. Default: 1.0.

  • low_dtr (quantity (string or DataArray, with units)) – The lower bound for daily temperature range adjustment. Default: ‘10 degC’. [Required units : [temperature]]

  • high_dtr (quantity (string or DataArray, with units)) – The higher bound for daily temperature range adjustment. Default: ‘13 degC’. [Required units : [temperature]]

  • max_daily_degree_days (quantity (string or DataArray, with units)) – The maximum number of biologically effective degrees days that can be summed daily. Default: ‘9 degC’. [Required units : [temperature]]

  • start_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = April, south = October). Default: ‘04-01’.

  • end_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = October, south = April). This date is non-inclusive. Default: ‘11-01’.

  • freq (offset alias (string)) – Resampling frequency (For Southern Hemisphere, should be “YS-JUL”). Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [K days] – Integral of mean daily temperature above {thresh_tasmin}, with maximum value of {max_daily_degree_days}, multiplied by day-length coefficient and temperature range modifier based on {method} method for days between {start_date} and {end_date}. With additional attributes: description: Heat-summation index for agroclimatic suitability estimation, developed specifically for viticulture. Computed with {method} formula (Summation of min((max((Tn + Tx)/2 - {thresh_tasmin}, 0) * k) + TR_adj, Dmax), where coefficient `k` is a latitude-based day-length for days between {start_date} and {end_date}), coefficient `TR_adj` is a modifier accounting for large temperature swings, and `Dmax` is the maximum possibleamount of degree days that can be gained within a day ({max_daily_degree_days}).

Return type:

xarray.DataArray

Notes

Lat coordinate must be provided if method is “gladstones”, “gladstones_simple”, or “huglin”; The “icclim” method for BEDD here differs from the approach detailed in the Heliothermal Index of Huglin (HI) by not considering the latitude coefficient.

The tasmax ceiling of 19°C is assumed to be the maximum temperature beyond which no further gains from warmer daily temperatures occur. Index originally published in Gladstones [1992].

Let \(TX_{i}\) and \(TN_{i}\) be the daily maximum and minimum temperature at day \(i\), \(lat\) the latitude of the point of interest, \(degdays_{max}\) the maximum amount of degrees that can be summed per day (typically, 9). Then the sum of daily biologically effective growing degree day (BEDD) units between 1 April and 31 October is:

\[BEDD_i = \sum_{i=\text{April 1}}^{\text{October 31}} min\left( \left( max\left( \frac{TX_i + TN_i)}{2} - 10, 0 \right) * k \right) + TR_{adj}, degdays_{max} \right)\]
\[\begin{split}TR_{adj} = f(TX_{i}, TN_{i}) = \begin{cases} 0.25(TX_{i} - TN_{i} - 13), & \text{if } (TX_{i} - TN_{i}) > 13 \\ 0, & \text{if } 10 < (TX_{i} - TN_{i}) < 13\\ 0.25(TX_{i} - TN_{i} - 10), & \text{if } (TX_{i} - TN_{i}) < 10 \\ \end{cases}\end{split}\]
\[k = f(lat) = 1 + \left( \frac{\left| lat \right|}{50} * 0.06, \text{if }40 < |lat| <50, \text{else } 0\right)\]

An alternative version of the BEDD (method=”icclim”) does not consider \(TR_{adj}\) and \(k\) and employs a different end date (30 September) [Project team ECA&D and KNMI, 2013]. The simplified formula is as follows:

\[BEDD_i = \sum_{i=\text{April 1}}^{ \text{September 30} } min\left( max\left( \frac{TX_i + TN_i)}{2} - 10, 0 \right), degdays_{max} \right)\]

References

Gladstones [1992], Hall and Jones [2010], Huglin and Schneider [1998], Project team ECA&D and KNMI [2013]

xclim.indicators.atmos._temperature.chill_portions(tas='tas', *, freq='YS', ds=None, **indexer)

Chill portions

Chill portions are a measure to estimate the bud breaking potential of different crops. The constants and functions are taken from Luedeling et al. (2009) which formalises the method described in Fishman et al. (1987). The model computes the accumulation of cold temperatures in a two-step process. First, cold temperatures contribute to an intermediate product that is transformed to a chill portion once it exceeds a certain concentration. The intermediate product can be broken down at higher temperatures but the final product is stable even at higher temperature. Thus the dynamic model is more accurate than other chill models like the Chilling hours or Utah model, especially in moderate climates like Israel, California or Spain.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function chill_portions().

Parameters:
  • tas (str or DataArray) – Hourly temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.compute.generic.select_time().

Returns:

xarray.DataArray, [unitless] – Chill portions after the Dynamic Model. With additional attributes: cell_methods: time: sum, description: Chill portions are a measure to estimate the bud breaking potential of different crops. The constants and functions are taken from Luedeling et al. (2009) which formalises the method described in Fishman et al. (1987).

Return type:

xarray.DataArray

Notes

Typically, this indicator is computed for a period of the year. You can use the **indexer arguments of select_time in combination with the freq argument to select e.g. a winter period:

cp = chill_portions(tas, date_bounds=("09-01", "03-30"), freq="YS-JUL")

Note that incomplete periods will lead to NaNs.

References

Fishman, Erez, and Couvillon [1987], Luedeling [2012]

xclim.indicators.atmos._temperature.chill_units(tas='tas', *, positive_only=False, freq='YS', ds=None, **indexer)

Chill units

Chill units are a measure to estimate the bud breaking potential of different crop based on Richardson et al. [1974]. The Utah model assigns a weight to each hour depending on the temperature recognising that high temperatures can actual decrease, the potential for bud breaking. Providing positive_only=True will ignore days with negative chill units.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function chill_units().

Parameters:
  • tas (str or DataArray) – Hourly temperature. Default: ‘tas’. [Required units : [temperature]]

  • positive_only (boolean) – If True, only positive daily chill units are aggregated. Default: False.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – Chill units after the Utah Model. With additional attributes: cell_methods: time: sum, description: Chill units are a measure to estimate the bud breaking potential of different crops based on the Utah model developed in Richardson et al. (1974). The Utah model assigns a weight to each hour depending on the temperature recognising that high temperatures can actually decrease the potential for bud breaking.

Return type:

xarray.DataArray

References

Richardson, Seeley, and Walker [1974]

xclim.indicators.atmos._temperature.cold_spell_days(tas='tas', *, window=5, condition='<', thresh, freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell days

The number of days that are part of a cold spell. A cold spell is defined as a minimum number of consecutive days with mean daily temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=sum, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 5.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Required. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – cold_spell_days, Total number of days constituting events of at least {window} consecutive days where the mean daily temperature is below {thresh}. With additional attributes: description: {freq} number of days that are part of a cold spell. A cold spell is defined as {window} or more consecutive days with mean daily temperature below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.cold_spell_duration_index(tasmin='tasmin', tasmin_per='tasmin_per', *, window=6, freq='YS', resample_before_rl=True, bootstrap=False, condition='<', ds=None)

Cold Spell Duration Index (CSDI)

Number of days part of a percentile-defined cold spell. A cold spell occurs when the daily minimum temperature is below a given percentile for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function cold_spell_duration_index().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmin_per (str or DataArray) – The nth percentile of daily minimum temperature with dayofyear coordinate. Default: ‘tasmin_per’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperature below threshold to qualify as a cold spell. Default: 6.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Keep bootstrap to False when there is no common period, as bootstrapping is computationally expensive, and it might provide the wrong results. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – cold_spell_duration_index, Total number of days constituting events of at least {window} consecutive days where the daily minimum temperature is below the {tasmin_per_thresh}th percentile. With additional attributes: description: {freq} number of days with at least {window} consecutive days where the daily minimum temperature is below the {tasmin_per_thresh}th percentile. A {tasmin_per_window} day(s) window, centred on each calendar day in the {tasmin_per_period} period, is used to compute the {tasmin_per_thresh}th percentile(s).

Return type:

xarray.DataArray

Notes

Let \(TN_i\) be the minimum daily temperature for the day of the year \(i\) and \(TN10_i\) the 10th percentile of the minimum daily temperature over the 1961-1990 period for day of the year \(i\), the cold spell duration index over period \(\phi\) is defined as:

\[\sum_{i \in \phi} \prod_{j=i}^{i+6} \left[ TN_j < TN10_j \right]\]

where \([P]\) is 1 if \(P\) is true, and 0 if false.

References

From the Expert Team on Climate Change Detection, Monitoring and Indices (ETCCDMI; [Zhang et al., 2011]).

xclim.indicators.atmos._temperature.cold_spell_frequency(tas='tas', *, window=5, condition='<', thresh='-10 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell frequency

The frequency of cold periods of N days or more, during which the temperature over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=count, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 5.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of cold periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is below {thresh}.. With additional attributes: description: The {freq} number of cold periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.cold_spell_max_length(tas='tas', *, window=1, condition='<', thresh='-10 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell maximum length

The maximum length of a cold period of N days or more, during which the temperature over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=max, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 1.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a cold period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is under {thresh}.. With additional attributes: description: The maximum {freq} number of consecutive days in a cold period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.cold_spell_total_length(tas='tas', *, window=3, condition='<', thresh='-10 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Cold spell total length

The total length of cold periods of N days or more, during which the temperature over a given time window of days is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=sum, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in cold periods of {window} day(s) or more, during which thetemperature within windows of {window} day(s) is under {thresh}.. With additional attributes: description: The {freq} number of days in cold periods of {window} day(s) or more, during which the temperature within windows of {window} day(s) is under {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.consecutive_frost_days(tasmin='tasmin', *, condition='<', thresh='0 degC', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Consecutive frost days

Maximum number of consecutive days where the daily minimum temperature is below a given threshold

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=max, statistic=max, min_gap=1, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_below_threshold, Maximum number of consecutive days where minimum daily temperature is {condition} {thresh}. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum number of consecutive days where minimum daily temperature is {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.cool_night_index(tasmin='tasmin', lat=None, *, freq='YS', ds=None)

Cool night index

A night coolness variable which takes into account the mean minimum night temperatures during the month when ripening usually occurs beyond the ripening period.

This indicator will check for missing values according to the method “from_context”. Based on function cool_night_index().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • lat (str or DataArray, optional) – Latitude coordinate as an array, float or string. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: None.

  • freq ({‘YS-JAN’, ‘YS’}) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [degC] – Mean minimum temperature in late summer. With additional attributes: cell_methods: time: mean over days, description: Mean minimum temperature for September (Northern hemisphere) or March (Southern hemisphere).

Return type:

xarray.DataArray

Notes

Given that this index only examines September and March months, it is possible to send in DataArrays containing only these timesteps. Users should be aware that due to the missing values checks in wrapped Indicators, datasets that are missing several months will be flagged as invalid. This check can be ignored by setting the following context:

with xclim.set_options(check_missing="skip"):
    cni = cool_night_index(tasmin)

References

Tonietto and Carbonneau [2004]

xclim.indicators.atmos._temperature.cooling_degree_days(tas='tas', *, thresh='18.0 degC', freq='YS', ds=None, **indexer)

Cooling degree days

The cumulative degree days for days when the mean daily temperature is above a given threshold and buildings must be air conditioned.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=>.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘18.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for mean daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative cooling degree days (mean temperature above {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.cooling_degree_days_approximation(tasmax='tasmax', tasmin='tasmin', tas='tas', *, thresh='18.0 degC', freq='YS', ds=None, **indexer)

Cooling degree days approximation

The cumulative degree days for days when temperatures are above a given threshold and buildings must be air conditioned. This method integrates mean, minimum, and maximum temperatures, accounting for asymmetry in the distributions of temperatures throughout the diurnal cycle.

This indicator will check for missing values according to the method “from_context”. Based on function degree_days_above_approximation().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Temperature threshold above which degree days are accumulated. Default: ‘18.0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for daily temperatures above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative cooling degree days (temperature above {thresh}) using a combination of minimum, maximum, and mean daily temperatures.

Return type:

xarray.DataArray

Notes

For each day, the integrated quantity depends on where the threshold lies in relation to the 3 temperature statistics.

  • thresh > tasmax : 0

  • tasmax >= thresh > tas : (tasmax - thresh) / 4

  • tas >= thresh > tasmin : (tasmax - thresh) / 2 - (thresh - tasmin) / 4,

  • `` tasmin > thresh`` : (tas - thresh).

References

Spinoni, Vogt, Barbosa, Dosio, McCormick, Bigano, and Füssel [2018]

xclim.indicators.atmos._temperature.corn_heat_units(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='4.44 degC', thresh_tasmax='10 degC', ds=None)

Corn heat units

A temperature-based index used to estimate the development of corn crops. Corn growth occurs when the daily minimum and maximum temperatures exceed given thresholds.

Based on function corn_heat_units().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The minimum temperature threshold needed for corn growth. Default: ‘4.44 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The maximum temperature threshold needed for corn growth. Default: ‘10 degC’. [Required units : [temperature]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [unitless] – Corn heat units (Tmin > {thresh_tasmin} and Tmax > {thresh_tasmax}). With additional attributes: description: Temperature-based index used to estimate the development of corn crops. Corn growth occurs when the minimum and maximum daily temperatures both exceed {thresh_tasmin} and {thresh_tasmax}, respectively.

Return type:

xarray.DataArray

Notes

Formula used in calculating the Corn Heat Units for the Agroclimatic Atlas of Quebec [Audet et al., 2012].

The thresholds of 4.44°C for minimum temperatures and 10°C for maximum temperatures were selected following the assumption that no growth occurs below these values.

Let \(TX_{i}\) and \(TN_{i}\) be the daily maximum and minimum temperature at day \(i\). Then the daily corn heat unit is:

\[CHU_i = \frac{YX_{i} + YN_{i}}{2}\]

with

\[\begin{split}\begin{aligned} YX_i &= 3.33(TX_i - 10) - 0.084(TX_i - 10)^2, &\text{if } TX_i > 10^\circ\mathrm{C} \\ YN_i &= 1.8(TN_i - 4.44), &\text{if } TN_i > 4.44^\circ\mathrm{C} \end{aligned}\end{split}\]

Where \(YX_{i}\) and \(YN_{i}\) is 0 when \(TX_i \leq 10°C\) and \(TN_i \leq 4.44°C\), respectively.

References

Audet, Côté, Bachand, and Mailhot [2012], Bootsma, Tremblay, and Filion [1999]

xclim.indicators.atmos._temperature.daily_freezethaw_cycles(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', condition_tasmin='<=', condition_tasmax='>', freq='YS', resample_before_rl=True, ds=None, **indexer)

Daily freeze-thaw cycles

The number of days with a freeze-thaw cycle. A freeze-thaw cycle is defined as a day where maximum daily temperature is above a given threshold and minimum daily temperature is at or below a given threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: window=1, statistic=sum.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • condition_tasmin ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation for tasmin. Default: “<=”. Default: ‘<=’.

  • condition_tasmax ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation for tasmax. Default: “>”. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [days] – Number of days where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin}. With additional attributes: description: {freq} number of days with a diurnal freeze-thaw cycle, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin}.

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos._temperature.daily_temperature_range(tasmin='tasmin', tasmax='tasmax', *, statistic='mean', freq='YS', ds=None, **indexer)

Mean of daily temperature range

The average difference between the daily maximum and minimum temperatures.

This indicator will check for missing values according to the method “from_context”. Based on function difference_statistics(). With injected parameters: absolute=False.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • statistic ({‘min’, ‘sum’, ‘max’, ‘mean’}) – The statistic to compute over the difference between the two variables. Default: ‘mean’.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean diurnal temperature range. With additional attributes: cell_methods: time range within days time: mean over days, description: {freq} mean diurnal temperature range.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.daily_temperature_range_variability(tasmin='tasmin', tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Variability of daily temperature range

The average day-to-day variation in daily temperature range.

This indicator will check for missing values according to the method “from_context”. Based on function interday_difference_statistics(). With injected parameters: statistic=mean, absolute=False.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after differentiating along time.

Returns:

xarray.DataArray, [K] – air_temperature, Mean diurnal temperature range variability. With additional attributes: cell_methods: time range within days time: difference over days time: mean over days, description: {freq} mean diurnal temperature range variability, defined as the average day-to-day variation in daily temperature range for the given time period.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.day_to_day_temperature_variability(tas='tas', *, freq='YS', ds=None, **indexer)

Day-to-day temperature variability

Computes the standard deviation of the variable within each sub-period (e.g. month), then averages those standard deviations over the main resampling period (e.g. year). This provides a measure of typical day-to-day variability as described in Kotz et al. [2021].

This indicator will check for missing values according to the method “from_context”. Based on function day_to_day_variability(). With injected parameters: subfreq=MS.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency used to average the sub-period standard deviations. Default is "YS" (yearly). Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – Mean of the day-to-day temperature variability. With additional attributes: cell_methods: time: standard_deviation within months time: mean over months, description: {freq} mean of the day-to-day variability computed as the {subfreq} standard deviation

Return type:

xarray.DataArray

References

Kotz, Wenz, Stechemesser, Kalkuhl, and Levermann [2021]

xclim.indicators.atmos._temperature.degree_days_exceedance_date(tas='tas', *, thresh='0 degC', sum_thresh='25 K days', condition='>', after_date=None, never_reached=None, freq='YS', ds=None)

Degree day exceedance date

The day of the year when the sum of degree days exceeds a threshold, occurring after a given date. Degree days are calculated above or below a given temperature threshold.

This indicator will check for missing values according to the method “from_context”. Based on function degree_days_exceedance_date().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold temperature on which to base degree-days evaluation. Default: ‘0 degC’. [Required units : [temperature]]

  • sum_thresh (quantity (string or DataArray, with units)) – Threshold of the degree days sum. Default: ‘25 K days’. [Required units : K days]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – If equivalent to ‘>’, degree days are computed as tas - thresh and if equivalent to ‘<’, they are computed as thresh - tas. Default: ‘>’.

  • after_date (date (string, MM-DD)) – Date at which to start the cumulative sum. In “MM-DD” format, defaults to the start of the sampling period. Default: None.

  • never_reached (date (string, MM-DD)) – What to do when sum_thresh is never exceeded. If an int, the value to assign as a day-of-year. If a string, must be in “MM-DD” format, the day-of-year of that date is assigned. Default (None) assigns “NaN”. Default: None.

  • freq (offset alias (string)) – Resampling frequency. If after_date is given, freq should be annual. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Day of year when the integral of mean daily temperature {condition} {thresh} exceeds {sum_thresh}. With additional attributes: description: <function <lambda> at 0x7c95fe5313a0>

Return type:

xarray.DataArray

Notes

Let \(TG_{ij}\) be the daily mean temperature at day \(i\) of period \(j\), \(T\) is the reference threshold and \(ST\) is the sum threshold. Then, starting at day :math:i_0:, the degree days exceedance date is the first day \(k\) such that:

\[\begin{split}\begin{cases} ST < \sum_{i=i_0}^{k} \max(TG_{ij} - T, 0) & \text{if $condition$ is '>' | '>='} \\ ST < \sum_{i=i_0}^{k} \max(T - TG_{ij}, 0) & \text{if $condition$ is '<' | '<='} \end{cases}\end{split}\]

The resulting \(k\) is expressed as a day of year.

Cumulated degree days have numerous applications including plant and insect phenology. See: https://en.wikipedia.org/wiki/Growing_degree-day for examples (Wikipedia Contributors [2021]).

xclim.indicators.atmos._temperature.extreme_temperature_range(tasmin='tasmin', tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Extreme temperature range

The maximum of the maximum temperature minus the minimum of the minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function extreme_range().

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Intra-period extreme temperature range. With additional attributes: description: {freq} range between the maximum of daily maximum temperature and the minimum of dailyminimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.fire_season(tas='tas', snd=None, *, method='WF93', freq=None, temp_start_thresh='12 degC', temp_end_thresh='5 degC', temp_condition_days=3, snow_condition_days=3, snow_thresh='0.01 m', ds=None)

Fire season mask.

Binary mask of the active fire season, defined by conditions on consecutive daily temperatures and, optionally, snow depths.

Based on function fire_season().

Parameters:
  • tas (str or DataArray) – Daily surface temperature, cffdrs recommends using maximum daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • snd (str or DataArray, optional) – Snow depth, used with method == ‘LA08’. Default: None. [Required units : [length]]

  • method ({‘LA08’, ‘GFWED’, ‘WF93’}) – Which method to use. “LA08” and “GFWED” need the snow depth. Default: ‘WF93’.

  • freq (offset alias (string)) – If given only the longest fire season for each period defined by this frequency, Every “seasons” are returned if None, including the short shoulder seasons. Default: None.

  • temp_start_thresh (quantity (string or DataArray, with units)) – Minimal temperature needed to start the season. Must be scalar. Default: ‘12 degC’. [Required units : [temperature]]

  • temp_end_thresh (quantity (string or DataArray, with units)) – Maximal temperature needed to end the season. Must be scalar. Default: ‘5 degC’. [Required units : [temperature]]

  • temp_condition_days (number) – Number of days with temperature above or below the thresholds to trigger a start or an end of the fire season. Default: 3.

  • snow_condition_days (number) – Parameters for the fire season determination. See fire_season(). Temperature is in degC, snow in m. The snow_thresh parameters is also used when dry_start is set to “GFWED”. Default: 3.

  • snow_thresh (quantity (string or DataArray, with units)) – Minimal snow depth level to end a fire season, only used with method “LA08”. Must be scalar. Default: ‘0.01 m’. [Required units : [length]]

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray – Fire season mask.. With additional attributes: description: Fire season mask, computed with method {method}.

Return type:

xarray.DataArray

References

Lawson and Armitage [2008], Wotton and Flannigan [1993]

xclim.indicators.atmos._temperature.first_day_tg_above(tas='tas', *, condition='>', thresh='0 degC', freq='YS', window=1, ds=None, after_date='01-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of mean temperature above {thresh}. With additional attributes: description: First day of year with mean temperature above {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.first_day_tg_below(tas='tas', *, condition='<', thresh='0 degC', freq='YS', window=1, ds=None, after_date='07-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of mean temperature below {thresh}. With additional attributes: description: First day of year with mean temperature below {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.first_day_tn_above(tasmin='tasmin', *, condition='>', thresh='0 degC', freq='YS', window=1, ds=None, after_date='01-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of minimum temperature above {thresh}. With additional attributes: description: First day of year with minimum temperature above {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.first_day_tn_below(tasmin='tasmin', *, condition='<', thresh='0 degC', freq='YS', window=1, ds=None, after_date='07-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of minimum temperature below {thresh}. With additional attributes: description: First day of year with minimum temperature below {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.first_day_tx_above(tasmax='tasmax', *, condition='>', thresh='0 degC', freq='YS', window=1, ds=None, after_date='01-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of maximum temperature above {thresh}. With additional attributes: description: First day of year with maximum temperature above {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.first_day_tx_below(tasmax='tasmax', *, condition='<', thresh='0 degC', freq='YS', window=1, ds=None, after_date='07-01', **indexer)

First or last day of values fulfilling a condition.

Returns first or last day of period where values meet a given condition for a minimum number of consecutive days, limited to a starting or ending calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day of year with a period of at least {window} days of maximum temperature below {thresh}. With additional attributes: description: First day of year with maximum temperature below {thresh} for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.freezethaw_spell_frequency(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', window=1, condition_tasmin='<=', condition_tasmax='>', freq='YS', resample_before_rl=True, ds=None, **indexer)

Freeze-thaw spell frequency

Frequency of daily freeze-thaw spells. A freeze-thaw spell is defined as a number of consecutive days where maximum daily temperatures are above a given threshold and minimum daily temperatures are at or below a given threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: statistic=count.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • window (number) – The minimal length of spells to be included in the statistics. Default: 1.

  • condition_tasmin ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation for tasmin. Default: “<=”. Default: ‘<=’.

  • condition_tasmax ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation for tasmax. Default: “>”. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [time] – Frequency of events where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).. With additional attributes: description: {freq} number of freeze-thaw spells, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos._temperature.freezethaw_spell_max_length(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', window=1, condition_tasmin='<=', condition_tasmax='>', freq='YS', resample_before_rl=True, ds=None, **indexer)

Maximal length of freeze-thaw spells

Maximal length of daily freeze-thaw spells. A freeze-thaw spell is defined as a number of consecutive days where maximum daily temperatures are above a given threshold and minimum daily temperatures are at or below a threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: statistic=max.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • window (number) – The minimal length of spells to be included in the statistics. Default: 1.

  • condition_tasmin ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation for tasmin. Default: “<=”. Default: ‘<=’.

  • condition_tasmax ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation for tasmax. Default: “>”. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [days] – Maximal length of events where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).. With additional attributes: description: {freq} maximal length of freeze-thaw spells, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos._temperature.freezethaw_spell_mean_length(tasmin='tasmin', tasmax='tasmax', *, thresh_tasmin='0 degC', thresh_tasmax='0 degC', window=1, freq='YS', resample_before_rl=True, ds=None, **indexer)

Freeze-thaw spell mean length

Average length of daily freeze-thaw spells. A freeze-thaw spell is defined as a number of consecutive days where maximum daily temperatures are above a given threshold and minimum daily temperatures are at or below a given threshold, usually 0°C for both.

This indicator will check for missing values according to the method “from_context”. Based on function multiday_temperature_swing(). With injected parameters: statistic=mean, condition_tasmin=<=, condition_tasmax=>.

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh_tasmin (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a freeze event. Default: ‘0 degC’. [Required units : [temperature]]

  • thresh_tasmax (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a thaw event. Default: ‘0 degC’. [Required units : [temperature]]

  • window (number) – The minimal length of spells to be included in the statistics. Default: 1.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Subsetting is done after finding the events, but before computing the statistic over them.

Returns:

xarray.DataArray, [days] – Average length of events where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).. With additional attributes: description: {freq} average length of freeze-thaw spells, where maximum daily temperatures are above {thresh_tasmax} and minimum daily temperatures are at or below {thresh_tasmin} for at least {window} consecutive day(s).

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) be the maximum temperature at day \(i\) and \(TN_{i}\) be the daily minimum temperature at day \(i\). Then freeze thaw spells during a given period are consecutive days where:

\[TX_{i} > 0℃ \land TN_{i} < 0℃\]

This function returns a given statistic of the found lengths, optionally dropping those shorter than window. For example, window=1 and statistic=’sum’ returns the same value as daily_freezethaw_cycles().

xclim.indicators.atmos._temperature.freezing_degree_days(tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Freezing degree days

The cumulative degree days for days when the average temperature is below a given threshold, typically 0°C.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=<.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_deficit_wrt_time, Cumulative sum of temperature degrees for mean daily temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} freezing degree days (mean temperature below {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.freshet_start(tas='tas', *, condition='>', thresh='0 degC', freq='YS', window=5, ds=None, after_date='01-01', **indexer)

Day of year of spring freshet start

Day of year of the spring freshet start, defined as the first day when the temperature exceeds a certain threshold for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=first, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 5.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • after_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘01-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, First day where temperature threshold of {thresh} is exceeded for at least {window} days. With additional attributes: description: Day of year of the spring freshet start, defined as the first day a temperature threshold of {thresh} is exceeded for at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.frost_days(tasmin='tasmin', *, thresh='0 °C', freq='YS', ds=None, **indexer)

Frost days

Number of days where the daily minimum temperature is below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days where the daily minimum temperature is below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the daily minimum temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.frost_free_season_end(tasmin='tasmin', *, condition='>=', thresh='0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Frost free season end

First day when the temperature is below a given threshold for a given number of consecutive days after a median calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=end, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day, after {mid_date}, following a period of {window} days with minimum daily temperature below {thresh}. With additional attributes: description: Day of the year of the end of the frost-free season, defined as the interval between the first set of {window} days when the minimum daily temperature is at or above {thresh} and the first set (after {mid_date}) of {window} days when it is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.frost_free_season_length(tasmin='tasmin', *, condition='>=', thresh='0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Frost free season length

Duration of the frost free season, defined as the period when the minimum daily temperature is above 0°C without a freezing window of N days, with freezing occurring after a median calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=length, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} after {mid_date}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.frost_free_season_start(tasmin='tasmin', *, condition='>=', thresh='0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Frost free season start

First day when minimum daily temperature exceeds a given threshold for a given number of consecutive days

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=start, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day following a period of {window} days with minimum daily temperature at or above {thresh}. With additional attributes: description: Day of the year of the beginning of the frost-free season, defined as the {window}th consecutive day when minimum daily temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.frost_free_spell_max_length(tasmin='tasmin', *, window=1, condition='>=', thresh='0 °C', freq='YS-JUL', resample_before_rl=True, ds=None, **indexer)

Frost free spell maximum length

The maximum length of a frost free period of N days or more, during which the minimum temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=max, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 1.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a frost free period of {window} day(s) or more, during which the minimum temperature within windows of {window} day(s) is above {thresh}.. With additional attributes: description: The maximum {freq} number of consecutive days in a frost free period of {window} day(s) or more, during which the minimum temperature within windows of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.frost_season_length(tasmin='tasmin', *, condition='<', thresh='0 degC', window=5, freq='YS-JUL', mid_date='01-01', ds=None, **indexer)

Frost season length

Duration of the freezing season, defined as the period when the daily minimum temperature is below 0°C without a thawing window of days, with the thaw occurring after a median calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=length, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS-JUL’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘01-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} after {mid_date}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days between the first occurrence of at least {window} consecutive days with minimum daily temperature below {thresh} and the first occurrence of at least {window} consecutive days with minimum daily temperature at or above {thresh} after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.growing_degree_days(tas='tas', *, thresh='4.0 degC', freq='YS', ds=None, **indexer)

Growing degree days

The cumulative degree days for days when the average temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=>.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘4.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for mean daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} growing degree days (mean temperature above {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.growing_season_end(tas='tas', *, condition='>=', thresh='5.0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Growing season end

The first day when the temperature is below a certain threshold for a certain number of consecutive days after a given calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=end, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘5.0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day of the first series of {window} days with mean daily temperature {condition} {thresh}, occurring after {mid_date}. With additional attributes: description: Day of year of end of growing season, defined as the first day of consistent inferior threshold temperature of {thresh} after a run of {window} days superior to threshold temperature, occurring after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.growing_season_length(tas='tas', *, condition='>=', thresh='5.0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Growing season length

Number of days between the first occurrence of a series of days with a daily average temperature above a threshold and the first occurrence of a series of days with a daily average temperature below that same threshold, occurring after a given calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=length, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘5.0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – growing_season_length, Number of days between the first occurrence of at least {window} consecutive days with mean daily temperature over {thresh} and the first occurrence of at least {window} consecutive days with mean daily temperature below {thresh}, occurring after {mid_date}. With additional attributes: description: {freq} number of days between the first occurrence of at least {window} consecutive days with mean daily temperature over {thresh} and the first occurrence of at least {window} consecutive days with mean daily temperature below {thresh}, occurring after {mid_date}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.growing_season_start(tas='tas', *, condition='>=', thresh='5.0 degC', window=5, freq='YS', mid_date='07-01', ds=None, **indexer)

Growing season start

The first day when the temperature exceeds a certain threshold for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function season(). With injected parameters: aspect=start, constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Comparison operation. Computed as data {condition} thresh. Default: ‘>=’.

  • thresh (quantity (string or DataArray, with units)) – Threshold for the condition. Default: ‘5.0 degC’. [Required units : ([temperature])]

  • window (number) – Minimum number of days that the condition must be met / not met for the start / end of the season. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • mid_date (date (string, MM-DD)) – An optional middle date. The start must happen before and the end after for the season to be valid. Default: ‘07-01’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] or [time] – day_of_year, First day of the first series of {window} days with mean daily temperature {condition} {thresh}. With additional attributes: description: Day of the year marking the beginning of the growing season, defined as the first day of the first series of {window} days with mean daily temperature {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heat_spell_frequency(tasmin='tasmin', tasmax='tasmax', *, window=3, freq='YS', min_gap=1, resample_before_rl=True, ds=None, win_reducer='mean', thresh_tasmin='20 °C', thresh_tasmax='33 °C', **indexer)

Heat spell frequency

Number of heat spells. A heat spell occurs when rolling averages of daily minimum and maximumtemperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: condition=>=, statistic=count, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • win_reducer ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘mean’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for tasmin Default: ‘20 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for tasmax Default: ‘33 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of heat spells. With additional attributes: description: {freq} number of heat spells events. A heat spell occurs when the {window}-day averages of daily minimum and maximum temperatures each exceed {thresh_tasmin} and {thresh_tasmax}. All days of the {window}-day period are considered part of the spell. Gaps of fewer than {min_gap} day(s) are allowed within a spell.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heat_spell_max_length(tasmin='tasmin', tasmax='tasmax', *, window=3, freq='YS', min_gap=1, resample_before_rl=True, ds=None, win_reducer='mean', thresh_tasmin='20 °C', thresh_tasmax='33 °C', **indexer)

Heat spell maximum length

The longest heat spell of a period. A heat spell occurs when rolling averages of daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: condition=>=, statistic=max, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • win_reducer ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘mean’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for tasmin Default: ‘20 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for tasmax Default: ‘33 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Longest heat spell. With additional attributes: description: {freq} maximum length of heat spells. A heat spell occurs when the {window}-day averages of daily minimum and maximum temperatures each exceed {thresh_tasmin} and {thresh_tasmax}. All days of the {window}-day period are considered part of the spell. Gaps of fewer than {min_gap} day(s) are allowed within a spell.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heat_spell_total_length(tasmin='tasmin', tasmax='tasmax', *, window=3, freq='YS', min_gap=1, resample_before_rl=True, ds=None, win_reducer='mean', thresh_tasmin='20 °C', thresh_tasmax='33 °C', **indexer)

Heat spell total length

Total length of heat spells. A heat spell occurs when rolling averages of daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: condition=>=, statistic=sum, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • min_gap (number) – The shortest possible gap between two spells. Spells closer than this are merged by assigning the gap steps to the merged spell. Default: 1.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • win_reducer ({‘integral’, ‘max’, ‘sum’, ‘mean’, ‘min’}) – Reduction along the window length to compute running statistic. Note that this does not matter when window is 1, in which case any occurrence of data {condition} thresh is considered a valid “spell”. Default: ‘mean’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for tasmin Default: ‘20 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for tasmax Default: ‘33 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Total length of heat spells.. With additional attributes: description: {freq} total length of heat spell events. A heat spell occurs when the {window}-day  averages of daily minimum and maximum temperatures each exceed {thresh_tasmin} and {thresh_tasmax}.  All days of the {window}-day period are considered part of the spell. Gaps of fewer than {min_gap} day(s) are allowed within a spell.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heat_wave_frequency(tasmin='tasmin', tasmax='tasmax', *, window=3, condition='>', freq='YS', resample_before_rl=True, ds=None, thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Heat wave frequency

Number of heat waves. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: window_statistic=min, statistic=count, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold to test against for data1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold to test against for data2. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Total number of series of at least {window} consecutive days with daily minimum temperature above {thresh_tasmin} and daily maximum temperature above {thresh_tasmax}. With additional attributes: description: {freq} number of heat wave events within a given period. A heat wave occurs when daily minimum and maximum temperatures exceed {thresh_tasmin} and {thresh_tasmax}, respectively, over at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heat_wave_index(tasmax='tasmax', *, thresh='25 degC', window=5, freq='YS', op='>', resample_before_rl=True, ds=None)

Heat wave index

Number of days that constitute heatwave events. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function hot_spell_total_length().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a hot spell. Default: ‘25 degC’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperatures below the threshold to qualify as a hot spell. Default: 5.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • op ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – Total number of days constituting events of at least {window} consecutive days with daily maximum temperature above {thresh}. With additional attributes: description: {freq} total number of days that are part of a heatwave within a given period. A heat wave occurs when daily maximum temperatures exceed {thresh} over at least {window} days.

Return type:

xarray.DataArray

Notes

The threshold on tasmax follows the one used in heat waves. A day temperature threshold between 30° and 35°C was selected by Health Canada professionals, following a temperature–mortality analysis. This absolute temperature threshold characterize the occurrence of hot weather events that can result in adverse health outcomes for Canadian communities [Casati et al., 2013].

In Robinson [2001] where heat waves are also considered, the corresponding parameters would be thresh=39.44, window=2 (103F).

xclim.indicators.atmos._temperature.heat_wave_max_length(tasmin='tasmin', tasmax='tasmax', *, window=3, condition='>', freq='YS', resample_before_rl=True, ds=None, thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Heat wave maximum length

Maximal duration of heat waves. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: window_statistic=min, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold to test against for data1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold to test against for data2. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Longest series of at least {window} consecutive days with daily minimum temperature above {thresh_tasmin} and daily maximum temperature above {thresh_tasmax}. With additional attributes: description: {freq} maximum length of heat wave events occurring within a given period. A heat wave occurs when daily minimum and maximum temperatures exceed {thresh_tasmin} and {thresh_tasmax}, respectively, over at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heat_wave_total_length(tasmin='tasmin', tasmax='tasmax', *, window=3, condition='>', freq='YS', resample_before_rl=True, ds=None, thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Heat wave total length

Total length of heat waves. A heat wave occurs when daily minimum and maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_spell_length_statistics(). With injected parameters: window_statistic=min, statistic=sum, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold to test against for data1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold to test against for data2. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Total length of events of at least {window} consecutive days with daily minimum temperature above {thresh_tasmin} and daily maximum temperature above {thresh_tasmax}. With additional attributes: description: {freq} total length of heat wave events occurring within a given period. A heat wave occurs when daily minimum and maximum temperatures exceed {thresh_tasmin} and {thresh_tasmax}, respectively, over at least {window} days.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heating_degree_days(tas='tas', *, thresh='17.0 degC', freq='YS', ds=None, **indexer)

Heating degree days

The cumulative degree days for days when the mean daily temperature is below a given threshold and buildings must be heated.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=<.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘17.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_deficit_wrt_time, Cumulative sum of temperature degrees for mean daily temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative heating degree days (mean temperature below {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.heating_degree_days_approximation(tasmax='tasmax', tasmin='tasmin', tas='tas', *, thresh='17.0 degC', freq='YS', ds=None, **indexer)

Heating degree days approximation

The cumulative degree days for days where temperatures are below a given threshold and buildings must be heated. This method integrates mean, minimum, and maximum temperatures, accounting for asymmetry in the distributions of temperatures throughout the diurnal cycle.

This indicator will check for missing values according to the method “from_context”. Based on function degree_days_below_approximation().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Temperature threshold below which degree days are accumulated. Default: ‘17.0 degC’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_deficit_wrt_time, Cumulative sum of temperature degrees for daily temperatures below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} cumulative heating degree days (temperature below {thresh}) using a combination of minimum, maximum, and mean daily temperatures.

Return type:

xarray.DataArray

Notes

For each day, the integrated quantity depends on where the threshold lies in relation to the 3 temperature statistics.

  • thresh > tasmax : (thresh - tas)

  • tasmax >= thresh > tas : (thresh - tasmin) / 2 - (tasmax - thresh) / 4

  • tas >= thresh > tasmin : (thresh - tasmin) / 4

  • tasmin > thresh : 0.

References

Spinoni, Vogt, Barbosa, Dosio, McCormick, Bigano, and Füssel [2018]

xclim.indicators.atmos._temperature.hot_days(tasmax='tasmax', *, thresh='25 °C', freq='YS', ds=None, **indexer)

Hot days

Number of days where the daily maximum temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=>, constrain=>.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘25 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days where the daily maximum temperature is above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the daily maximum temperature is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.hot_spell_frequency(tasmax='tasmax', *, window=3, condition='>', thresh='30 °C', freq='YS', resample_before_rl=True, ds=None, **indexer)

Hot spell frequency

The frequency of hot periods of N days or more, during which the temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=min, statistic=count, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘30 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray – Number of hot periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is above {thresh}.. With additional attributes: description: The {freq} number of hot periods of {window} day(s) or more, during which the temperature on a window of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.hot_spell_max_length(tasmax='tasmax', *, window=1, condition='>', thresh='30 °C', freq='YS', resample_before_rl=True, ds=None, **indexer)

Hot spell maximum length

The maximum length of a hot period of N days or more, during which the temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=min, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 1.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘30 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Maximum consecutive number of days in a hot period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is above {thresh}.. With additional attributes: description: The maximum {freq} number of consecutive days in a hot period of {window} day(s) or more, during which the temperature within windows of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.hot_spell_max_magnitude(tasmax='tasmax', *, thresh='25.0 degC', window=3, freq='YS', resample_before_rl=True, ds=None)

Hot spell maximum magnitude

Magnitude of the most intensive heat wave per {freq}. A heat wave occurs when daily maximum temperatures exceed given thresholds for a number of days.

This indicator will check for missing values according to the method “from_context”. Based on function hot_spell_max_magnitude().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold temperature on which to designate a heatwave. Default: ‘25.0 degC’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperature above the threshold to qualify as a heatwave. Default: 3.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [K d] – Maximum cumulative difference between daily maximum temperature and {thresh} for days within a heat wave. A heat wave is defined as a series of at least {window} consecutive days with daily maximum temperature above {thresh}.. With additional attributes: description: Magnitude of the most intensive heat wave per {freq}. The magnitude is the cumulative exceedance of daily maximum temperature over {thresh}. A heat wave is defined as a series of at least {window} consecutive days with daily maximum temperature above {thresh}

Return type:

xarray.DataArray

References

Russo, Dosio, Graversen, Sillmann, Carrao, Dunbar, Singleton, Montagna, Barbola, and Vogt [2014], Zhang, She, Zhang, Wang, Chen, and Hao [2022].

xclim.indicators.atmos._temperature.hot_spell_total_length(tasmax='tasmax', *, window=3, condition='>', thresh='30 °C', freq='YS', resample_before_rl=True, ds=None, **indexer)

Hot spell total length

The total length of hot periods of N days or more, during which the temperature over a given time window of days is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window_statistic=min, statistic=sum, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • window (number) – Minimum length of a spell. Default: 3.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘30 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – Number of days in hot periods of {window} day(s) or more, during which thetemperature within windows of {window} day(s) is above {thresh}.. With additional attributes: description: The {freq} number of days in hot periods of {window} day(s) or more, during which the temperature within windows of {window} day(s) is above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.huglin_index(tas='tas', tasmax='tasmax', lat='lat', *, thresh='10 degC', method='jones', cap_value=1.0, start_date='04-01', end_date='10-01', freq='YS', ds=None)

Huglin heliothermal index

Heat-summation index for agroclimatic suitability estimation, developed specifically for viticulture. Considers daily minimum and maximum temperature with a given base threshold, typically between 1 April and 30September, and integrates a day-length coefficient calculation for higher latitudes. Metric originally published in Huglin (1978). Day-length coefficient based on Hall & Jones (2010).

This indicator will check for missing values according to the method “from_context”. Based on function huglin_index().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • lat (str or DataArray) – Latitude coordinate. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: ‘lat’. [Required units : []]

  • thresh (quantity (string or DataArray, with units)) – The temperature threshold. Default: “10 degC”. Default: ‘10 degC’. [Required units : [temperature]]

  • method ({‘jones’, ‘huglin’, ‘interpolated’}) – The formula to use for the latitude coefficient calculation. The “huglin” method uses a stepwise latitude coefficient for values between 40° and 50° based on Huglin [1978]. The “interpolated” method uses a smoothed curve latitude coefficient for values based on the intervals set in Huglin [1978]. The “jones” method integrates axial tilt, latitude, and day-of-year based on Hall and Jones [2010]. Default: ‘jones’.

  • cap_value (number) – The value to use for the latitude coefficient when latitude is above 50°N or below 50°S. Only applicable for methods “huglin” and “interpolated” (default: 1.0). Default: 1.0.

  • start_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = April, south = October). Default: ‘04-01’.

  • end_date (date (string, MM-DD)) – The hemisphere-based start date to consider (north = October, south = April). This date is non-inclusive. Default: ‘10-01’.

  • freq ({‘YS-JAN’, ‘YS’, ‘YS-JUL’}) – Resampling frequency (default: “YS”; For Southern Hemisphere, should be “YS-JUL”). Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [unitless] – Integral of mean daily temperature above {thresh} multiplied by day-length coefficient with {method} method for days between {start_date} and {end_date}. With additional attributes: description: Heat-summation index for agroclimatic suitability estimation, developed specifically for viticulture, computed with {method} formula (Summation of ((Tn + Tx)/2 - {thresh}) * k), where coefficient `k` is a latitude-based day-length for days between {start_date} and {end_date}.

Return type:

xarray.DataArray

Notes

Let \(TX_{i}\) and \(TG_{i}\) be the daily maximum and mean temperature at day \(i\) and \(T_{thresh}\) the base threshold needed for heat summation (typically, 10 degC). A day-length multiplication, \(k\), based on latitude, \(lat\), is also considered. Then the heliothermal index for dates between 1 April and 30 September is:

\[HI = \sum_{i=\text{April 1}}^{\text{September 30}} \left(\frac{TX_i + TG_i}{2} - T_{thresh} \right) * k\]

There are a few methods provided for calculating the day-length multiplication factor (\(k\)) based on latitude:

  • For the “huglin” and “interpolated” methods, values for k increase from 1.0 at 40°N or 40°S to 1.06 at 50°N or 50°S, where the interpolated method uses a smoothed curve and the huglin method uses a stepwise function. Values above 50°N or below 50°S are set via the cap_value variable, with 1.0 set as default. See: xclim.compute.helpers.huglin_day_length_latitude_coefficient() for more information.

  • For the “jones” method, A more robust day-length calculation based on latitude, calendar, day-of-year, and obliquity is used. The current implementation requires an annual frequency for consistent results. See: xclim.compute.generic.jones_day_length_coefficient() or Hall and Jones [2010] for more information.

For compatibility with the original ICCLIM implementation [Project team ECA&D and KNMI, 2013], end_date should be set to 11-01 with method=”huglin”.

References

Hall and Jones [2010], Huglin [1978]

xclim.indicators.atmos._temperature.ice_days(tasmax='tasmax', *, thresh='0 °C', freq='YS', ds=None, **indexer)

Ice days

Number of days where the daily maximum temperature is below 0°C

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with maximum daily temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the maximum daily temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.last_spring_frost(tasmin='tasmin', *, condition='<', thresh='0°C', freq='YS', window=1, ds=None, before_date='07-01', **indexer)

Last spring frost

The last day when minimum temperature is below a given threshold for a certain number of days, limited by a final calendar date.

This indicator will check for missing values according to the method “from_context”. Based on function day_threshold_reached(). With injected parameters: which=last, constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold. Default: ‘0°C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • window (number) – Minimum number of days with values above thresh needed for evaluation. Default: 1. Default: 1.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • before_date (date (string, MM-DD)) – Date of the year after which to look for the first event, or before which to look for the last event. Should have the format ‘%m-%d’. None means there is no limit. Default: ‘07-01’.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [dimensionless] – day_of_year, Last day of minimum daily temperature below a threshold of {thresh} for at least {window} days before a given date ({before_date}). With additional attributes: description: Day of year of last spring frost, defined as the last day a minimum temperature remains below a threshold of {thresh} for at least {window} days before a given date ({before_date}).

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.late_frost_days(tasmin='tasmin', *, thresh='0 °C', freq='YS', ds=None, **indexer)

Late frost days

Number of days where the daily minimum temperature is below a given threshold between a givenstart date and a given end date.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘0 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days where the daily minimum temperature is below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where the daily minimum temperature is below {thresh}over the period {indexer}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.latitude_temperature_index(tas='tas', lat='lat', *, freq='YS', ds=None)

Latitude temperature index

A climate indice based on mean temperature of the warmest month and a latitude-based coefficient to account for longer day-length favouring growing conditions. Developed specifically for viticulture. Mean temperature of warmest month multiplied by the difference of latitude factor coefficient minus latitude. Metric originally published in Jackson, D. I., & Cherry, N. J. (1988).

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function latitude_temperature_index(). With injected parameters: lat_factor=60.

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • lat (str or DataArray) – Latitude coordinate. If None, a CF-conformant “latitude” field must be available within the passed DataArray. Default: ‘lat’. [Required units : []]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [unitless] – Mean temperature of warmest month multiplied by the difference of {lat_factor} minus latitude. With additional attributes: description: A climate indice based on mean temperature of the warmest month and a latitude-based coefficient to account for longer day-length favouring growing conditions. Developed specifically for viticulture. Mean temperature of warmest month multiplied by the difference of {lat_factor} minus latitude.

Return type:

xarray.DataArray

Notes

The latitude factor of 75 is provided for examining the poleward expansion of wine-growing climates under scenarios of climate change [Kenny and Shao, 1992]. For comparing 20th century/observed historical records, the original scale factor of 60 is more appropriate [Jackson and Cherry, 1988].

Let \(Tn_{j}\) be the average temperature for a given month \(j\), \(lat_{f}\) be the latitude factor, and \(lat\) be the latitude of the area of interest. Then the Latitude-Temperature Index (\(LTI\)) is:

\[LTI = max(TN_{j}: j = 1..12)(lat_f - | lat | )\]

References

Jackson and Cherry [1988], Kenny and Shao [1992]

xclim.indicators.atmos._temperature.max_daily_temperature_range(tasmin='tasmin', tasmax='tasmax', *, statistic='max', freq='YS', ds=None, **indexer)

Maximum of daily temperature range

The maximum difference between the daily maximum and minimum temperatures.

This indicator will check for missing values according to the method “from_context”. Based on function difference_statistics(). With injected parameters: absolute=False.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • statistic ({‘min’, ‘sum’, ‘max’, ‘mean’}) – The statistic to compute over the difference between the two variables. Default: ‘max’.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum diurnal temperature range. With additional attributes: cell_methods: time range within days time: max over days, description: {freq} maximum diurnal temperature range.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.maximum_consecutive_frost_free_days(tasmin='tasmin', *, condition='>', thresh='0 degC', freq='YS', resample_before_rl=True, ds=None, **indexer)

Maximum consecutive frost free days

Maximum number of consecutive frost-free days: where the daily minimum temperature is above or equal to given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function spell_length_statistics(). With injected parameters: window=1, window_statistic=min, statistic=max, min_gap=1, constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator. Computed as rolling_stat {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold to test against. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time(). Indexing is done after finding the days part of a spell, but before taking the spell statistics.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Maximum number of consecutive days with minimum temperature {condition} {thresh}. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum number of consecutive days with minimum daily temperature {condition} {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.maximum_consecutive_warm_days(tasmax='tasmax', *, thresh='25 °C', freq='YS', op='>', resample_before_rl=True, ds=None)

Maximum consecutive warm days

Maximum number of consecutive days where the maximum daily temperature exceeds a certain threshold.

This indicator will check for missing values according to the method “from_context”. Based on function hot_spell_max_length(). With injected parameters: window=1.

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The temperature threshold needed to trigger a hot spell. Default: ‘25 °C’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • op ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – spell_length_of_days_with_air_temperature_above_threshold, Maximum number of consecutive days with #maximum daily temperature {op} {thresh}. With additional attributes: cell_methods: time: maximum over days, description: {freq} longest spell of consecutive days with maximum daily temperature {op} {thresh}.

Return type:

xarray.DataArray

Notes

The threshold on tasmax follows the one used in heat waves. A day temperature threshold between 30° and 35°C was selected by Health Canada professionals, following a temperature–mortality analysis. This absolute temperature threshold characterizes the occurrence of hot weather events that can result in adverse health outcomes for Canadian communities [Casati et al., 2013].

In Robinson [2001] where heat waves are also considered, the corresponding parameters would be thresh=39.44, window=2 (103F).

References

Casati, Yagouti, and Chaumont [2013], Robinson [2001]

xclim.indicators.atmos._temperature.tg10p(tas='tas', tas_per='tas_per', *, freq='YS', bootstrap=False, condition='<', ds=None, **indexer)

Days with mean temperature below the 10th percentile

Number of days with mean temperature below the 10th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tg10p().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • tas_per (str or DataArray) – 10th percentile of daily mean temperature. Default: ‘tas_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with mean temperature below the 10th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with mean temperature below the 10th percentile. A {tas_per_window} day(s) window, centered on each calendar day in the {tas_per_period} period, is used to compute the 10th percentile.

Return type:

xarray.DataArray

Notes

The 10th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos._temperature.tg90p(tas='tas', tas_per='tas_per', *, freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Days with mean temperature above the 90th percentile

Number of days with mean temperature above the 90th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tg90p().

Parameters:
  • tas (str or DataArray) – Mean daily temperature. Default: ‘tas’. [Required units : [temperature]]

  • tas_per (str or DataArray) – 90th percentile of daily mean temperature. Default: ‘tas_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days with mean temperature above the 90th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with mean temperature above the 90th percentile. A {tas_per_window} day(s) window, centered on each calendar day in the {tas_per_period} period, is used to compute the 90th percentile.

Return type:

xarray.DataArray

Notes

The 90th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos._temperature.tg_days_above(tas='tas', *, condition='>', thresh='10 °C', freq='YS', ds=None, **indexer)

Number of days with mean temperature above a given threshold

The number of days with mean temperature above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, The number of days with mean temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily mean temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tg_days_below(tas='tas', *, condition='<', thresh='10 °C', freq='YS', ds=None, **indexer)

Number of days with mean temperature below a given threshold

The number of days with mean temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_below_threshold, The number of days with mean temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily mean temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tg_max(tas='tas', *, freq='YS', ds=None, **indexer)

Maximum of mean temperature

Maximum of daily mean temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum daily mean temperature. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum of daily mean temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tg_mean(tas='tas', *, freq='YS', ds=None, **indexer)

Mean temperature

Mean of daily mean temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean daily mean temperature. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily mean temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tg_min(tas='tas', *, freq='YS', ds=None, **indexer)

Minimum of mean temperature

Minimum of daily mean temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Minimum daily mean temperature. With additional attributes: cell_methods: time: minimum over days, description: {freq} minimum of daily mean temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.thawing_degree_days(tas='tas', *, thresh='0 degC', freq='YS', ds=None, **indexer)

Thawing degree days

The cumulative degree days for days when the average temperature is above a given threshold, typically 0°C.

This indicator will check for missing values according to the method “from_context”. Based on function integrated_difference(). With injected parameters: condition=>.

Parameters:
  • tas (str or DataArray) – Mean surface temperature. Default: ‘tas’. [Required units : [temperature]]

  • thresh (quantity (string or DataArray, with units)) – The value threshold. Default: ‘0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K days] – integral_of_air_temperature_excess_wrt_time, Cumulative sum of temperature degrees for mean daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} thawing degree days (mean temperature above {thresh}).

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tn10p(tasmin='tasmin', tasmin_per='tasmin_per', *, freq='YS', bootstrap=False, condition='<', ds=None, **indexer)

Days with minimum temperature below the 10th percentile

Number of days with minimum temperature below the 10th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tn10p().

Parameters:
  • tasmin (str or DataArray) – Mean daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmin_per (str or DataArray) – 10th percentile of daily minimum temperature. Default: ‘tasmin_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with minimum temperature below the 10th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with minimum temperature below the 10th percentile. A {tasmin_per_window} day(s) window, centered on each calendar day in the {tasmin_per_period} period, is used to compute the 10th percentile.

Return type:

xarray.DataArray

Notes

The 10th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos._temperature.tn90p(tasmin='tasmin', tasmin_per='tasmin_per', *, freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Days with minimum temperature above the 90th percentile

Number of days with minimum temperature above the 90th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tn90p().

Parameters:
  • tasmin (str or DataArray) – Minimum daily temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmin_per (str or DataArray) – 90th percentile of daily minimum temperature. Default: ‘tasmin_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days with minimum temperature above the 90th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with minimum temperature above the 90th percentile. A {tasmin_per_window} day(s) window, centered on each calendar day in the {tasmin_per_period} period, is used to compute the 90th percentile.

Return type:

xarray.DataArray

Notes

The 90th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos._temperature.tn_days_above(tasmin='tasmin', *, condition='>', thresh='20 °C', freq='YS', ds=None, **indexer)

Number of days with minimum temperature above a given threshold

The number of days with minimum temperature above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘20 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, The number of days with minimum temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily minimum temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tn_days_below(tasmin='tasmin', *, condition='<', thresh='-10 °C', freq='YS', ds=None, **indexer)

Number of days with minimum temperature below a given threshold

The number of days with minimum temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘-10 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_below_threshold, The number of days with minimum temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily minimum temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tn_max(tasmin='tasmin', *, freq='YS', ds=None, **indexer)

Maximum of minimum temperature

Maximum of daily minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum daily minimum temperature. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum of daily minimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tn_mean(tasmin='tasmin', *, freq='YS', ds=None, **indexer)

Mean of minimum temperature

Mean of daily minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean daily minimum temperature. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily minimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tn_min(tasmin='tasmin', *, freq='YS', ds=None, **indexer)

Minimum temperature

Minimum of daily minimum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Minimum daily minimum temperature. With additional attributes: cell_methods: time: minimum over days, description: {freq} minimum of daily minimum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tropical_nights(tasmin='tasmin', *, condition='>', thresh='20.0 degC', freq='YS', ds=None, **indexer)

Tropical nights

Number of days where minimum temperature is above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘20.0 degC’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, Number of days with minimum daily temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of Tropical Nights, defined as days with minimum daily temperature above {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tx10p(tasmax='tasmax', tasmax_per='tasmax_per', *, freq='YS', bootstrap=False, condition='<', ds=None, **indexer)

Days with maximum temperature below the 10th percentile

Number of days with maximum temperature below the 10th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tx10p().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmax_per (str or DataArray) – 10th percentile of daily maximum temperature. Default: ‘tasmax_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘lt’, ‘<’, ‘le’, ‘<=’}) – Comparison operation. Default: “<”. Default: ‘<’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_below_threshold, Number of days with maximum temperature below the 10th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with maximum temperature below the 10th percentile. A {tasmax_per_window} day(s) window, centered on each calendar day in the {tasmax_per_period} period, is used to compute the 10th percentile.

Return type:

xarray.DataArray

Notes

The 10th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos._temperature.tx90p(tasmax='tasmax', tasmax_per='tasmax_per', *, freq='YS', bootstrap=False, condition='>', ds=None, **indexer)

Days with maximum temperature above the 90th percentile

Number of days with maximum temperature above the 90th percentile.

This indicator will check for missing values according to the method “from_context”. Based on function tx90p().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmax_per (str or DataArray) – 90th percentile of daily maximum temperature. Default: ‘tasmax_per’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Indexing parameters to compute the indicator on a temporal subset of the data. It accepts the same arguments as xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – days_with_air_temperature_above_threshold, Number of days with maximum temperature above the 90th percentile. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with maximum temperature above the 90th percentile. A {tasmax_per_window} day(s) window, centered on each calendar day in the {tasmax_per_period} period, is used to compute the 90th percentile.

Return type:

xarray.DataArray

Notes

The 90th percentile should be computed for a 5-day window centered on each calendar day for a reference period.

xclim.indicators.atmos._temperature.tx_days_above(tasmax='tasmax', *, condition='>', thresh='25 °C', freq='YS', ds=None, **indexer)

Number of days with maximum temperature above a given threshold

The number of days with maximum temperature above a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘>’, ‘>=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘>’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘25 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, The number of days with maximum temperature above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily maximum temperature exceeds {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tx_days_below(tasmax='tasmax', *, condition='<', thresh='25 °C', freq='YS', ds=None, **indexer)

Number of days with maximum temperature below a given threshold

The number of days with maximum temperature below a given threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: constrain=(‘<’, ‘<=’).

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • condition ({‘lt’, ‘<’, ‘le’, ‘ge’, ‘gt’, ‘>=’, ‘>’, ‘<=’}) – Logical comparison operator. Comparison is done as data {condition} thresh. Default: ‘<’.

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘25 °C’. [Required units : ([temperature])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_below_threshold, The number of days with maximum temperature below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days where daily max temperature is below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tx_max(tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Maximum temperature

Maximum of daily maximum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Maximum daily maximum temperature. With additional attributes: cell_methods: time: maximum over days, description: {freq} maximum of daily maximum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tx_mean(tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Mean of maximum temperature

Mean of daily maximum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Mean daily maximum temperature. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily maximum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tx_min(tasmax='tasmax', *, freq='YS', ds=None, **indexer)

Minimum of maximum temperature

Minimum of daily maximum temperature.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [K] – air_temperature, Minimum daily maximum temperature. With additional attributes: cell_methods: time: minimum over days, description: {freq} minimum of daily maximum temperature.

Return type:

xarray.DataArray

xclim.indicators.atmos._temperature.tx_tn_days_above(tasmin='tasmin', tasmax='tasmax', *, freq='YS', ds=None, condition='>', thresh_tasmin='22 °C', thresh_tasmax='30 °C', **indexer)

Number of days with daily minimum and maximum temperatures exceeding thresholds

Number of days with daily maximum and minimum temperatures above given thresholds.

This indicator will check for missing values according to the method “from_context”. Based on function bivariate_count_occurrences(). With injected parameters: condition2=None, var_reducer=all, constrain1=(‘>’, ‘>=’), constrain2=None.

Parameters:
  • tasmin (str or DataArray) – Minimum surface temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • tasmax (str or DataArray) – Maximum surface temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • condition ({‘lt’, ‘<’, ‘ne’, ‘le’, ‘ge’, ‘gt’, ‘==’, ‘>=’, ‘eq’, ‘!=’, ‘>’, ‘<=’}) – Logical comparison operator for data variable 1. Default: ‘>’.

  • thresh_tasmin (quantity (string or DataArray, with units)) – Threshold for data variable 1. Default: ‘22 °C’. [Required units : ([temperature])]

  • thresh_tasmax (quantity (string or DataArray, with units)) – Threshold for data variable 2. If None, thresh1 is used. Default: ‘30 °C’. [Required units : ([temperature])]

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, Number of days with daily minimum above {thresh_tasmin} and daily maximum temperatures above {thresh_tasmax}. With additional attributes: description: {freq} number of days where daily maximum temperature exceeds {thresh_tasmax} and minimum temperature exceeds {thresh_tasmin}.

Return type:

xarray.DataArray

Notes

Sampling length is derived from data1.

xclim.indicators.atmos._temperature.usda_hardiness_zones(tasmin='tasmin', *, window=30, freq='YS', ds=None)

USDA hardiness zones

A climate indice based on a multi-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The USDA classificationscheme divides categories into 10 degree Fahrenheit zones, with 5-degree Fahrenheit half-zones, starting from -65 degrees Fahrenheit and ending at 65 degrees Fahrenheit.

This indicator will check for missing values according to the method “from_context”. Requested resampling periods are restricted to Y Based on function hardiness_zones(). With injected parameters: method=usda.

Parameters:
  • tasmin (str or DataArray) – Minimum temperature. Default: ‘tasmin’. [Required units : [temperature]]

  • window (number) – The length of the averaging window, in years. Default: 30.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [dimensionless] – Hardiness zones. With additional attributes: description: A climate indice based on a {window}-year rolling average of the annual minimum temperature. Developed specifically to aid in determining plant suitability of geographic regions. The USDA classificationscheme divides categories into 10 degree Fahrenheit zones, with 5-degree Fahrenheit half-zones, starting from -65 degrees Fahrenheit and ending at 65 degrees Fahrenheit.

Return type:

xarray.DataArray

References

Dawson [1991], USDA Agricultural Research Service [2012]

xclim.indicators.atmos._temperature.warm_spell_duration_index(tasmax='tasmax', tasmax_per='tasmax_per', *, window=6, freq='YS', resample_before_rl=True, bootstrap=False, condition='>', ds=None)

Warm spell duration index

Number of days part of a percentile-defined warm spell. A warm spell occurs when the maximum daily temperature is above a given percentile for a given number of consecutive days.

This indicator will check for missing values according to the method “from_context”. Based on function warm_spell_duration_index().

Parameters:
  • tasmax (str or DataArray) – Maximum daily temperature. Default: ‘tasmax’. [Required units : [temperature]]

  • tasmax_per (str or DataArray) – Percentile(s) of daily maximum temperature. Default: ‘tasmax_per’. [Required units : [temperature]]

  • window (number) – Minimum number of days with temperature above threshold to qualify as a warm spell. Default: 6.

  • freq (offset alias (string)) – Resampling frequency. Default: ‘YS’.

  • resample_before_rl (boolean) – Determines if the resampling should take place before or after the run length encoding (or a similar algorithm) is applied to runs. Default: True.

  • bootstrap (boolean) – Flag to run bootstrapping of percentiles. Used by percentile_bootstrap decorator. Bootstrapping is only useful when the percentiles are computed on a part of the studied sample. This period, common to percentiles and the sample must be bootstrapped to avoid inhomogeneities with the rest of the time series. Do not enable bootstrap when there is no common period, otherwise it will provide the wrong results. Note that bootstrapping is computationally expensive. Default: False.

  • condition ({‘>=’, ‘gt’, ‘ge’, ‘>’}) – Comparison operation. Default: “>”. Default: ‘>’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

Returns:

xarray.DataArray, [days] – number_of_days_with_air_temperature_above_threshold, Number of days with at least {window} consecutive days where the maximum daily temperature is above the {tasmax_per_thresh}th percentile(s). With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with at least {window} consecutive days where the maximum daily temperature is above the {tasmax_per_thresh}th percentile(s). A {tasmax_per_window} day(s) window, centred on each calendar day in the {tasmax_per_period} period, is used to compute the {tasmax_per_thresh}th percentile(s).

Return type:

xarray.DataArray

References

From the Expert Team on Climate Change Detection, Monitoring and Indices (ETCCDMI; [Zhang et al., 2011]). Used in Alexander, Zhang, Peterson, Caesar, Gleason, Klein Tank, Haylock, Collins, Trewin, Rahimzadeh, Tagipour, Rupa Kumar, Revadekar, Griffiths, Vincent, Stephenson, Burn, Aguilar, Brunet, Taylor, New, Zhai, Rusticucci, and Vazquez-Aguirre [2006]

xclim.indicators.atmos._wind module

Wind indicator definitions.

xclim.indicators.atmos._wind.calm_days(sfcWind='sfcWind', *, thresh='2 m s-1', freq='MS', ds=None, **indexer)

Calm days

Number of days with surface wind speed below threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=<, constrain=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘2 m s-1’. [Required units : ([speed])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘MS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – Number of days with surface wind speed below {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with surface wind speed below {thresh}.

Return type:

xarray.DataArray

xclim.indicators.atmos._wind.sfcWind_max(sfcWind='sfcWind', *, freq='YS', ds=None, **indexer)

Maximum near-surface mean wind speed

Maximum of daily mean near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Maximum daily mean wind speed. With additional attributes: cell_methods: time: max over days, description: {freq} maximum of daily mean wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos._wind.sfcWind_mean(sfcWind='sfcWind', *, freq='YS', ds=None, **indexer)

Mean near-surface wind speed

Mean of daily near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Mean daily mean wind speed. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily mean wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos._wind.sfcWind_min(sfcWind='sfcWind', *, freq='YS', ds=None, **indexer)

Minimum near-surface mean wind speed

Minimum of daily mean near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Minimum daily mean wind speed. With additional attributes: cell_methods: time: min over days, description: {freq} minimum of daily mean wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos._wind.sfcWindmax_max(sfcWindmax='sfcWindmax', *, freq='YS', ds=None, **indexer)

Maximum near-surface maximum wind speed

Maximum of daily maximum near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=max, out_units=None.

Parameters:
  • sfcWindmax (str or DataArray) – Surface maximum wind speed. Default: ‘sfcWindmax’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Maximum daily maximum wind speed. With additional attributes: cell_methods: time: max over days, description: {freq} maximum of daily maximum wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos._wind.sfcWindmax_mean(sfcWindmax='sfcWindmax', *, freq='YS', ds=None, **indexer)

Mean near-surface maximum wind speed

Mean of daily maximum near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=mean, out_units=None.

Parameters:
  • sfcWindmax (str or DataArray) – Surface maximum wind speed. Default: ‘sfcWindmax’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Mean daily maximum wind speed. With additional attributes: cell_methods: time: mean over days, description: {freq} mean of daily maximum wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos._wind.sfcWindmax_min(sfcWindmax='sfcWindmax', *, freq='YS', ds=None, **indexer)

Minimum near-surface maximum wind speed

Minimum of daily maximum near-surface wind speed.

This indicator will check for missing values according to the method “from_context”. Based on function statistics(). With injected parameters: statistic=min, out_units=None.

Parameters:
  • sfcWindmax (str or DataArray) – Surface maximum wind speed. Default: ‘sfcWindmax’. [Required units : [speed]]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘YS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [m s-1] – wind_speed, Minimum daily maximum wind speed. With additional attributes: cell_methods: time: min over days, description: {freq} minimum of daily maximum wind speed

Return type:

xarray.DataArray

xclim.indicators.atmos._wind.windy_days(sfcWind='sfcWind', *, thresh='10.8 m s-1', freq='MS', ds=None, **indexer)

Windy days

Number of days with surface wind speed at or above threshold.

This indicator will check for missing values according to the method “from_context”. Based on function count_occurrences(). With injected parameters: condition=>=, constrain=None.

Parameters:
  • sfcWind (str or DataArray) – Surface wind speed. Default: ‘sfcWind’. [Required units : [speed]]

  • thresh (quantity (string or DataArray, with units)) – Threshold value. Should have the same dimensionality as data. Default: ‘10.8 m s-1’. [Required units : ([speed])]

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. Default: ‘MS’.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default: None.

  • indexer – Time attribute and values over which to subset the array. See xclim.core.calendar.select_time().

Returns:

xarray.DataArray, [days] – number_of_days_with_wind_speed_above_threshold, Number of days with surface wind speed at or above {thresh}. With additional attributes: cell_methods: time: sum over days, description: {freq} number of days with surface wind speed at or above {thresh}.

Return type:

xarray.DataArray