NCL Website header
NCL Home> Application examples> Non-uniform grids || Data files for some examples

Example pages containing: tips | resources | functions/procedures

Contouring one-dimensional X, Y, Z (random) data

If you have X, Y, Z data represented by one-dimensional (1D) arrays of the same length, then there are a few options on contouring this data:

  1. Simply set the sfXArray and sfYArray resources to the X and Y arrays respectively, and pass the 1D Z data to the appropriate gsn_csm contouring routine.

  2. In NCL V6.4.0 and later, you can set the special "lat1d" / "lon1d" attributes. See the scripts below called "contour1d_n_640.ncl" for examples.

  3. Regrid the data to a two-dimensional (2D) grid using functions like cssgrid, natgrid and triple2grid. See the Random to Grid examples.

In all cases, the quality of the resulting plot will be a function of the distribution of the X and Y arrays, the number of sampling points and the 'shape' of the data be contoured.
contour1d_1.ncl / contour1d_1_640.ncl: The data in this example is a one-dimensional (1D) array with corresponding 1D lat/lon arrays. To contour this data, you must set both the sfYArray and sfXArray resources to these lat/lon arrays respectively. NCL will internally use the triangular mesh capability to contour this data.

The data files for this example are pw.dat and stn_latlon.dat.

The second frame of this example shows how to draw markers at the locations of the random lat, lon data.

contour1d_2.ncl / contour1d_2_640.ncl: This example shows how to contour an ARPEGE grid, which came to us from Christophe Cassou of Meteo-France.

The data for this example are spread across two NetCDF files. The resolution is pretty fine, so raster contours (cnFillMode = "RasterFill") are used. Again, the lat/lon information is provided by setting the resources sfXArray and sfYArray.

contour1d_3.ncl / contour1d_3_640.ncl: Gridded sea level pressures are read; then, for demonstration purposes, NOBS are randomly sampled from the grid using generate_unique_indices or random_uniform and small random location perturbations are added. The resulting lat[*], lon[*], Z[*] triplet is then contoured using the sfYArray and sfXArray resources. In this example, the trGridType resource is explicitly set to "TriangularMesh". However, as noted above, this is not necessary.

Note: The input data are on a global grid. Hence, the data are cyclic in longitude. The resulting plot clearly shows [left and right edges] that the "TriangularMesh" is not capable of handling this situation.

contour1d_4.ncl / contour1d_4_640.ncl: This example is very similar to the first one on this page, except the markers are colored according to the labelbar generated by the color contours.

The color contours are made more transparent by setting cnFillOpacityF to 0.5 (default is 1.0). This will only work in V6.2.0 of NCL, to be released in winter 2013. The main purpose of this example is to show how to color the markers based on an existing contour field.