XCDO is a Python-based command-line tool built around Xarray. It provides a collection of operators for working with datasets such as NetCDF, GRIB, and Zarr, using a familiar CDO like interface. With the help of Pythonโs type annotations, creating new operators becomes effortless, making it easy to extend the tool with simple functions and build reusable, organised analysis workflows.
$ pip install xcdo!!! warning "Windows support!" - Not well tested on Windows. But it should work! ๐
### Installing in a virtual environment You may want to install `xcdo` to an isolated virtual environment to avoid conflicts with other packages.
# Choose any of: micromamba, mamba, or conda
$ micromamba create -n xcdo python=3.13
$ micromamba activate xcdo
(xcdo)$ pip install xcdo$ uv venv --python 3.13 .venv
$ source .venv/bin/activate
(.venv)$ pip install xcdoGenerally, XCDO works much like CDO. For example:
$ xcdo -selvar,var1 indata.nc outdata.nc
$ xcdo -timemean -zonmean in.nc out.ncYou can find a list of all available operators here.
or run xcdo --list on the command line.
$ xcdo --list
Available Operators
โโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Operator โ Description โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ cdo โ Operator to run CDO commands โ
โ showtimestamp โ Show time stamp โ
โ mermean โ Meridional mean โ
โ mermin โ Meridional minimum โ
โ mermax โ Meridional maximum โ
โ merstd โ Meridional standard deviation โ
โ mersum โ Meridional sum โTo get detailed information and the synopsis (or signature) about a specific operator, use:
$ xcdo --show <operator>$ xcdo --show selvar
โญโ Synopsis โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ xcdo -selvar,name input output โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Description โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Select a data variable by name. โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Positional Arguments
โโโโโโโโโโโโโณโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโ
โ Parameter โ Type โ Required โ Description โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ name โ TEXT โ Required โ Name of the variable โ
โโโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโ
โญโ Examples โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ xcdo -selvar,tas infile.nc outfile.nc โ
โ xcdo -selname,tas infile.nc outfile.nc โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏYou can easily turn a regular Python function into your own XCDO operator. For example, hereโs a small operator in a file named dump.py that simply prints a dataset to the terminal:
# dump.py
from xcdo import operator, DatasetIn
@operator()
def main(input: DatasetIn):
print(input)And this can be used as follows in xcdo:
$ xcdo -dump.py in.ncYou can see the signature and documentation of the custom operator by running:
$ xcdo --show dump.py
โญโ Synopsis โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ xcdo -dump.py input โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
!!! Note
Notice the .py extension on the custom operator? Thatโs because the operator name simply comes from the Python fileโs name.
See Writing your own operators for more details.
- Simple Python functions. If you know Python, you can create new operators instantly. This opens the door for real community-driven development.
- Automatic help and documentation. XCDO automatically generates help and documentation for your operators, making it easy to share and reuse them.
- CLI and Library. As these operators are Python functions, it can be called from Python scripts as well.
- Custom operators. Drop a Python function into a file and call it like any other XCDO operator. This keeps your analysis workflows clean, modular, and easy to reuse.
- Zarr support. Since XCDO builds on Xarray, it naturally supports modern formats like Zarr, which CDO doesnโt handle yet.
- CDO integration. When you need the performance of CDO, you can call it directly with the โ-cdoโ operator and combine it with XCDO or custom operators in one chain.
With community support, XCDO can grow into a unified library of reusable and well-structured tools for climate and weather analysis.
Please report any issues here.
Fork the repository and make your changes and submit a pull request.
Please contact me at prajeeshag@gmail.com for any questions or start a discussion on GitHub Discussions.
!!! warning "Under active development" XCDO is under active development. Although everything will work as expected, many features are not documented well yet.