NCL: Putting it all together

It is assumed that you have read most of the other modules in the NCL User Guide by the time you read this. This module takes you through an example that illustrates the main features of the NCL language.

NCL is a powerful tool for data exploration and analysis. It is particularly useful in examining netCDF files. Recall the information on the NCL data model from the data model module.

A typical NCL application will read in a netCDF file for analysis. Datasets in the netCDF file will be plotted. Subsets of datasets are easily extracted (as discussed in the NCL array subscripting module) and plotted.

The cn10n.ncl example is considered in this module. The Quick Start Guide explains how to run this example.

The example begins by reading in a netCDF file using the NCL addfile function. This netCDF file was created from an ASCII ".cdl" file by using the netCDF ncgen command. For reference, here is the original ASCII source used to create the netCDF file:

netcdf mound {  // A mound to use as a demo for NCL data manipulation
                // and plotting.

dimensions:
    xdim = 15;
    ydim = 18;

variables:

    float       mound(xdim,ydim);
                mound:long_name = "2-D mound for data demo";
                mound:units = "dimensionless";
                mound:valid_range = 0.f, 7.f ;
                mound:_FillValue = -9999.0f;

    float       xdim(xdim);
                xdim:long_name = "X axis dimension";
                xdim:units = "dimensionless";

    float       ydim(ydim);
                ydim:long_name = "Y axis dimension";
                ydim:units = "dimensionless";

    :history = "created by SCD for demo purposes";
    :title = "Two dimensional mound for data demo";

data:

 xdim = -40, -30, -20, -10,   0,  10,  20,  30,  40,  50,  60,  70, 
         80,  90, 100;

 ydim = -60, -50, -40, -30, -20, -10,   0,  10,  20,  30,  40,  50,
         60,  70,  80,  90, 100, 110;

mound =

34.81, 36.60, 38.06, 39.20, 40.01, 40.50, 40.66, 40.50, 40.01, 
39.20, 38.06, 36.60, 34.81, 32.70, 30.26, 27.50, 24.41, 21.00, 

36.56, 38.35, 39.81, 40.95, 41.76, 42.25, 42.41, 42.25, 41.76, 
40.95, 39.81, 38.35, 36.56, 34.45, 32.01, 29.25, 26.16, 22.75, 

37.81, 39.60, 41.06, 42.20, 43.01, 43.50, 43.66, 43.50, 43.01, 
42.20, 41.06, 39.60, 37.81, 35.70, 33.26, 30.50, 27.41, 24.00, 

38.56, 40.35, 41.81, 42.95, 43.76, 44.25, 44.41, 44.25, 43.76, 
42.95, 41.81, 40.35, 38.56, 36.45, 34.01, 31.25, 28.16, 24.75, 

38.81, 40.60, 42.06, 43.20, 44.01, 44.50, 44.66, 44.50, 44.01, 
43.20, 42.06, 40.60, 38.81, 36.70, 34.26, 31.50, 28.41, 25.00, 

38.56, 40.35, 41.81, 42.95, 43.76, 44.25, 44.41, 44.25, 43.76, 
42.95, 41.81, 40.35, 38.56, 36.45, 34.01, 31.25, 28.16, 24.75, 

37.81, 39.60, 41.06, 42.20, 43.01, 43.50, 43.66, 43.50, 43.01, 
42.20, 41.06, 39.60, 37.81, 35.70, 33.26, 30.50, 27.41, 24.00, 

36.56, 38.35, 39.81, 40.95, 41.76, 42.25, 42.41, 42.25, 41.76, 
40.95, 39.81, 38.35, 36.56, 34.45, 32.01, 29.25, 26.16, 22.75, 

34.81, 36.60, 38.06, 39.20, 40.01, 40.50, 40.66, 40.50, 40.01, 
39.20, 38.06, 36.60, 34.81, 32.70, 30.26, 27.50, 24.41, 21.00, 

32.56, 34.35, 35.81, 36.95, 37.76, 38.25, 38.41, 38.25, 37.76, 
36.95, 35.81, 34.35, 32.56, 30.45, 28.01, 25.25, 22.16, 18.75, 

29.81, 31.60, 33.06, 34.20, 35.01, 35.50, 35.66, 35.50, 35.01, 
34.20, 33.06, 31.60, 29.81, 27.70, 25.26, 22.50, 19.41, 16.00, 

26.56, 28.35, 29.81, 30.95, 31.76, 32.25, 32.41, 32.25, 31.76, 
30.95, 29.81, 28.35, 26.56, 24.45, 22.01, 19.25, 16.16, 12.75, 

22.81, 24.60, 26.06, 27.20, 28.01, 28.50, 28.66, 28.50, 28.01, 
27.20, 26.06, 24.60, 22.81, 20.70, 18.26, 15.50, 12.41,  9.00, 

18.56, 20.35, 21.81, 22.95, 23.76, 24.25, 24.41, 24.25, 23.76, 
22.95, 21.81, 20.35, 18.56, 16.45, 14.01, 11.25,  8.16,  4.75, 

13.81, 15.60, 17.06, 18.20, 19.01, 19.50, 19.66, 19.50, 19.01, 
18.20, 17.06, 15.60, 13.81, 11.70,  9.26,  6.50,  3.41,  0.00;

}

This file has a simple 2-D dataset called "mound" that represents a smooth mound. It should be instructive to refer to this file as you read through example cn10n.ncl.

After the netCDF file is read in, a quick-and-dirty contour plot is drawn of the mound. After this plot, an improved contour plot is drawn by using color fill and modifying the label fonts, and so forth. In the third picture, a subregion of the original data is selected and plotted. In the next plot, a slice is taken through the data with X held constant, and a curve is drawn by creating an XyPlot object and plotting it. In the final plot, the original 2-D array is contoured and overlayed on top of the state of Colorado using MapPlot to draw a Lambert Conformal projection of an appropriate region of the United States.

This example illustrates most of the important features of NCL as well as how NCL interacts with plot objects of the HLU library.


User Guide Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, UG Contents, UG WhereAmI?


$Revision: 1.10 $ $Date: 1998/06/15 22:08:59 $