M_CORRELATE $RSI/m_correlate.pro
[Previous] [Next]
 NAME:
       M_CORRELATE

 PURPOSE:
       This function computes the multiple correlation coefficient of a
       dependent variable and two or more independent variables.

 CATEGORY:
       Statistics.

 CALLING SEQUENCE: 
       Result = M_correlate(X, Y)
                           
 INPUTS:
       X:    An array of m-columns and n-rows of type integer, float or double
             that specifies the independent variable data. The columns of this
             two dimensional array correspond to the n-element vectors of 
             independent variable data.

       Y:    An n-element vector of type integer, float or double that
             specifies the dependent variable data.

 KEYWORD PARAMETERS:
    DOUBLE:  If set to a non-zero value, computations are done in
             double precision arithmetic.

 CALLS: ***
	CORRELATE, P_CORRELATE
 EXAMPLE:
       Define the independent (X) and dependent (Y) data.
         X = [[0.477121, 2.0, 13.0], $
              [0.477121, 5.0,  6.0], $
              [0.301030, 5.0,  9.0], $
              [0.000000, 7.0,  5.5], $
              [0.602060, 3.0,  7.0], $
              [0.698970, 2.0,  9.5], $
              [0.301030, 2.0, 17.0], $
              [0.477121, 5.0, 12.5], $
              [0.698970, 2.0, 13.5], $
              [0.000000, 3.0, 12.5], $
              [0.602060, 4.0, 13.0], $
              [0.301030, 6.0,  7.5], $
              [0.301030, 2.0,  7.5], $
              [0.698970, 3.0, 12.0], $
              [0.000000, 4.0, 14.0], $
              [0.698970, 6.0, 11.5], $
              [0.301030, 2.0, 15.0], $
              [0.602060, 6.0,  8.5], $
              [0.477121, 7.0, 14.5], $
              [0.000000, 5.0, 9.5]]

          Y = [97.682, 98.424, 101.435, 102.266,  97.067,  97.397, 99.481, $
               99.613, 96.901, 100.152,  98.797, 100.796,  98.750, 97.991, $
              100.007, 98.615, 100.225,  98.388,  98.937, 100.617]

       Compute the multiple correlation of Y on the first column of X.
       The result should be 0.798816
         result = m_correlate(X(0,*), Y)

       Compute the multiple correlation of Y on the first two columns of X.
       The result should be 0.875872
         result = m_correlate(X(0:1,*), Y)

       Compute the multiple correlation of Y on all columns of X.
       The result should be 0.877197
         result = m_correlate(X, Y)
         
 PROCEDURE:
       M_CORRELATE uses relationships based upon partial correlation to
       compute the multiple correlation coefficient of linear models with
       two or more independent variables: y(x0, x1), y(x0, x1, ... , xn-1).   

 REFERENCE:
       APPLIED STATISTICS (third edition)
       J. Neter, W. Wasserman, G.A. Whitmore
       ISBN 0-205-10328-6

 MODIFICATION HISTORY:
       Written by:   GGS, RSI, July 1994
       Modified by:  GGS, RSI, August 1996
                     Added DOUBLE keyword.
                     Modified keyword checking and use of double precision.


Map_2Points $RSI/map_2points.pro
[Previous] [Next]
 NAME:
	Map_2Points

 PURPOSE:
	Return parameters such as distance, azimuth, and path relating to
	the great circle or rhumb line connecting two points on a sphere.

 CATEGORY:
	Maps.

 CALLING SEQUENCE:
	Result = Map_2Points(lon0, lat0, lon1, lat1)
 INPUTS:
	Lon0, Lat0 = longitude and latitude of first point, P0.
	Lon1, Lat1 = longitude and latitude of second point, P1.

 KEYWORD PARAMETERS:
   RADIANS = if set, inputs and angular outputs are in radians, otherwise
	degrees.
   NPATH, DPATH = if set, return a (2, n) array containing the
	longitude / latitude of the points on the great circle or rhumb
	line connecting P0 and P1.  If NPATH is set, return NPATH equally
	spaced points.  If DPATH is set, it specifies the maximum angular
	distance between the points on the path in the prevalent units,
	degrees or radians.
   PARAMETERS: if set, return [sin(c), cos(c), sin(az), cos(az)]
	the parameters determining the great circle connecting the two
	points.  c is the great circle angular distance, and az is the
	azimuth of the great circle at P0, in degrees east of north.
   METERS: Return the distance between the two points in meters,
	calculated using the Clarke 1866 equatorial radius of the earth.
   MILES: Return the distance between the two points in miles,
	calculated using the Clarke 1866 equatorial radius of the earth.
   RADIUS: If given, return the distance between the two points
	calculated using the given radius.
   RHUMB: Set this keyword to return the distance and azimuth of the
	rhumb line connecting the two points, P0 to P1. The default is to
	return the distance and azimuth of the great circle connecting the
	two points.  A rhumb line is the line of constant direction
	connecting two points.

 OUTPUTS:
	If the keywords NPATH, DPATH, METERS, MILES, or RADIUS, are not
	specified, the function result is a two element vector containing
	the distance and azimuth of the great circle or rhumb line
	connecting the two points, P0 to P1, in the specified angular units.

	If MILES, METERS, or RADIUS is not set, Distances are angular
	distance, from 0 to 180 degrees (or 0 to !pi if the RADIANS keyword
	is set), and Azimuth is measured in degrees or radians, east of north.

 EXAMPLES:
	Given the geocoordinates of two points, Boulder and London:
	B = [ -105.19, 40.02]	;Longitude, latitude in degrees.
	L = [ -0.07,   51.30]

	print, Map_2Points(B[0], B[1], L[0], L[1])
 prints: 67.854333 40.667833 for the angular distance and
 azimuth, from B, of the great circle connecting the two
 points.

	print, Map_2Points(B[0], B[1], L[0], L[1],/RHUMB)
 prints 73.966280 81.228056, for the angular distance and
 course (azimuth), connecting the two points.

	print, Map_2Points(B[0], B[1], L[0], L[1],/MILES)
 prints:  4693.5845 for the distance in miles between the two points.

	print, Map_2Points(B[0], B[1], L[0], L[1], /MILES,/RHUMB)
 prints: 5116.3569, the distance in miles along the rhumb line
 connecting the two points.

 The following code displays a map containing the two points, and
 annotates the map with both the great circle and the rhumb line path
 between the points, drawn at one degree increments.
	MAP_SET, /MOLLWEIDE, 40,-50, /GRID, SCALE=75e6,/CONTINENTS
	PLOTS, Map_2Points(B[0], B[1], L[0], L[1],/RHUMB, DPATH=1)
	PLOTS, Map_2Points(B[0], B[1], L[0], L[1],DPATH=1)


 MODIFICATION HISTORY:
 	Written by:
	DMS, RSI	May, 2000. Written.
   CT, RSI, September 2001: For /RHUMB, reduce lon range to -180,+180
   CT, RSI, September 2002: For /RHUMB, fix computation at poles.


MAP_CONTINENTS $RSI/map_continents.pro
[Previous] [Next]
 NAME:
       MAP_CONTINENTS

 PURPOSE:
       The MAP_CONTINENTS procedure draws continental boundaries,
 filled continents, political boundaries, coastlines, and/or rivers,
 over an existing map projection established by MAP_SET. Outlines can
 be drawn in low or high-resolution (if the optional high-resolution
 CIA World Map database is installed). If MAP_CONTINENTS is called
 without any keywords, it draws low-resolution, unfilled continent
 outlines.

 MAP_SET must be called before MAP_CONTINENTS to establish the
 projection type, the center of the projection, polar rotation
 and geographic limits.

 Keywords not recognized are passed along in _EXTRA to PLOTS and/or
 POLYFILL depending on options requested.

 CATEGORY:
              MAPPING

 CALLING SEQUENCE:
              MAP_CONTINENTS

 INPUTS:
              NONE

 INPUT KEYWORD PARAMETERS:
 COASTS -- Set this keyword to draw coastlines, islands, and lakes instead of
           the default continent outlines. Note that if you are using the
           low-resolution map database (if the HIRES keyword is not set), many
           islands are drawn even when COASTS is not set. If you are using the
           high-resolution map database (if the HIRES keyword is set),
           no islands are drawn unless COASTS is set.

 COLOR -- The color index of the lines being drawn.

 CONTINENTS:  Set this keyword to plot the continental boundaries.
       This is the default.
       Note that if you are using the low-resolution map database
       (if the HIRES keyword is not set), outlines for continents, islands,
       and lakes are drawn when the CONTINENTS keyword is set. If
       you are using the high-resolution map database (if the HIRES keyword
       is set), only continental outlines are drawn when the CONTINENTS
       keyword is set. To draw islands and lakes when using the
       high-resolution map database, use the COASTS keyword.

 COUNTRIES -- Set this keyword to draw political boundaries as of 1993.
 _EXTRA -- Other keywords passed along to PLOTS/POLYFILL depending on
           options selected. Note that command line keywords (like
           MLINETHICK) will take precedence over options specified with
           _EXTRA or their natural names (like THICK).
 FILL_CONTINENTS -- Set this keyword to 1 to fill continent boundaries with
                    a solid color. The color is set by the COLOR keyword.
                    Set this keyword to 2 to fill continent boundaries with a
                    line fill. For line filling, the COLOR, MLINESTYLE,
                    MLINETHICK, ORIENTATION, and SPACING keywords can be used
                    to control the type of line fill. Any option valid for
                    polyfill can also be used (i.e. PATTERN).

 HIRES -- Set this keyword to use high-resolution map data instead of the
          default low-resolution data. This option is only available if you
          have installed the optional high-resolution map datasets. If the
          high-resolution data is not available, a warning is printed and
          the low-resolution data is used instead.

          This keyword can be used in conjunction with the COASTS, COUNTRIES,
          FILL_CONTINENTS, and RIVERS keywords.

 LIMIT: Set this keyword to a four-element vector
        [Lat min, Lon min, Lat max, Lon max ] to only plot continents that
        pass through the LIMIT rectangle.
        The points (Lat min, Lon min ) and (Lat max, Lon max ) are
        the latitudes and longitudes of two points diagonal from each other
        on the region’s boundary.
        The default is to use the limits from the current map projection.

     Note - Line segments for continents which extend outside of the
        LIMIT rectangle will still be plotted.

 MAP_STRUCTURE: Set this keyword to a !MAP structure, as returned from
      MAP_PROJ_INIT. If this keyword is set then the !MAP system variable
      is ignored, and the polygons and polylines are drawn using
      UV (Cartesian) coordinates.

 MLINESTYLE -- The line style of the boundaries being drawn.
               The default is solid lines.
 MLINETHICK -- The thickness of the boundary or fill lines.
               The default thickness is 1.
 ORIENTATION -- Set this keyword to the counterclockwise angle in degrees
                from horizontal that the line fill should be drawn. The
                default is 0. This keyword only has effect if the
                FILL_CONTINENTS keyword is set to 2.
 RIVERS  -- Set this keyword to draw rivers.
 SPACING -- Set this keyword to the spacing, in centimeters, for a line fill.
            This keyword only has effect if the FILL_CONTINENTS keyword is
            set to 2. The default is 0.5 centimeters.

 T3D: Set this keyword to indicate that the generalized transformation
      matrix in !P.T is to be used. If not present, the user-supplied
      coordinates are simply scaled to screen coordinates.

 USA -- Set this keyword to draw borders for each state in the United States
        in addition to continental boundaries.

 ZVALUE: Sets the Z coordinate, in normalized coordinates in the
         range of 0 to 1, at which to output the continents.

      Note - This keyword has effect only if keyword T3D is set and the
         transformation is stored in !P.T

 OUTPUT KEYWORD PARAMETERS:
              NONE

 OUTPUTS:
       Draws continents, etc. over the current map display.

 CALLS: ***
	FILEPATH, MAP_DO_SEGMENTS, MAP_DO_UNITEDSTATES, MAP_GETINDEX, MAP_STRUCT_APPEND
	REVERSE
 CALLED BY:
	_idlitmapprojection__define [1], _idlitmapprojection__define [2], map_set
 COMMON BLOCKS:
       None.

 SIDE EFFECTS:
       None.

 RESTRICTIONS:
       See DESCRIPTION.

 DESCRIPTION:
       See PURPOSE.

 EXAMPLES:

         Draw Low-Resolution continents, with high resolution
         political boundaries.

         MAP_SET
         MAP_CONTINENTS
         MAP_CONTINENTS,/hires,/countries

   Example using MAP_STRUCTURE:
       ; GCTP Polar stereographic projection
       mapStruct = MAP_PROJ_INIT(106, LIMIT=[0,-180,90,180], $
           CENTER_LATITUDE=90)
       ; Create a plot window using the UV Cartesian range.
       PLOT, mapStruct.uv_box[[0,2]],mapStruct.uv_box[[1,3]], $
           /NODATA, /ISOTROPIC, XSTYLE=1, YSTYLE=1
       MAP_CONTINENTS, MAP_STRUCTURE=mapStruct
       MAP_GRID, MAP_STRUCTURE=mapStruct

 DEVELOPMENT NOTES:
         This version uses !type=3 and uses the NEW (IDL5) map software.
         requires map_struct_append in map_set.pro

 MODIFICATION HISTORY:
   SVP, 11/96 ;  Added header template.
   CT, RSI, Nov 2002: Added MAP keyword.
   CT, RSI, Feb 2004: Renamed MAP keyword to MAP_STRUCTURE, now documented.


