Project

General

Profile

enlarge of netCDF grids

Added by Augusto Sanabria over 11 years ago

I have two netCDF files with regular grids of the same resolution and one variable in each file.
The grid of file 2 is about one tenth of the grid of file 1.
How can I expand file 2 to match the grid of file 1? (I need to multiply together the variables of each file
in the smaller grid).
I have tried 'enlarge' but it crash with the error message 'missing values unsupported'.

Any suggestions to solve this problem are appreciated.

Thanks,

Augusto


Replies (4)

RE: enlarge of netCDF grids - Added by Uwe Schulzweida over 11 years ago

Hi Augusto,

The undocumented CDO operator mergegrid is the best solution for this task:

cdo setrtomiss,-1.e30,1.e30 file1.nc tmp.nc
cdo mergegrid tmp.nc file2.nc file3.nc
setrtomiss creates temporary file with the grid size of file1 and all values are missing.
mergegrid fills the temporary file at the grid positions from file2.

The following command combines the above to lines:

cdo mergegrid -setrtomiss,-1.e30,1.e30 file1.nc file2.nc file3.nc

Best regards,
Uwe

RE: enlarge of netCDF grids - Added by Augusto Sanabria over 11 years ago

Thank you Uwe.

I tried the commands you suggested, they do the job, but I don't understand why 'mergegrid' copies the smaller grid data
into 'file3.nc' as a series of discrete cells. The final result (a file of the right grid size) looks like a chess board
with little rectangles in the area corresponding to the smaller grid. The smaller grid data is a surface of correction
factors and it is continuous. I cannot figure out why the discrete cells. Do you have any ideas why this is happening?
Thanks for any suggestion to solve this one.

Regards,

Augusto

RE: enlarge of netCDF grids - Added by Uwe Schulzweida over 11 years ago

Hi Augusto,

The CDO operator mergegrid has the status experimental. We will release it in the next CDO version. Here is the preliminary documentation:

SYNOPSIS
    mergegrid  ifile1 ifile2 ofile

DESCRIPTION
    Merges grid points of all variables from ifile2 to ifile1 and write the result to ofile.
    Only the non missing values of ifile2 will be used. The horizontal grid of ifile2 should 
    be smaller or equal to the grid of ifile1 and the resolution must be the same.
    Only regular rectangular grids are supported. Both input files need to have the same variables 
    and the same number of timesteps.
Could you please attach your example data? That will help us to improve this operator.

Cheers,
Uwe

RE: enlarge of netCDF grids - Added by Augusto Sanabria over 11 years ago

Thank you Uwe.
I tried again making sure that the variables had the same name and number of steps and 'mergegrid'
produced the same results. I'm in the process of generating small test files to show the problem,
I will post them as soon as they are ready.

Cheers,

Augusto

    (1-4/4)