NAME:
  cw_osipl
 PURPOSE:
  Display the various spectra generated by xdavg 
 DESCRIPTION:

  This program takes spectra, badflags, and profiles and displays them via a
    multiple page format.  Several spectra can be plotted at once by selecting
    the number of columns and rows to use to display the spectra.  If profiles
    are provided then they are plotted alongside the spectra.  A smoothing
    factor can also be applied to the spectra to reduce the effects of noise.
    The y-range of the plots can be specified by switching to the "fixed"
    option.  The automatic y-range is a min-max range.  The current page can
    also be printed out or all pages and the printer to which they go be
    specified

 CATEGORY:
  Widgets
 CALLING SEQUENCE:
  cw_osipl,leader,type
 INPUTS:
  leader - the Id of the mainbase of the calling widget
  type   - a flag indicating whether or not the the plot is called from the top
           or the bottom of the xdavg tool.  Different defaults are implied by
           this for the number of rows and columns as well as the size cw_osipl
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  TITLE - Optional title of widget, default = 'OSIRIS XD PLOT'
 OUTPUTS:
  Spectra and profiles are plotted to the screen and can be printed
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
  
  This plot widget is used by creating it as a compound widget from within the
    calling program and recording its Id.  Plots are then displayed by the
    program by setting its value to the following data structure in a
    widget_control statement:

  data={

        *Required information*

        nspecs:  The number of spectra that need to be plotted
        calib:   The calibration structure for the spectra
        pref:    The index of the spectrum that is prefered to be displayed
        filenam: The filename of the spectrum, this added to the objname field
                 is displayed as the title of the plot
        objname: The name of the object
        display: The array of spectra to be plotted
        badflag: The array of badflags to be plotted
        pflag:   Flag indicating whether profiles are to be hidden
        cflag:   Flag indicating whether a each order of the spetrum should be
                 plotted in a different color
        pageflg: Flag to indicate that the plotter should only replot if the
                 prefered spectrum is not on the current page

        *Optional information*

          (required if pflag is set)
        prof:    The array of profiles values
        index:   The indices for the profile points
        upbnd:   The upper bound values for the sky level for the profiles
        lwbnd:   The lower bound values for the sky level for the profiles
        relsig:  The signal relative to the brightest spectrum in the set
        mate:    The mate used in the extraction by xdspec

        airmass: The airmass for each spectrum
        juldate: The Julian date of the exposure
        exptime: The exposure time of the spectrum
        ncoads:  The # of coadds used to make the spectrum

        } - UVALUE of state.mainbase

 MODIFICATION HISTORY:
  98/06/12 - Written by Chris Dalla Piazza, Lycoming College