I'd like to compute the daily climatology and standard deviation of a variable (in this case pressure on two levels).
I'm able to do this, but currently can't create a single data object which I can download as a netcdf.
My code currently outputs a data object area_ave_c
which is the climatology, and area_ave_s
which has the standard deviations.
I can get the function to return either one of these objects, but ideally I would like to merge them and return one data object (downloaded as a netcdf) which contains both variables.
import cdstoolbox as ct
@ct.application(title='Retrieve Data')
@ct.output.download()
def retrieve_sample_data():
data = ct.catalogue.retrieve(
'reanalysis-era5-pressure-levels',
{
'product_type': 'reanalysis',
'pressure_level': [
'1','2',
],
'year': [ '1979', '1980', '1981'
],
'month': [
'01','02','12',
],
'day': [
'01', '02', '03',
'04', '05', '06',
],
'time': [
'00:00',
],
"grid": [1, 1],
"area":[90,-180,60,180],
}
)
climatology = ct.climate.climatology_mean(data,frequency='dayofyear')
std_deviation = ct.climate.climatology_std(data,frequency='dayofyear')
area_ave_c = ct.geo.spatial_average(climatology)
area_ave_s = ct.geo.spatial_average(std_deviation)
return (area_ave_s, area_ave_c)
The return line throws a bug currently, but I would like to download both data objects and running the code twice to output them sequentially is wasteful (as it gets all the data twice).