Hi guys,
I'm submitting a workflow to perform the daily agreggation of temperature_2m on your server side, but after 2 hours, the request failed due to memory issues.
Unfortunattely it will cost to much if I download hourly data and perform this operation locally.
Do you have any advice?
Check my script bellow:
import cdsapi
cw = cdsapi.Client()
with open("workflows/daily_bboxbrazil_Tmax2m.py") as f:
code = f.read()
rw = cw.workflow(code)
print(cw.download(rw))
script of 'daily_bboxbrazil_Tmax2m.py':
import cdstoolbox as ct
@ct.application(title = 'Daily download Tmax2m')
@ct.output.download()
def application():
data = ct.catalogue.retrieve(
'reanalysis-era5-single-levels',
{
'variable': '2m_temperature',
'product_type': 'reanalysis',
'year': ['2010', '2011', '2012', '2013', '2014',
'2015', '2016', '2017', '2018', '2019',
'2020'],
'month': ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
'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', '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'],
'area': [5, -74, -35, -34,],
}
)
daily_aggregation = ct.cube.resample(data, how='max', freq='day', keep_attrs = True)
# print(data, daily_aggregation)
return daily_aggregation
4 Comments
José Lucas Safanelli
Ops, here is the console message:
Kevin Marsh
Hi Jose,
I believe the memory error is because you are trying to read the data for all years in one request; for hourly data is is best to loop over months /years, requesting 1 month, subset the data you need and concatenate the results together as you go along. See:
How to calculate daily data from hourly data/process a large amount of data in the Toolbox
However, if you want daily statistics of ERA5 hourly data, there is an application which will do this :
https://cds.climate.copernicus.eu/cdsapp#!/software/app-c3s-daily-era5-statistics?tab=app
and you can call this application via a CDS API script; see:
Retrieve daily ERA5/ERA5-Land data using the CDS API
Hope that helps,
Kevin
José Lucas Safanelli
Dear Kevin, you nailed it! Thanks for the quick support
José Lucas Safanelli
Just out of curiosity, do you know how to change the name of the file when downloading it from the workflow? It uses the CDS 'location' by default.
Some change un this part, perhaps:
rw = cw.workflow(code)
print(cw.download(rw))