CHAPTER 2 Getting Started

CDAT uses the Python language as a glue to link together the various tools. Python has one of the fastest growing user bases among programming languages today and is extensively documented online and in publications. It must be stressed that it is not essential to have any knowledge of Python before being able to use CDAT tools. The Graphical User Interface (VCDAT) can be used with no knowledge of Python and is the first topic introduced in this chapter. This is highly recommended for beginners. For the more adventurous beginner who wishes to learn the use of scripting capabilities, a brief background of the Python language and syntax is provided in the next section.

CDAT comes with a suite of tutorials in the form of online video tutorials and scripts to help you learn how to use it. These tutorials are described in brief to enable the user to find the appropriate tutorials and to give a flavor of the power of CDAT. Finally, the various documentation and help avenues available to the user are described in this chapter.

Try the Visual CDAT browser first

The beginning user is encouraged to try the VCDAT browser first. This is accomplished by simply typing the command "vcdat" at your shell prompt, i.e:

% vcdat

Online video tutorials are available through the CDAT home page at http://cdat.sf.net. These short streaming video tutorials are a convenient way to see VCDAT in action. VCDAT was designed to be used from left-to-right and top-to-bottom and has on-line help balloons to assist the user in navigating through the interface. That is, if the user becomes unsure of what to do at any give time, then by moving the mouse over the region of question and letting it rest will result in a help balloon popup with information to assist the user. VCDAT allows the user to enter command line instructions and logs most button click instructions in a script file for later reference. Although it is not required to learn CDAT scripting in order to use VCDAT, the interface can be used as a CDAT script-learning tool by translating every button press and keystroke into a script file. All scripts include comment lines to assist the user. The script file can be modified, saved, and executed by the user. Thus, helping the user learn how to read and write CDAT scripts. This facility also allows the non-interactive repetition of common tasks.

To demonstrate quickly, the use of VCDAT try the following example sequence of button clicks:

Example 1: To quickly browse and plot data:

  1. Select the directory where the data is stored
  2. Select the desired file that is located in the directory
  3. Select a variable from the file
  4. Click the "Plot" button.

Example 2: To select data ranges and plot type:

  1. Select the directory where the data is stored
  2. Select the desired file that is located in the directory
  3. Select a variable from the file
  4. Select variable ranges (i.e., experiment by adjusting the horizontal slider bars located just below the "Plot" button)
  5. Select graphics method (e.g., select "Isofill" in the choice button located to the right of the "Plot" button)
  6. Click the "Plot" button.

Example 3: To average over a dimension:

  1. Select the directory where the data is stored
  2. Select the desired file that is located in the directory
  3. Select a variable from the file
  4. Select "avg" if applicable (e.g., to the right of the horizontal slider bars, which are located below the "Plot" button, are choice buttons displaying "def". Select "avg" in place of "def".)
  5. Click the "Plot" button.

Example 4: To define a variable in memory:

  1. Select the directory where the data is stored
  2. Select the desired file that is located in the directory
  3. Select a variable from the file
  4. If desired, select dimension sub ranges
  5. Select the "Define" button
  6. Select the defined variable located in the "Defined Variables" window located just below the "Dimension" panel
  7. Click the "Plot" button.
Description of the VCDAT Interface

There are six sections of the VCDAT interface (figure 1) that are listed here from top-to-bottom: Main Menu (i.e., File, Options, Tools, PCMDI Tools, Help); Select Variable (Directory, File, and Variable); Graphics (i.e., Plot, Boxfill, VCS Canvas 1, Options, Define); Dimensions (Z-time, Y-latitude, X-longitude); Defined Variables (Operational Icons, Defined Variable List, Function Icons); and Variable Information.

 

Main Menu (i.e., File, Options, Tools, PCMDI Tools, Help)

