Advanced exercise on nco/cdo operators

nco and OPeNDAP protocol

This section taken from nco manual.

Once NCO is DAP-enabled the operators are OPeNDAP clients. All OPeNDAP clients have network transparent access to any files controlled by a OPeNDAP server. Simply specify the input file path(s) in URL notation and all NCO operations may be performed on remote files made accessible by a OPeNDAP server.

This command tests the basic functionality of OPeNDAP-enabled NCO clients:

> ncks -O -o ~/foo.nc -C -H -v one -l /tmp \
-p http://thredds-test.ucar.edu/thredds/dodsC/testdods in.nc
> ncks -H -v one ~/foo.nc
one = 1

The one = 1 outputs confirm (first) that ncks correctly retrieved data via the OPeNDAP protocol and (second) that ncks created a valid local copy of the subsetted remote file.

With minor changes to the above command, netCDF4 can be used as both the input and output file format:

% ncks -4 -O -o ~/foo.nc -C -H -v one -l /tmp \
-p http://thredds-test.ucar.edu/thredds/dodsC/testdods in_4.nc
% ncks -H -v one ~/foo.nc
one = 1

Now something more complex:

ncwa -C -a lat,lon,time -d lon,-10.,10. -d lat,-10.,10. -l /tmp -p \
http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/ncep.reanalysis.dailyavgs/surface \
pres.sfc.1969.nc ~/foo.nc

The above command requests an equatorial hyperslab from remotely stored NCEP reanalyses data of the year 1969. The NOAA OPeNDAP server (hopefully!) serves these data. The local ncwa client then computes and stores (locally) the regional mean surface pressure (in Pa).