Skip to main content

XCDO

Test codecov PyPI - Version PyPI - Python Version Doc pre-commit

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.

Installation

$ 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.

micromamba/mamba/conda

# Choose any of: micromamba, mamba, or conda
$ micromamba create -n xcdo python=3.13
$ micromamba activate xcdo
(xcdo)$ pip install xcdo

uv

$ uv venv --python 3.13 .venv
$ source .venv/bin/activate
(.venv)$ pip install xcdo

Usage

Generally, XCDO works much like CDO. For example:

$ xcdo -selvar,var1 indata.nc outdata.nc
$ xcdo -timemean -zonmean in.nc out.nc

You 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                     │
│                                                             │
╰─────────────────────────────────────────────────────────────╯

User-defined operators

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.nc

You 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.

Why XCDO?

  • 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.

Issues

Please report any issues here.

Contributing

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.

Metadata

Release files for xcdo 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xcdo 0.4.0
File Size Uploaded
xcdo-0.4.0.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xcdo 0.4.0
File Interpreter ABI Platform
xcdo-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / xcdo-0.4.0.tar.gz

Download URL xcdo-0.4.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6c665715bb36d8ee9a1f73a2d5235882e7513df7455540c5d7a669c0736a36db
BLAKE2b-256 checksum
How to use checksums
723b6049ce7228512e742c07d97414d0d0cb6902a3992da91a49530d2ab29c5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 23, 2026.

Transparency log

Release files / xcdo-0.4.0-py3-none-any.whl

Download URL xcdo-0.4.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c68788c141832c9d0d237e04265f8599f648429652b88c98110ab1d123b4a6f0
BLAKE2b-256 checksum
How to use checksums
a667245660c643f124990a44fc49d06ce3b2606312a35abd3bb305dd5e923c65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page