There are five static pull down options in VCDAT's main menu. In addition, the user can add their own customized pull down menus to VCDAT's main menu.

  • File: Under the "File" option, the user can choose to: open data files located on their local disk, select searches for specific data types (e.g., netCDF, XML, etc.), send plots directly to local printers, save the state of the system for total recall, read Python or VCS script files into the system, and exit out of VCDAT.
  • Options: The "Options" option sets information referring to a selected or defined variable, or sets the state of the graphical user interface. For example, the "Select Predefined Region" selects a region of the globe (e.g., "Africa", "Asia", etc.). Thus, every selected or defined variable will automatically be set to the predefined region. Note: This works only if the x-axis equals longitude and the y-axis equals latitude.
  • Dimension aliases for longitude, latitude, time, and level can also be set under the "Options" pull down menu. For example, the user can set "X", "lon" and "X_Long" as aliases for longitude. So when VCDAT sees these dimension names it will interpret them as longitude axes.
  • If the user modifies the VCDAT GUI and wants to save the settings for the next session, then select "Save GUI State..." located under this option.
  • Tools (IDLE): The "Tools" option displays additional GUIs that allow the user to: create new script files for edit, edit old script files, issue keystroke commands, add new user menu options to the "Main Menu" (note, the new menu option will be placed between the PCMDITools and Help menu options), and view recorded script commands.
  • When invoked, the "Command Line Window..." option is really executing the Python Integrated DeveLopment Environment (IDLE) developed by Guido van Rossum, who is also the developer of Python. The Python Shell Window gives the user access into Python's interactive mode. This Python Shell Window has been slightly modified to allow the user to register keystroke script commands and GUI button commands simultaneously and seamlessly in VCDAT.
  • When the "Python Shell Window" (i.e., called "VCDAT's Command Line Window" in VCDAT) appears, the user should read the information describing hooks into VCS. For additional online information about the "Python Shell Window", select the "F1" button while running it.
  • The script editors are also part of IDLE. IDLE can also be invoked outside of VCDAT. That is, at the prompt type, "idle". For more information on IDLE, visit: http://www.python.org/idle.
  • To add more menus to "Main Menu", the user must select the "Add User New Menu..." menu item. See help balloons to assist with the addition of new menus. Once the new menu has been added, the user must select "Save GUI State..." located under "Main Menu" -> "Options" to retain the new menu for later VCDAT sessions.
  • PCMDITools: The "PCMDITools" option contains the start of time tools and statistical functions deemed necessary (by the PCMDI climate researchers) to do common fundamental analysis. For the "Time Tools", the data must have a time dimension in order to work. Under "Options", see "Dimension Aliases for" specifying additional time axis names.
  • For in-depth information on these tools and their functionalities, see the CDAT Utilities Reference Guide.
  • Help: The "Help" option allows the user to turn the help balloons off or on, display CDAT related web sites by means of the user's client web browser, and displays information about VCDAT to the user (for example, version number and place of execution).

 

Select Variable

