How to use remapcon
Added by Fredrik Boberg over 7 years ago
I want to regrid using remapcon the data in SAFRAN_PR_19890101net3.nc onto the CORDEX EUR-11 grid using the command
cdo -remapcon,EUR-11_grid.nc -setgrid,grid_corners_SAFRAN.nc SAFRAN_PR_19890101net3.nc ofile.nc
where grid_corners_SAFRAN.nc contains the grid corner lats and lons.
I get the following messages:
setgrid (Warning): No grid with 572 points found!
remapcon (Abort): Grid corner missing!
Any suggestions on what I do wrong are greatly appreciated.
/Fredrik
SAFRAN_PR_19890101net3.nc (415 KB) SAFRAN_PR_19890101net3.nc | |||
grid_corners_SAFRAN.nc (1.46 MB) grid_corners_SAFRAN.nc | |||
EUR-11_grid.nc (3.33 MB) EUR-11_grid.nc |
Replies (5)
RE: How to use remapcon - Added by Ralf Mueller over 7 years ago
hi Fredrik!
in order to link the corners to the centers, you have to use the bounds
attribute for the centers like this
double lon(ncells) ; lon:standard_name = "longitude" ; lon:long_name = "center longitude" ; lon:units = "radian" ; lon:bounds = "lon_vertices" ; double lon_vertices(ncells, vertices) ;
hth
ralf
RE: How to use remapcon - Added by Fredrik Boberg over 7 years ago
Thanks!
Should I add this to all 3 files?
(I'm not that experienced with cdo/nco so feel free to explain more in detail)
/Fredrik
RE: How to use remapcon - Added by Fredrik Boberg over 7 years ago
I have now added the bounds attribute to the grid_corners_SAFRAN.nc file (see attached file).
But now I get an error message stating that the file contains illegal characters (when doing the cdo remapcon line given above).
If i try to do a cdo info I get "Open failed - unsupported file structure".
Please advice.
/Fredrik
grid_corners_SAFRAN.nc (1.46 MB) grid_corners_SAFRAN.nc |
RE: How to use remapcon - Added by Ralf Mueller over 7 years ago
hi!
it was some manual work, but I guess I merges the variables. please check the new upload.
some general hints
- use the 'bounds' attribute whenever possible - it helps linking data and its coordinates
- put data and all coordinate information in the same file
- cdo needs a data-variable (CF-Convention) to work on a file - that's why 'grid_corners'-file cannot be used directly with setgrid.
hth
ralf
RE: How to use remapcon - Added by Karin Meier-Fleischer over 7 years ago
Hi Fredrik,
first your EUR-11_grid.nc don't have the lon_bnds and lat_bnds variables. If you do an ncdump -h on a correct file the first lines would look like this
netcdf EUR-11_grid_info { dimensions: rlon = 424 ; rlat = 412 ; vertices = 4 ; time = UNLIMITED ; // (1 currently) bnds = 2 ; variables: float lon(rlat, rlon) ; lon:standard_name = "longitude" ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; lon:_CoordinateAxisType = "Lon" ; lon:bounds = "lon_bnds" ; float lon_bnds(rlat, rlon, vertices) ; float lat(rlat, rlon) ; lat:standard_name = "latitude" ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; lat:_CoordinateAxisType = "Lat" ; lat:bounds = "lat_bnds" ; float lat_bnds(rlat, rlon, vertices) ;
To add the grid_corner_lat and grid_corner_lon variables to your data file you can use NCL (http://ncl.ucar.edu/). I wrote an NCL script which reads the files SAFRAN_PR_19890101net3.nc and the grid_corners_SAFRAN.nc and write everything needed to a new file SAFRAN_PR_19890101net3_added_vertices.nc.
Run NCL script in the data directory
ncl read_data_and_grid_corner_write_data_and_grid_corners.ncl
and run cdo as mentioned before, but with the correct EUR-11 grid file
cdo -remapcon,EUR-11_grid_info.nc SAFRAN_PR_19890101net3_added_grid_corners.nc ofile_EUR11_grid_corners.nc
Bye,
Karin
read_data_and_grid_corner_write_data_and_grid_corners.ncl (6.32 KB) read_data_and_grid_corner_write_data_and_grid_corners.ncl | NCL script | ||
EUR-11_grid_info.nc (7.39 MB) EUR-11_grid_info.nc | EUR-11 grid information with lat_bnds/lon_bnds | ||
SAFRAN_PR_19890101net3_added_grid_corners.nc (1.57 MB) SAFRAN_PR_19890101net3_added_grid_corners.nc | NCL output netCDF file with grid_corner_lat/grid_corner_lon |