Setting up NetCDF on Ubuntu

The following was tested with 14.04

Install NetCDF

Use the following command to install the base NetCDF library and associated tools like ncdump.

sudo apt-get install libnetcdf-dev netcdf-bin

Not all mirrors actually contain the NetCDF libraries, so if you are getting 404s on the installation you will need to add some alternative mirrors to your sources list. In my case, my favourite mirror is hosted by Internode (which seems fairly stable and reliable).

To edit your sources list, do the following:

sudo vi /etc/apt/sources.list

Then add the following to your sources list (subbing in your mirror of choice):

# Additional Mirrors
deb http://mirror.internode.on.net/pub/ubuntu/ubuntu/ trusty main restricted
deb http://mirror.internode.on.net/pub/ubuntu/ubuntu/ trusty-updates main restricted
deb http://mirror.internode.on.net/pub/ubuntu/ubuntu/ trusty-security main restricted

Then run the following to update APT:

sudo apt-get update

You should now be able to run the install command above without getting 404s.

Install ncview

Ncview is a useful tool for quick viewing of your data on the command line, you will have had to connect through SSH with the -X flag to forward the display on to your local machine.

sudo apt-get install ncview

Then when you want to look at a NetCDF file, just use the following command and play with the GUI that appears.

ncview myfile.nc

Install NCO

The NetCDF Operators Software Stack (NCO) is a collection of super useful tools for working in with netcdf files. It allows you to perform a myriad of operations on data (such as subsetting, averaging etc.) on the command line without breaking into another programming language. It generally works well with well-formed CF-Compliant files, so get in the habit of writing them!

sudo apt-get install nco

For more information and a boatload of documentation on NCO, head to the official website http://nco.sourceforge.net/

Install CDO

The Climate Data Operators (CDO) library is another useful collection of tools for working with netcdf. It is complimentary to NCO in that it is more targeted towards the regridding and geospatial aspects of netcdf data, so if you are working in this space it is well worth installing. It is primarily for the use of climate and atmospheric sciences, but works just as well with just about any compliant NetCDF data.

sudo apt-get install cdo

For more information and documentation on CDO, head to the official website https://code.zmaw.de/projects/cdo.