Adding New Indicators

Adding New Indicators#

CLIX primarily uses functions available within the xclim.indices package. You can find their comprehensive documentation here: xclim indices Documentation.

If you identify an essential indicator that is not yet implemented and is available in xclim.indices, please open a new issue on our GitHub repository: pyku GitHub Issues. When opening an issue, refer to the specific xclim.indices function and provide a clear definition of the new climate indicator you would like to see implemented.

For flexible integration of custom indicators not available through xclim, CLIX provides a mechanism to include them as functions within a centralized location. The clix_custom_indicators.py file serves this purpose as the entry point for individually defined indicators. To implement new indicators, the following instructions should be followed:

  • The function must accept at least one input xarray.DataArray, defined as a mandatory argument.

  • The function’s output must also be an xarray.DataArray.

  • A complete docstring should be included for the function to aid in understanding the indicator’s purpose and usage.

To ensure a consistent layout for the indicators, it can be helpful to review the indices defined in xclim and the generic functions that can be configured to address a broader set of problems.

Below is an example of a function within the clix_custom_indicators.py file and its integration within the climate_indicators.yaml file.

Example: Definition for a New Indicator (Potential Snow Days)

This example illustrates the definition of “Potential Snow Days” using a generic xclim function embedded as a Python wrapper, which is then linked within the YAML configuration file.

rge1mmtmle2:
  standard_name: potential_snow_days
  long_name: "Potential snow days"
  units: days
  description: "The number of potential snow days, where daily precipitation is above or equal {thresh_pr} and daily mean temperature is below or equal {thresh_tas}."
  cell_methods: 'time: mean within days time: sum over days'
  function: pyku.indices.clix_custom_indicators.potsnowdays
  default_parameters:
    thresh_pr: 1 mm/day
    thresh_tas: 2 degC
    op_pr: '>='
    op_tas: '<='