Overview of the PyNGL examples

The PyNGL examples give you an overview of the graphic capabilities of the package and provide a tutorial introduction. Other useful example-related links are provided - a summary is presented in a list below.

Setting up your environment to run the examples

To run most of the examples, you must have NumPy installed in your Python implementation, and you must also have the appropriate version of PyNGL and PyNIO installed.

Many examples use the Nio module from PyNIO to read in a netCDF file (or files). The Nio module comes bundled with PyNGL. netCDF is a self-documenting and network-transparent data format - see the netCDF User Guide for details.

How to run the examples

To run any of the examples, the following requirements must be met:

The easiest way to run any, or all, of the examples is to use the pynglex script. This will copy over all necessary files and run the specified example, or examples.

Here is an example of how to use pynglex:


   pynglex ngl01p
This command will copy over the necessary source files to run the example named "ngl01p" (actually only ngl01p.py in this case), invoke Python to run the example, and generate the output graphic in the PostScript file ngl01p.ps. A complete list of the example names is given on the alphabetical page or by running "pynglex -l". The pynglex script takes several command line options, see the pynglex documentation for details.

If you wish, you can download these examples from the web using the links that are provided for each example.

General PyNGL example code structure

The general code structure of the PyNGL examples is as follows:

Read data
Data are either generated from within the PyNGL script or read from either an ASCII file or a netCDF file.

Process data
Some of the examples show how to process data by converting units, masking values, interpolating to a regular grid, and so forth.

Visualize data
Almost every example generates one or more visualizations, including XY plots, contour plots, vector plots, map plots, and streamline plots.

Write data
Some of the examples show how to write data to a file.

Useful example-related links.

gallery
Provides all graphic images produced from PyNGL examples as well as links to all source codes used to create the examples.
alphabetical
An alphabetical listing of all PyNGL examples together with brief descriptions and links to the sources.
tutorial
A step-by-step guide to PyNGL that introduces new concepts through a series of example Python scripts. Each of the eleven examples contains line-by-line descriptions.
by category
Lists the examples by category (such as "contouring", "vectors", and so forth) and provides links to the examples in those categories.
by function
For any given PyNGL function, this page lists all the examples where that function is called.
by resource
For any given PyNGL resource that is used in an example, this page lists all the example where the resource is used.
by effect
This page provides links to examples that illustrate specific effects, such as changing lines thicknesses, explicitly specifying contour levels, and so forth.