Climate Data Operators

I needed to re-grid the CMIP5 climate data and had no idea how to best do this. I searched for solutions online and discovered Climate Data Operators – CDO. This is an extremely useful toolbox that I highly recommend you install and start using.

To install, download the tarball, unpack the files and cd into the directory. Installation was easy as I already had netcdf4 installed:

./configureĀ --with-netcdf=/usr/local
make
make check
sudo make install

The CDO contains more than 600 commands and i started testing with the ‘sinfon’ command which is really useful and provides a ton of information that you do not have access to using ncdump (output suppressed):

trond@trondlaptop [15:50:24]> cdo sinfon pdi_CNRM_2006-2100.nccod sinfon
File format: netCDF
-1 : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter name
1 : unknown unknown instant 42 1 105704 1 F32 : pdi
Grid coordinates :
1 : curvilinear > size : dim = 105704 nx = 362 ny = 292
lon : min = 0.049801331 max = 359.994934 degrees_east circular
lat : min = -78.3935013 max = 89.7417679 degrees_north
available : xvals yvals xbounds ybounds
.....
Time coordinate : 95 steps
RefTime = 2006-01-01 00:00:00 Units = days Calendar = standard Bounds = true
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
2006-07-02 12:00:00 2007-07-02 12:00:00 2008-07-02 00:00:00 2009-07-02 12:00:00
2010-07-02 12:00:00 2011-07-02 12:00:00 2012-07-02 00:00:00 2013-07-02 12:00:00
2014-07-02 12:00:00 2015-07-02 12:00:00 2016-07-02 00:00:00 2017-07-02 12:00:00

Next, I generated the weights for the bilinear interpolation:

cdo genbil,r360x180 pdi_CNRM_2006-2100.nc pdi_CNRM_2006-2100_wgts.nc
cdo genbil: Processed 105704 values from 1 variable over 1 timestep ( 0.38s )

Using the newly generated weights, I then called the remap method of CDO to create a rectangular grid:

cdo remap,r360x180,pdi_CNRM_2006-2100_wgts.nc pdi_CNRM_2006-2100.nc pdi_CNRM_2006-2100_rectangular.nc
cdo remap: Using remapbil
cdo remap: Processed 421758960 values from 1 variable over 95 timesteps ( 21.86s )

The new file can then be inspected using the sinfon command again

cdo sinfon pdi_CNRM_2006-2100_rectangular.nc
File format: netCDF
-1 : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter name
1 : unknown unknown instant 42 1 64800 1 F32 : pdi
Grid coordinates :
1 : lonlat > size : dim = 64800 nx = 360 ny = 180
lon : first = 0 last = 359 inc = 1 degrees_east circular
lat : first = -89.5 last = 89.5 inc = 1 degrees_north

...

One thought on “Climate Data Operators”

  1. Thank you very much! Exact what I was looking for. I spent hours trying to make a lonlat grid from a gaussian… Keep sharing your experiences!

Leave a Reply

Your email address will not be published. Required fields are marked *