MAP_GRID $RSI/map_grid.pro
[Previous] [Next]
 NAME:
	MAP_GRID

 PURPOSE:
       The MAP_GRID procedure draws the graticule of parallels and meridians,
 according to the specifications established by MAP_SET. MAP_SET must be called
 before MAP_GRID to establish the projection type, the center of the
 projection, polar rotation and geographical limits.

 CATEGORY:
	Mapping.

 CALLING SEQUENCE:
       MAP_GRID

 INPUTS:
	NONE

 OPTIONAL INPUTS:
	NONE

 KEYWORD PARAMETERS:


 BOX_AXES: Surround the map window with a "box" style axes with
	      annotations, outside the box, where the parallels intersect the
	      sides, and the meridians intersect the bottom and top edges of the
	      box.  The border of the box is drawn in alternating foreground and
	      background colors, with color changes at each intersection with
	      a parallel or meridian.  This keyword determines the thickness of
	      the box's border, in millimeters.  If LABEL is not explicitly
	      specified, it defaults to 1 when this keyword is present.  If this
	      feature is selected, be sure to leave enough room around the map
	      window for the annotation, usually by specifying the XMARGIN and
	      YMARGIN keywords to MAP_SET.  See the example below.
   CHARSIZE: The size of the characters used for the labels. The default is 1.
      COLOR: The color index for the grid lines.
FILL_HORIZON: Fills the current map_horizon.
    HORIZON: Draws the current map horizon.
  INCREMENT: Determines the spacing between graticle points.
 GLINESTYLE: If set, the line style used to draw the grid of parallels and
             meridians. See the IDL User's Guide for options. The default is
             dotted.
 GLINETHICK: The thickness of the grid lines. Default is 1.
      LABEL: Set this keyword to label the parallels and meridians with their
             corresponding latitudes and longitudes. Setting this keyword to
             an integer will cause every LABEL gridline to be labeled (i.e,
             if LABEL=3 then every third gridline will be labeled). The
             starting point for determining which gridlines are labeled is the
             minimum latitude or longitude (-180 to 180), unless the LATS or
             LONS keyword is set to a single value. In this case, the starting
             point is the value of LATS or LONS.
   LATALIGN: This keyword controls the alignment of the text baseline for
             latitude labels. A value of 0.0 left justifies the label,
             1.0 right justifies it, and 0.5 centers it.
     LATDEL: The spacing in degrees between parallels of latitude in the grid.
             If not set, a suitable value is determined from the current map
             projection.
       LATS: The desired latitudes to be drawn (and optionally labeled). If
             this keyword is omitted, appropriate latitudes will be generated
             with consideration of the optional LATDEL keyword. If this
             keyword is set to a single value, drawn (and optionally labeled)
             latitudes will be automatically generated  as
             [...,LATS-LATDEL,LATS,LATS+LATDEL,...] over the extent of the
             map.  The single valued LATS is taken to be the starting point
             for labelling (See the LABEL keyword).
     LATLAB: The longitude at which to place latitude labels. The default is
             the center longitude on the map.
   LATNAMES: An array specifing the names to be used for the latitude labels.
             By default, this array is automatically generated in units of
             degrees. This array can be a string array or numeric, but should
             not be of mixed type. When LATNAMES is specified, LATS must also
             be specified, but the number of elments in the two arrays need not
             be equal. Extra LATNAMES are ignored, while LATNAMES not supplied
             are automatically reported in degrees. LATNAMES can be used when
             LATS is set to a single value. It this case, the LATS used will
             start at the specified latitude and progress northward, wrapping
             around the globe if appropriate. Caution should be used when
             using LATNAMES in conjunction with a single LATS, since the
             number of visible latitude gridlines is dependent on many factors.
   LONALIGN: This keyword controls the alignment of the text baseline for
             longitude labels. A value of 0.0 left justifies the label,
             1.0 right justifies it, and 0.5 centers it.
     LONDEL: The spacing in degrees between meridians of longitude in the grid.
             If not set, a suitable value is determined from the current map
             projection.
     LONLAB: The latitude at which to place longitude labels. The default is
             the center latitude on the map.
       LONS: The desired longitudes to be drawn (and optionally labeled). If
             this keyword is omitted, appropriate longitudes will be generated
             with consideration of the optional LONDEL keyword. If this
             keyword is set to a single value, drawn (and optionally labeled)
             longitudes will be automatically generated as
             [...,LONS-LONDEL,LONS,LONS+LONDEL,...] over the extent of the map.
             The single valued LONS is taken to be the starting point for
             labeling (See the LABEL keyword).
   LONNAMES: An array specifing the names to be used for the longitude labels.
             By default, this array is automatically generated in units of
             degrees. This array can be a string array or numeric, but should
             not be of mixed type. When LONNAMES is specified, LATS must also
             be specified, but the number of elments in the two arrays need not
             be equal. Extra LONNAMES are ignored, while LATNAMES not supplied
             are automatically reported in degrees. LONNAMES can be used when
             LONS is set to a single value. It this case, the LONS used will
             start at the specified longitude and progress eastward, wrapping
             around the globe if appropriate. Caution should be used when
             using LONNAMES in conjunction with a single LONS, since the number
             of visible longitude gridlines is dependent on many factors.

 MAP_STRUCTURE: Set this keyword to a !MAP structure, as returned from
       MAP_PROJ_INIT. If this keyword is set then the gridlines are passed
       through MAP_PROJ_FORWARD and the resulting lines are drawn using
       Cartesian coordinates. If this keyword is not set then it is assumed
       that MAP_SET has been called to set up a map projection.

 NO_GRID: Set this keyword if you only want labels but not gridlines.

ORIENTATION: Specifies the clockwise angle in degrees from horizontal
             of the text baseline that the labels should be rotated. Note,
             that the rotation used in MAP_SET is also clockwise, but XYOUTS
             is normally counterclockwise.

 T3D: Set this keyword to indicate that the generalized transformation
      matrix in !P.T is to be used. If not present, the user-supplied
      coordinates are simply scaled to screen coordinates.

 ZVALUE: Sets the Z coordinate, in normalized coordinates in the
         range of 0 to 1, at which to output the continents.

      Note - This keyword has effect only if keyword T3D is set and the
         transformation is stored in !P.T

OUTPUTS:
         Draws gridlines and labels on the current map.

 CALLS: ***
	MAP_GRID_INCR, MAP_GRID_SOLVE, MAP_HORIZON, MAP_POINT_VALID, MAP_PROJ_INFO
	MAP_STRUCT_APPEND, REVERSE
 CALLED BY:
	_idlitmapprojection__define [1], _idlitmapprojection__define [2], map_set
 EXAMPLE:
	  map_set,10,20,23.5,/cont,/ortho,/horizon     ; establish a projection
         lats=[-65,-52,-35,-20,-2.59,15,27.6,35,45,55,75,89]
                     ; choose the parallels to draw
         map_grid,lats=lats,londel=20,lons=-13,label=2,lonlab=-2.5,latlab=7
                     ;draw the grid
   Make a map with a grid surrounded by a box style axis:
	map_set, /STEREO, 40, -90,scale=50e6,/CONTINENTS, XMARGIN=3, YMARGIN=3
	map_grid, /BOX_AXES, COLOR=3, CHARSIZE=1.5  ;

 MODIFICATION HISTORY:
 	Written by:	SVP, May, 23 1996.
	DMS, Feb, 1996 Note that this version plots all gridlines
			unless a 4 element LIMIT was specified to MAP_SET.
       SVP, Nov 1996   Changed over !map1 (new IDL5 maps)
	SVP, May 1996	Map_Grid used to live inside of map_set.pro, now
                       it lives here.
       SVP, May 1996   Changed LABEL to determine the skip between labelled
                       gridlines.
                       Also, added the LATS and LONS keywords to give complete
                       control over where the labels go.
       SVP, Sept 1996  Added LATNAMS,LONAMES, and ORIENTATION keywords
	DMS, Nov, 1996	Rev 2 of maps.
	DMS, Jul, 1997  Added Box Axes
   CT, Jan 2004: Added MAP_STRUCTURE keyword.


map_patch $RSI/map_patch.pro
[Previous] [Next]
NAME:
     map_patch
PURPOSE:
   This function linearly interpolates a data sampled in
   latitude/longitude into device space.  Data values may be
   either rectangularly or irregularly gridded over the globe.
Category:
        Mapping
Calling Sequence:
        result = map_patch(Image_Orig [, Lons] [, Lats])
