Contour Plots
|
8: Contour PlotsContour plots can be done with either pregridded data or randomly distributed (ie, ungridded) data.
This section presents two examples of contouring pre-gridded data, the first example illustrating a boilerplate program to quickly contour data stored in a simple matrix form in a file, the second example illustrating a case with more control of the details (e.g., nonuniform grid).
8.1.1: Simple exampleThis example was hardwired to know the size of the grid, etc. Here's an example which is more general, in that it determines the dimensions of the grid data from using unix system commands. Note that the grid is set to run from 0 to 1 in both x and y; you'll most likely want to change that after you see the initial plot, but this should get you started.
(Note the use of `
8.1.2: Complicated exampleTo get a simple contour graph based on pre-gridded data, with full control of axes, etc, do something like this:
Here several new things have been introduced.
First, you've got to define a grid in xy space. This example uses a
non-uniform x-grid, and reads it in from the commandfile. In this form,
the blank line is essential; it tells Gri that the end of data has been
located; if you like, you can specify the number of lines to read, as in
`
The y-grid for this example is uniform, however, so it may be specified
with the `
Having defined a grid, it's time to read in the gridded data. Here this
is done with the ` The first dataline is the top of the y-grid. In other words, the data appear in the file just as they would on the graph, assuming that the x-grid and y-grid both increase.
Sometimes you want to read in the transpose of a matrix. Gri lets you
do that. If the `
If you have an extraneous column of data to the left of your data
matrix, do `
Now Gri has the grid in it's head. We tell it to draw some contours
with the ` When you have f=f(x,y) points at random x and y, you must cast them onto a grid to contour them. This is a difficult problem. There are many ways to grid data, and all have both good and bad features. You should try various methods, and various settings of the parameters of the methods. If you have a favorite gridding method that you prefer, you should probably pre-grid the data yourself. If not, Gri can do it for you. Gri has two methods for doing this, the ``boxcar'' method and the ``objective analysis'' method. Each method puts holes in the grid wherever there are too few data to map to grid points, unless you specifically ask to fill in the whole grid. The next two sections show first an example, then a discussion of the methods and how to use them.
8.2.1: ExampleThis example uses data taken from Figure 5 of S. E. Koch and M. DesJardins and P. J. Kocin, 1983. ``An interactive Barnes objective map anlaysis scheme for use with satellite and conventional data,'', J. Climate Appl. Met., vol 22, p. 1487-1503. Readers should compare Figures 5 and 6 of that paper to the results shown here.
8.2.2: Discussion of MethodsThe various commands for converting columns to a grid are given in see Convert Columns to Grid. Generally, the Barnes method is best.
|