2007 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF Utilities
4.2 NCO Utilities
As an example of third-party software built on top of Unidata's netCDF
libraries, the NCO package from Charlie Zender at the University of
California at Irvine is particularly useful. It's philosophy is to
handle any netCDF files (which is what is meant by generic).
Currently there are 13 NCO utility programs:
- ncap and ncap2: arithmetic processor
- ncatted: attribute editor
- ncbo: binary operator
- ncea: ensemble averager
- ncecat: ensemble concatenator
- ncflint: file interpolator
- ncks: kitchen sink
- ncpdq: permute dimensions quickly
- ncra: record averager
- ncrcat: record concatenator
- ncrename: renamer
- ncwa: weighted averager
Some NCO Examples
- Pythagorean theorem for vectors, creating a new windspeed
variable from component wind variables, u and v:
ncap -O -s "windspeed=sqrt(u^2+v^2)" in.nc out.nc
- Compute monthly temperature anomalies from 1985 mean:
ncdiff -v T 85_0112.nc 85.nc t_anm_85_0112.nc
- Average five ensemble members (see documentation to average N ensemble
members):
ncea 85_0[1-5].nc 85.nc
- Concatenate five ensemble members into single file (see documentation to conatenate N ensemble
members):
ncecat 85_0[1-5].nc 85.nc
- Interpolate fields known at times 85 and 87 to time=86:
ncflint -i time,86 85.nc 87.nc 86.nc
- Print value of variable near specified coordinates. For
example to print the value of the variable "tos" nearest
longitude 203 degrees E and latitude 19.5 degree N from the file
sst.nc:
ncks -H -v tos -d lon,203.0 -d lat,19.5 sst.nc
- Extract variables time and pressure from file in.nc and write to
out.nc, including any needed dimensions, coordinate variables, and
variable attributes:
ncks -v time,pressure in.nc out.nc
- Pack all variables in file in.nc and store the results in out.nc,
using scale_factor and add_offset attributes:
ncpack in.nc out.nc
- Re-order in.nc to dimension order lon,lat,time:
ncpdq -a lon,lat,time in.nc out.nc
- Average timeseries across five files (see documentation to average across N files):
ncra 85_0[1-5].nc 85.nc
- Concatenate timeseries across five files (see documentation to average across N files):
ncrcat 85_0[1-5].nc 85.nc
- Globally average file, weighting variables by area:
ncwa -w area -a lat,lon in.nc out.nc
2007 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF Utilities