icclim._core.generic.threshold.bounded#

BoundedThreshold module.

A BoundedThreshold is a composite threshold that binds two other thresholds for example “> 95 doy_per AND >= 30 deg_C”.

Module Contents#

class icclim._core.generic.threshold.bounded.BoundedThreshold(thresholds: collections.abc.Sequence[icclim._core.model.threshold.Threshold | str | icclim._core.model.threshold.ThresholdBuilderInput], logical_link: icclim._core.model.logical_link.LogicalLink, initial_query: str | None, **kwargs)[source]#

Threshold that binds two other thresholds (e.g. “> 95 doy_per AND >= 30 deg_C”).

The logical link must be either “and” or “or”.

property unit: str | None[source]#

The unit of the bounded threshold.

Returns:

The unit of the threshold if both thresholds have the same unit, otherwise None.

Return type:

str | None

compute(comparison_data: xarray.DataArray, override_op: Callable[[xarray.DataArray, xarray.DataArray], xarray.DataArray] | None = None, **kwargs) xarray.DataArray[source]#

Compute the threshold exceedance value.

Uses the logical link to combine the result of both thresholds.

Parameters:
  • comparison_data (xr.DataArray) – The data array to compare with the threshold value.

  • override_op (Callable[[DataArray, DataArray], DataArray] | None, optional) – A custom override function to compute the threshold value. If provided, this function will be used instead of the default operator.

  • **kwargs – Additional keyword arguments.

Returns:

The computed threshold value.

Return type:

DataArray

Notes

If override_op is not None, the override_op function will be used to compute the thresholds exceedances on both thresholds.

format_metadata(*, jinja_scope: dict[str, Any], jinja_env: jinja2.Environment, **kwargs) icclim._core.generic.threshold.threshold_templates.ThresholdMetadata[source]#

Generate the metadata for the bounded threshold.

These metadata are used to fill the generic template.

Parameters:
  • jinja_scope (dict) – The jinja scope, it contains the variables to be used in the jinja template.

  • jinja_env (jinja2.Environment) – The jinja environment, it contains the jinja rendering engine.

  • **kwargs – Additional keyword arguments, ignored for compatibility with other format_metadata methods.

Returns:

The metadata for the threshold.

Return type:

ThresholdMetadata