Learn R Programming

rcdo

rcdo is a wrapper around Climate Data Operators.

Installation

You can install rcdo from CRAN with

install.packages("rcdo")

or the development version of rcdo from GitHub with:

# install.packages("pak")
pak::pak("eliocamp/rcdo")

Most operators are supported and are partially documented. The functions start with cdo_ an the name of the operator (e.g. the selname operator is the cdo_selname() function)

Example

library(rcdo)
cdo_use("packaged")  # use package version of cdo that can be installed with `cdo_install()`. 
ncep <- "hgt_ncep.nc"

The ymonmean operator computes monthly annual cycle. The rcdo function is cdo_ymonmean()

ncep |> 
  cdo_ymonmean() 

The output just prints the command with a place holder output. Use cdo_execute() to actually run the command. If no output file is specified, then the result is saved in a tempfile.

ncep |> 
  cdo_ymonmean() |> 
  cdo_execute()

Operators can be chained. Lets select just the Southern Hemisphere first.

ncep |> 
  cdo_sellonlatbox(lon1 = 0, lon2 = 360, lat1 = -90, lat2 = 0) |> 
  cdo_ymonmean() 

Now also select the 500 hPa level

ncep |> 
  cdo_sellonlatbox(lon1 = 0, lon2 = 360, lat1 = -90, lat2 = 0) |> 
  cdo_sellevel(level = 500) |> 
  cdo_ymonmean() 
ncep |> 
  cdo_sellonlatbox(lon1 = 0, lon2 = 360, lat1 = -90, lat2 = 0) |> 
  cdo_sellevel(level = 500) |> 
  cdo_ymonmean() 

Prior art

The ClimateOperators package also wrapps CDO, but it’s approach is different. Instead of wrapping each operator as its own function with parameters as arguments, it provides a generic cdo() function that runs the operators that the user needs to write as strings. Instead of

ncep |> 
  rcdo::cdo_sellonlatbox(lon1 = 0, lon2 = 360, lat1 = -90, lat2 = 0) 

one would write

ClimateOperators::cdo("sellonlatbox,0,360,-90,0", ncep, output_file)

Copy Link

Version

Install

install.packages('rcdo')

Monthly Downloads

1,982

Version

0.3.2

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Elio Campitelli

Last Published

November 28th, 2025

Functions in rcdo (0.3.2)

cdo_execute

Execute a CDO operation
comp

Comparison of two fields
cdo_set_output

Set output and options
cdo_options_use

Manage CDO options
collgrid

Collect horizontal grid
cdo_install

Install the supported CDO version
cmorlite

CMOR lite
compc

Comparison of a field with a constant
cond

Conditional select one field
cond2

Conditional select two fields
deltat

Difference between timesteps
derivepar

Derived model parameters
condc

Conditional select a constant
consecstat

Consecute timestep periods
daypctl

Daily percentile values
daystat

Daily statistics
copy

Copy datasets
cdo_use

Chose CDO version to use
change

Change field header
ecacdd

Consecutive dry days index per time period
diff

Compare two datasets field by field
dayarith

Daily arithmetic
dhourstat

Multiday hourly statistics
ecacwd

Consecutive wet days index per time period
ecacsu

Consecutive summer days index per time period
detrend

Detrend time series
dminutestat

Multiday by the minute statistics
duplicate

Duplicates a dataset
ecaid

Ice days index per time period
ecacfd

Consecutive frost days index per time period
ecapd

Precipitation days index per time period
ecahwdi

Heat wave duration index wrt mean of reference period
ecaetr

Intraperiod extreme temperature range
ecafd

Frost days index per time period
ecar75p

Moderate wet days wrt 75th percentile of reference period
ecar75ptot

Precipitation percent due to R75p days
ecar95p

Very wet days wrt 95th percentile of reference period
ecagsl

Thermal Growing season length index
ecahd

Heating degree days per time period
distgrid

Distribute horizontal grid
ecar95ptot

Precipitation percent due to R95p days
ecacwdi

Cold wave duration index wrt mean of reference period
ecar90p

Wet days wrt 90th percentile of reference period
ecar90ptot

Precipitation percent due to R90p days
ecarr1

Wet days index per time period
ecatn90p

Warm nights percent wrt 90th percentile of reference period
ecahwfi

Warm spell days index wrt 90th percentile of reference period
ecatr

Tropical nights index per time period
ecarx1day

Highest one day precipitation amount per time period
ecatg10p

Cold days percent wrt 10th percentile of reference period
ecar99ptot

Precipitation percent due to R99p days
ecatx10p

Very cold days percent wrt 10th percentile of reference period
ecar99p

Extremely wet days wrt 99th percentile of reference period
ecasu

Summer days index per time period
filedes

Dataset description
ecatx90p

Very warm days percent wrt 90th percentile of reference period
filter

Time series filtering
ensstat

Statistical values over an ensemble
enlarge

Enlarge fields
fldcovar

Covariance in grid space
fldcor

Correlation in grid space
healpix

Change healpix resolution
ecarx5day

Highest fiveday precipitation amount per time period
expr

Evaluate expressions
fdns

Frost days where no snow index per time period
ecasdii

Simple daily intensity index per time period
ensstat2

Statistical values over an ensemble
ecatn10p

Cold nights percent wrt 10th percentile of reference period
ecacwfi

Coldspell days index wrt 10th percentile of reference period
ecatg90p

Warm days percent wrt 90th percentile of reference period
intlevel3d

