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.
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
3 Comments
Vivien MAVEL
Dear Lei,
When you retrieve multiple data the retrieve function return a list of data objects so 'data' in your code is a list.
I suggest you to retrieve the data as follows
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
Lei Zhang
Dear Vivien,
Thank you very much for your kind help. I really appreciate it.
It works perfect now!
Best regards,
Lei
Mohanmurali KRISHNA
Sir, i m unable to download data by using above code. here i m not able to get how can i get multiple variables in one file .
how can i use data object in line of day_mean=ct.climate.daily_mean(????,keep_attrs=True) when it is for multiple variable download (like t,u,v)