The main purpose of this section is to select a variable for analysis and/or display. There are five main components here: the "Directory"; the "Database", this component take the place of the "Directory" when it is invoked; the "File"; the "Datasets", this component takes the place of the "File" when the "Database" is invoked, and the Variable.

  • Directory: The "Directory" component of "Select Variable" contains: a home directory icon, which if selected will take the user directly to their $HOME directory; a file selection browser icon that will display a file selection GUI for selecting the directory and a file; an input window for specifying the directory by means of a keypad; a bookmark icon for saving favorite working directories; and a cycle icon for cycling through the list of favorite working directories.
  • Note: the "Directory" input window will turn salmon pink when the user enters text. The textual information requesting a new directory will not be excepted until the <Return> key is depressed.
  • Database: The "Database" component is displayed only when the user has changed the choice button from "Directory" to "Database". If the user has not installed "esg" on their system and the environment variable "CDMSROOT" has not been set, then the "Database" option will not appear. If the "Database" option is selected, then a popup will appear allowing the user to log onto a remote database. After connecting to a remote database the "File" component will change to display "Datasets".
  • File: The "File" component displays all the files located in the directory. To view only a specific file type, select under "Main Menu" -> "File" -> "Open File Types" the desired file specifications. If an OPeNDAP enabled version of CDAT has been installed, then, a URL of a dataset on an OPeNDAP server may be entered.
  • Datasets: The "Datasets" components displays all the datasets located in the database. This is only visible if the "Database" component is visible.
  • Variable: The "Variable" component displays the variables, axes, and bounds in a file or dataset. To alter the viewing of "Variable" (i.e., don't display or display axes, bounds and weights), toggle "Main Menu" -> "Options" -> "View axes in Variable List" and "Main Menu" -> "Options" -> "View bounds and weights in Variable List".

 

Graphics (i.e., Plot, Boxfill, VCS Canvas 1, Options, Define)

There are only four components to "Graphics", but because of screen real estate and design considerations, the "Define" button was added to this row. Therefore, "Graphics" consist of five components: the "Plot" button, the "Graphics Method" (e.g., "Boxfill", "Isofill", etc.) choice button, the "VCS Canvas" choice button, the graphics "Options" menu, and the "Define" button.

  • Plot: After the "Variable" has been selected, the user can select the "Plot" button to display the variable. The user can also select the "Plot" button to display a "Define Variable", which is described later in this document.
  • Graphics Method: By default, the "Boxfill" graphics method will be displayed. To choose a different graphics method, the user must depress and hold the choice menu button. Then move the pointer over the desired graphics method (e.g., "Isofill"). At this point, the user can reselect the "Plot" button to redisplay the variable.
  • VCS Canvas: VCDAT allows up to four VCS Canvases. More can be added if necessary. The user can select which canvas to display the variable information. Note, if the user wishes to display the information on the "Background Canvas", then rendering is done in memory and no canvas drawing is visible to the user, but the user can still send the unseen plot to the printer or to a graphics output file. See "Main Menu" -> "Save Plot As" and "Main Menu" -> "Print Plot On" for sections on file output and printer selections. Also, view the VCS document for details on the PCMDI_GRAPHICS directory and the HARD_COPY file.
  • Options: The "Options" menu displays additional GUIs for controlling the outcome of the plot. These plot options are: "Continents Types", "Page Orientation", "Overlay", "Isoline Labels", "Annotation", "Set VCS Canvas Geometry", "Set Min Max Values", "Set Graphics Method Attributes", Number of Plots on VCS Canvas", "Set Plot Map Projection", "Editors", "Animate", "Clear VCS Canvas", and "Close VCS Canvas".
  • Define: After the "Variable" has been selected, the user can select the "Define" button to transfer the variable from a file or remote database to memory. The selected variable will be visible in the "Defined Variables" below.
  • The "Define" button is also used to save a defined variable under a new name and can be used to overwrite an existing defined variable. That is, in the "Defined Variable List" window, select a defined variable, and then select the "Define" button. A pop up will appear with simple instructions for both actions.

 

Dimensions Panel

The "Dimension Panel" is blank if no variable or defined variable is selected. It is located just under the "Graphics" section. It can currently display up to six dimensions. But more display dimensions can be easily added if necessary. The displayed dimensions are separated by lines and contain four components: the "Dimension Menu"; the "Dimension Selection"; the "Dimension Sliders"; and the "Dimension Functions".

  • Dimension Menu: The "Dimension Menu" allows the user to change the view of the "Dimension Selection" from axes defined values to index values. For example, from longitude or latitude coordinate values to index values. In the case of the time dimension, the user can change the time coordinate values, i.e., "units since base time" (See Handling Time.) to either raw time values or index values.
  • The user can get the weights of an axis' by selecting the "Get Axis Weight Values" menu item. The weights variable will be stored in memory and displayed in the "Defined Variable" window below.
  • By selecting the "Replace Axis Values", the user can replace the axis node values with a defined variable, provided that the axes and the defined variable are the same size. The new axis must be visible in the "Defined Variables" window.
  • To reorder the dimensions, depress and hold the "Re-Order Dimensions". Then select the desired dimension to trade places. The "Dimensions Panel" will restructure itself accordingly.
  • Dimension Selection: The "Dimension Selection" allows the user to select a single node value, a subset of node values, and a selection of every nth node value. When selecting the arrow button to the right will display the list axes node values. The highlighted value indicates the selected node(s). The input text window representation the dimension as "first: last by stride".
  • The user can enter the node value(s) in the input text window. When entering values, the input window becomes salmon pink. To except the changes, the user must depress the <Return> key. To select every nth node value, the user must enter the stride number after the "by" and then depress the <Return> key.
  • To select a single node, the user can either enter the value in the input text window or select the arrow button to the right and then select the desired node value. To select a sub-range, the user can either enter the values in the input text window or select the arrow button to the right and then select the second desired node value.
  • Dimension Slider: The slider bars are yet another way to select the first and last values of a sub-range or single node point. The top slider changes the first selected node value and the bottom slider changes the last selected node value. The values below the second slider bar represent the first selected node value and the last selected node value.
  • Dimension Functions: Each dimension can have a function operate on it exclusively. Select the choice menu button for a detailed description of each function operation. The last two functions "awt" and "gtm" are slightly different. "awt" allows the user to replace the weights before operating the weighted average function. The new weights must be located in the "Defined Variables" window before using this function. The geometrical mean "gtm" is generated by the following function: gtm(x) = exp(mean ( log(x)))).

 

Defined Variables

The "Defined Variables" section operates on variables that are stored in memory. Variables can be defined in memory by selecting the "Define" button located in the "Graphics" section. Variables can also be defined by operations located in the "Main Menu" section. For example: selecting from "Main Menu" -> "PCMDITools" -> "Statistics" -> "Mean" on a variable would produce "_Statistics_mean_variablename ()" in the "Defined Variables List". Other possible ways to produce a defined variable are: by the use of "Function Icons" and command line operations via VCDAT's "Command Line Window". For example: typing "import MV; a = MV.array((1,2,3))" in the VCDAT "Command Line Window" would produce "a (3)" in the "Defined Variables List".

Note that everything associated with defined variables has the same background color as the "Define" button located in the "Graphics" section.

  • Operational Icons: The first column of icons (from top to bottom) allows the user to: edit the variable's attributes, save the variable to a netCDF file, display variable information, move selected defined variables to the trashcan, move all variables to the trashcan, view logged information about the size of variables in memory, and permanently remove or restore defined variables.
  • Defined Variables List: The "Defined Variables List" is located to the right of the "Operational Icons" and contains, in alphabetical, the list of all variables stored in memory. As the user selects variables in the list, a record of the order of selection is kept. Among other things, this selection list is important when it becomes necessary to plot or do calculations by means of the "Function Icons".
  • Function Icons: The "Function Icons" are located to the right of the "Defined Variables List". There are two modes for calculating defined variables. If the user moves the pointer over the top left icon, a detailed description of how the calculation works in both modes is given.

 

Variable Information

The "Variable Information" section immediately displays variable or defined variable information to the user. To quickly browser through many variables and examine their content, resize the variable information panel by selecting the small button located to the upper right of the "Variable Information" text. While keeping the button depressed, move the panel to the desired location.

A brief introduction to Python scripting

Python is documented down to the last detail at the Python language website http://python.org and the SourceForge website http://python.sourceforge.net. There are now many books discussing the use of Python and how to use it with other open source software. We can recommend the free tutorial available at www.python.org in the documentation section. The book "Learning Python" from O'Reilly Press is another excellent resource. This section provides a very brief introduction to some basic concepts aimed at "getting started". The interested reader can refer to any of the other sources referred to above for details.

We begin with the traditional "Hello World" program. To start the python interpreter type:

% python

 