Linear level interpolation from/to 3D vertical coordinates
intlevel

Linear level interpolation
eofcoeff

Principal coefficients of EOFs
eofs

Empirical Orthogonal Functions
fourier

Fourier transformation
fldstat

Statistical values over a field
ensval

Ensemble validation tools
gridboxstat

Statistical values over grid boxes
getgridcell

Get grid cell index
inttime

Time interpolation
intyear

Year interpolation
gridcell

Grid cell quantities
hourpctl

Hourly percentile values
maggraph

Line graph plot
hourstat

Hourly statistics
math

Mathematical functions
info

Information and simple statistics
input

Formatted input
invert

Invert latitudes
invertlev

Invert levels
mastrfu

Mass stream function
magplot

Lat/Lon plot
merstat

Meridional statistics
monarith

Monthly arithmetic
histogram

Histogram
mrotuvb

Backward rotation of MPIOM data
ncl_wind

Wind transformation
outputgmt

GMT output
maskregion

Mask regions
ninfo

Print the number of parameters, levels or times
maskbox

Mask a box
pack

Pack data
gradsdes

GrADS data descriptor file
importamsr

Import AMSR binary files
hurr

Hurricane days index per time period
remapnn

Nearest neighbor remapping
remapstat

Remaps source points to target cells
output

Formatted output
remapdis

Distance weighted average remapping
remapcon

First order conservative remapping
pressure

Pressure on model levels
magvector

Lat/Lon vector plot
importbinary

Import binary data sets
mapreduce

Reduce fields to userdefined mask
importcmsaf

Import CMSAF HDF5 files
seaspctl

Seasonal percentile values
samplegrid

Resample grid
remaplaf

Largest area fraction remapping
remapeta

Remap vertical hybrid level
runpctl

Running percentile values
runstat

Running statistics
outputtab

Table output
mergegrid

Merge grid
merge

Merge datasets
monstat

Monthly statistics
regres

Regression
monpctl

Monthly percentile values
selvar

Select fields
seltimeidx

Select timestep by index
replace

Replace variables
setgrid

Set grid information
remap

Grid remapping
replacevalues

Replace variable values
setfilter

Set NetCDF4 filter
rhopot

Calculates potential density
setmiss

Set missing value
setpartab

Set parameter table
selregion

Select horizontal regions
selmulti

Select multiple fields via GRIB1 parameters
select

Select fields
rotuvb

Rotation
selgridcell

Select grid cells
seltime

Select timesteps
selsurface

Extract surface
settime

Set time
setbox

Set a box to constant
setattribute

Set attributes
remapbil

Bilinear interpolation
selyearidx

Select year by index
remapbic

Bicubic interpolation
set

Set field info
seasstat

Seasonal statistics
showinfo

Show variables, levels or times
selbox

Select a box
setzaxis

Set zaxis information
shiftxy

Shift field
setgridcell

Set the value of a grid cell
sethalo

Set the bounds of a field
sinfo

Short information
timselpctl

Time range percentile values
strgal

Strong gale days index per time period
timselstat

Time range statistics
strwin

Strong wind days index per time period
splitdate

Splits a file into dates
showattribute

Show attributes
splitsel

Split selected timesteps
timfillmiss

Temporal filling of missing values
timpctl

Percentile values over all timesteps
timcor

Correlation over time
spectral

Spectral transformation
split

Split a dataset
tee

Duplicate a data stream and write it to file
varsstat

Statistical values over all variables
vertintgh

Vertical height interpolation
vertintml

Vertical interpolation
verifygrid

Verify grid coordinates
smooth

Smooth grid points
specconv

Spectral conversion
timcovar

Covariance over time
ydrunpctl

Multiyear daily running percentile values
ydrunstat

Multiyear daily running statistics
wind2

D and V to velocity potential and stream function
wind

Wind transformation
vertstat

Vertical statistics
trend

Trend of time series
yeararith

Yearly arithmetic
trendarith

Add or subtract a trend
ydaystat

Multiyear daily statistics
ydaypctl

Multiyear daily percentile values
timcumsum

Cumulative sum over all timesteps
vertintap

Vertical pressure interpolation
vertfillmiss

Vertical filling of missing values
wct

Windchill temperature
strbre

Strong breeze days index per time period
timsort

Timsort
splittime

Split timesteps of a dataset
ymoncomp

Multiyear monthly comparison
ymonarith

Multiyear monthly arithmetic
unpack

Unpack data
timstat

Statistical values over all timesteps
yearpctl

Yearly percentile values
yearstat

Yearly statistics
yhourarith

Multiyear hourly arithmetic
yhourstat

Multiyear hourly statistics
zonstat

Zonal statistics
yearmonstat

Yearly mean from monthly data
yseasstat

Multiyear seasonal statistics
vargen

Generate a field
ymonpctl

Multiyear monthly percentile values
ydayarith

Multiyear daily arithmetic
xsinfo

Extra short information
ymonstat

Multiyear monthly statistics
yseaspctl

Multiyear seasonal percentile values
yseasarith

Multiyear seasonal arithmetic
cdo_cache_set

Manages the cache
adisit

Potential temperature to insitu temperature and vice versa
arithdays

Arithmetic with days
arith

Arithmetic on two datasets
afterburner

ECHAM standard post processor
arithc

Arithmetic with a constant
cdo

Execute a custom operator
bitrounding

Bit rounding
apply

Apply operators
arithlat

Arithmetic with latitude