How to get GRIB data with multiple variables

Hi all,


I would like to get some ERA5 hourly data at single levels for some variables, through the CDS Toolbox. I have a few issues :

  1. Even if I use the key "'format' : 'grib'", I get netCDF files in output (see the code below), and this whatever the variable chosen. I would like to have GRIB data only.
  2.  Is there any better way to have data for multiple variables ? I have here a code that I have to run for each variable, however I would like to have all variables needed downloaded. I tried using " 'variables' : '<var1>','<var2>' " but it only downloads the first variable.
  3.  And by chance, does someone know how to download automatically (without having to click on the link after the code has been run ?)


Thanks a lot ! My code is the one below : 

--------------------------

import cdstoolbox as ct

variables = {
    'Near-Surface Air Temperature': '2m_temperature',
    'Eastward Near-Surface Wind': '10m_u_component_of_wind',
}
@ct.input.dropdown('variable', label='Variable', values=variables.keys())
@ct.application(title='Hello World!')
@ct.output.download()
def application(variable):

    data = ct.catalogue.retrieve(
        'reanalysis-era5-single-levels',
        {
            'product_type':'reanalysis',
            'format':'grib',
            'area':           '47.00/-1.00/45.00/1.00',
            'variable': variables[variable],
            'year':'2005',
            'month':'03',
            'day':'04',
            'time':[
                '03:00','04:00','05:00',
                '06:00','07:00','08:00',
                '09:00'
            ]
        })
    return data

--------------------------------

Hello Julien,

1) I think the Toolbox now returns NetCDF data by default, regardless of the format the data are stored/retrieved in;

2) Currently each variable is returned in a separate (netCDF) file for download; i think future versions of the Toolbox may allow a user to download all variables in a single file;

3)  I don't think it is currently possible to automate downloads from the Toolbox yet - although there may be a Toolbox API in the future which may allow this,

Thanks,

Kevin

Thanks Kevin.

I have another question. How can I understand the "time" in the netCDF file, what is the reference ? I guess it can be Jan 1, 1970 but I would like to convert the netCDF files I get to a simple timeseries (.csv file for example, in python) which can be read easily, therefore I want to convert the time to a user-friendly format.


Thanks a lot,


Julien

Hi Julien,

The CDO software (https://code.mpimet.mpg.de/projects/cdo/  ) is very useful for working with  netCDF files (esp. for climate data). One of the commands will print out the data values along with the specified columns e.g.

$ cdo -outputkey,year,month,day,time,lat,lon,value ERA5.nc 
# year month day     time    lat    lon    value  
1979  1  1 00:00:00    -10    113 289.4848  
1979  1  1 00:00:00    -10 113.25 244.5822  
1979  1  1 00:00:00    -10  113.5  211.952  
1979  1  1 00:00:00    -10 113.75  247.903  
1979  1  1 00:00:00    -10    114 305.7999  
1979  1  1 00:00:00    -10 114.25 390.6962

You could pipe this output to a file and then modify the date/time strings to get the required form, e.g.

$ cdo -outputkey,year,month,day,time,lat,lon,value ERA5.nc > ERA5.txt

(Although this may not be advisable for large netCDF files, as you would get very large .txt files)


Hope that helps,

Kevin

Hi Julien,

It seems that you don't do any processing or visualizing data in the toolbox. If you just want to download data, why don't you try just CDSAPI? Then you can choose grib and put multiple variables in the same file, do stuff automatically all without limitations of the toolbox.