Project

General

Profile

Converting GRIB to NetCDF with two parameters with same code but different leveltype

Added by Brian Højen-Sørensen almost 7 years ago

Hi,

I have a GRIB file with two parameters (surface pressure and mean sea-level pressure) that have the same GRIB code, 1, but different level type, 103 and 105, respectively.

wgrib -v <infile>
...
13:30512448:D=2017062509:PRES:0 m above gnd:kpds=1,105,0:39hr fcst:winds in grid direction:"Pressure [Pa]
...
17:43470006:D=2017062509:PRES:0 m above MSL:kpds=1,103,0:39hr fcst:winds in grid direction:"Pressure [Pa]
...

However, when converting to NetCDF the codetab (GRIB-table) cannot distinguish between the two, since you can only provide the GRIB code, which is 1 for both of them.
1 PRES Pressure [Pa]
1 SP Surface pressure [Pa]

Is there anyway to handle leveltype during the convertion (in the codetab), or is there an easy way of changing the code of one of them before the convertion?
The only solution I have that works is by splitting it first (using select,ltype=105) and the doing the convertion separately. But that is really not a nice way to do it since I'm converting a lot of GB every day.

Regards
Brian Højen-Sørensen


Replies (4)

RE: Converting GRIB to NetCDF with two parameters with same code but different leveltype - Added by Uwe Schulzweida almost 7 years ago

The latest CDO release 1.8.2 comes with the new operator changemulti. This operator can change GRIB code/leveltype/level combinations.
Here is an example to change the code number 100 to 200 for the leveltype 105 on all levels:

cdo changemulti,'(100;105;*|200;105;*)'  infile  outfile
This operator is a CDO contribution of the KNMI. We don't have expirience with it, I used it the first time today.

RE: Converting GRIB to NetCDF with two parameters with same code but different leveltype - Added by Brian Højen-Sørensen almost 7 years ago

Hi Uwe,

Thanks for the answer, it works quite well it seems.
It's not the ideal solution, but I guess I can work with it.

I still think it would be nice to define a new codetab format with:
1;105;0 MSLP Mean sea-level pressure [Pa]
1;103;0 SP Surface pressure [Pa]

as an alternative to the one we have now.
1 MSLP Mean sea-level pressure [Pa]
1 SP Surface pressure [Pa]

Cheers,
Brian

RE: Converting GRIB to NetCDF with two parameters with same code but different leveltype - Added by Uwe Schulzweida almost 7 years ago

Hi Brian,

Thats a good idea! I have implemented the level type for the code table for the next CDO release. A prerelease for testing is available in the download area.
You can use this new feature only with the operator setcodetab:

cat > mycodetab << EOR
1;105 MSLP Mean sea-level pressure [Pa]
1;103 SP Surface pressure [Pa]
EOR

cdo -f nc setcodetab,mycodetab  infile  outfile

Cheers,
Uwe

RE: Converting GRIB to NetCDF with two parameters with same code but different leveltype - Added by Brian Højen-Sørensen almost 7 years ago

Hi Uwe,

It works perfectly. :-)
Exactly what I was looking for. That really simplifies the pre-processing of my GRIB files (and reduces I/O significantly).

Thanks
Brian

    (1-4/4)