A brief introduction to the CDAT software package.



Climate Data Analysis Tools (CDAT) is a freely available software infrastructure used for analysis, manipulation and plotting of atmospheric science (and other) data. It is designed for gridded datasets but can also cope with other types.

Below are some key features of CDAT:

  • the software is open-source, consisting of a collection of Python modules.
  • available for multiple platforms (but not Windows).
  • a choice of interfaces: command-line, scripting or graphical user-interface (Visual CDAT (VCDAT)).
  • an XML-based format and tools for aggregating large datasets.
  • manipulation of large data arrays possible due to use of Python Numeric package.
  • interfaces to external packages such as the Live Access Server (LAS) for web-based access to datasets

Return to the top

Example output

Figure 1 shows the VCDAT interface and a plot that has been produced from it. Note that VCDAT is a GUI that sits on top of CDAT. Any operations performed on VCDAT can be replicated at the command line in CDAT or can be written into a Python script (*.py) which can then be run.


Figure 1. VCDAT and example output.

Return to the top

File formats catered for

CDAT can open the following file formats:

  • NetCDF - directly (using at the command line).
  • GRIB - using the GrADS/GRIB interface. You must generate a control ('.ctl') file and gribmap (index - '.idx') file before opening ( Note that CDAT will only understand regular (rectilinear) gridded data.
  • HDF - not necessarily installed with the standard installation, may conflict with the NetCDF libraries.
  • PCMDI DRS - may not be enabled in normal installation.

CDAT writes output to NetCDF. ASCII files can also be written using the standard python function for writing output to a file ( f=open('output.txt','w')).

Return to the top

Typical operations

CDAT will typically be used for operations such as:

  • Plotting a variable from a file on a polar stereographic projection.
  • Aggregating 1000s of files into one XML file so that slices of data can be read in across multiple files.
  • Differencing 2 different datasets (as the Python Numeric package allows array algebra).
  • Calculating departures from a climatology from a dataset.
  • Regridding a dataset and then calculating a spatial average.
  • Calculating the covariance between two variables.
  • Calculating the mean and standard deviation of a variable.

Return to the top

Quick start tutorial

In order to use CDAT you must have it installed on your machine. It can be downloaded from:

This tutorial uses CDAT at the command line. You can also open the file using VCDAT (just type  vcdat at the command line to start the GUI). Plotting and saving is then straightforward. Note that when running VCDAT you can view the underlying CDAT (Python) commands by going to the 'Tools' menu and choosing the 'View Teaching Commands' or 'View Recorded Commands' options.

This tutorial requires that you have a sample NetCDF file. You can download the sample file  here (84KB). The file (called '') is a NetCDF file containing u-wind and v-wind data over the globe at a 2.5° resolution at the 1000hPA level. Save the NetCDF in the directory you are working in before you start the tutorial.

The following commands should allow you to calculate the wind-speed ('wspd') from the u-wind ('u') and v-wind ('v'), plot the resulting variable and write it to an output NetCDF file.

The command to type is shown in bold and the output in plain type. The commands are annotated in normal font in the right-hand column. The tutorial follows:

> cdat This starts the CDAT shell, identical to the Python shell.
Executing /usr/local/cdat/bin/python 
Python 2.2.2 (#1, Jul 15 2003, 15:31:17) 
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2 
Type "help", "copyright", "credits" or "license" for more information.
> import cdms Imports the CDMS module.
>'') Opens the NetCDF file and assigns the file object to variable 'f'.
> f.listvariables() Shows the variable names in the file.
['u', 'v']
> u_wind=f('u') Reads the variable 'u' and assigns it to the Python variable 'u_wind'.
> u_wind.attributes Displays all the attributes pertaining to the variable 'u_wind'.
AttributeDict ({'_grid_': None, '_shared_mask': 0, 'name': 'u', 'parent': None 
, 'title': '** U-velocity m s**-1', '_mask': None, 'id': 'u', 'standard_name': 

'_TransientVariable__domain': [

( id: time 
Designated a time axis. 
units: hours since 2003-1-1 0:0 
Length: 1 
First: 0.0 
Last: 0.0 
Other axis attributes: 
calendar: proleptic_gregorian 
axis: T 
Python id: 8201a24 
, 0, 1, 1),

( id: level 
Designated a level axis. 
units: lev 
Length: 1 
First: 1000.0 
Last: 1000.0 
Other axis attributes: 
axis: Z 
Python id: 8201a4c 
, 0, 1, 1),

( id: latitude 
Designated a latitude axis. 
units: degrees_north 
Length: 73 
First: -90.0 
Last: 90.0 
Other axis attributes: 
axis: Y 
Python id: 8201c94 
, 0, 73, 73),

( id: longitude 
Designated a longitude axis. 
units: degrees_east 
Length: 144 
First: 0.0 
Last: 357.5 
Other axis attributes: 
axis: X 
modulo: [ 360.,] 
topology: circular 
Python id: 82035e4

, 0, 144, 144)], '_data': array (1,1,73,144) , type = f, has 10512 elements, ' 
missing_value': [ 9.99899956e+20,], '_node_': None, '_fill_value': [ 9.99899 

> v_wind=f('v') Reads the variable 'v' and assigns it to the Python variable 'v_wind'.
> wspd=(u_wind**2+v_wind**2)**0.5 Calculates the combined wind speed and assigns it to the Python variable 'wspd'.
>'wspd' Sets the 'id' attribute on the 'wspd' variable.
> wspd.long_name='Wind speed' Sets the 'long_name' attribute on the 'wspd' variable.
> wspd.units='m s**-1' Sets the 'units' attribute on the 'wspd' variable.
> import vcs Imports the VCS (Visualisation Control System) module.
> p=vcs.init() Initialise a VCS canvas and assign Python variable 'p' to it.
> p.plot(wspd) Plot the wind speed variable on canvas 'p'.

>'', 'w') Open a file to write out the wind speed variable to.
> fout.write(wspd) Write the wind speed variable to the output file.
<Variable: wspd, file:, shape: (1, 1, 73, 144)>
> fout.close() Close the output file.
> CTRL^D Press Control and D to close CDAT.

Return to the top

Further information

Further documentation, tutorials, download and installation instructions for CDAT can be found at the CDAT web pages

Still need help? Contact Us Contact Us