NCO Arithmetic Operators and Their Uses

NCO Arithmetic Operators and Their Uses

Postby yiboj » Mon Apr 04, 2016 10:21 am

The NCO (netCDF Operators) utilities are a set of powerful command line tools for manipulating and analyzing netCDF (including HDF5) files. They can be used to subset, aggregate and modify data and metadata stored in netCDF. If the NCO utilities are not installed on your computer they can be found here:

Some useful utilities offered by NCO are their arithmetic manipulators that allow you to add, multiply, divide and subtract data between files . The default for ncbo is to subtract.

Here is an example command:

ncbo --op_typ=sbt

This will create a file called that contains the difference between and
ncbo is the command and --op_typ=sbt means that the operation to be preformed is subtraction. Instructions can be found here .
Other options include add for addition, mlt for multiplication, and dvd for division.

The following image shows the sea surface temperature data that results when the average files for the years 1997 and 1998 are subtracted.

sst_diff.jpg (45.09 KiB) Viewed 4028 times

Standard deviation can also be calculated using the nco utilites. If we have a file called of which we want to find the standard deviation of some variables we can do these three commands to get it.

    1. ncwa –v variable_name
    2. ncbo –v variable_name
    3. ncwa –y rmssdn

To see your answer do ncdump and find the value for your variable_name.

It is also relatively easy to create a graph of standard deviation over time. Fist you will need to concatenate your files together using the nce/ncrcat commands that are described above. Once you have a concatenated file follow these steps:
1. Find the mean of your concatenated files
2. Subtract the mean from the concatenated file
3. Now use the rmssdn option to finish the calculation and averages over lat and lon
    ncwa –y rmssdn –a lat,lon

Now you have a file that contains the standard deviation over time.
Posts: 130
Joined: Mon Mar 30, 2015 11:22 am

Return to Data Access and Services