INPUT:
      Image_Orig- A array containing the data to be overlayed on map.
       It may be either 1D or 2D.  If 2D, it has Nx columns,
       and Ny rows.  The cell connectivity must be
       rectangular, unless the TRIANGULATE keyword is specified.
       If Image_Orig is 1D, then Lats and Lons must contain
       the same number of points.
   Lons-   A vector or 2D array containing the longitude of each
       data point or column.  If Lons is 1D, lon(image_orig(i,j)) =
       Lons(i); if Lons is 2D, lon(image_orig(i,j)) = Lons(i,j).
       This optional parameter may be omitted if the
       longitudes are equally spaced and are
       specified with the LON0 and LON1 keywords.
   Lats-   A vector or 2D array containing the latitude of each
       data point or row  If Lats is 1D, lat(image_orig(i,j))
       = Lats(j); if Lats is 2D, lat(image_orig(i,j)) =
       Lat(i,j). This optional parameter may be omitted
       if the latitudes are equally spaced and are specified
       with the LAT0 and LAT1 keywords.
KEYWORDS:
   LAT0-   The latitude of the first row of data.  Default=-90.
   LAT1-   The latitude of the last row of data.  Default=+90.
   LATMIN, LATMAX - For compatibility with MAP_IMAGE, the
                        latitude range of equally spaced cells may be
                        specified using these keywords, rather than
                        with LAT0 and LAT1.
   LON0-   The longitude of the first column of data.  Default=-180.
   LON1-   The longitude of the last column of data.  Default=180-360/Ny.
   LONMIN, LONMAX - For compatibility with MAP_IMAGE, the
                        longitude range of equally spaced cells may be
                        specified using these keywords, rather than
                        with LON0 and LON1.
   MISSING = value to set areas outside the valid map coordinates.
       If omitted, areas outside the map are set to 255 (white) if
       the current graphics device is PostScript, or 0 otherwise.
   MAX_VALUE = values in Image_Orig greater than MAX_VALUE
       are considered missing.  Pixels in the output image
       that depend upon missing pixels will be set to MISSING.
   TRIANGULATE = if set, the points are Delauny triangulated on
       the sphere using the TRIANGULATE procedure to determine
       connectivity.   Otherwise, rectangular connectivity is assumed.
 Optional Output Keywords:
   xstart --- the  x coordinate where the left edge of the image
       should be placed on the screen.
   ystart --- the y coordinate where th bottom edge of the image
       should be placed on the screen.
   xsize ---  returns the width of the resulting image expressed in
       graphic coordinate units.  If current graphics device has
       scalable pixels,  the value of XSIZE and YSIZE should
       be passed to the TV procedure.
   ysize ---  returns the pixel height of the resulting image, if the
       current graphics device has scalable pixels.

 CALLS: ***
	MAP_REDUCE_360
 Restrictions:
   This could be quicker.
 Output:
      The interpolated function/warped image is returned.

 Procedure:
   An object space algorithm is used, so the time required
   is roughly proportional to the size, in elements, of Image_Orig.
   Computations are performed in floating point.
   For rectangular grids, each rectangular cell of the original
   image is divided by a diagonal, into two triangles.  If
   TRIANGULATE is set, indicating irregular gridding, the cells are
   triangulated.  The trianges are then converted from lat/lon to
   image coordinates and then interpolated into
   the image array using TRIGRID.

MODIFICATION HISTORY:
   DMS of RSI, July, 1994.     Written.
   DMS, Nov, 1996. Rewritten and adapted for new maps, rev 2.


map_proj_image $RSI/map_proj_image.pro
[Previous] [Next]
 NAME:
     map_proj_image

 PURPOSE:
   This function returns the Image_Orig image warped to fit
   the current map. Image_Orig must be centered at 0.  This
   routine works in image space.

 SYNTAX:
   Result = MAP_PROJ_IMAGE(Image_Orig [, Range] )

 INPUT:
   Image_Orig: A two-dimensional array representing geographical
       image data.

   Range: An optional 4-element vector giving the image extents as:
       [Lonmin, Latmin, Lonmax, Latmax].

 KEYWORDS:
   BILINEAR: Set this keyword to use bilinear interpolation. The
     default is nearest neighbor.

   DIMENSIONS: Set this keyword to a two-element vector giving
       the width and height of the desired Result.
       The UVRANGE keyword may be used to retrieve
       the resulting range of the UV coordinates.
       If DIMENSIONS is not specified then the Result has the
       same dimensions as the input image.

   IMAGE_STRUCTURE: Set this keyword to a !MAP structure as returned
       from MAP_PROJ_INIT, giving the map projection of the
       original image. If this keyword is present, the original image
       is assumed to be in meters. In this case, the image is first
       warped from the IMAGE_STRUCTURE projection to degrees lat/lon,
       and then wraped to the final MAP_STRUCTURE.
       If this keyword is omitted, the original image is assumed to be
       in degrees longitude/latitude (geographic coordinates).

   MAP_STRUCTURE: Set this keyword to a !MAP structure as returned
       from MAP_PROJ_INIT, giving the map projection to which to
       warp the image. If this keyword is omitted,
       the !MAP system variable is used.

   MASK: Set this keyword to a named variable in which to return
       a byte array of the same dimensions as the Result, containing
       a mask of the good values. Values in the Result that were
       set to MISSING will have a mask value of zero, while all
       other mask values will be one.

   MISSING: Set this keyword to the value to set areas outside
       the valid map coordinates. If omitted, areas outside the map
       are set to 0.

   MAX_VALUE = values in Image_Orig greater than or equal to MAX_VALUE
     are considered missing.  Pixels in the output image
     that depend upon missing pixels will be set to MISSING.

   MIN_VALUE = values in Image_Orig less than or equal to MIN_VALUE
     are considered missing.

   UVRANGE: Set this keyword to a named variable in which to return
       the range of the UV coordinates as: [umin, vmin, umax, vmax].

   XINDEX: The XINDEX and YINDEX keywords are used when warping multiple
       images (or image channels) that have the same dimensions and map
       projection. For the first call to MAP_PROJ_IMAGE, XINDEX and YINDEX
       should be set to named variables which are either undefined or
       contain scalar values. Upon return, XINDEX and YINDEX will contain
       the indices that were used for warping the image. For subsequent
       images, the XINDEX and YINDEX variables should be passed in
       unmodified. In this case the map projection is bypassed and the
       indices are used to warp the image.

   YINDEX: The XINDEX and YINDEX keywords are used when warping multiple
       images. See the XINDEX keyword above for details.

   Note: If the XINDEX and YINDEX keywords are present and contain
       arrays of indices, then the Range argument and the IMAGE_STRUCTURE,
       MAP_STRUCTURE, and UVRANGE keywords are ignored. If you specified
       the BILINEAR, DIMENSIONS, MAX_VALUE, MIN_VALUE, or MISSING keywords
       on the first call to MAP_PROJ_IMAGE, then you should also supply
       the same keywords with the same values on subsequent calls.

 OUTPUT:
      The warped image is returned.

 CALLS: ***
	MAP_PROJ_IMAGE_MISSING, MAP_PROJ_IMAGE_UVSIZE
 CALLED BY:
	idlitvisimage__define [10], idlitvisimage__define [11]
	idlitvisimage__define [12], idlitvisimage__define [13]
	idlitvisimage__define [14], idlitvisimage__define [1]
	idlitvisimage__define [2], idlitvisimage__define [3]
	idlitvisimage__define [4], idlitvisimage__define [5]
	idlitvisimage__define [6], idlitvisimage__define [7]
	idlitvisimage__define [8], idlitvisimage__define [9]
 PROCEDURE:  An image space algorithm is used, so the time required
   is roughly proportional to the size of the final image.
   For each pixel in the Result, the inverse coordinate transform is
   applied to obtain lat/lon.  The lat/lon coordinates are then scaled
   into image pixel coordinates, and these coordinates are then
   interpolated from Image values.

 MODIFICATION HISTORY:
   Written: CT, RSI, April 2004.
   Modified: CT, RSI, Dec 2004: Added docs for XINDEX, YINDEX.


MAP_PROJ_INIT $RSI/map_proj_init.pro
[Previous] [Next]
 NAME:
   MAP_PROJ_INIT

 PURPOSE:
   Set up IDL or GCTP map projections.

 CALLING SEQUENCE:
   Result = MAP_PROJ_INIT(Projection)

 INPUTS:
   Projection: Either an integer giving the projection number,
       or a string giving the projection name. If Projection is a string,
       then the GCTP keyword may be used to select the GCTP projection
       rather than the IDL projection.

 OUTPUTS:
   Result: This is a !MAP structure with the projection parameters.
       This Result may then be passed into other map projection routines
       such as MAP_PROJ_FORWARD and MAP_PROJ_INVERSE.
       Note: The !MAP system variable is not affected by MAP_PROJ_INIT.

 KEYWORDS:
   DATUM: Set this keyword to either an integer code or a string name
       for the datum to use for the ellipsoid. The default depends upon
       the projection, but is either the Clarke 1866 ellipsoid, or a
       sphere of radius 6370.997 km.

   GCTP: Set this keyword to indicate that the GCTP projection
       should be used rather than the IDL projection.
       If the Projection name only exists in one system (GCTP or IDL)
       but not the other (such as "Satellite") then this keyword is ignored.

   LIMIT: Set this keyword to a four-element vector of the form
       [Latmin, Lonmin, Latmax, Lonmax] that specifies the boundaries
       of the region to be mapped. (Lonmin, Latmin) and (Lonmax, Latmax)
       are the longitudes and latitudes of two points diagonal from each
       other on the region's boundary.

       Note - If the longitude range is less than or equal to 180 degrees,
       then the map clipping is done in lat/lon before the transform.
       If the longitude range is greater than 180 degrees then
       the map clipping is done in X/Y cartesian space after transforming.
       For non-cylindrical projections, clipping in X/Y space may include
       lat/lon points that are outside of the original LIMIT.

   RADIANS: Set this keyword to indicate that all projection parameters
       which are angles are being specified in radians. The default is
       to assume that all angles are in degrees.

   RELAXED: If this keyword is set, then any projection parameters which
       do not apply to the given Projection will be quietly ignored.
       The default behavior is to issue errors for illegal parameters.

 REFERENCE:
   Snyder, John P. (1987), Map Projections - A Working Manual,
       U.S. Geological Survey Professional Paper 1395,
       U.S.Government Printing Office, Washington, D.C.

 CALLS: ***
	CROSSP, MAP_PROJ_CHECKPARAMS, MAP_PROJ_CHECKPROJECTION, MAP_PROJ_GETDATUM
	MAP_PROJ_INIT_COMMON, MAP_PROJ_MAP_STRUCTURE, MAP_PROJ_ROTATE
	MAP_PROJ_SET_CLIP, MAP_PROJ_SET_LIMIT, MAP_PROJ_SET_SPLIT
	MAP_PROJ_TODEGMINSEC
 CALLED BY:
	_idlitmapprojection__define [1], _idlitmapprojection__define [2]
 MODIFICATION HISTORY:
   Written by:  CT, RSI, Feb 2002
       Heavily based upon Dave Stern code.
       Exposed GCTP projections, previously available only in ENVI.
       Extracted projection code from MAP_SET, without graphics portion.

   Modified:


map_set $RSI/map_set.pro
[Previous] [Next]
         Limit         =  A four or eight element vector.
             If a four element vector, [Latmin, Lonmin, Latmax,
                          Lonmax] specifying the boundaries of the region
                          to be mapped. (Latmin, Lonmin) and (Latmax,
                          Lonmax) are the latitudes and longitudes of
                          two diagonal points on the boundary with
                          Latmin < Latmax and Lonmin < Lonmax.
              For maps that cross the international dateline,
              specify west longitudes as angles between
              180 and 360.
             If an eight element vector: [ lat0, lon0,
               lat1, lon1, lat2, lon2, lat3, lon3] specify
               four points on the map which give, respectively,
               the location of a point on the left edge,
               top edge, right edge, and bottom edge of
               the map extent.
 CALLS: ***
	CROSSP, GREAT_CIRCLE, MAP_CONTINENTS, MAP_GRID, MAP_HORIZON, MAP_POINT_VALID
	MAP_PROJ_INFO, MAP_ROTXYZ, MAP_SET_CLIP, MAP_SET_LIMITS, MAP_SET_LL_BOX
	MAP_SET_SPLIT, MAP_STRUCT_APPEND, MAP_STRUCT_MERGE


MATRIX_POWER $RSI/matrix_power.pro
[Previous] [Next]
 NAME:
   MATRIX_POWER

 PURPOSE:
   This function computes the product of a matrix with itself.
   For example, the fifth power of array A is A # A # A # A # A.
   Negative powers are computed using the matrix inverse
   of the positive power. A power of zero returns the identity matrix.


 CALLING SEQUENCE:
   Result = MATRIX_POWER(Array, N)


 RETURN VALUE:
   The result is the matrix power.


 INPUTS:
   Array: A two-dimensional square array.
          Array may be of any numeric type.

   N: An integer giving the power.


 KEYWORD PARAMETERS:

   DOUBLE = Set this keyword to 1 return a double-precision result,
       or to 0 to return a single-precision result.
       The default return type depends upon the precision of Array.
       Computations are always performed using double precision.

   STATUS = Set this keyword to a named variable in which to return
       the status of the matrix inverse for negative powers.
       Possible values are:
         0 = Successful completion.
         1 = Singular array (which indicates that the inversion is invalid).
         2 = Warning that a small pivot element was used and that
             significant accuracy was probably lost.
       For nonnegative powers STATUS is always set to 0.


 CALLS: ***
	IDENTITY
 EXAMPLE:

    Print an array to the one millionth power:
           Array = [ [0.401d, 0.600d], $
                     [0.525d, 0.475d] ]
           print, MATRIX_POWER(Array, 1e6)

    IDL prints:
           2.4487434e+202  2.7960773e+202
           2.4465677e+202  2.7935929e+202

 MODIFICATION HISTORY:
   Written by:  CT, RSI, July 2002
   Modified:


MD_TEST $RSI/md_test.pro
[Previous] [Next]
 NAME:
       MD_TEST

 PURPOSE:
       This function tests the hypothesis that a sample population
       is random against the hypothesis that it is not random. The 
       result is a two-element vector containing the nearly-normal
       test statistic Z and the one-tailed probability of obtaining
       a value of Z or greater. This test is often refered to as the
       Median Delta Test.

 CATEGORY:
       Statistics.

 CALLING SEQUENCE:
       Result = MD_test(X)

 INPUTS:
       X:    An n-element vector of type integer, float or double.

 KEYWORD PARAMETERS:
   ABOVE:    Use this keyword to specify a named variable which returns
             the number of sample population values greater than the
             median of X.

   BELOW:    Use this keyword to specify a named variable which returns
             the number of sample population values less than the
             median of X.

     MDC:    Use this keyword to specify a named variable which returns
             the number of Median Delta Clusters; sequencial values of
             X above and below the median.

 CALLS: ***
	GAUSS_PDF
 EXAMPLE:
       Define a sample population.
         x = [2.00,  0.90, -1.44, -0.88, -0.24,  0.83, -0.84, -0.74,  0.99, $
             -0.82, -0.59, -1.88, -1.96,  0.77, -1.89, -0.56, -0.62, -0.36, $
             -1.01, -1.36]

       Test the hypothesis that X represents a random population against the
       hypothesis that it does not represent a random population at the 0.05
       significance level.
         result = md_test(x, mdc = mdc)

       The result should be the 2-element vector:
         [0.459468, 0.322949]

       The computed probability (0.322949) is greater than the 0.05
       significance level and therefore we do not reject the hypothesis 
       that X represents a random population. 

 PROCEDURE:
       MD_TEST computes the nonparametric Median Delta Test. Each sample
       in the population is tagged with either a 1 or a 0 depending on
       whether it is above or below the population median. Samples that
       are equal to the median are removed and the population size is 
       corresponding reduced. This test is an extension of the Runs Test 
       for Randomness. 

 REFERENCE:
       APPLIED NONPARAMETRIC STATISTICAL METHODS
       Peter Sprent
       ISBN 0-412-30610-7

 MODIFICATION HISTORY:
       Written by:  GGS, RSI, November 1994
       Modified:    GGS, RSI, November 1996
                    Fixed an error in the computation of the median with
                    even-length input data. See EVEN keyword to MEDIAN.


MEAN $RSI/mean.pro
[Previous] [Next]
 NAME:
       MEAN

 PURPOSE:
       This function computes the mean of an N-element vector. 

 CATEGORY:
       Statistics.

 CALLING SEQUENCE:
       Result = MEAN(X)

 INPUTS:
       X:      An N-element vector of type integer, float or double.

 KEYWORD PARAMETERS:
       DOUBLE: IF set to a non-zero value, computations are done in
               double precision arithmetic.
       NAN:    If set, treat NaN data as missing.

 CALLS: ***
	MOMENT
 CALLED BY:
	REGION_GROW, WV_DENOISE
 EXAMPLE:
       Define the N-element vector of sample data.
         x = [65, 63, 67, 64, 68, 62, 70, 66, 68, 67, 69, 71, 66, 65, 70]
       Compute the standard deviation.
         result = MEAN(x)
       The result should be:
       66.7333

 PROCEDURE:
       MEAN calls the IDL function MOMENT.

 REFERENCE:
       APPLIED STATISTICS (third edition)
       J. Neter, W. Wasserman, G.A. Whitmore
       ISBN 0-205-10328-6

 MODIFICATION HISTORY:
       Written by:  GSL, RSI, August 1997


MeanAbsDev $RSI/meanabsdev.pro
[Previous] [Next]
 NAME:
       MeanAbsDev

 PURPOSE:
       MeanAbsDev computes the mean absolute deviation (average
       deviation) of a vector or array.

 CATEGORY:
       Statistics.

 CALLING SEQUENCE:
       Result = MeanAbsDev(X)

 INPUTS:
       X:      A vector or array of type integer, float or double.

 KEYWORD PARAMETERS:

       DOUBLE: If set to a non-zero value, MEANABSDEV performs its
               computations in double precision arithmetic and returns
               a double precision result. If not set to a non-zero value,
               the computations and result depend upon the type of the
               input data (integer and float data return float results,
               while double data returns double results). This has no
               effect if the Median keyword is set.

       MEDIAN: If set to a non-zero value, meanabsdev will return
               the average deviation from the median, rather than
               the mean.  If Median is not set, meanabsdev will return
               the average deviation from the mean.

       NAN:    If set, treat NaN data as missing.

 EXAMPLES:
       Define the N-element vector of sample data.
         x = [1, 1, 1, 2, 5]
       Compute the average deviation from the mean.
         result = MeanAbsDev( x )
       The result should be:
       1.20000

       Compute the average deviation from the median.
         result = MeanAbsDev( x, /median )
       The result should be:
       1.00000

 PROCEDURE:
       MeanAbsDev calls the IDL function MEAN.

       MeanAbsDev calls the IDL function MEDIAN if the Median
       keyword is set to a nonzero value.

 REFERENCE:
       APPLIED STATISTICS (third edition)
       J. Neter, W. Wasserman, G.A. Whitmore
       ISBN 0-205-10328-6

 MODIFICATION HISTORY:
       Written by:  GSL, RSI, August 1997
		     RJF, RSI, Sep 1998, Removed NaN keyword from Median call
				         as NaN is not currently supported by
					 the Median routine.
   CT, RSI, July 2004: Better handling for NAN keyword, to avoid
       overflow errors in the ABS call. Also faster & uses less memory.


MESH_OBJ $RSI/mesh_obj.pro
[Previous] [Next]
 NAME:
       MESH_OBJ

 PURPOSE:
       MESH_OBJ generates a polygon mesh (vertex list and polygon list) that
       represent the desired primitive object. The available primitive
       objects are: triangulated surface, rectangular surface, polar surface,
       cylindrical surface, spherical surface, surface of extrusion, surface
       of revolution, and ruled surface.

 CATEGORY:
       Graphics.

 CALLING SEQUENCE:
       MESH_OBJ, Type, Vertex_List, Polygon_List, Array1, Array2

 INPUTS:

       Type:   An integer which specifies what type of object to create.

                  TYPE CODE:      SURFACE TYPE:
                  ----------      -------------

                  0               TRIANGULATED
                  1               RECTANGULAR
                  2               POLAR
                  3               CYLINDRICAL
                  4               SPHERICAL
                  5               EXTRUSION
                  6               REVOLUTION
                  7               RULED

                  ELSE            none

       Vertex_List:
               On input, Vertex_List may be undefined. On output, it contains
               the mesh vertices. Vertex_List and Polygon_List have the same
               format as the lists returned by the SHADE_VOLUME procedure.

       Polygon_List:
               On input, Polygon_List may be undefined. On output, it contains
               the mesh indexes.

       Array1:
               An array whose use depends on the type of object being created.

                  SURFACE TYPE:   Array1 type
                  -------------   --------------------------------------------

                  TRIANGULATED    A (3, n) array containing random [x, y, z]
                                  points to build a triangulated surface from.
                                  The resulting polygon mesh will have n
                                  vertices. When shading a triangulated mesh,
                                  the shading array should have (n) elements.

                  RECTANGULAR     A two dimensional (n, m) array containing
                                  z values. The resulting polygon mesh will
                                  have n*m vertices.
                                  When shading a rectangular mesh, the shading
                                  array should have (n, m) elements.

                  POLAR           A two dimensional (n, m) array containing
                                  z values. The resulting polygon mesh will
                                  have n*m vertices. The n dimension of the
                                  array is mapped to the polar angle, and the
                                  m dimension is mapped to the polar radius.
                                  When shading a polar mesh, the shading array
                                  should have (n, m) elements.

                  CYLINDRICAL     A two dimensional (n, m) array containing
                                  radius values. The resulting polygon mesh
                                  will have n*m vertices. The n dimension of
                                  the array is mapped to the polar angle,
                                  and the m dimension is mapped to the Z axis.
                                  When shading a cylindrical mesh, the shading
                                  array should have (n, m) elements.

                  SPHERICAL       A two dimensional (n, m) array containing
                                  radius values. The resulting polygon mesh
                                  will have n*m vertices. The n dimension of
                                  the array is mapped to the longitude (0.0 to
                                  360.0 degrees), and the m dimension is
                                  mapped to the latitude (-90.0 to +90.0
                                  degrees).
                                  When shading a spherical mesh, the shading
                                  array should have (n, m) elements.

                  EXTRUSION       A (3, n) array of connected 3-D points which
                                  define the shape to extrude. The resulting
                                  polygon mesh will have n*(steps+1) vertices
                                  (where steps is the number of "segments" in
                                  the extrusion). (See the P1 keyword).
                                  If the order of the elements in Array1 is
                                  reversed, then the polygon facing is
                                  reversed.
                                  When shading an extrusion mesh, the shading
                                  array should have (n, steps+1) elements.

                  REVOLUTION      A (3, n) array of connected 3-D points which
                                  define the shape to revolve. The resulting
                                  polygon mesh will have n*((steps>3)+1)
                                  vertices (where steps is the number of
                                  "steps" in the revolution). (See the P1
                                  keyword). If the order of the elements in
                                  Array1 is reversed, then the polygon facing
                                  is reversed.
                                  When shading a revolution mesh, the shading
                                  array should have (n, (steps>3)+1) elements.

                  RULED           A (3, n) array of connected 3-D points which
                                  define the shape of the first ruled vector.
                                  The optional (3, m) Array2 parameter defines
                                  the shape of the second ruled vector. The
                                  resulting polygon mesh will have
                                  (n>m)*(steps+1) vertices (where steps is the
                                  number of intermediate "steps"). (See the P1
                                  keyword).
                                  When shading a ruled mesh, the shading
                                  array should have (n>m, steps+1) elements.

 OPTIONAL INPUTS:

       Array2:
               If the object type is 7 (Ruled Surface) then Array2 is a (3, m)
               array containing the 3-D points which define the second ruled
               vector. If Array2 has fewer elements than Array1 then Array2 is
               processed with CONGRID to give it the same number of elements
               as Array1. If Array1 has fewer elements than Array2 then Array1
               is processed with CONGRID to give it the same number of
               elements as Array2.
               Array2 MUST be supplied if the object type is 7. Otherwise,
               Array2 is ignored.

 KEYWORD PARAMETERS:

       P1 - P5:
               The meaning of the keywords P1 through P5 vary depending upon
               the object type.

                  SURFACE TYPE:   Keywords
                  -------------   --------------------------------------------

                  TRIANGULATED    P1, P2, P3, P4, and P5 are ignored.

                  RECTANGULAR     If Array1 is an (n, m) array, and if P1 has
                                  n elements, then the values contained in
                                  P1 are the X coordinates for each column of
                                  vertices. Otherwise, FINDGEN(n) is used for
                                  the X coordinates. If P2 has m elements,
                                  then the values contained in P2 are the Y
                                  coordinates for each row of vertices.
                                  Otherwise, FINDGEN(m) is used for the Y
                                  coordinates. The polygon facing is reversed
                                  if the order of either P1 or P2 (but not
                                  both) is reversed.
                                  P3, P4, and P5 are ignored.

                  POLAR           P1 specifies the polar angle of the first
                                  column of Array1 (the default is 0). P2
                                  specifies the polar angle of the last column
                                  of Array1 (the default is 2*PI). If P2 is
                                  less than P1 then the polygon facing is
                                  reversed. P3 specifies the radius of the
                                  first row of Array1 (the default is 0). P4
                                  specifies the radius of the last row of
                                  Array1 (the default is m-1). If P4 is less
                                  than P3 then the polygon facing is reversed.
                                  P5 is ignored.

                  CYLINDRICAL     P1 specifies the polar angle of the first
                                  column of Array1 (the default is 0). P2
                                  specifies the polar angle of the last column
                                  of Array1 (the default is 2*PI). If P2 is
                                  less than P1 then the polygon facing is
                                  reversed. P3 specifies the Z coordinate of
                                  the first row of Array1 (the default is 0).
                                  P4 specifies the Z coordinate of the last
                                  row of Array1 (the default is m-1). If P4 is
                                  less than P3 then the polygon facing is
                                  reversed. P5 is ignored.

                  SPHERICAL       P1 specifies the longitude of the first
                                  column of Array1 (the default is 0). P2
                                  specifies the longitude of the last column
                                  of Array1 (the default is 2*PI). IF P2 is
                                  less than P1 then the polygon facing is
                                  reversed. P3 specifies the latitude of the
                                  first row of Array1 (the default is -PI/2).
                                  P4 specifies the latitude of the last row of
                                  Array1 (the default is +PI/2). If P4 is less
                                  than P3 then the polygon facing is reversed.
                                  P5 is ignored.

                  EXTRUSION       P1 specifies the number of steps in the
                                  extrusion (the default is 1). P2 is a three
                                  element vector specifying the direction
                                  (and length) of the extrusion (the default
                                  is [0, 0, 1]). P3, P4, and P5 are ignored.

                  REVOLUTION      P1 specifies the number of "facets" in the
                                  revolution (the default is 3). If P1 is less
                                  than 3 then 3 is used. P2 is a three element
                                  vector specifying a point that the rotation
                                  vector passes through (the default is
                                  [0, 0, 0]). P3 is a three element vector
                                  specifying the direction of the rotation
                                  vector (the default is [0, 0, 1]). P4
                                  specifies the starting angle for the
                                  revolution (the default is 0). P5 specifies
                                  the ending angle for the revolution (the
                                  default is 2*PI). If P5 is less than P4 then
                                  the polygon facing is reversed.

                  RULED           P1 specifies the number of "steps" in the
                                  ruling (the default is 1).
                                  P2, P3, P4, and P5 are ignored.

       DEGREES:   If set, then the input parameters are in degrees
                  (where applicable). Otherwise, the angles are in
                  radians.

       CLOSED:    If set, then the polygonal mesh is "closed" topologically
                  by using the first vertex in a row for both the first and
                  last polygons in that row.  This keyword parameter is only
                  applicable to the CYLINDRICAL, SPHERICAL, REVOLUTION, and
                  EXTRUSION surface types.  This keyword parameter removes the
                  discontinuity where the mesh wraps back around on itself,
                  which can improve the mesh's appearance when viewing it as
                  a shaded object.  For the EXTRUSION surface type, this
                  procedure handles input polygons that form a closed loop
                  with the last vertex being a copy of the first vertex,
                  as well as those that do not.

 CALLS: ***
	CONGRID, CV_COORD, T3D, VERT_T3D
 CALLED BY:
	idlitmanipvissphere__define [1], idlitmanipvissphere__define [2]
	idlitmanipvissphere__define [3], idlitmanipvissphere__define [4]
	idlitmanipvissphere__define [5], idlitmanipvissphere__define [6]
 EXAMPLE:

       ; Create a 48x64 cylinder with a constant radius of 0.25.
       MESH_OBJ, 3, Vertex_List, Polygon_List, Replicate(0.25, 48, 64), $
          P4=0.5

       ; Transform the vertices.
       T3d, /Reset
       T3d, Rotate=[0.0, 30.0, 0.0]
       T3d, Rotate=[0.0, 0.0, 40.0]
       T3d, Translate=[0.25, 0.25, 0.25]
       Vertex_List = Vert_T3d(Vertex_List)

       ; Create the window and view.
       Window, 0, Xsize=512, Ysize=512
       Create_View, Winx=512, Winy=512

       ; Render the mesh.
       Set_Shading, Light=[-0.5, 0.5, 2.0], Reject=0
       Tvscl, Polyshade(Vertex_List, Polygon_List, /Normal)


       ; Create a cone (surface of revolution).
       MESH_OBJ, 6, Vertex_List, Polygon_List, $
          [[0.75, 0.0, 0.25], [0.5, 0.0, 0.75]], P1=16, P2=[0.5, 0.0, 0.0]

       ; Create the window and view.
       Window, 0, Xsize=512, Ysize=512
       Create_View, Winx=512, Winy=512, Ax=30.0, Ay=(140.0), Zoom=0.5

       ; Render the mesh.
       Set_Shading, Light=[-0.5, 0.5, 2.0], Reject=0
       Tvscl, Polyshade(Vertex_List, Polygon_List, /Data, /T3d)

 MODIFICATION HISTORY:
       Written by:     Daniel Carr, Thu Mar 31 19:16:43 MST 1994
       KWS 07/13/01 -  Added CLOSED keyword


MIN_CURVE_SURF $RSI/min_curve_surf.pro
[Previous] [Next]
 NAME:
   MIN_CURVE_SURF

 PURPOSE:
   This function Interpolates a regularly or irregularly-gridded
   set of points, over either a plane or a sphere, with either a
   minimum curvature surface or a thin-plate-spline surface.

 CATEGORY:
   Mathematical functions, Interpolation, Surface Fitting

 CALLING SEQUENCE:
   Result = MIN_CURVE_SURF(Z [, X, Y])

 INPUTS:
   X, Y, Z:  arrays containing the X, Y, and Z coordinates of the
         data points on the surface. Points need not be
         regularly gridded. For regularly gridded input data,
         X and Y are not used: the grid spacing is specified
         via the XGRID and YGRID (or XVALUES and YVALUES)
         keywords, and Z must be a two dimensional array.
         For irregular grids, all three parameters must be
         present and have the same number of elements.  If
         the keyword SPHERE is set, X and Y are given in
         degrees of longitude and latitude, respectively.

 KEYWORD PARAMETERS:
   TPS:    If set, use the thin-plate-spline method, otherwise
       use the minimum curvature surface method.
    DOUBLE:    If set, perform computations in double precision,
           enhancing accuracy. Also, if Z is double precision the
           computations will also be done in double precision.
    SPHERE:    If set, perform interpolation on the surface of a
           sphere.  The inputs X and Y should be given in degrees of
       longitude and latitude, respectively.
     CONST:    If set, data on the sphere is fit with a constant
           baseline, otherwise, data on the sphere is fit with a basline
           that contains a constant term plus linear X, Y, and Z terms.
           Has effect only if SPHERE is specified.  See the Procedure
           section below for the formulae.

  Input grid description:
   REGULAR:  if set, the Z parameter is a two dimensional array
         of dimensions (N,M), containing measurements over a
         regular grid. If any of XGRID, YGRID, XVALUES, YVALUES
         are specified, REGULAR is implied. REGULAR is also
         implied if there is only one parameter, Z. If REGULAR is
         set, and no grid (_VALUE or _GRID) specifications are
         present, the respective grid is set to (0, 1, 2, ...).
   XGRID:    contains a two element array, [xstart, xspacing],
         defining the input grid in the X direction. Do not
         specify both XGRID and XVALUES.
   XVALUES:  if present, XVALUES(i) contains the X location
         of Z(i,j). XVALUES must be dimensioned with N elements.
   YGRID:    contains a two element array, [ystart, yspacing],
         defining the input grid in the Y direction. Do not
         specify both YGRID and YVALUES.
   YVALUES:  if present, YVALUES(i) contains the Y location
         of Z(i,j). YVALUES must be dimensioned with N elements.

  Output grid description:
   GS:   If present, GS must be a two-element vector [XS, YS],
         where XS is the horizontal spacing between grid points
         and YS is the vertical spacing. The default is based on
         the extents of X and Y. If the grid starts at X value
         Xmin and ends at Xmax, then the default horizontal
         spacing is (Xmax - Xmin)/(NX-1). YS is computed in the
         same way. The default grid size, if neither NX or NY
         are specified, is 26 by 26.
   BOUNDS:   If present, BOUNDS must be a four element array containing
         the grid limits in X and Y of the output grid:
         [Xmin, Ymin, Xmax, Ymax]. If not specified, the grid
         limits are set to the extent of X and Y.
   NX:       The output grid size in the X direction. NX need not
         be specified if the size can be inferred from GS and
         BOUNDS. The default value is 26.
   NY:       The output grid size in the Y direction. See NX.
   XOUT:     If present, XOUT must be a vector containing the output
         grid X values. If this parameter is supplied, GS, BOUNDS,
         and NX are ignored for the X output grid. Use this
         parameter to specify irregularly spaced output grids.
   YOUT:     If present, YOUT must be a vector containing the output
         grid Y values. If this parameter is supplied, GS, BOUNDS,
         and NY are ignored for the Y output grid. Use this
         parameter to specify irregularly spaced output grids.
   XPOUT:    If present, the arrays XPOUT and YPOUT contain the X and Y
   YPOUT:    values for the output points. With these keywords, the
         output grid need not be regular, and all other output
         grid parameters are ignored. XPOUT and YPOUT must have
         the same number of points, which is also the number of
         points returned in the result.

 OUTPUTS:
   This function returns a two-dimensional floating point array
   containing the interpolated surface, sampled at the grid points.

 CALLS: ***
	MIN_CURVE_SPHERE_BASIS_FUNCTION
 RESTRICTIONS:
   The accuracy of this function is limited by the single precision
   floating point accuracy of the machine.

       SAMPLE EXECUTION TIMES  (measured on a Sun IPX)
   # of input points   # of output points  Seconds
   16          676         0.19
   32          676         0.42
   64          676         1.27
   128         676         4.84
   256         676         24.6
   64          256         1.12
   64          1024            1.50
   64          4096            1.97
   64          16384           3.32

 PROCEDURE:
   A minimum curvature spline surface is fitted to the data points
   described by X, Y, and Z.  The basis function:
       C(x0,x1, y0,y1) = d^2 log(d^k),
   where d is the distance between (x0,y0), (x1,y1), is used,
   as described by Franke, R., "Smooth interpolation of scattered
   data by local thin plate splines," Computers Math With Applic.,
   v.8, no. 4, p. 273-281, 1982.  k = 1 for minimum curvature surface,
   and 2 for Thin Plate Splines.  For N data points, a system of N+3
   simultaneous equations are solved for the coefficients of the
   surface.  For any interpolation point, the interpolated value
   is:
     F(x,y) = b(0) + b(1)*x + b(2)*y + Sum(a(i)*C(X(i),x,Y(i),y))

   For a sphere the value is:
     F(l,t) = b(0) + b(1)*x + b(2)*y +b(3)*z + Sum(a(i)*C(L(i),l,T(i),t))
   On the sphere, l and t are longitude and latitude. C(L(i),l,
   T(i),t) is the basis function above, with distance between the
   two points, (L(i),T(i)), and (l,t)  measured in radians of arc length.
   x, y, and z are the 3D cartesian coordinates of the point (l,t) on
   the unit sphere.

   For a sphere with the keyword CONST set the value is:
     F(l,t) = b(0) + Sum(a(i)*C(L(i),l,T(i),t))

   The results obtained the thin plate spline (TPS) or the minimum
   curvature surface (MCS) methods are very similar.  The only
   difference is in the basis functions: TPS uses d^2*alog(d^2),
   and MCS uses d^2*alog(d), where d is the distance from
   point (x(i),y(i)).

 EXAMPLES:
 Example 1: Irregularly gridded cases
   Make a random set of points that lie on a gaussian:
     n = 15                ;# random points
     x = RANDOMU(seed, n)
     y = RANDOMU(seed, n)
     z = exp(-2 * ((x-.5)^2 + (y-.5)^2))    ;The gaussian

   get a 26 by 26 grid over the rectangle bounding x and y:
     r = min_curve_surf(z, x, y)   ;Get the surface.

   Or: get a surface over the unit square, with spacing of 0.05:
     r = min_curve_surf(z, x, y, GS=[0.05, 0.05], BOUNDS=[0,0,1,1])

   Or: get a 10 by 10 surface over the rectangle bounding x and y:
     r = min_curve_surf(z, x, y, NX=10, NY=10)

 Example 2: Regularly gridded cases
   Make some random data
     z = randomu(seed, 5, 6)

   interpolate to a 26 x 26 grid:
     CONTOUR, min_curve_surf(z, /REGULAR)

 MODIFICATION HISTORY:
   DMS, RSI, March, 1993.  Written.
   DMS, RSI, July, 1993.   Added XOUT and YOUT, XPOUT and YPOUT.
   DMS, RSI, May, 1999.    Added DOUBLE keyword.
   DMS, RSI, Feb 2000.     Switch from INVERT to LUDC.
   DMS, RSI, May 2000.     Added SPHERE and CONST keywords.
   CT, RSI, Aug 2001.      Per Scott Bennett's suggestion, vectorize loop
                           when calculating planar distance.


MK_HTML_HELP $RSI/mk_html_help.pro
[Previous] [Next]
 NAME:
	MK_HTML_HELP

 PURPOSE:
	Given a list of IDL procedure files (.PRO) or directories that
	contain such files, this procedure generates a file in the HTML
	format that contains the documentation for those routines that
	contain a DOC_LIBRARY style documentation template.  The output
	file is compatible with World Wide Web browsers.

 CATEGORY:
	Help, documentation.

 CALLING SEQUENCE:
	MK_HTML_HELP, Sources, Outfile

 INPUTS:
     Sources:  A string or string array containing the name(s) of the
		.pro files (or the names of directories containing such files)
		for which help is desired. If a source file is an IDL procedure,
		it must include the .PRO file extension. All other source files
		are assumed to be directories.

     Outfile:	The name of the output file which will be generated.

 KEYWORDS:
     TITLE:	If present, a string which supplies the name that
		should appear as the Document Title for the help.

     VERBOSE:	Normally, MK_HTML_HELP does its work silently.
		Setting this keyword to a non-zero value causes the procedure
		to issue informational messages that indicate what it
		is currently doing. !QUIET must be 0 for these messages
               to appear.

     STRICT: If this keyword is set to a non-zero value, MK_HTML_HELP
     will adhere strictly to the HTML format by scanning the document
     headers for characters that are reserved in HTML (<,>,&,").
     These are then converted to the appropriate HTML syntax in the
     output file. By default, this keyword is set to zero (to allow
     for faster processing).

 CALLS: ***
	FILEPATH, MHH_GEN_FILE, MHH_GRAB_HDR, MHH_STRICT, PATH_SEP
 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	A help file with the name given by the Outfile argument is
	created.

 RESTRICTIONS:
	The following rules must be followed in formatting the .pro
	files that are to be searched.
		(a) The first line of the documentation block contains
		    only the characters ";+", starting in column 1.
     (b) There must be a line which contains the string "NAME:",
         which is immediately followed by a line containing the
         name of the procedure or function being described in
         that documentation block.  If this NAME field is not
         present, the name of the source file will be used.
		(c) The last line of the documentation block contains
		    only the characters ";-", starting in column 1.
		(d) Every other line in the documentation block contains
		    a ";" in column 1.

  Note that a single .pro file can contain multiple procedures and/or
  functions, each with their own documentation blocks. If it is desired
  to have "invisible" routines in a file, i.e. routines which are only
  for internal use and should not appear in the help file, simply leave
  out the ";+" and ";-" lines in the documentation block for those
  routines.

	No reformatting of the documentation is done.

 MODIFICATION HISTORY:
  July 5, 1995, DD, RSI. Original version.
  July 13, 1995, Mark Rivers, University of Chicago. Added support for
          multiple source directories and multiple documentation
          headers per .pro file.
  July 17, 1995, DD, RSI. Added code to alphabetize the subjects;
          At the end of each description block in the HTML file,
          added a reference to the source .pro file.
  July 18, 1995, DD, RSI. Added STRICT keyword to handle angle brackets.
  July 19, 1995, DD, RSI. Updated STRICT to handle & and ".
          Changed calling sequence to accept .pro filenames, .tlb
          text library names, and/or directory names.
          Added code to set default subject to name of file if NAME
          field is not present in the doc header.
  27 August 2003, AB, Remove VMS support. Fix bug with leaking
          file units.
  8 March 2005, DD, RSI. If none of the input .pro files contain
          documentation headers, display an informative error
          message, clean up, and exit. Also report the full path
          to the output file after creation.


MODIFYCT $RSI/modifyct.pro
[Previous] [Next]
 NAME:
	MODIFYCT

 PURPOSE:
	Update the distribution color table file "colors1.tbl" or the
	user-supplied file with a new table.

 CATEGORY:
	Z4 - Image processing, color table manipulation.

 CALLING SEQUENCE:
	MODIFYCT, Itab, Name, R, G, B

 INPUTS:
	Itab:	The table to be updated, numbered from 0 to 255.  If the
		table entry is greater than the next available location
		in the table, then the entry will be added to the table
		in the available location rather than the index specified
		by Itab.  On return, Itab will contain the index for the
		location that was modified or extended.  The table
		can be loaded with the IDL command:  LOADCT, Itab.

	Name:	A string up to 32 characters long that contains the name for
		the new color table.

	R:	A 256-element vector that contains the values for the red
		color gun.

	G:	A 256-element vector that contains the values for the green
		color gun.

	B:	A 256-element vector that contains the values for the blue
		color gun.

 KEYWORD PARAMETERS:
	FILE:	If this keyword is set, the file by the given name is used
		instead of the file colors1.tbl in the IDL directory.  This
		allows multiple IDL users to have their own color table file.
		The file specified must be a copy of the colors1.tbl file.
		The file must exist.

 OUTPUTS:
	Itab:	The index of the entry which was updated, 0 to 255.  This
		may be different from the input value of Itab if the
		input value was greater than the next available location
		in the table.  If this was the case the entry was added to
		the table in the next available location instead of leaving
		a gap in the table.

 CALLS: ***
	FILEPATH
 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	The distribution file "colors.tbl1" or the user-supplied file is
	modified with the new table.

 PROCEDURE:
	Straightforward.

 MODIFICATION HISTORY:
	Aug, 1982, DMS, Written.
	Unix version, 1987, DMS.
	ACY, 9/92, Update for new color table structure, Add FILE keyword.
		   Allow extending table.
	WSO, 1/95, Updated for new directory structure


MOMENT $RSI/moment.pro
[Previous] [Next]
 NAME:
       MOMENT

 PURPOSE:
       This function computes the mean, variance, skewness and kurtosis
       of an N-element vector. IF the vector contains N identical elements, 
       the mean and variance are computed; the skewness and kurtosis are 
       not defined and are returned as IEEE NaN (Not a Number). Optionally, 
       the mean absolute deviation and standard deviation may also be 
       computed. The returned result is a 4-element vector containing the
       mean, variance, skewness and kurtosis of the input vector X.

 CATEGORY:
       Statistics.

 CALLING SEQUENCE:
       Result = Moment(X)

 INPUTS:
       X:      An N-element vector of type integer, float or double.

 KEYWORD PARAMETERS:
       DOUBLE: IF set to a non-zero value, computations are done in
               double precision arithmetic.

       MDEV:   Use this keyword to specify a named variable which returns
               the mean absolute deviation of X.

       SDEV:   Use this keyword to specify a named variable which returns
               the standard deviation of X.

       MAXMOMENT:
               Use this keyword to limit the number of moments:
               Maxmoment = 1  Calculate only the mean.
               Maxmoment = 2  Calculate the mean and variance.
               Maxmoment = 3  Calculate the mean, variance, and skewness.
               Maxmoment = 4  Calculate the mean, variance, skewness,
                              and kurtosis (the default).

       NAN:    Treat NaN elements as missing data.
               (Due to problems with IEEE support on some platforms,
                infinite data will be treated as missing as well. )

 CALLED BY:
	FV_TEST, IDLitwdGridWizard, KURTOSIS, MEAN, SKEWNESS, STDDEV, TM_TEST, VARIANCE, iImage
 EXAMPLE:
       Define the N-element vector of sample data.
         x = [65, 63, 67, 64, 68, 62, 70, 66, 68, 67, 69, 71, 66, 65, 70]
       Compute the mean, variance, skewness and kurtosis.
         result = moment(x)
       The result should be the 4-element vector: 
       [66.7333, 7.06667, -0.0942851, -1.18258]
  

 PROCEDURE:
       MOMENT computes the first four "moments" about the mean of an N-element
       vector of sample data. The computational formulas are given in the IDL 
       Reference Guide. 

 REFERENCE:
       APPLIED STATISTICS (third edition)
       J. Neter, W. Wasserman, G.A. Whitmore
       ISBN 0-205-10328-6

 MODIFICATION HISTORY:
       Written by:  GGS, RSI, August 1994
       Modified:    GGS, RSI, September 1995
                    Added DOUBLE keyword. 
                    Added checking for N identical elements. 
                    Added support for IEEE NaN (Not a Number).
                    Modified variance formula.
       Modified:    GGS, RSI, April 1996
                    Modified keyword checking and use of double precision. 
                    GSL, RSI, August 1997
                    Added Maxmoment keyword.
       Modified:    Wed Jan 28 13:28:07 1998, Scott Lett, RSI Added
                    NAN keyword.


MORPH_CLOSE $RSI/morph_close.pro
[Previous] [Next]
 NAME:
	MORPH_CLOSE

 PURPOSE:
	This function applies the closing operator to a binary or grayscale
	image.

 CATEGORY:
	Image Processing.

 CALLING SEQUENCE:

	Result = MORPH_CLOSE(Image, Structure)

 INPUTS:
	Image:	A one-, two-, or three-dimensional array upon which the
		closing operation is to be performed.  If the GRAY or
		VALUES keyword is set, the image is treated as a grayscale
		image; in this case, if the image is not of type unsigned
		long, a temporary unsigned long copy is obtained.  If neither
		the GRAY nor VALUES keyword is set, the image is treated
		as a binary image with all nonzero pixels considered as 1;
		in this case, if the image is not of type byte, a temporary
		byte copy is obtained.
	Structure: A one-, two-, or three-dimensional array to be used
		as the structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.

 KEYWORD PARAMETERS:
	GRAY:	Set this keyword to perform a grayscale, rather than binary,
		operation.  Nonzero elements of the Structure parameter
		determine the shape of the structuring element.

	VALUES:	Set this keyword to an array providing the values of the
		structuring element.  This array must have the same
		dimensions as the Structure parameter.  The presence of
		this keyword implies a grayscale operation.

 OUTPUTS:
	This function returns an array (of the same dimensions as the
	input Image parameter) that represents the result of the closing
	operation.

 PROCEDURE:
	The closing operator is implemented as a dilation followed by
	an erosion.

 REFERENCE:
	Edward R. Dougherty
	AN INTRODUCTION TO MORPHOLOGICAL IMAGE PROCESSING
       The Society of Photo-Optical Instrumentation Engineers, 1992.

 EXAMPLE:

	Apply the closing operator to a sample image:

               ; Load an image.
               img = BYTARR(256,256)
		filename = FILEPATH('galaxy.dat',SUBDIR=['examples','data'])
		OPENR, lun, filename, /GET_LUN
		READU, lun, img
		CLOSE, lun

               ; Apply closing operator.
               s = [[0,0,1,0,0],$
                    [0,1,1,1,0],$
                    [1,1,1,1,1],$
                    [0,1,1,1,0],$
                    [0,0,1,0,0]]
		oimg = MORPH_CLOSE(img, s, /GRAY)

 MODIFICATION HISTORY:
 	Written by:	David Stern, July 1999.
   Modified: CT, RSI, Oct 2003: Add ON_ERROR


MORPH_GRADIENT $RSI/morph_gradient.pro
[Previous] [Next]
 NAME:
	MORPH_GRADIENT

 PURPOSE:
	This function applies the morphological gradient operator to a
	grayscale image.

 CATEGORY:
	Image Processing.

 CALLING SEQUENCE:

	Result = MORPH_GRADIENT(Image, Structure)

 INPUTS:
	Image:	A one-, two-, or three-dimensional array upon which the
		morphological gradient operation is to be performed.  The
		image is treated as a grayscale	image.  If the image is not
		of type unsigned long, a temporary unsigned long copy is
		obtained.
	Structure: A one-, two-, or three-dimensional array to be used
		as the structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.

 KEYWORD PARAMETERS:
	VALUES:	Set this keyword to an array providing the values of the
		structuring element.  This array must have the same
		dimensions as the Structure parameter.

 OUTPUTS:
	This function returns an array (of the same dimensions as the
	input Image parameter) that represents the result of the morphological
	gradient operation.

 PROCEDURE:
	The morphological gradient operator is implemented as the subtraction
	of an eroded version of the original image from a dilated version of
	the original image.

 REFERENCE:
	Edward R. Dougherty
	AN INTRODUCTION TO MORPHOLOGICAL IMAGE PROCESSING
       The Society of Photo-Optical Instrumentation Engineers, 1992.

 EXAMPLE:

	Apply the morphological gradient operator to a sample image:

               ; Load an image.
               img = BYTARR(256,256)
		filename = FILEPATH('galaxy.dat',SUBDIR=['examples','data'])
		OPENR, lun, filename, /GET_LUN
		READU, lun, img
		CLOSE, lun

               ; Apply closing operator.
               s = [[0,0,1,0,0],$
                    [0,1,1,1,0],$
                    [1,1,1,1,1],$
                    [0,1,1,1,0],$
                    [0,0,1,0,0]]
		oimg = MORPH_GRADIENT(img, s)

 MODIFICATION HISTORY:
 	Written by:	David Stern, July 1999.
   Modified: CT, RSI, Oct 2003: Add ON_ERROR


MORPH_HITORMISS $RSI/morph_hitormiss.pro
[Previous] [Next]
 NAME:
	MORPH_HITORMISS

 PURPOSE:
	This function applies the hit-or-miss operator to a binary image.

 CATEGORY:
	Image Processing.

 CALLING SEQUENCE:

	Result = MORPH_HITORMISS(Image, HitStructure, MissStructure)

 INPUTS:
	Image:	A one-, two-, or three-dimensional array upon which the
		hit-or-miss operation is to be performed.  The image is treated
		as a binary image with all nonzero pixels considered as 1.
		If the image is not of type byte, a temporary byte copy is
		obtained.
	HitStructure: A one-, two-, or three-dimensional array to be used
		as the hit structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.
	MissStructure: A one-, two-, or three-dimensional array to be used
		as the miss structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.

          NOTE: It is assumed that the HitStructure and MissStructure are
                disjoint.

 KEYWORD PARAMETERS:
	<None>

 OUTPUTS:
	This function returns an array (of the same dimensions as the
	input Image parameter) that represents the result of the hit-or-miss
	operation.

 CALLED BY:
	MORPH_THIN
 PROCEDURE:
	The hit-or-miss operator is implemented by first applying an erosion
	operator to the original image (using a 'hit' structuring element),
	then applying an erosion operator to the complement of the original
	image (using a secondary 'miss' structuring element), and computing
	the intersection of the two results.

 REFERENCE:
	Edward R. Dougherty
	AN INTRODUCTION TO MORPHOLOGICAL IMAGE PROCESSING
       The Society of Photo-Optical Instrumentation Engineers, 1992.

 EXAMPLE:

	Apply the hit-or-miss operator to a sample image:

               ; Load an image.
               img = BYTARR(256,256)
		filename = FILEPATH('galaxy.dat',SUBDIR=['examples','data'])
		OPENR, lun, filename, /GET_LUN
		READU, lun, img
		CLOSE, lun

               ; Map to binary.
               bimg = img
               bimg[WHERE(img lt 128)] = 0

               ; Apply hit-or-miss operator.
               hit = [[0,0,0],[0,1,0],[0,0,0]]
               miss = 1 - hit
		oimg = MORPH_HITORMISS(bimg, hit, miss)

 MODIFICATION HISTORY:
 	Written by:	David Stern, July 1999.
   Modified: CT, RSI, Oct 2003: Add ON_ERROR


MORPH_OPEN $RSI/morph_open.pro
[Previous] [Next]
 NAME:
	MORPH_OPEN

 PURPOSE:
	This function applies the opening operator to a binary or grayscale
	image.

 CATEGORY:
	Image Processing.

 CALLING SEQUENCE:

	Result = MORPH_OPEN(Image, Structure)

 INPUTS:
	Image:	A one-, two-, or three-dimensional array upon which the
		opening operation is to be performed.  If the GRAY or
		VALUES keyword is set, the image is treated as a grayscale
		image; in this case, if the image is not of type unsigned
		long, a temporary unsigned long copy is obtained.  If neither
		the GRAY nor VALUES keyword is set, the image is treated
		as a binary image with all nonzero pixels considered as 1;
		in this case, if the image is not of type byte, a temporary
		byte copy is obtained.
	Structure: A one-, two-, or three-dimensional array to be used
		as the structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.

 KEYWORD PARAMETERS:
	GRAY:	Set this keyword to perform a grayscale, rather than binary,
		operation.  Nonzero elements of the Structure parameter
		determine the shape of the structuring element.

	VALUES:	Set this keyword to an array providing the values of the
		structuring element.  This array must have the same
		dimensions as the Structure parameter.  The presence of
		this keyword implies a grayscale operation.

 OUTPUTS:
	This function returns an array (of the same dimensions as the
	input Image parameter) that represents the result of the opening
	operation.

 CALLED BY:
	MORPH_TOPHAT
 PROCEDURE:
	The opening operator is implemented as an erosion followed by
	a dilation.

 REFERENCE:
	Edward R. Dougherty
	AN INTRODUCTION TO MORPHOLOGICAL IMAGE PROCESSING
       The Society of Photo-Optical Instrumentation Engineers, 1992.

 EXAMPLE:

	Apply the opening operator to a sample image:

               ; Load an image.
               img = BYTARR(256,256)
		filename = FILEPATH('galaxy.dat',SUBDIR=['examples','data'])
		OPENR, lun, filename, /GET_LUN
		READU, lun, img
		CLOSE, lun

               ; Apply opening operator.
               s = [[0,0,1,0,0],$
                    [0,1,1,1,0],$
                    [1,1,1,1,1],$
                    [0,1,1,1,0],$
                    [0,0,1,0,0]]
		oimg = MORPH_OPEN(img, s, /GRAY)

 MODIFICATION HISTORY:
 	Written by:	David Stern, July 1999.
   Modified: CT, RSI, Oct 2003: Add ON_ERROR


MORPH_THIN $RSI/morph_thin.pro
[Previous] [Next]
 NAME:
	MORPH_THIN

 PURPOSE:
	This function applies a thinning operator to a binary image.

 CATEGORY:
	Image Processing.

 CALLING SEQUENCE:

	Result = MORPH_THIN(Image, HitStructure, MissStructure)

 INPUTS:
	Image:	A one-, two-, or three-dimensional array upon which the
		thinning operation is to be performed.  The image is treated
		as a binary image with all nonzero pixels considered as 1.
		If the image is not of type byte, a temporary byte copy is
		obtained.
	HitStructure: A one-, two-, or three-dimensional array to be used
		as the hit structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.
	MissStructure: A one-, two-, or three-dimensional array to be used
		as the miss structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.

          NOTE: It is assumed that the HitStructure and MissStructure are
                disjoint.

 KEYWORD PARAMETERS:
	<None>

 OUTPUTS:
	This function returns an array (of the same dimensions as the
	input Image parameter) that represents the result of the thinning
	operation.

 PROCEDURE:
	The thinning operator is implemented by first applying a hit-or-miss
	operator to the original image (using a pair of structuring elements),
	and subtracting the result from the original image.

 REFERENCE:
	Edward R. Dougherty
	AN INTRODUCTION TO MORPHOLOGICAL IMAGE PROCESSING
       The Society of Photo-Optical Instrumentation Engineers, 1992.

 CALLS: ***
	MORPH_HITORMISS
 EXAMPLE:

	Apply the thinning operator to a sample image:

               ; Load an image.
               img = BYTARR(256,256)
		filename = FILEPATH('galaxy.dat',SUBDIR=['examples','data'])
		OPENR, lun, filename, /GET_LUN
		READU, lun, img
		CLOSE, lun

               ; Map to binary.
               bimg = img
               bimg[WHERE(img lt 128)] = 0

               ; Apply thinning operator.
               hit =  [[0,0,0,0,0],$
                       [0,0,0,0,0],$
                       [0,0,1,0,0],$
                       [0,0,0,0,0],$
                       [0,0,0,0,0]]
               miss = [[1,1,1,1,1],$
                       [1,0,0,0,1],$
                       [1,0,0,0,1],$
                       [1,0,0,0,1],$
                       [1,1,1,1,1]]
		oimg = MORPH_THIN(bimg, hit, miss)

 MODIFICATION HISTORY:
 	Written by:	David Stern, July 1999.
   Modified: CT, RSI, Oct 2003: Add ON_ERROR


MORPH_TOPHAT $RSI/morph_tophat.pro
[Previous] [Next]
 NAME:
	MORPH_TOPHAT

 PURPOSE:
	This function applies the top-hat operator to a grayscale image.

 CATEGORY:
	Image Processing.

 CALLING SEQUENCE:

	Result = MORPH_TOPHAT(Image, Structure)

 INPUTS:
	Image:	A one-, two-, or three-dimensional array upon which the
		top-hat operation is to be performed.  The image is treated
		as a grayscale	image.  If the image is not of type unsigned
		long, a temporary unsigned long copy is obtained.
	Structure: A one-, two-, or three-dimensional array to be used
		as the structuring element.  The elements are interpreted
		as binary values -- either zero or nonzero.  The structuring
		element must have the same number of dimensions as the
		Image argument.

 KEYWORD PARAMETERS:
	VALUES:	Set this keyword to an array providing the values of the
		structuring element.  This array must have the same
		dimensions as the Structure parameter.

 OUTPUTS:
	This function returns an array (of the same dimensions as the
	input Image parameter) that represents the result of the top-hat
	operation.

 PROCEDURE:
	The top-hat operator is implemented as the subtraction of an opened
	version of the original image from the original image.

 REFERENCE:
	Edward R. Dougherty
	AN INTRODUCTION TO MORPHOLOGICAL IMAGE PROCESSING
       The Society of Photo-Optical Instrumentation Engineers, 1992.

 CALLS: ***
	MORPH_OPEN
 EXAMPLE:

	Apply the top-hat operator to a sample image:

               ; Load an image.
               img = BYTARR(256,256)
		filename = FILEPATH('galaxy.dat',SUBDIR=['examples','data'])
		OPENR, lun, filename, /GET_LUN
		READU, lun, img
		CLOSE, lun

               ; Apply closing operator.
               s = REPLICATE(1,3,3)
		oimg = MORPH_TOPHAT(img, s)

 MODIFICATION HISTORY:
 	Written by:	David Stern, July 1999.
   Modified: CT, RSI, Oct 2003: Add ON_ERROR


MPEG_CLOSE $RSI/mpeg_close.pro
[Previous] [Next]
 NAME:
	MPEG_CLOSE

 PURPOSE:
       Frees all information associated with the given MPEG sequence.
       The given MPEG identifier will no longer be valid after this call.

 CATEGORY:
       Input/Output

 CALLING SEQUENCE:
       MPEG_CLOSE, mpegID

 INPUTS:
       mpegID: The unique identifier of the MPEG sequence (as returned
               from MPEG_OPEN) to be stored.

 CALLED BY:
	CW_ANIMATE, XINTERANIMATE
 EXAMPLE:
       MPEG_CLOSE, mpegID

 MODIFICATION HISTORY:
 	Written by:	Scott J. Lasica, December, 1997


MPEG_OPEN $RSI/mpeg_open.pro
[Previous] [Next]
 NAME:
	MPEG_OPEN

 PURPOSE:
       This function initializes MPEG encoding.

 CATEGORY:
       Input/Output

 CALLING SEQUENCE:
       Result = MPEG_OPEN(Dimensions)

 INPUTS:
       Dimensions: A vector of the form [xsize,ysize] indicating the
                   dimensions of each of the images to be used as
                   frames for the MPEG file.

 KEYWORD PARAMETERS:
       FILENAME: Set this keyword to a string representing the name of
                 the file to which the encoded MPEG sequence is to be
                 saved.  The default is 'idl.mpg'.

 OUTPUTS:
       Result: The ID of the underlying MPEG object.

 EXAMPLE:
       mpegID = MPEG_OPEN([100,100])

 MODIFICATION HISTORY:
 	Written by:	Scott J. Lasica, December, 1997


MPEG_PUT $RSI/mpeg_put.pro
[Previous] [Next]
 NAME:
	MPEG_PUT

 PURPOSE:
       Stores the given image at the given frame index.

 CATEGORY:
       Input/Output

 CALLING SEQUENCE:
       MPEG_PUT, mpegID

 INPUTS:
       mpegID: The object reference returned from an MPEG_OPEN call.

 KEYWORD PARAMETERS:
	COLOR: Set to write 24 bit MPEG from 8 bit pseudo color direct
		graphics windows.
       FRAME: Set this keyword to the frame at which the image is to
              be loaded.  If the frame number matches a previously
              put frame, the previous frame is overwritten.  The 
              default is 0.
       IMAGE: Set this keyword to an mxn or 3xmxn array representing
              the image to be loaded at the given frame.  Mutually
              exclusive of the WINDOW keyword.
       ORDER: Set this keyword to a non-zero value to indicate that
              the rows of the image should be drawn from top to bottom.
              By default, the rows are drawn from bottom to top.
       WINDOW: Set this keyword to the index of a Direct Graphics
              Window (or to an object reference to an IDLgrWindow or
              IDLgrBuffer object) to indicate that the image to be
              loaded is to be read from the given window or buffer.

 CALLS: ***
	REVERSE
 CALLED BY:
	CW_ANIMATE, XINTERANIMATE
 EXAMPLE:
       MPEG_PUT, mpegID, FRAME=2, IMAGE=DIST(100)

 MODIFICATION HISTORY:
 	Written by:	Scott J. Lasica, December, 1997


MPEG_SAVE $RSI/mpeg_save.pro
[Previous] [Next]
 NAME:
	MPEG_SAVE

 PURPOSE:
       Encodes and saves the MPEG sequence.

 CATEGORY:
       Input/Output

 CALLING SEQUENCE:
       MPEG_SAVE, mpegID

 INPUTS:
       mpegID: The unique identifier of the MPEG sequence (as returned
               from MPEG_OPEN) to be stored.

 KEYWORD PARAMETERS:
       FILENAME: Set this keyword to a string representing the name of
                 the file to which the encoded MPEG sequence is to be
                 saved.  The default is 'idl.mpg'.

 CALLED BY:
	CW_ANIMATE, XINTERANIMATE
 EXAMPLE:
       MPEG_SAVE, mpegID, FILENAME='myMPEG.mpg'

 MODIFICATION HISTORY:
 	Written by:	Scott J. Lasica, December, 1997


MULTI $RSI/multi.pro
[Previous] [Next]
 NAME:
	MULTI

 PURPOSE:
	Expand the current color table to wrap around N times.

 CATEGORY:
	Image display.

 CALLING SEQUENCE:
	MULTI, N

 INPUTS:
	N:	The number of times the color table will wrap.  This
		parameter does not need not be an integer.

 OUTPUTS:
	No explicit outputs, color tables are loaded.

 COMMON BLOCKS:
	COLORS, the IDL color table common block, contains current color
	tables, loaded by LOADCT, HLS, HSV, etc.

 SIDE EFFECTS:
	Color tables are loaded.

 RESTRICTIONS:
	One of the above procedures must have been called.

 PROCEDURE:
	Tables are expanded by a factor of n.

 EXAMPLE:
	Display an image, load color table 1, and make that color table
	"wrap around" 3 times.  Enter:
		TVSCL, DIST(256)	;A simple image.
		LOADCT, 1		;Load color table 1.
		MULTI, 3		;See how the new color table affects
					;the image.

 MODIFICATION HISTORY:
	DMS, May, 1984.
	Changed common, DMS, 4/87.