Using CDO & NCO commands

NCToolkit is a stand-alone package — no CDO knowledge is required to use it. But if you already know CDO or NCO, you can call them directly.

Using CDO commands

The cdo_command method lets you apply a CDO command directly in NCToolkit — just strip the leading cdo and the input/output file names. A typical CDO command:

shell
cdo yearmean infile.nc outfile.nc

becomes:

python
ds.cdo_command("yearmean")

If the command is an ensemble method that takes multiple files as input and produces one output, the stripping works the same way — drop cdo and every file name. So:

shell
cdo ensmean infile1.nc infile2.nc infile3.nc outfile.nc

becomes, with ensemble=True telling NCToolkit to treat it as a many-files-in, one-file-out command:

python
ds.cdo_command("ensmean", ensemble=True)

If you use CDO and NCToolkit together and find something in CDO that isn't yet wrapped as a proper NCToolkit method, open an issue.

Using NCO commands

NetCDF Operators (NCO) is an optional backend, available through nco_command. Strip the two file names from the command you want to apply. So:

shell
ncks -v kd_490 -d lat,40.0,70.0 -d lon,-20.0,15.0 infile.nc outfile.nc

becomes:

python
ds.nco_command("ncks -v kd_490 -d lat,40.0,70.0 -d lon,-20.0,15.0")

NCO is optional — NCToolkit will work without it unless you specifically call nco_command. See System dependencies for installation.