Learning by doing.

NCO examples

Jun 29, 2018 • NCO • Tags: NCO NetCDF

NCO is a convenient command line tool to modify NetCDF files. Several frequently used examples will be listed in this post.

Merge different files with the same variables but different time spans


Append a variable from one file to another file

ncks -h -A  # so that the variables in file1 will be appended to file2

Calculations of variables

ncap2 -s "var3=(var1+var2)*1000" -v  # var1 and var2 are from, and contains only var3

Modify meta information

ncatted -a units,pr,m,c,'mm/sec'  # modify the units of the variable pr in to be 'mm/sec'
ncatted -a long_name,pr,o,c,'(PRECC+PRECL)*1000'  # modify the long_name of the variable pr in to be '(PRECC+PRECL)*1000'

Modify variable name

Below is an example from this webpage:

Rename the variable p to pressure and t to temperature in netCDF In this case p must exist in the input file (or ncrename will abort), but the presence of t is optional:

ncrename -v p,pressure -v .t,temperature 

Tags: NCO NetCDF