# Error while trying to calculate & download ERA-5 daily mean data

**URL:** <https://forum.ecmwf.int/t/error-while-trying-to-calculate-download-era-5-daily-mean-data/1727>\
**Category:** Other - Software and tools\
**Tags:** c3s, toolbox\
**Created:** [6 June 2020 00:20 UTC](https://forum.ecmwf.int/t/error-while-trying-to-calculate-download-era-5-daily-mean-data/1727 "2020-06-06T00:20:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lei\_Zhang](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/l/6a8cbe/32.png) [@Lei\_Zhang](https://forum.ecmwf.int/u/Lei_Zhang)\
**Post date:** [6 June 2020 00:20 UTC](https://forum.ecmwf.int/t/error-while-trying-to-calculate-download-era-5-daily-mean-data/1727/1 "2020-06-06T00:20:33Z")

</div>

Hi,

Since ERA-5 does not provide daily mean data (at least I couldn't find it), I am trying to use the toolbox to calculate and download the data that I need.&nbsp;

Below is the code I wrote (based on the examples). I have met some issues, which seem related to the function ct.climate.daily\_mean().

I use Matlab, and am very new to Python. If any one could kindly give me some suggestions, I would greatly appreciate it.

The code:

**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': ['1979','1980'],**  
**'month': ['01'],**  
**'day': ['01','02'],**  
**'time': ['00:00', '06:00', '12:00','18:00'],**  
**}**  
**)**  
  
**# daily\_mean = ct.climate.climatology\_mean(data, frequency='dayofyear')**  
**data\_daily = ct.climate.daily\_mean(data)**  
  
**return data\_daily**

The error message:

```
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 38, 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/cdstools/cdstools/season.py", line 188, in daily_mean
    mean = util.resample(data, freq='D', **kwargs)
  File "/opt/cdstoolbox/cdstools/cdstools/util.py", line 350, in resample
    resample = data.resample(label=label, closed=closed, keep_attrs=keep_attrs,
AttributeError: 'list' object has no attribute 'resample'

Thank you!
```

Lei

---

<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:** [8 June 2020 06:45 UTC](https://forum.ecmwf.int/t/error-while-trying-to-calculate-download-era-5-daily-mean-data/1727/2 "2020-06-08T06:45:38Z")

</div>

Dear Lei,

When you retrieve multiple data the retrieve function return a list of data objects so 'data' in your code is a list.&nbsp;

I suggest you to retrieve the data as follows

```
u, v = ct.catalogue.retrieve(
	'reanalysis-era5-single-levels',
	{
		'product_type': 'reanalysis',
		'variable': [
		'10m_u_component_of_wind', '10m_v_component_of_wind',
		],
		'year': ['1979','1980'],
		'month': ['01'],
		'day': ['01','02'],
		'time': ['00:00', '06:00', '12:00','18:00'],
	}
)
```

u and v are then data objects as they are meant to be to be manipulated with the CDS Toolbox.

I hope this helps. Let me know if you have any further question.

Regards.

Vivien&nbsp;

---

<div class="post-metadata">

**Author:** ![Lei\_Zhang](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/l/6a8cbe/32.png) [@Lei\_Zhang](https://forum.ecmwf.int/u/Lei_Zhang)\
**Post date:** [8 June 2020 14:35 UTC](https://forum.ecmwf.int/t/error-while-trying-to-calculate-download-era-5-daily-mean-data/1727/3 "2020-06-08T14:35:36Z")

</div>

Dear Vivien,

Thank you very much for your kind help. I really appreciate it.

It works perfect now!

Best regards,

Lei

---

<div class="post-metadata">

**Author:** ![Mohanmurali\_KRISHNA](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@Mohanmurali\_KRISHNA](https://forum.ecmwf.int/u/Mohanmurali_KRISHNA)\
**Post date:** [4 August 2022 07:09 UTC](https://forum.ecmwf.int/t/error-while-trying-to-calculate-download-era-5-daily-mean-data/1727/4 "2022-08-04T07:09:54Z")

</div>

> import cdstoolbox as ct
> 
> @ct.application(title='Download data')  
> @ct.output.download()  
> def download\_application():  
> &nbsp; &nbsp; count=1  
> &nbsp; &nbsp; for yr in ['2019']:  
> &nbsp; &nbsp; &nbsp; &nbsp; for mn in [ '01', '02', '03',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '04', '05', '06',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '07', '08', '09',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '10', '11', '12'  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]:  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; t, u, v = ct.catalogue.retrieve(  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'reanalysis-era5-pressure-levels',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'product\_type': 'reanalysis',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'variable': [
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'temperature',&nbsp; 'u\_component\_of\_wind',&nbsp; 'v\_component\_of\_wind'  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'pressure\_level': [  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '1', '2', '3',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '5', '7', '10',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '20', '30', '50',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '70', '100', '125',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '150', '175', '200',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '225', '250', '300',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '350', '400', '450',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '500', '550', '600',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '650', '700', '750',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '775', '800', '825',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '850', '875', '900',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '925', '950', '975',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '1000',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'year': yr,  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'month': mn,  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'day': [  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '01', '02', '03',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '04', '05', '06',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '07', '08', '09',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '10', '11', '12',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '13', '14', '15',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '16', '17', '18',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '19', '20', '21',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '22', '23', '24',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '25', '26', '27',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '28', '29', '30', '31'  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;],  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'time': [  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '00:00', '01:00', '02:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '03:00', '04:00', '05:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '06:00', '07:00', '08:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '09:00', '10:00', '11:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '12:00', '13:00', '14:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '15:00', '16:00', '17:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '18:00', '19:00', '20:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '21:00', '22:00', '23:00',  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;],  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;)  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;day\_mean=ct.climate.daily\_mean(????,keep\_attrs=True)  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if count == 1:  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;day\_mean\_all=day\_mean  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else: &nbsp; &nbsp; &nbsp;&nbsp;  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;day\_mean\_all=ct.cube.concat([day\_mean\_all, day\_mean], dim='time')  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;count = count + 1  
> &nbsp; &nbsp; return day\_mean\_all

Sir, i m unable to download data by using above code.&nbsp; here i m not able to get how can i get multiple variables in one file .&nbsp;

how can i use data object in line of&nbsp; day\_mean=ct.climate.daily\_mean(????,keep\_attrs=True) when it is for multiple variable download (like t,u,v)
