Hello.
I would like to use CDS Toolbox to process ERA5 data and down time series as csv. I have tried using the codes I modified below. I am able to do so with 1 time series data (refer to test2 in the code below). I would like to download two time series (refer to test3 in the code below) in one csv file. How do I do that? Can I strip the test (<xarray.DataArray 'tas' (time: 24)>) into just values, combined several of them together and save as csv?
My goal is to have 16 time series from several location in one csv file, and several csv files for several parameters. The simple code below is not related to my goal.
import cdstoolbox as ct
variables = {
'Near-Surface Air Temperature': '2m_temperature',
'Eastward Near-Surface Wind': '10m_u_component_of_wind',
'Northward Near-Surface Wind': '10m_v_component_of_wind',
'Sea Level Pressure': 'mean_sea_level_pressure',
'Surface Pressure': 'surface_pressure',
}@ct.application(title="AWS Matching data acquisation", description="Download point data matching AWS location for TNB Project. Main purpose is to compare AWS observation with ERA5 and ERA5-Land. Data downloaded will be further processed in R.")
@ct.input.dropdown('variable', label='Variable', values=variables.keys())
@ct.output.download()
@ct.output.download()
def application(variable):
# Retrieve the hourly 2m temperature over Europe for the selected year
data = ct.catalogue.retrieve(
'reanalysis-era5-single-levels',
{
'variable': variables[variable],
'product_type': 'reanalysis',
'year': 1999,
'month': 1,
'day': 1,
'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'
],
'grid': [3, 3],
'area': [60., -11., 34., 35.], # retrieve data for Europe only
}
)
test = ct.geo.spatial_average(data)
print(test)
test2 = ct.cdm.to_csv(test)
#Create an empty list
empty_list = []
#
temporary_list=test
empty_list.append(temporary_list)
empty_list.append(temporary_list-50)
test3 = ct.cdm.to_csv(empty_list)
print(test2)
print(test3)
return test2, test3
Yunus.