Project

General

Profile

Calculating area of SCRIP grid

Added by Andreas Hilboll over 6 years ago

I manually (i.e., without CDO) created a netCDF file which I believe to follow the SCRIP standard:

netcdf blatest88 {
dimensions:
    grid_ysize = 210 ;
    grid_xsize = 210 ;
    grid_corners = 4 ;
    grid_rank = 2 ;
    grid_size = 44100 ;
variables:
    float dummydata(grid_ysize, grid_xsize) ;
    float grid_center_lat(grid_ysize, grid_xsize) ;
        grid_center_lat:units = "degrees" ;
        grid_center_lat:FieldType = 104 ;
        grid_center_lat:MemoryOrder = "XY " ;
        grid_center_lat:description = "Latitude on mass grid" ;
        grid_center_lat:stagger = "M" ;
        grid_center_lat:sr_x = 1 ;
        grid_center_lat:sr_y = 1 ;
        grid_center_lat:bounds = "grid_corner_lat" ;
    float grid_center_lon(grid_ysize, grid_xsize) ;
        grid_center_lon:units = "degrees" ;
        grid_center_lon:FieldType = 104 ;
        grid_center_lon:MemoryOrder = "XY " ;
        grid_center_lon:description = "Longitude on mass grid" ;
        grid_center_lon:stagger = "M" ;
        grid_center_lon:sr_x = 1 ;
        grid_center_lon:sr_y = 1 ;
        grid_center_lon:bounds = "grid_corner_lon" ;
    float grid_corner_lat(grid_ysize, grid_xsize, grid_corners) ;
        grid_corner_lat:units = "degrees" ;
    float grid_corner_lon(grid_ysize, grid_xsize, grid_corners) ;
        grid_corner_lon:units = "degrees" ;
    int64 grid_dims(grid_rank) ;
    double grid_imask(grid_size) ;
        grid_imask:units = "unitless" ;

However, cdo griddes reports the grid as "generic", and cdo gridarea complains that "Unsupported grid type: generic".

I was hoping to be able to use cdo gridarea on such a manually created file. Any help is greatly appreciated.

(Ultimately, I would like to use cdo gencon using the grid defined like this as target grid)


Replies (4)

RE: Calculating area of SCRIP grid - Added by Uwe Schulzweida over 6 years ago

A grid description file in SCRIP format is directly supported as a CDO grid description file. That means it can be used wherever a grid description file is needed in CDO.

cdo gridarea -random,<grid_description_file>
But those files can't be used as a CDO datafile, because it doesn't follow the netCDF CF convention. To make it netCDF CF conform, you have to add the following attributes:
netcdf blatest88 {
dimensions:
    grid_ysize = 210 ;
    grid_xsize = 210 ;
    grid_corners = 4 ;
    grid_rank = 2 ;
    grid_size = 44100 ;
variables:
    float dummydata(grid_ysize, grid_xsize) ;
-->     dummydata:coordinates = "grid_center_lon grid_center_lat" ;
    float grid_center_lat(grid_ysize, grid_xsize) ;
-->     grid_center_lat:standard_name = "latitude" ;
        grid_center_lat:units = "degrees" ;
        grid_center_lat:FieldType = 104 ;
        grid_center_lat:MemoryOrder = "XY " ;
        grid_center_lat:description = "Latitude on mass grid" ;
        grid_center_lat:stagger = "M" ;
        grid_center_lat:sr_x = 1 ;
        grid_center_lat:sr_y = 1 ;
        grid_center_lat:bounds = "grid_corner_lat" ;
    float grid_center_lon(grid_ysize, grid_xsize) ;
-->     grid_center_lon:standard_name = "longitude" ;
        grid_center_lon:units = "degrees" ;
        grid_center_lon:FieldType = 104 ;
        grid_center_lon:MemoryOrder = "XY " ;
        grid_center_lon:description = "Longitude on mass grid" ;
        grid_center_lon:stagger = "M" ;
        grid_center_lon:sr_x = 1 ;
        grid_center_lon:sr_y = 1 ;
        grid_center_lon:bounds = "grid_corner_lon" ;
    float grid_corner_lat(grid_ysize, grid_xsize, grid_corners) ;
        grid_corner_lat:units = "degrees" ;
    float grid_corner_lon(grid_ysize, grid_xsize, grid_corners) ;
        grid_corner_lon:units = "degrees" ;
    int64 grid_dims(grid_rank) ;
    double grid_imask(grid_size) ;
        grid_imask:units = "unitless" ;
-->     grid_imask:coordinates = "grid_center_lon grid_center_lat" ;

RE: Calculating area of SCRIP grid - Added by Andreas Hilboll over 6 years ago

Great, thank you, Uwe! After adding these attributes, cdo griddes correctly shows the curvilinear grid. However, that curvilinear grid is only the second grid in the file; I had to remove grid_rank and grid_dims before cdo griddes would report only one grid in the file. Are grid_rank and grid_dims needed for anything?

RE: Calculating area of SCRIP grid - Added by Uwe Schulzweida over 6 years ago

The original SCRIP software need the grid_rank and grid_dims to read the grid correctly.

RE: Calculating area of SCRIP grid - Added by Andreas Hilboll over 6 years ago

So I understand CDO doesn't need grid_rank and grid_dims. Great - thanks a lot, Uwe!

    (1-4/4)