Average of muliple variables in a data set

Trying to average multiple variables at the same time. Doesn't seem to be working. Seems like "data" is an xarray object with two variables (vas,uas) but the daily_means doesn't want to operate on both. I tried accessing individual DataArrays by using data.uas, data.vas but that doesn't seem to work either.


import cdstoolbox as ct

@ct.application(title='Download data')
def download_application():
data = ct.catalogue.retrieve(
'product_type': 'reanalysis',
'variable': [
'10m_u_component_of_wind', '10m_v_component_of_wind',
'year': '2017',
'month': '01',
'day': [
'01', '02',
'time': [
'00:00', '01:00', '02:00',
'03:00', '04:00', '05:00',
'06:00', '07:00', '08:00',
'09:00', '10:00', '11:00',
'12:00', '13:00', '14:00',
'15:00', '16:00', '17:00',
'18:00', '19:00', '20:00',
'21:00', '22:00', '23:00',
return data

Dear Axel,

When you use 'variable': ['10m_u_component_of_wind', '10m_v_component_of_wind'] in the retrieve requests, the output of the retrieve is a list of two data objects.

You could do either uas, vas = ct.catalogue.retrieve(....) or after the retrieve do uas = data[0] and vas = data[1].

Then you can perform the mean operation one variable a a time. Here is a suggestion of how you could do: https://cds.climate.copernicus.eu/toolbox-editor/168/forum_multiple_variables

The objects you manipulate in the Toolbox Editor are not xarrays they are data objects or remote objects i.e. references to a netCDF on disk which is opened as an xarray when performing a computation or printing the object. So the Toolbox tools you can use are similar / directly ported from xarray but the object itself does not have the usual xarray attributes this is why data.uas would not work (beside the fact that in your case it actually was a list).



Wonderful! Thanks so much