The Climate Change Service API contains an example that computes consecutive summer days index per time period (‘eca_csu’), see this link.
The associated Python code for the calculation of 'eca_scu' is as follows:
eca_csu = ct.climate.compute_extreme_index(data, 'eca_csu', [26.0, 5])
I ran this code in the toolbox and it works like a charm.
Question: how does this code look like for the calculation of the warm spell days index (ECAHWFI)?
According to the reference manual, the syntax is as follows:
cdo eca_hwfi tgfile tgn90file outfile
The API requires this syntax for the data item:
data (data object or list of data objects) – Data or list of data objects required to compute the cdo_index
which would translate in Python to the following line, where p90data was obtained from cdstoolbox.climate.climatology_perc:
eca_csu = ct.climate.compute_extreme_index([data, p90data], 'eca_hwfi', [6, 5])
However, when it use this line of code in the toolbox, then I get an AttributeError: 'list' object has no attribute 'name'.
2 Comments
Vivien MAVEL
Dear Martien,
The full traceback and workflow would help but my feeling is that p90data is a list. The way you call the cdo index looks right but cdstoolbox.climate.climatology_perc returns a list so if you have not selected the right element when declaring p90data it might sill be a list.
Let me know if that was the issue and if not try to share your workflow here.
Regards.
Vivien
Martien Lubberink
Hi Vivien,
Thank you for your reply. Running the script in the toolbox works, except for the penultimate line: (eca_hwfi = ct.climate.compute_extreme_index([data_daily, clim_perc], 'eca_hwfi', [6, 5]))
I hope this helps.
Martien
The error message when using eca_hwfi = ct.climate.compute_extreme_index([data_daily, clim_perc], 'eca_hwfi', [6, 5])