Skip to main content

Easy chaining of cdo methods.

Project description

This module helps create chains of cdo commands for easy manipulation of climate data.


  • Method execution is lazy and gets processed only on function call Chain.execute().
  • Input supports Unix style pathname pattern search.
  • The Input will be first run with glob and checked if several files match. :exclamation: If that is the case a temporary file will be created.
  • Output can be a file on disc, an netCDF4.Dataset or (not) masked numpy.ndarray.


python3.5 -m pip install cdochain --pre

— or —

git clone
cd cdochain
python3.5 install


from cdochain import chaining as cch

input = './tests/testdata/'
output = './'
data = cch.Chain(ifile=input, ofile=output)
enso34 = data.sellonlatbox(190,240,-5,5).monmean()
out = enso34.execute()


This module implements method chaining for the Climate Data Operators (CDO) tool from the Max Planck Institute for Meteorology. Let us start:

from cdochain import chaining as cch

For initialisation one has to define input, output, and may define several options.


Now we have to define the files we want to work on:

  • To use one file
input = './tests/testdata/'
  • To use several files you can give a Unix style pattern
input = './tests/testdata/*.nc'

This creates a temporary file :exclamation:


For defining the output we have several options.

  • To output a file on disc:
data = cch.Chain(ifile=input, ofile='/path/to/')
  • To output an netcdf4.Dataset object:
data = cch.Chain(ifile=input, ofile='netCDF4')
  • To output an numpy.ndarray object:
data = cch.Chain(ifile=input, ofile='array:<var>')  # numpy.ndarray
# or
data = cch.Chain(ifile=input, ofile='maarray:<var>')  # masked numpy.ndarray

<var> defines the variable to be extracted and saved to numpy.ndarray.


As for options one can use the same as described on the CDO website. The default is options='-O -f nc'.


The operations defined in CDO can now be used on the data element.

analysis = data.sellonlatbox(190,240,-5,5).sellevidx(1).mermean()
fn = analysis.execute()

Have fun :neckbeard:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cdochain, version 0.2b3
Filename, size File type Python version Upload date Hashes
Filename, size cdochain-0.2b3.tar.gz (5.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page