.. _ecad_functions_api:

###############
 ECA&D indices
###############

icclim 5.2 comes with convenience functions to call each individual
index from `icclim` namespace. These functions are autogenerated and are
stored in `_generated/_ecad.py`. Additionally, user custom indices can be
called with the `icclim.custom_index`.

For example to use this new API with the index `su` you can do:

.. code:: python

   import glob
   import icclim


   tasmax = glob.glob("netcdf_files/tasmax*.nc")

   # Old API
   # via icclim::index
   summer_days = icclim.index(in_files=tasmax, index_name="SU")
   # via a custom index (output metadata will be different)
   summer_days = icclim.custom_index(
                     {"calc_operation": "nb_events", "logical_operation": "gt", "thresh": 25, },
                     in_files=tasmax,
                  )

   # New API
   ## via the ECAD module
   summer_days = icclim.ecad.su(in_files=tasmax)
   ## via generic indices (output metadata will be different)
   summer_days = icclim.count_occurrences(tasmax, threshold="> 25 °C")

The full API is now here :ref:`ecad api`.
