icclim._core.legacy.user_index.parse#

Contain the parsing operations to create a user indices.

Module Contents#

icclim._core.legacy.user_index.parse.read_indicator(user_index: icclim._core.legacy.user_index.model.UserIndexDict) icclim._core.generic.indicator.GenericIndicator[source]#

Read the user index and return the corresponding generic indicator.

Parameters:

user_index (UserIndexDict) – The user index dictionary containing the calculation operation and extreme mode.

Returns:

The corresponding generic indicator based on the user index.

Return type:

GenericIndicator

Raises:
  • InvalidIcclimArgumentError – If the user index does not contain a calculation operation. If the user index’s calculation operation is unknown.

  • NotImplementedError – If the calculation operation or extreme mode is not implemented.

Notes

This function reads the user index dictionary and maps the calculation operation and extreme mode to the corresponding generic indicator. It raises errors if the required information is missing or if the operation is not implemented.

Read the logical link from the user index dictionary.

Parameters:

user_index (UserIndexDict) – The user index dictionary containing the logical link information.

Returns:

The corresponding LogicalLink based on the logical link information in the user index dictionary.

Return type:

LogicalLink

Notes

If the logical link is not specified in the user index dictionary, the default logical link is LogicalLinkRegistry.LOGICAL_AND.

icclim._core.legacy.user_index.parse.read_coef(user_index: icclim._core.legacy.user_index.model.UserIndexDict) float | None[source]#

Read the coefficient value from the user index dictionary.

Parameters:

user_index (UserIndexDict) – The user index dictionary containing the coefficient value.

Returns:

The coefficient value if it exists in the user index dictionary, otherwise None.

Return type:

float or None

icclim._core.legacy.user_index.parse.read_date_event(user_index: icclim._core.legacy.user_index.model.UserIndexDict) bool[source]#

Read the ‘date_event’ key from the given UserIndexDict.

Parameters:

user_index (UserIndexDict) – The dictionary containing user index information.

Returns:

The value associated with the ‘date_event’ key in the UserIndexDict, if missing returns False.

Return type:

bool

icclim._core.legacy.user_index.parse.read_thresholds(user_index: icclim._core.legacy.user_index.model.UserIndexDict, doy_window_width: int, reference_period: collections.abc.Sequence[datetime.datetime | str] | None, only_leap_years: bool, interpolation: icclim._core.model.quantile_interpolation.QuantileInterpolation) icclim._core.model.threshold.Threshold | None | list[icclim._core.model.threshold.Threshold][source]#

Read the thresholds from the user index dictionary.

Parameters:
  • user_index (UserIndexDict) – The user index dictionary containing the threshold information.

  • doy_window_width (int) – The width of the day of year window for calculating the threshold.

  • reference_period (Sequence[dt.datetime | str] | None) – The reference period for calculating the threshold.

  • only_leap_years (bool) – Whether to consider only leap years when calculating the threshold.

  • interpolation (QuantileInterpolation) – The interpolation method to use for calculating the threshold.

Returns:

The corresponding Threshold object(s) based on the threshold information in the user index dictionary.

Return type:

Threshold or None or list[Threshold]

Notes

This function reads the threshold information from the user index dictionary and maps it to the corresponding Threshold object(s). If the threshold is already a Threshold object, it is returned as is. If the threshold is a tuple or list, multiple Threshold objects are created based on the logical operation and link specified in the user index dictionary. If the threshold is a single value, a single Threshold object is created.