Project

General

Profile

Help Reducing grib files resolution

Added by Ran Glattstein about 6 years ago

Hi,
I have grib1 files with increments of 0.025 degrees in both directions.
I would like to reduce the resolution to around 0.125 degrees.

How can I do that with cdo?


Replies (15)

RE: Help Reducing grib files resolution - Added by Ran Glattstein about 6 years ago

Hi Ralf!

Thanks for the quick response.

I was looking on the documentation and decided to use the following command:

/home/ran/cdo-static/bin/cdo remapbil,r161x129 infile outfile

WHERE infile was a grib1 file already with r161x129 grid, so I was expecting the command to keep the file as is.

For some reason the command reduced the file size dramatically, and when I opened it using pygrib I found it containing nans across all of the values:

\\ Python code
msg = indx.select(shortName=field)[0]
val = msg.values
val = val.flatten()
print val[:20]
[-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --]

I would be so thankful for your further help.
Thanks!

RE: Help Reducing grib files resolution - Added by Ralf Mueller about 6 years ago

I need some sample data to play with for more help

RE: Help Reducing grib files resolution - Added by Ran Glattstein about 6 years ago

Hi,

OK I'm attaching a grib file with forecasts from COSMO-DE model, with rotated grid (North pole at 40N, 170W).
The increment is of 0.025 as I mentioned.
in the rotated grid the files contain [-5,5]x[-5,5] which is around Germany.

I attach the original file (401x401 lonlat grid) and the same file after running the following command (that should not change it):

cdo remapbil,r401x401 /tmp/Ran-5x5A_Trial_cde_for_20130401_0000_013.grib (infile) /tmp/cde_for_20130401_0000_013_R401x401.grib (outfile)_

Thanks a lot!
Ran.

RE: Help Reducing grib files resolution - Added by Ralf Mueller about 6 years ago

the term r401x401 is by definition a global grid. Hence the area from the original file is only a tiny part of the global grid and most of the grid is filled with missing values.

RE: Help Reducing grib files resolution - Added by Ran Glattstein about 6 years ago

OK,
So is there a way I can still reduce the resolution given that I start with this original file?
I would like to take 1/4 of the longitudes and 1/4 of the latitudes and thus get a grid with resolution ~0.025*4 = 0.10

Thanks again!

RE: Help Reducing grib files resolution - Added by Ralf Mueller about 6 years ago

you need the bounding box in regular lon-lat-coordinates

I uploaded a starting point for germany. use it with

cdo remapbil,targetGrid cde_for_20130401_0000_013_original.grib tr.grb

for getting things right, this site might help: https://boundingbox.klokantech.com/

targetGrid (288 Bytes) targetGrid

RE: Help Reducing grib files resolution - Added by Ran Glattstein about 6 years ago

Hi Ralf!
Thank you so much for the amazingly quick responses!

so this configuration file should refer to both my original grib and then below it should specify the outfile properties?
or is it only specifying the outfile properties?

Plus, Does the fact that I'm dealing with a rotated grid as I mentioned, shall I write in the file the rotated degrees or the original ones?

Thank you!
Ran.

RE: Help Reducing grib files resolution - Added by Ralf Mueller about 6 years ago

the target grid should be a regular lon-lat grid area covering your original (curved) grid. that's what I had in mind. it does not contain any information about the source grid. Thats all handled by the remapbil opearator.

I thought your original aim was to convert the rotated grid into a regular (non-rotated) one, right? ... just to keep me on the right track ...

cheers
ralf

RE: Help Reducing grib files resolution - Added by Ran Glattstein about 6 years ago

What happens is that I have this file, which has resolution 0.025 degrees both directions and is rotated.
I eventually would like to :

1. move back to Normal coordinates
2. interpolate to have the points (47.0N, 5E),(47.125, 5),(47.25, 5).....(47,5.125),(47,5.25).... And so on.

So if I understand correctly - the command you mentioned should help me get the normal coordinates?
If so, How do I interpolate and make sure to have the sampling points mentioned?

Thanks!

RE: Help Reducing grib files resolution - Added by Ralf Mueller about 6 years ago

hi Ran!

move back to normal coordinates and interpolate to (47.0N, 5E),(47.125, 5),(47.25, 5).....(47,5.125),(47,5.25) are the same thing in my opinion.

The only thing, you can do without interpolation is overwriting the coordinates itself.

your data looks like this

it does not fit into a regular grid, maybe into a curvilinear. the rempabil command will perform the interpolation to the new coordinates

cdo -P 8 -f nc remapbil,targetGrid cde_for_20130401_0000_013_original.grib cde_lonlat.nc

the data looks like this:

or like this in panoply

This does not look correct. is the data in the original correctly show in the first image?

RE: Help Reducing grib files resolution - Added by Ralf Mueller about 6 years ago

I took the wrong field in my last reply. THIS is the correct one

RE: Help Reducing grib files resolution - Added by Ralf Mueller about 6 years ago

Finally: CDO does the coordinate transformation and data interpolation in a single step.

RE: Help Reducing grib files resolution - Added by Ran Glattstein about 6 years ago

Hi Ralf!

Thank you so much for the help! it seems to be working, EXCEPT FOR 1 issue:

When I run :

/home/ran/cdo-static/bin/cdo remapbil,/mnt/Ranger/targetGrid_0.0625 /mnt/DE/cde_for_separated/2015/201506/cde_for_20150625_0600_013.grib /tmp/RAN1_0.0625.grib

the input_file contains also a message for VMAX_10M (and the data exists - checked by grib_dump to json).
the output_file seems to contain it also (grib_ls shows it) BUT when I try to get the values for VMAX_10M using the grib_dump to json I get an empty file...

Thanks in advance!!!
Ran.

RE: Help Reducing grib files resolution - Added by Ran Glattstein about 6 years ago

and Here is the configuration file :

    (1-15/15)