Python 2.2.1c2 (#1, Apr 11 2002, 12:36:10)

[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> print "Hello World"

Hello World

Programs can be placed in files with a .py extension. The helloworld.py program would contain the following lines:

# helloworld.py

print "Hello World"

The program can then be executed by providing the name of the program file to the interpreter as follows:

% python helloworld.py

Hello World

%

 

Variables and arithmetic expressions

A simple program can best illustrate the use of arithmetic expressions.

# simple_program.py

pi = 3.1415

degrees = 0

while degs <= 90:

rads = degs * pi / 180.0

print degs, " degrees = ", rads, " radians"

degs = degs + 10.

The output of this program is the following table:

0 degrees = 0.0 radians

10.0 degrees = 0.174527777778 radians

20.0 degrees = 0.349055555556 radians

30.0 degrees = 0.523583333333 radians

40.0 degrees = 0.698111111111 radians

50.0 degrees = 0.872638888889 radians

60.0 degrees = 1.04716666667 radians

70.0 degrees = 1.22169444444 radians

80.0 degrees = 1.39622222222 radians

90.0 degrees = 1.57075 radians

Python is a dynamically typed language (i.e you do not need to declare the variable types apriori) and the names can represent different types depending on the arithmetic operations performed. In the above example, "degs" was initially set to the integer 0, and is seen in the first line printed. Subsequently a real number (10.) is added at each stage of the loop and this changed the type of "degs" as it can be seen that "degs" values printed are real. Note that the above example is contrived to illustrate this point and there is no real reason to add a real value 10.0 in the loop.

The output of the program looks less than ideally formatted. To make it look better, we can make use of format strings. For example:

>>> print "%3d degrees = %0.4f radians" %(degs, rads)

would produce output that looks like this:

0 degrees = 0.0000 radians

10 degrees = 0.1745 radians

20 degrees = 0.3491 radians

30 degrees = 0.5236 radians

40 degrees = 0.6981 radians

50 degrees = 0.8726 radians

60 degrees = 1.0472 radians

70 degrees = 1.2217 radians

80 degrees = 1.3962 radians

90 degrees = 1.5708 radians

The format strings %d, %s denote integers and strings respectively, and %g and %f denote floats.

Conditional statements

The if and else statements provide an easy way to perform tests. For instance:

>>> if x != y:

>>> print 'x is not equal to y'

>>> else:

>>> print 'x and y are equal'

The indentation is required to isolate the if and else clauses, but the else clause is optional. Do nothing clauses can be created by using the pass statement.

>>> if x != y:

>>> pass

>>> else:

>>> print 'x and y are equal!'

Multiple test cases can be implemented using the elif clause.

>>> if x == 'n':

>>> print 'Answered no'

>>> elif x == 'y':

>>> print 'Answered yes'

>>> else:

>>> print 'invalid answer'

Boolean expressions can be formed by using or, and, and not keywords.

>>> if x > y and z > x:

>>> print 'z is the max value'

>>> if not (x==z or y==z or x==y):

>>> print 'There are no equal values'

 

File Input and Output

To open a text file and read its contents you would

>>> f = open("myfile.txt")

# The above line returns a file object

>>> line = f.readline()

# The readline() method is invoked on file

# and one line is read from the file.

# The following section keeps printing and reading

# subsequent lines of data while there are new lines to

# be read

>>> while line:

>>> print line

>>> line = f.readline()

# The while loop is exited when there are no more lines

# to be read. To close the open file:

>>> f.close()

To write output to a file,

>>> fout = open("out.txt", `w')

# The `w' indicates file should be opened for writing

# and is created if it does not already exist.

>>> fout.write("hello\n")

# or equivalently

>>> print >>fout, "hello"

Lists and Tuples

Lists and tuples are sequences of arbitrary objects. Lists can be created by:

>>> mylist = ["a", 1.0, "c", 4]

Note that you can mix items of any type in a list. You can also have lists nested inside lists.

>>> my_other_list = ["a", "b", [1,2,3], "d"]

The lists are indexed by integers starting with zero. To see the first item in mylist, you would:

>>> firstitem = mylist[0]

# returns the item "a"

# To set an item:

>>> mylist[2] = "x"

# Changes the item in the index position 2.

>>> print mylist

["a", 1.0, "x", 4]

To append new members to the list, the append() method is used as follows:

>>> mylist.append("nextitem")

>>> print mylist

["a", 1.0, "x", 4, "nextitem"]

Similarly, individual items can be removed from the list using the remove() method:

>>> mylist.remove(1.0)

>>> print mylist

["a", "x", 4, "nextitem"]

You can also insert items into specific positions:

>>> mylist.insert(1, "inserted_item")

>>> print mylist

["a", "inserted_item", "x", 4, "nextitem"]

Lists can be concatenated by using the "+" operator:

>>> newlist = mylist + [9, 10, 11]

>>> print newlist

["a", "inserted_item", "x", 4, "nextitem", 9, 10, 11]

Tuples are very similar to lists and are constructed by using parentheses instead of brackets or just a comma-separated list.

>>> mytuple = (1, 2, -3)

>>> myvector = (magnitude, direction)

# is the same as

>>> myvector = magnitude, direction

Tuples support the same operations as are supported by lists except the appending or modification of elements after they are created. That is, you cannot modify elements or append elements to a tuple.

 

Loops

We saw the simple loop using the while statement in the previous examples. Other looping constructs such as the for statement are available to the user. It is important to note that statements within the loop are indented. An example of its usage is:

>>> for i in range(3):

>>> print "10 raised to ", i, " is ", 10**i

# will produce the result

10 raised to 0 is 1

10 raised to 1 is 10

10 raised to 2 is 100

Note that a=range(3) is equivalent to a=[0,1,2]. Similarly the range(1, 6) is equivalent to [1,2,3,4,5] and range(10, 8, -1) is equivalent to [10, 9]. To generalize, range(i, j, k) produces a list of integers from i to j-1 using a stride k. If i is omitted, it is taken to be zero and k defaults to 1 if omitted. A more efficient (in terms of memory and runtime) is the xrange() function used exactly like range().

One can also loop through lists using the for statement so:

>>> mylist = [`a', `b', 3]

>>> for item in mylist:

>>> print item

# produces the output

a

b

3

 

Dictionaries

A dictionary allows you to associate values index by keys. Dictionaries can be created using values in curly braces like this:

>>> a = {

"name" : "CCM3",

"center" : "NCAR,"

"model_of" : "Atmosphere"

}

To access members of the dictionary, we use the key-indexing facility

>>> model_name = a["model"]

>>> modelling_center = a["center"]

The keys associated with a dictionary can be obtained as a list by:

>>> b = a.keys()

and you can check the dictionary membership by using the has_key() method:

>>> if a.has_key("model_of"):

>>> print a["model_of"]

>>> else:

>>> print "Unknown model of"

 

Functions

A function can be created using the def statement as shown below.

def myadd(a, b):

c = a*10 + b

return c

Note once again that the statements inside the function are indented after the "def" statement. To invoke the function we do the following:

>>> addvalue = myadd(2, 5)

It is possible to return multiple values using comma separated names in the return statement inside the function.

def myaddsub(a, b):

c = a*10 + b

d = a*10 - b

return c, d

In this case the function is invoked as follows:

>>> addvalue, subvalue = myaddsub(2, 5)

The function definition can also be done in a way such that default values for input parameters can be set.

def myaddsub(a, b, base=10):

c = a*base + b

d = a*base - b

return c, d

Then, when you need base to take a different value than the default 10, you can

>>> addvalue, subvalue = myaddsub(2, 5, base=2)

Modules

To keep your programs manageable as they grow in size, you may want to break them up into several files. Python allows you to put multiple function definitions into a file and use them as a module that can be imported into other scripts and programs. These files must have a .py extension. For example

# file my_function.py

def minmax(a,b):

if a <= b:

min, max = a, b

else:

min, max = b, a

return min, max

To use the above module in other programs, you would use the import statement.

>>> import my_function

>>> x,y = my_function.minmax(25, 6.3)

How to get the tutorials and data

The tutorials are designed to introduce you to the most common operations for climate data analysis. They are available as a Python script from our download area under "Tutorials". If you want to try executing these examples, follow these steps:

  1. From the Tutorials section of the download facility under the CDAT home page at http://cdat.sf.net, download the data files tarball (cdat_tutorial_data.tar.gz) and unpack it.
  2. Download the tutorial files tarball (cdat_tutorials.tar.gz) and unpack it. In each tutorial you may need to edit the line(s) near the top that sets the location of the data files to match the location where the data will be on your system.
  3. At some point during the tutorials you may wish to also read Reading, creating, and altering variables for a discussion of the difference between several array-like abstractions that our software uses: numerical arrays, masked arrays, transient variables, and file variables.

What do the tutorials cover?

There are five tutorial files provided with data required to run them. The tutorials are CDAT scripts that give the user a flavor of how scripts work and to give an idea of how to accomplish specific tasks. A brief description of the tutorials follows:

getting_started_tutorial.py

This tutorial is the first one to study. The tutorial consists of three examples:

Example 0: The basics

This example runs through some basic operations such as opening, closing, writing to files, and reading data by location or at specified time intervals. The tutorial is presented with a series of questions and answers in the style of a FAQ.

Example 1: Dealing with data from other sources

This example shows (in excruciating detail) how to read in Fortran formatted data, use it within CDAT, and writing to a netCDF file. Some simple averaging operations are carried out on the data. This example also shows how to change/insert metadata for the variable.

Example 2. Using Masks.

This example shows how to generate data masks, applying masks and averaging using area weights.

times_tutorial.py

This tutorial demonstrates the uses of the time averaging functions. Basic examples cover topics such as computing the December-February seasonal means, computing the climatology, anomalies (departures) from climatology, construction of seasons not already defined, customization, and use of powerful criteria to specify minimum temporal coverage and data distribution.

statistics_tutorial.py

This tutorial covers some of the basic statistical functions such as rms, correlation, mean absolute difference and their usage with climate data.

vcs_tutorial.py

This tutorial guides you through some basic plotting functions and features to visualize the data and produce presentation quality output. This is by no means an exhaustive demonstration of features - just a very basic set of capabilities are addressed. Specific examples cover animations, creating and altering graphics methods, creating and altering display templates, producing output files for printing and displaying and changing colormaps etc.

xmgrace_tutorial.py

In this tutorial, the interface to the XmGrace utility is demonstrated by showing simple plot generation and customization. XmGrace is a plotting tool developed independent of CDAT and has a wide user base. To download and install XmGrace, see the Grace home page at http://plasma-gate.weizmann.ac.il/Grace

Documentation and Help

The CDAT home page http://cdat.sf.net is your source for documentation- both online and printable and support. Documentation is available to help users at various levels of expertise starting with the beginning user's guide (this document) to the advanced user who needs a quick reference to commands or details of usage in the programming API reference guides. CDAT makes heavy use of Numerical Python, a fast array facility for Python. The Numerical Python website at http://numpy.sourceforge.net contains extensive documentation.

Online Documentation
Using VCDAT

The VCDAT graphical user interface has a "help" button that provides access to all the documentation that a user may require at the click of a button. The interface also has helpful information in pop-up balloons that instruct the user when the cursor is moved over the buttons.

Using "docstrings"

Python also has a powerful feature: most objects in Python, including the modules, classes, and functions, have documentation strings ("docstrings") attached to them. The special attribute name "__doc__" (which has two underscores on each end) is used to access this string supplied by the module author. If you have an object x, try the command

>>> print x.__doc__

Using pydoc to generate documentation

You can also use the pydoc utility. This is a standard facility for extracting documentation from Python installations.

You can generate Python documentation in HTML or text for interactive use.

Interactive use

In the Python interpreter, do "from pydoc import help" to provide online help. Calling help(thing) on a Python object documents the object. Also, typing help() will put the user in a help environment indicated by the prompt changing to

help>

From the shell

At the shell command line outside of Python: Run "pydoc <name>" to show documentation on something. <name> may be the name of a function, module, package, or a dotted reference to a class or function within a module or module in a package. If the argument contains a path segment delimiter (e.g. slash on Unix, backslash on Windows) it is treated as the path to a Python source file. Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines of all available modules.

Starting a browser / server

pydoc -g starts an HTTP server and also pops up a little window for controlling it.

Writing out HTML

Run "pydoc -w <name>" to write out the HTML documentation for a module to a file named "<name>.html".

Using happydoc

A utility named "happydoc" is able to generate documentation for modules written in Python.

Printable documentation
Quick Start Guides

The documents cdms_quick_start.pdf and vcs_quick_start.pdf provide a quick look at useful commands in the core CDAT modules; cdms and vcs respectively on a single page that is useful even to the experienced user.

Programming reference guides

The core CDAT modules cdms and vcs are extensively documented in separate documents that can be downloaded from http://cdat.sf.net. The most up-to-date versions of the following guides can be found there.

  • cdat.pdf : This document
  • cdms.pdf : Climate Data Management System
  • vcs.pdf : Visualization and Control System: Python Command Line and Application Programming Interface
  • cdat_utilities.pdf : CDAT Utilities Reference Guide
  • numpy.pdf : Numerical Python
  • vcs_quick_ref.pdf A one page reference to VCS commands.
Getting Support

The CDAT Home Page is http://cdat.sf.net. CDAT is hosted at SourceForge, a free service provided by VA Linux, Inc. to the Open Source Community. SourceForge enables us to provide the following services for users:

You can use these facilities without registering at SourceForge, but registration, which is quick, easy, and free, will enable you to participate in the fullest possible way. In particular, it is very helpful to us if you are registered when you submit a bug report.

Go to Main Go to Previous Go to Next