Project

General

Profile

ECMWF GRIB to NetCDF conversion of reduced Gaussian grid data does not include geolocation

Added by Maarten Sneep over 10 years ago

Hi,

I'm using meteo data from ECMWF on a reduced Gaussian grid. The file is converted by ECMWF from GRIB to NetCDF. The history attribute in the netCDF file tells me:

cdo -t ecmwf -f nc copy ecmwf_od_sfc_2013052300+3to12_rg.gb ecmwf_od_sfc_2013052300+3to12_rg.nc

In the output there is no indication of geolocation information. We currently rely an external conversion table that basically contains the tables from ECMWF: Descriptions of the Gaussian grids. We would like to see the tables inside the netCDF files, because the data is going to be used operationally for Sentinel 5 precursor processing. Right now if ECMWF upgrades the spatial resolution we can't handle the result (not good).

However, the information we need (the latitude values, the number of longitudes at each latitude) is available from the GRIB file. A colleague wrote the following using pygrib:

#!/usr/bin/env python
import pygrib

f='testfile1.grb' # reduced_gg
#f='testfile2.grb' # regular lat-lon

grbs = pygrib.open(f)
grb = grbs.next()
if grb.has_key('pl'): # only available for reduced grids
    print('number of lons_per_lat: {0}; number of longitudes: {1}'.format(grb['pl'], len(grb['pl']))
print('Nx = {0}; Ny = {1}'.format(grb['Nx'], grb['Ny'])) # Nx not used for reduced_gg; number of lat. values
print('Ni = {0}; Nj = {1}'.format(grb['Ni'], grb['Nj'])) # not used for reduced_gg; max. num. lon values
print('distinctLatitudes {0}'.format(grb['distinctLatitudes']))   # actual latitude values
print('Number of latitudes = {0}'.format(len(grb['distinctLatitudes']))
print('distinctLongitudes {0}'.format(grb['distinctLongitudes'])) # all possible lon values
print('Number of longitudes = {0}'.format(len(grb['distinctLongitudes']))

lons = grb['distinctLongitudes']
print(lons[:1280*2]) # print lons at equator

Is it possible to instruct CDO to include two variables in the output:

  1. A list of latitudes
  2. A list of the number of longitudes for each latitude
  3. Sticking to the Python theme: The cumulative number of longitudes (to allow quick and easy indexing into the linear spatial dimension).

I know nothing about GRIB, and I prefer to keep it that way. Of course with pygrib we could develop our own conversion tool, and have our data processing center do the conversion including the geolocation information. If this can be done with CDO, then all the better.


Replies (1)

RE: ECMWF GRIB to NetCDF conversion of reduced Gaussian grid data does not include geolocation - Added by Uwe Schulzweida over 10 years ago

There is no way to add this information to a netCDF file with CDO.

    (1-1/1)