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
import cdstoolbox as ct
@ct.application(title='Extract')
@ct.output.download()
def plot_time_series():
data = ct.catalogue.retrieve(
'reanalysis-era5-single-levels',
{
'variable': '2m_temperature',
'grid': ['1', '1'],
'product_type': 'reanalysis',
'year': ['2018', '2019'],
'month': ['01', '02', '03', '04', '05', '06','07', '08', '09', '10', '11', '12'],
'day': [
'01', '02', '03', '04', '05', '06',
'07', '08', '09', '10', '11', '12',
'13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24',
'25', '26', '27', '28', '29', '30',
'31'
],
'time': ['11:00', '12:00', '13:00', '14:00', '15:00'],
}
)
# Daily mean on selection
data_daily = ct.climate.daily_max(data)
# This works:
# eca_csu = ct.climate.compute_extreme_index(data_daily, 'eca_csu', [26.0, 5])
# For eca_hwfi I need two inputs: see CDO handbook: cdo eca_hwfi tgfile tgn90file outfile
# Hence this:
clim_perc = ct.climate.climatology_perc(data_daily, percentiles=[90]) # <- This works too
# eca_hwfi = ct.climate.compute_extreme_index([data_daily, clim_perc], 'eca_hwfi', [6, 5]) # <- This throws an error
return clim_perc
The error message when using eca_hwfi = ct.climate.compute_extreme_index([data_daily, clim_perc], 'eca_hwfi', [6, 5])
Traceback (most recent call last):
File "/opt/cdstoolbox/cdscompute/cdscompute/cdshandlers/services/handler.py", line 49, in handle_request
result = cached(context.method, proc, context, *context.args, **context.kwargs)
File "/opt/cdstoolbox/cdscompute/cdscompute/caching.py", line 108, in cached
result = proc(context, *context.args, **context.kwargs)
File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 118, in __call__
return p(*args, **kwargs)
File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 59, in __call__
return self.proc(context, *args, **kwargs)
File "/home/cds/cdsservices/services/python_service.py", line 32, in execute
raise exceptions.InternalError(logging + traceback, '')
cdsclient.exceptions.InternalError: Traceback (most recent call last):
File "/opt/cdstoolbox/jsonrequest/jsonrequest/requests.py", line 71, in jsonrequestcall
resp = coding.encode(req.callable(*req.args, **req.kwargs), register=encoders, **context)
File "/opt/cdstoolbox/cdscdo/cdscdo/cdo.py", line 462, in _compute_extreme_index
infiles_list = [io.dataarray_to_netcdf(infile, remove_atexit=True) for infile in data]
File "/opt/cdstoolbox/cdscdo/cdscdo/cdo.py", line 462, in <listcomp>
infiles_list = [io.dataarray_to_netcdf(infile, remove_atexit=True) for infile in data]
File "/opt/cdstoolbox/cdscdm/cdscdm/io.py", line 128, in dataarray_to_netcdf
if data.name is None:
AttributeError: 'list' object has no attribute 'name'