Project

General

Profile

Grid area for earth surface only

Added by Yousef Albuhaisi almost 5 years ago

Hi,
I hope I am not asking something already been asked before!

I have calculated grid area and grid weights for a box of lon 2,42 lat 55,72. However, I only want earth surface and want to take out oceans from my calculations. would that be possible?


Replies (6)

RE: Grid area for earth surface only - Added by Karin Meier-Fleischer almost 5 years ago

Hi Yousef,

| I hope I am not asking something already been asked before!

Oh, you do. I've googled the simple question 'cdo get data only on land' for you and voila there are many, many links to the answers. For example, the first one will point you to an older forum issue: https://code.mpimet.mpg.de/boards/2/topics/5225

-Karin

RE: Grid area for earth surface only - Added by Yousef Albuhaisi almost 5 years ago

Hi Karin,

Thank you.

but I still have a problem. When I do mask targeted lat lon box and do calculate weights, the sum of the weights is not 1! do you have any idea how to solve this?

Yousef

RE: Grid area for earth surface only - Added by Karin Meier-Fleischer almost 5 years ago

Please, tell us what your cdo calls are. It is not possible to help without any further information!

RE: Grid area for earth surface only - Added by Yousef Albuhaisi almost 5 years ago

I have methane emissions for Scandinavia and I want to calculate grid area for each cell in order to divide the emissions value of each cell by cell area, then to sum total emissions. Cell weights is needed as well.

Here what I have done:

Generate template of targeted resolution (0.1 degree for example)
cdo -f nc -sellonlatbox,2,42,55,72 -random,r3600x1800 template_0.1deg.nc

Create sea mask for the same resolution
cdo -f nc2 setctomiss,0 -gtc,0 -remapcon,r3600x1800 -topo seamask.nc

Clip targeted template to sea mask nc file

cdo ifthen seamask_new.nc template_0.1deg.nc template_0.1deg_masked.nc

Make grid area and weighted area calculated nc file
cdo gridarea template_0.1deg_masked.nc grid_area_0.1deg.nc
cdo gridweights template_0.1deg_masked.nc grid_weights_0.1deg.nc

when I checked the weights, the sum of them is not 1

Hope I did explain it well!

RE: Grid area for earth surface only - Added by Karin Meier-Fleischer almost 5 years ago

The 3rd line has given an error! You forgot to do sellonlatbox in the second call, too. So, the question is what files do you check and how?

The correct calls should be

cdo -f nc -sellonlatbox,2,42,55,72 -random,r3600x1800 template_0.1deg.nc

cdo -f nc2 setctomiss,0 -gtc,0 -sellonlatbox,2,42,55,72 -remapcon,r3600x1800 -topo seamask.nc

cdo ifthen seamask.nc template_0.1deg.nc template_0.1deg_masked.nc

cdo gridarea template_0.1deg_masked.nc grid_area_0.1deg.nc

cdo gridweights template_0.1deg_masked.nc grid_weights_0.1deg.nc

Do you mean with checksum the file size? Using 'cdo sinfo' and 'ncdump' show you that the grids are the same only the metadata differs.

cdo sinfon grid_area_0.1deg.nc
   File format : NetCDF2
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : unknown  unknown  c instant       1   1     68170   1  F64  : cell_area     
   Grid coordinates :
     1 : lonlat                   : points=68170 (401x170)
                              lon : 2 to 42 by 0.1 degrees_east
                              lat : 55.05 to 71.95 by 0.1 degrees_north
   Vertical coordinates :
     1 : surface                  : levels=1
cdo sinfon: Processed 1 variable [0.00s 22MB]
[~/CDO/Support/remap] > cdo sinfon grid_weights_0.1deg.nc 
   File format : NetCDF2
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : unknown  unknown  c instant       1   1     68170   1  F64  : cell_weights  
   Grid coordinates :
     1 : lonlat                   : points=68170 (401x170)
                              lon : 2 to 42 by 0.1 degrees_east
                              lat : 55.05 to 71.95 by 0.1 degrees_north
   Vertical coordinates :
     1 : surface                  : levels=1
cdo sinfon: Processed 1 variable [0.00s 22MB]
ncdump -h grid_area_0.1deg.nc
netcdf grid_area_0.1deg {
dimensions:
    lon = 401 ;
    lat = 170 ;
variables:
    double lon(lon) ;
        lon:standard_name = "longitude" ;
        lon:long_name = "longitude" ;
        lon:units = "degrees_east" ;
        lon:axis = "X" ;
    double lat(lat) ;
        lat:standard_name = "latitude" ;
        lat:long_name = "latitude" ;
        lat:units = "degrees_north" ;
        lat:axis = "Y" ;
    double cell_area(lat, lon) ;
        cell_area:standard_name = "area" ;
        cell_area:long_name = "area of grid cell" ;
        cell_area:units = "m2" ;

// global attributes:
        :CDI = "Climate Data Interface version 1.9.6 (http://mpimet.mpg.de/cdi)" ;
        :Conventions = "CF-1.6" ;
        :history = "Wed Dec 11 10:57:20 2019: cdo gridarea template_0.1deg_masked.nc grid_area_0.1deg.nc\n",
            "Wed Dec 11 10:57:20 2019: cdo ifthen seamask.nc template_0.1deg.nc template_0.1deg_masked.nc\n",
            "Wed Dec 11 10:56:46 2019: cdo -f nc2 setctomiss,0 -gtc,0 -sellonlatbox,2,42,55,72 -remapcon,r3600x1800 -topo seamask.nc" ;
        :CDO = "Climate Data Operators version 1.9.6 (http://mpimet.mpg.de/cdo)" ;
}
[~/CDO/Support/remap] > ncdump -h grid_weights_0.1deg.nc 
netcdf grid_weights_0.1deg {
dimensions:
    lon = 401 ;
    lat = 170 ;
variables:
    double lon(lon) ;
        lon:standard_name = "longitude" ;
        lon:long_name = "longitude" ;
        lon:units = "degrees_east" ;
        lon:axis = "X" ;
    double lat(lat) ;
        lat:standard_name = "latitude" ;
        lat:long_name = "latitude" ;
        lat:units = "degrees_north" ;
        lat:axis = "Y" ;
    double cell_weights(lat, lon) ;

// global attributes:
        :CDI = "Climate Data Interface version 1.9.6 (http://mpimet.mpg.de/cdi)" ;
        :Conventions = "CF-1.6" ;
        :history = "Wed Dec 11 10:57:20 2019: cdo gridweights template_0.1deg_masked.nc grid_weights_0.1deg.nc\n",
            "Wed Dec 11 10:57:20 2019: cdo ifthen seamask.nc template_0.1deg.nc template_0.1deg_masked.nc\n",
            "Wed Dec 11 10:56:46 2019: cdo -f nc2 setctomiss,0 -gtc,0 -sellonlatbox,2,42,55,72 -remapcon,r3600x1800 -topo seamask.nc" ;
        :CDO = "Climate Data Operators version 1.9.6 (http://mpimet.mpg.de/cdo)" ;
}

-Karin

    (1-6/6)