Below my workflow. Sorry indentation got clobbered with cut andp paste. Can't quite understand the update_attributes method above and what it is supposed to do but I just do this after download.
cdo.setreftime('1900-01-01,00:00:00,1day',input=outname[0],output=temp)
I assume the "daily_means" method isn't smart enough to deal with computing daily averages for "accumulated" values in the analysis to address that they cross day boundaries? In general my problem is to efficiently calculate daily averages for several ERA5 variables including for example total_precipitation.
daily_mean=ct.climate.daily_mean(data,keep_attrs=True)
Axel
import cdstoolbox as ct
@ct.application(title='Daily Download')
@ct.output.download()
def application(month,year):
print("Month to retrieve",month)
data = ct.catalogue.retrieve(
'reanalysis-era5-single-levels',
{
'variable': '2m_temperature',
'product_type': 'ensemble_mean',
'year': year,
'month': month,
'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': [
'00:00',
'03:00',
'06:00',
'09:00',
'12:00',
'15:00',
'18:00',
'21:00',
],
}
)
# fig = ct.cdsplot.figure(subplot_kw={'projection': ct.cdsplot.crs.Robinson()})
# ct.cdsplot.geomap(
# data, pcolormesh_kwargs={'cmap': 'RdBu_r'}, fig=fig,
# title='Mean {long_name}'
# )
daily_mean=ct.climate.daily_mean(data,keep_attrs=True)
return daily_mean