HomeMy BADCDataSearchCommunityHelp
Guided Tour Getting data Formats Software 10 FAQ

CDAT (Climate Data Analysis Tools)

A brief introduction to the CDAT software package.

Contents


Overview

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:

Return to top of page


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 top of page


File formats catered for

CDAT can open the following file formats:

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 top of page


Typical operations

CDAT will typically be used for operations such as: Return to top of page

Quick start tutorial

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

http://esg.llnl.gov/cdat

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 'wind_comps.nc') 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:

> cdatThis 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 cdmsImports the CDMS module.
> f=cdms.open('wind_comps.nc')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.attributesDisplays 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':
'eastward_wind',

'_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
956e+20,]})

> 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.5Calculates the combined wind speed and assigns it to the Python variable 'wspd'.
> wspd.id='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 vcsImports 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'.

> fout=cdms.open('output.nc', '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: output.nc, shape: (1, 1, 73, 144)>
> fout.close()Close the output file.
> CTRL^DPress Control and D to close CDAT.

If you have problems with the tutorial please contact BADC Support.

Return to top of page


Further information

Further documentation, tutorials, download and installation instructions for CDAT can be found at the CDAT web pages (http://www-pcmdi.llnl.gov/software-portal/cdat).

Return to top of page

Home    Contact    Disclaimer   
Last Modified: