NAME
        FlipLat

   DESCRIPTION
        This module flips, in one of two different ways, the data and coordinates
        of any 2-D or 3-D lattice along any combination of its axes.  The same
        data and coordinate types used for the input lattice will be used for the
        output lattice.
        
        In the first flipping mode ("Reverse"), the lattice can be reordered so
        that increasing values of the axis index (eg, "K") will be associated with
        increasing coordinate values.  For example, suppose at K=1,2,3 we have
        H=100,40,10.  Flipping this would create a new lattice with K=1,2,3 now
        referring to coordinates 10,40,100.  Why is this necessary?  After all,
        you may have a perfectly legal right-handed coordinate system (ie,
        increasing H is consistent with increasing Z). The answer is that certain
        modules (notably IsosurfaceLat when coloring an isosurface by a
        second lattice) get confused unless increasing K is associated with
        increasing values of the K-coordinate.
        
        The second mode ("Invert") can be used to convert a lattice which is
        left-handed into one which is right-handed.  An example of this (again,
        using an example where the lattice is flipped along the K axis) is
        atmospheric numerical models which employ a sigma vertical
        coordinate.  Since sigma=0 is at the "top" of the atmosphere and
        sigma=1 at the bottom, Explorer (assuming a right-handed coordinate
        system) would render the lattice upside-down.  The K coordinates
        could be multiplied by -1 to obtain a right-handed coordinate system,
        but then they would decrease as K increased.  You could then apply the
        same reordering as in the first flipping mode and things would get
        rendered properly spatially, except that all the data would apear to lie
        beneath the X,Y plane.  This could be remedied by adding a constant
        offset to the revised K coordinates to make all the points lie above the
        X,Y plane.  For all intents and purposes, this is what the second flipping
        mode does.  The only drawback is that the final vertical coordinate
        values, while positioned correctly relative to one another, will have what
        appear to be strange values.
        
        Since flipping affects the coordinates, what about proper labelling?
        FlipLat provides a solution to this problem.  It has the ability to flip a
        lattice, but retain the values of the coordinates of another lattice on the
        "Coords In" port.  This is essential if the primary lattice is flipped on
        any of its axes, but the result must be labelled in the Render module (eg,
        using the AllAxis module).  The "Coords In" port will typically be wired to
        the same lattice as the "Input" port (although it may be a different one if,
        for example, "Input" has a lattice with scaled coordinates and you want
        to label using the unscaled coordinates).  The coordinates of the
        "Coords In" lattice are treated differently than those of the "Input"
        lattice.  The "Coords Out" port, which contains the flipped coordinates
        from the "Coords In" port, must then be connected to the "Coords In"
        port of AllAxis.  (Naturally, the "Output" from FlipLat must also be
        connected to the "Input" of AllAxis.)  All these connections are required,
        otherwise AllAxis would not know whether a lattice was flipped, and the
        coordinate labels would be "wrong".  AllAxis uses the lattice on its
        "Coords In" port for labelling.  If the port is empty then it defaults to
        using the coordinates of the lattice on its "Input" port.
        
        FlipLat also has the ability to flip 2-D lattices, but the catch is that, in
        the case where it is "flipped" on the dimension orthogonal to the plane
        of the lattice, it needs bounding values to determine where to flip.  This
        is further explained in the sections describing the "Key In" and
        "Key Out" ports.
        
        CAUTION: THE OUTPUTS FROM FLIPLAT SHOULD NOT BE USED IN
        ANY ANALYSIS MODULES THAT DEPEND ON THE ORIGINAL
        COORDINATES.  IT IS RECOMMENDED THAT THEY ONLY BE USED
        WITH VISUALIZATION-RELATED MODULES SUCH AS ALLAXIS,
        ISOSURFACELAT, ETC.  OTHER OPERATIONS SHOULD BE DONE
        BEFORE THE DATA GETS TO FLIPLAT.

   INPUTS

      Input -- Lattice
         (2..3-D).
         This is the input lattice to be flipped.

      Coords In -- Lattice (Opt.)
         (2..3-D).
         This is an optional lattice whose coordinates will be passed through
         to the "Coords Out" port, but flipped along the specified axes.  The
         data portion of the lattice is ignored.

      Key In -- Lattice (Opt.)
         (3-D, 1-vector, uniform).
         This is an optional lattice containing key values from the "Key Out"
         port of another FlipLat module.  It is used to properly position a 2-D
         lattice that must be flipped the same way as another 3-D lattice.  For
         example, an IxJ lattice cannot be flipped on K because there are no
         values to determine where to flip it.  These key values give FlipLat
         upper and lower bounds so the lattice could be flipped as if it was 3-D.

   WIDGETS

      Flip I -- Radio Box
         This determines the mode in which the lattice is flipped along the I axis.

      Flip J -- Radio Box
         This determines the mode in which the lattice is flipped along the J axis.

      Flip K -- Radio Box
         This determines the mode in which the lattice is flipped along the K axis.

   OUTPUTS

      Output -- Lattice
         This is the lattice flipped along the specified axes.

      Coords Out -- Lattice
         (2..3-D).
         This is the lattice containing only the coordinates from the lattice
         connected to the "Coords In" port, but flipped along the specified
         axes.  This port is designed to be connected to the "Coords In" port
         of the AllAxis module for proper labelling when flipping.

      Key Out -- Lattice
         (3-D, 1-vector, uniform).
         This is the lattice of key values based on how the "Input" lattice is
         flipped.  These are just upper and lower coordinate bounds from the
         flipping calculations which can be utilized by other FlipLat modules to
         flip a 2-D lattice the same way as a 3-D lattice.

   KNOWN PROBLEMS
      There are no known bugs.

   SEE ALSO
      AllAxis

      -
            
      Hans Vahlenkamp (Hans.Vahlenkamp@noaa.gov)
      Geophysical Fluid Dynamics Laboratory / NOAA
      Princeton University Forrestal Campus
      http://www.gfdl.noaa.gov