Hacking with Environmental Data

Logo

WALD's help page for geospatial hackers

View ANU WALD GitHub

View ANU WALD website

View ANU WALD Slack channel

26 March 2020

Intro to Climate Data Operators (CDO)

by

Description

Climate Data Operators (CDO) is a command line tool for transforming, converting and even performing computations on data contained in NetCDF files. Operations such as selecting, merging or splitting variables, computing averages or performing temporal aggregations are quite straight forward to implement. This tool is available on the NCI (both Gadi and VDI) by typing module load cdo.

As an example, if we want to list the dates in the temporal dimenion of a NetCDF, we’d do:

$ cdo showdate my_data.nc

CDO offers a long list of functionalities that we can use to prepare and process our NetCDFs. See here for a quick reference of CDO or the official documention on the project’s website for a detailed description of each function. CDO presents a nice interface with a consistent notation for its operators. For the case when we request information or perform a computation on a NetCDF file the format is:

$ cdo cmd_name input.nc

When we perform a transformation, aggragation or select a subset of the data, we need to provide a name for the new NetCDF file that will store the output.

$ cdo cmd_name input.nc output.nc

Here there is a list of things that I normally do with CDO.

# Merge two NetCDFs with different variables but common dimensions
cdo merge input_1.nc input_2.nc output.nc

# Merge two (or more) NetCDFs along the temporal dimensions (variable names and spatial dimensions must be the same).
cdo input_*.nc output.nc

# Shift time by a fixed amount
cdo shifttime,30minutes input.nc output.nc

# Set date of add temporal dimension to a NetCDF
cdo setdate,2020-03-25 input.nc output.nc

# Change the time format in a NetCDF to standard epoch
cdo setreftime,1970-01-01 input.nc A.nc
cdo settunits,seconds B.nc C.nc
cdo setcalendar,standard C.nc output.nc

# Extract one atmospheric level
cdo --reduce_dim sellevel,1000 era5_geop_201811.nc z1000_201811.nc
tags: