# Average of muliple variables in a data set

**URL:** <https://forum.ecmwf.int/t/average-of-muliple-variables-in-a-data-set/1718>\
**Category:** Other - Software and tools\
**Tags:** c3s, toolbox\
**Created:** [28 April 2020 22:28 UTC](https://forum.ecmwf.int/t/average-of-muliple-variables-in-a-data-set/1718 "2020-04-28T22:28:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axel\_Schweiger](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Axel\_Schweiger](https://forum.ecmwf.int/u/Axel_Schweiger)\
**Post date:** [28 April 2020 22:28 UTC](https://forum.ecmwf.int/t/average-of-muliple-variables-in-a-data-set/1718/1 "2020-04-28T22:28:55Z")

</div>

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.

Thanks  
 Axel

import cdstoolbox as ct

@ct.application(title='Download data')  
 @ct.output.download()  
 def download\_application():  
 data = ct.catalogue.retrieve(  
 'reanalysis-era5-single-levels',  
 {  
 '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',  
 ],  
 }  
 )  
 print(data)  
 daily\_mean\_u=ct.climate.daily\_mean(data)  
 return data

---

<div class="post-metadata">

**Author:** ![Vivien\_MAVEL](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/v/ecccb3/32.png) [@Vivien\_MAVEL](https://forum.ecmwf.int/u/Vivien_MAVEL)\
**Post date:** [29 April 2020 06:21 UTC](https://forum.ecmwf.int/t/average-of-muliple-variables-in-a-data-set/1718/2 "2020-04-29T06:21:06Z")

</div>

Dear Axel,

When you use&nbsp;'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:&nbsp;[https://cds.climate.copernicus.eu/toolbox-editor/168/forum\_multiple\_variables](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).

Regards.

Vivien

---

<div class="post-metadata">

**Author:** ![Axel\_Schweiger](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Axel\_Schweiger](https://forum.ecmwf.int/u/Axel_Schweiger)\
**Post date:** [29 April 2020 17:43 UTC](https://forum.ecmwf.int/t/average-of-muliple-variables-in-a-data-set/1718/3 "2020-04-29T17:43:58Z")

</div>

Wonderful! Thanks so much

Axel
