[NCO] Simple Examples

From Here

Some NCO Examples
  • Create 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:
        ncra 85_0[1-5].nc 85.nc
  • Concatenate timeseries across five 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

NetCDF-4 note:  NCO currently supports netCDF-4 atomic data types and compression, and NCO can read and write netCDF-4 data that uses the classic model.

One thought on “[NCO] Simple Examples

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s