Cheat Sheet for Climate Data Operators (CDO)

CDO (Climate Data Operators) is a powerful command-line tool for processing NetCDF, GRIB, and other climate data formats. Below is a cheat sheet with commonly used commands and their explanations.

1. Viewing File Information

cdo info file.nc

Output:

File format : NetCDF

Variables : temperature, precipitation

Dimensions : time=365, lon=360, lat=180

2. Checking File Contents

cdo showname file.nc

Output:

temperature precipitation

3. Extracting a Time Slice

cdo seldate,2020-01-01,2020-01-31 input.nc output.nc
Extracts data for January 2020 and saves to output.nc

4. Merging Multiple Files

cdo merge file1.nc file2.nc merged.nc
Combines file1.nc and file2.nc into merged.nc

5. Calculating Monthly Means

cdo monmean input.nc monthly_means.nc
Calculates monthly mean values and saves to monthly_means.nc

6. Calculating Annual Means

cdo yearmean input.nc annual_means.nc
Calculates annual mean values and saves to annual_means.nc

7. Spatial Averaging

cdo fldmean input.nc spatial_avg.nc
Computes the global mean of all grid points and saves to spatial_avg.nc

8. Subsetting Data by Region

cdo sellonlatbox,-10,10,30,50 input.nc subset.nc
Extracts data for the region: Longitude (-10 to 10) and Latitude (30 to 50)

9. Regridding to a Regular Grid

cdo remapbil,r360x180 input.nc regridded.nc
Regrids the data to a 360×180 regular grid using bilinear interpolation

10. Calculating Anomalies

cdo sub input.nc climatology.nc anomalies.nc
Calculates anomalies by subtracting the climatology from the input data

11. Concatenating Files

cdo cat file1.nc file2.nc concatenated.nc
Concatenates multiple time steps from file1.nc and file2.nc into concatenated.nc

12. Removing Leap Years

cdo ydrunmin,365 input.nc noleap.nc
Removes leap days from the dataset

13. Computing Standard Deviation

cdo timstd input.nc std.nc
Computes the temporal standard deviation and saves to std.nc

14. Converting GRIB to NetCDF

cdo -f nc copy input.grb output.nc
Converts a GRIB file to NetCDF format

15. Extracting Statistics

cdo outputtab,mean input.nc

Output:

Mean: 273.15

16. Detecting Missing Values

cdo infon input.nc
Checks for missing values in the dataset

Leave a Reply

Your email address will not be published. Required fields are marked *