import cdstoolbox as ct
layout = {
‘input_ncols’: 1,
‘output_align’: ‘bottom’
}
@ct.input.dropdown(‘variable’, label=‘Variable’, values=[‘total_precipitation’])
@ct.application(title=‘Average Precipitation’, layout=layout)
@ct.output.figure()
def application(variable,):
request=['reanalysis-era5-single-levels-monthly-means',
{
'format':'grib',
'product_type':'monthly_averaged_reanalysis',
'variable':'total_precipitation',
'year':['%04d'%(year) for year in range(2014,2016)],
'month':['%02d'%(mnth) for mnth in range(1,13)],
'time':'00:00'
}]
data = ct.catalogue.retrieve(*request)
gdd_map = ct.cube.average(data, 'time')
fig = ct.cdsplot.geomap(gdd_map,
left=0.08, right=0.97, bottom=0.2, top=0.96,
pcolormesh_kwargs={
'cmap': 'YlGnBu','vmin':0, 'vmax':50,
'cbar_kwargs':{
'orientation': 'vertical', 'shrink': 0.6,
'extend':'max', 'pad':0.05,
},
'xticks':[0,60,120,-60,-120],
'yticks':[0,60,-60],
},
coastlines_kwargs={'linewidth':0.4, },
title='Average precipitation',
projection=ct.cdsplot.crs.PlateCarree(),
#xlabel='', ylabel='latitude',
)
return fig</pre>