NCL Home > Documentation > HLUs > User Guide

Transform class

Subclasses of the Transform class support a data coordinate space along with forward and reverse transformations between data coordinates and normalized device coordinates.

All HLU "plot objects" are instances of Transform subclasses. The existing Transform subclasses include XyPlot, ContourPlot, and MapPlot, as well as LogLinPlot and IrregularPlot. Each of these classes includes as composite class members one or more subclasses of the Transformation class. The Transform class itself provides the data coordinate space while the Transformation subclass performs the actual transformations of the data. Note that although the TickMark object understands and uses transformations, it does not belong to the Transform class, since it does not support its own data space. The following sections discuss the transformational capabilities of each of the Transform subclasses.

XyPlot

The XyPlot class includes both the LogLinTransformation and the IrregularTransformation as composite class members. It allows access only to the Transformation resources used to set the boundaries of the data coordinate space. Each XyPlot axis can be set individually to use a linear, log, or irregular transformation.

The transformation type of an axis for an XyPlot object is set using the resources xyXStyle and xyYStyle. The options are:

  • Irregular
  • Linear
  • Log

The default transformation type is Linear.

If you set either axis to "Irregular", you must supply an array of points as a representation of the irregular coordinate system. For the X Axis, you would set the array resource xyXIrregularPoints, and for the Y Axis, you would set xyYIrregularPoints.

ContourPlot

The ContourPlot class includes both the LogLinTransformation and the IrregularTransformation as composite class members. It allows limited access to a number of Transformation resources.

Selecting the transformation type for the ContourPlot object is a little more subtle than for the XyPlot. If either of the ScalarField object resources sfXArray or sfYArray is non null, then the axis corresponding to that array is assumed to be irregular. It does not need to be explicitly set by another resource.

To set a ContourPlot axis to logarithmic scaling, you set the LogLinTransformation composite resources, trXLog or trYLog, to a value of True. A value of False, the default, will result in that axis having linear scaling, unless it is assumed to be irregular.

MapPlot

The MapPlot class includes the MapTransformation as a composite class member. It allows access to all but one of the MapTransformation resources. Among the MapPlot transformation options are ten different geographic mapping projections, selected by setting the resource mpProjection:

  • Orthographic
  • Stereographic
  • LambertEqualArea
  • Gnomonic
  • AzimuthalEquidistant
  • Satellite
  • Mollweide
  • Mercator
  • CylindricalEquidistant
  • LambertConformal

CylindricalEquidistant is the default MapPlot transformation.

The MapTransformation class also includes a number of resources for limiting the boundaries of the projected area.

LogLinPlot

The LogLinPlot class includes the LogLinTransformation as a composite class member. It allows unrestricted access to all LogLinTransformation resources. Each axis of a LogLinPlot may be linear or logarithmic, depending on the setting of the boolean LogLinTransformation resources trXLog and trYLog.

IrregularPlot

The IrregularPlot class includes the IrregularTransformation as a composite class member. It allows unrestricted access to all IrregularTransformation resources. Each axis of an IrregularPlot may be linear, logarithim, or irregular, depending on the setting of the resources trXAxisType and trYAxisType. The options are:

  • IrregularAxis
  • LinearAxis
  • LogAxis

The default is LinearAxis.

If you set either axis to "IrregularAxis", you must supply an array of points as a representation of the irregular coordinate system. For the X Axis, you would set the array resource trXCoordPoints, and for the Y Axis, you would set trYCoordPoints.

Transformation classes

Keep in mind that you never need (or are allowed) to instantiate any of the Transformation subclasses since they are built in as composite class members of the Transform subclasses. The resources belonging to these transformation classes are available to instantiated Transform class objects. Of course, as with any composite class member, the Transform subclasses may intercept or disable some or most of the Transformation class resources. For examples of how to set transformation options in your code, or in your resource files refer to the examples listed in the following section.

Examples

  • xy08f.f and xy08c.c select irregular X and Y axes in the code.
  • xy09f.f and xy09c.c select logarithmic axes in the xy09.res resource file.
  • cn03f.f and cn03c.c select an irregular Y axis by setting sfYArray in the code.
  • mp01f.f and mp01c.c select map projections other than the default in the code.

To copy any of these examples into your current working directory, you can type:


ng4ex -n example_name 

(exclude the .c or .f, for example: ng4ex -n tm03f). To run the example, omit the -n.

See also: