NetCDF Operator (NCO) Reference Card version 4.6.1
This reference card includes some common features of NCO. It is for users to look up the syntax quickly. For details and morefeatures, see NCO User’s Guide at http://nco.sourceforge.net/#RTFM.
Syntax: Operator Options Input_File(s) Output_File
Hyperslab: ncks -d dim_name,min,max[,stride] in out# First through third longitudes
ncks -d lon,0,2# First through third longitudes
ncks -F -d lon,1,3# First through third longitudes
ncks -d lon,,2# Third to last longitudes
ncks -d lon,2,# First to last every other longitudes
ncks -d lon,,,2
ncks -d lon,-70.0,-10.0 # Lon values btw -70o and -10oncks -d time,‘1939-09-09 12:00:0.0’,\‘1945-05-08 00:00:0.0’
ncks -d time,‘1918-11-11’,‘1939-9-9’# Every January
ncks -d time,‘1979-1’,,12Concatenate Files: ncecat or ncrcat# Monthly files into annual with new dimension: month
ncecat -u month file_{1..12}.nc file_annual.nc# Station files into one with new dimension: stn
ncecat -u stn file_*.nc file_all.nc# Append files along time (ie, record dimension)
ncrcat f1979-2003.nc f2004-2014.nc f1979-2014.nc
Average: nces, ncra or ncwa
nces file_*.nc file_avg.nc# Average of multiple files# Average of a certain timences -d time,“1979”,“2005” file_*.nc file_avg.nc# Average of all March using montly datancra -d time,2,,12 in.nc out.nc# Average of all JJA using monthly datancra -d time,5,,12,3 in.nc out.nc# Average of each JJA using monthly datancra --mro -d time,5,,12,3 in.nc out.nc# Annual average from monthly datancra --mro -d time,,,12,12 in.nc out.nc# Monthly average of 2000 from daily data
for moy in {1..12}; do
mm=$( printf “%02d” ${moy} )ncra -d time, “2000-${mm}”, in.nc out_${mm}.nc
done
ncrcat out_??.nc out_mthly-avg.nc# Spatial average using geographical weights (gw)
ncwa -w gw -d lat,10.0,20.0 -d lon,30.0,35.0 \-a lat,lon in.nc out.nc# Ensemble average using groups
nces --nsm_grp in.nc out.nc
Edit Attributes: ncatted -a att,var,mode,type,value# Append string to global attribute history
ncatted -a history,global,a,c,‘some_string’ in.nc# Overwrite att. long_name for variable T to Pressure
ncatted -a long_name,T,o,c,‘Pressure’ in.nc# Overwrite _FillValue for all variable to a float number
ncatted -a _FillValue,,o,f,1.0e36 in.nc# Delete attribute units for all variables
ncatted -a units,,d,, in.nc# Delete all attributes for variable var
ncatted -a ,var,d,, in.nc

Anomaly:# Step 1: annual averagencra -d time,,11 in.nc annual_avg.nc# Step 2: subtraction
ncbo -d time,,11 in.nc annual_avg.nc out.nc
Standard Deviation (std):# Method 1: for large data file
# Temporal std of all data in one file
# Step 1: average
ncwa -a time in.nc avg.nc# Step 2: anomaly
ncbo in.nc avg.nc anm.nc# Step 3: root-mean squarencra -y rmssdn anm.nc std.nc# Spatial std of all data in one file using weights# Step 1: average
ncwa -a lat,lon -w gw in.nc avg.nc# Step 2: anomaly
ncbo in.nc avg.nc anm.nc# Step 3: root-mean squarencwa -y rmssdn -a lat,lon -w gw anm.nc std.nc# Method 2: for small data filencap2 -s 'var_std=(var-var.avg($time)).rmssdn($time)' \in.nc out.nc
Selection: Operator Options in*.nc out.nc# Include var1 and var2
<operator> -v var1,var2<operator> -x -v var1 # Include all variables but var1
<operator> -g group2 -v var1 # Include var1 in group2# Include all groups but grp1
<operator> -x -g grp1
Rename: ncrename Options in*.nc
ncrename -v old,new # Rename var from ‘old’ to ‘new’# Rename dimension
ncrename -d old,new# Rename groupncrename -g old,new# Rename var in groupncrename -v /grp/old,new# Rename global attributencrename -a old,newncrename -a var@old,new # Rename attribute of var
Specify Input Files:# input files: 85.nc, 86.nc, 87.nc, 88.nc, 89.nc
Operator -p input_path 85.nc 86.nc 87.nc 88.nc 89.nc
Operator 8[56789].nc
Operator 8?.nc# No other 8?.nc files
Operator -n file_num,digit_num,increment[,max_digit, \min_digit,yyyymm]
Operator -n 5,2,1 85.nc
Operator -n 3,2,1 85_06.nc # Input 85_06 85_07 85_08
Operator -n 3,2,1,12 85_12.nc # 85_12 85_01 85_02
Op -n 3,6,1,12,1 198512.nc # 198512 198501 198502# 198512 198601 198602
Op -n 3,6,1,12,1,yyyymm 198512.nc# 198512 198612 198712
Op -n 3,6,1,12,12,yyyymm 198512.nc