IUE RDAF Library

This page is a listing of the entire contents of this library for IDL. This listing is the long version. Viewing the much more compact listing may be handier.

[Go Back to Main IDL Libraries Search Page]


Last modified: Thu Dec 21 21:32:40 2000.

List of Routines


Routine Descriptions

ADDCOM

[Next Routine] [List of Routines]
*NAME:

  	ADDCOM      8/6/93
  
*CLASS:

	File Conversion 
  
*CATEGORY:
  
*PURPOSE:

       Adds information stored in input text file to the input FITS header.
  
*CALLING SEQUENCE:

  	ADDCOM,HEADER,FNAME,KEYW,newhd
  
*PARAMETERS:

       HEADER  (REQ) (IO) (1) (S)
               FITS header to be updated. Existing entries are 
               preserved and text from FNAME is added.

       FNAME   (REQ) (I) (0) (S)
               full name of input text file. The 1st 72 bytes from each line
               will be extracted, appended with the FIT keyword KEYW, and
               added to HEADER.

       KEYW    (REQ) (I) (0) (S)
               Keyword to precede ascii extracted from fname.

       NEWHD   (OPT) (O) (1) (S)
               If specified, output header is written to NEWHD rather
               than input header.
                

*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:

    	PARCHECK
  
*FILES USED:
  
        FNAME - input text file.
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

*PROCEDURE:

        Reads FNAME, extract 72 bytes from each line, adds KEYW and
        append to HEADER. Original END keyword is deleted from HEADER 
        and appended after text from FNAME.
  
*I_HELP nn:
  
*EXAMPLES:
  
*MODIFICATION HISTORY:

      	Written by R. Thompson 8/6/93

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/addcom.pro)


ADDICOM

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

  	ADDICOM      8/6/93
  
*CLASS:

	File Conversion 
  
*CATEGORY:
  
*PURPOSE:

       Adds information specified interactively by the user 
       to the input FITS header.
  
*CALLING SEQUENCE:

  	ADDICOM,HEADER,KEYW,newhd
  
*PARAMETERS:

       HEADER  (REQ) (IO) (1) (S)
               FITS header to be updated. Existing entries are 
               preserved and text from FNAME is added.

       KEYW    (REQ) (I) (0) (S)
               Keyword to precede ascii extracted from fname.

       NEWHD   (OPT) (O) (1) (S)
               If specified, output header is written to NEWHD rather
               than input header.
                

*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:

    	PARCHECK
  
*FILES USED:
  
       none
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

*PROCEDURE:

        Prompts user for input, extracts 72 bytes from each line, adds KEYW 
        and appends to HEADER. Original END keyword is deleted from HEADER 
        and appended after text from FNAME.
  
*I_HELP nn:
  
*EXAMPLES:
  
*MODIFICATION HISTORY:

      	Written by R. Thompson 9/20/94

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/addicom.pro)


ADDPAR

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

	ADDPAR

*PURPOSE:

	Add or modify a parameter in a FITS header array.

*CALLING SEQUENCE:

	ADDPAR, HEADER, NAME, VALUE, comment, location, format=format,
               before = before, after = after

*PARAMETERS:

	HEADER    (REQ)  (IO)  (1)  (S)
             String array containing FITS header. Max string length 
             must be equal to 80. If not defined, then ADDPAR will 
             create an empty FITS header array.

	NAME      (REQ)  (I)  (0)  (S)
             Name of parameter. If Name is already in the header the 
             value and possibly comment fields are modified. Otherwise 
             a new record is added to the header. Commentary keywords,
             (i.e. 'HISTORY', 'COMMENT' or ' ') will be added to the 
             header without replacement.  In these cases the comment 
             parameter is ignored.

	VALUE     (REQ)  (I)  (0)  (FIS)
             Value for parameter.  The value expression must be of the 
             correct type, e.g. integer, floating or string.  String 
             values of 'T' or 'F' are considered logical values.

	comment   (OPT)  (I)  (0)  (S)
             String field.  The '/' is added by this routine.  
             Added starting in position 31. If not supplied, or set 
             equal to '', then the previous comment field is retained 
             (when found). The comment field is ignored for commentary
             keywords.

	location  (OPT)  (I)  (0)  (S)
              Keyword string name.  The parameter will be placed
	       before the first location of this keyword.  For example, if 
              Location = 'HISTORY' then the parameter will be placed 
              before the first history location.   This applies only 
              when adding a new keyword; keywords already in the header 
              (except commentary keywords) are kept in the same position.
              Note this parameter is identical to using the BEFORE keyword
              described below.

	format    (KEY)  (I)  (0)   (S)  
              Keyword for specifying format for parameter.  A scalar
              string should be used.

	before    (KEY)  (I)  (0)   (S)  
              The Keyword specified by NAME is inserted before the location
              of this keyword. For example, before='extend' will place
              the new keyword before the extend keyword.

	after     (KEY)  (I)  (0)   (S)  
              Same as above except keyword specified by NAME is inserted
              after this keyword. (If optional parameter LOCATION is 
              specified, the default is to place the new keyword BEFORE 
              not AFTER.)

*SUBROUTINES CALLED:

	PARCHECK

*COMMON BLOCKS:

*SIDE EFFECTS:

*RESTRICTIONS:

	Warning -- Parameters and names are not checked
		against valid FITS parameter names, values and types.

*NOTES:

       If location is specified, keywords BEFORE and AFTER are ignored,
       and the keyword will be put before location. If BEFORE is specified, 
       then AFTER would be ignored. If none of the above are specified, 
       keyword is written at end of input header.

       If LOCATION, BEFORE, or AFTER refer to a commentary keyword,
       the first occurance will be used as the location for the 
       new keyword.

	tested with IDL version 2.1.2  (sunos sparc)    12 Nov 1991
       tested with IDL version 2.1.2  (ultrix mipsel)  12 Nov 1991
       tested with IDL version 2.2.0  (ultrix vax)     12 Nov 1991
       tested with IDL version 2.1.2  (vms vax)        14 Dec 1993

*PROCEDURE:

	Straightforward. Note that the special commentary keywords (i.e., 
       'HISTORY', 'COMMENT' and ' ') are treated slightly differently 
       in that they will not overwrite an existing 
       entry. This allows multiple commentary keywords to be included 
       within a FITS header. Also, the '=' and '/' characters are not 
       included for these keywords, the VALUE paramter is written as a
       comment, and the COMMENT parameter is ignored.
       

*MODIFICATION HISTORY:

	DMS, RSI, July, 1983.
	D. Lindler Oct. 86  Added longer string value capability
	Converted to NEWIDL  D. Lindler April 90
       Added Format keyword, J. Isensee, July, 1990
       12 Nov 91  GRA updated IUERDAF version of sxaddpar.pro, which
                      fixed errors when updating existing fits header
                      values; added PARCHECK; cleaned up; updated prolog.
       13 Dec 93  RWT allow multiple commentary keywords to be added 
                      anywhere, (without '=' or '/' characters), and add
                      BEFORE and AFTER parameters as suggested by
                      K. Venkatakrishna (May, 92).

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/addpar.pro)


ARTIFACT

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

	ARTIFACT		1989 August 7

*CLASS:

	File Retrieval

*CATEGORY:

*PURPOSE:

	To retrieve fits files which display low dispersion IUE camera
	artifacts.

*CALLING SEQUENCE:

	ARTIFACT,WCAMART,FCAMART

*PARAMETERS:

	WCAMART	(REQ) (O) (1) (ILFD)
		Wavelength vector in angstroms.

	FCAMART (REQ) (O) (1) (ILFD)
		Flux vector in ergs/cm2/a/s.

*EXAMPLES:

	To generate arrays of wavelength and flux for IUE artifacts:

	     artifact,wcamart,fcamart

	user is prompted for camera name and source type (pt or ext)


       To obtain values directly for LWP point source spectra:

            ifitsrd,!iuer.dat+'lwpskyp.fit',1,main,extd,h,wart,fart,e

*SYSTEM VARIABLES USED:

	!iuer.dat

INTERACTIVE INPUT:

	User is prompted to input camera name (lwp, lwr, or swp) and processing
	type (i.e. point source or extended)

SUBROUTINES CALLED:

	PARCHECK
	IFITSRD

*FILES USED:

       (in !iuer.dat)
	LWPSKYP.FIT	(LWP point source)
	LWPSKYE.FIT	(LWP extended source)
	LWRSKYP.FIT	(LWR point source)
	LWRSKYE.FIT	(LWR extended source)
	SWPSKYP.FIT	(SWP point source)
	SWPSKYE.FIT	(SWP extended source)

*SIDE EFFECTS:

*RESTRICTIONS:

	Only applicable to low dispersion data.

*NOTES:

	The "spectra" were obtained by averaging numerous sky background 
	exposures, all of which were at least 3 hours in duration.  These 
	features will only appear in long exposures.  N. b.:  The actual 
	numerical values for the fluxes (in ergs/cm2-s-A) of the "features" is
	indicative of their relative strengths, but should not be used as a 
	measure of their real values.  The strength of these "features" is 
	dependent upon exposure time.  See Bruegman and Crenshaw (1989, IUE 
	NASA Newsletter, 37, 36).

       The HEADER vector of the fits files contains information from one of;
	the averaged images, and the EPSILON vector contains time-integrated
	flux values.  Neither vector is used by ARTIFACT.

*PROCEDURE:

	The user is prompted for the correct camera and processing type.
	The appropriate file (in fits format) is retrieved with IFITSRD.

*I_HELP nn:

*MODIFICATION HISTORY:

	Original version written by T. J. Teays, 1989 Aug 7.
	    (SAV files were provided by D. M. Crenshaw)
       8-30-89 RWT modified for SUN IDL
       4-10-91 KBC branched filename structure based on operating system type
	6-27-91 PJL new directory structure environment variable with getenv;
		    added error checking for prompted values; cleaned up; 
		    tested on SUN and VAX; updated prolog
	16 Aug 93  PJL  converted sav format files to fits format; replaced
			IUEFETCH with IFITSRD
        2 Sep 94  LLT  replace getenv(iuer_dat) with !iuer.dat

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/artifact.pro)


ASC_READ

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    ASC_READ

*PURPOSE:

    Reads an ASCII file containing a table of numbers (up to 15 columns)
    and outputs the values as floating point vectors.

*CALLING SEQUENCE:

    ASC_READ,FILENAME,P1,p2,p3,p4...,p15,sl=f,ll=l,nel=n

*PARAMETERS:

    FILENAME  (REQ) (I) (0) (S)
        Input file name. If no extension is specified, .txt is assumed.

    P1  (REQ) (O) (1) (F)
        Output vector containing data from the first column of the 
        input table file.

    P2-P15  (OPT) (O) (1) (F)
        Output vectors containing data from additional columns in table
        (up to 15 are currently allowed).

    SL (OPT) (KEY) (0) (BILF)
        Keyword desribing first line of data to be read.
        (Allows column headings to be skipped.)

    LL (OPT) (KEY) (0) (BILF)
        Keyword describing last line of data to be read.
        
    NEL (OPT) (KEY) (0) (BILF)
        Keyword describing number of elements in output vector(s).
        Default = 2500.

*PROCEDURE:

    ASC_READ uses the number of parameters in the procedure call
    to determine the number of entries contained in each line
    of the input ASCII file. It then skips the appropriate 
    number of lines and starts extracting data on the following line. 
    Data is extracted until either an EOF is reached, NEL entries are
    read, or the specified rows are read. All 0 values at end of
    initialized arrays are removed.

*EXAMPLE:

    ASC_READ,'MOD1',SL=5,W,F
         assumes file MOD1.txt contains two parameters per line
         (i.e., a wavelength and a flux value) starting on the 5th
         line from the beginning of the file, and outputs all values
         found as W and F.
    ASC_READ,'SWP12345',H,W,F,E
         assumes file SWP12345.txt contains 4 parameters per line
         (H,W,F,E) with no column headings, and extracts values 
         as 4 vectors.
    ASC_READ,'SWP12345',H,W,F,E,SL=5,LL=30
         skips 4 lines and then reads rows 5 through 30 from the input 
         ASCII file.
    ASC_READ,'RADEC.TXT',CAM,IMAGE,RA,DEC,NEL=10000
         reads first 10,000 entries from input file. In this particular
         example, the camera number, image number, ra, and dec fields
         from an INGRES database table were converted to ASCII and copied
         to a disk file called RADEC.TXT using an SQL script. ASC_READ 
         could then be used to read the resulting file.

*SUBROUTINES:

    DECOMPOSE
    PARCHECK

*NOTES:

    Assumes each line of file has 1 to 15 parameters,
     and each line has the same number of parameters.
    Default array size is currently 2500 points.
    The number of entries read depends upon the smaller value of
     NEL, (LL - SL), or (EOF - SL).
    Uses the default formats defined by IDL to determine the number
     of significant figures. Therefore, some numbers may be rounded-off.

    tested with IDL version 2.1.0 (sunos sparc)	13 Sep 91
    tested with IDL version 2.3.2 (vms vax)		04 Dec 92
    tested with IDL version 2.1.0 (ultrix mispel)	N/A
    
*MODIFICATION HISTORY:

    written by RWT 11/12/90
    12-11-90 RWT add SKIPL parameter
    1-15-91 RWT add DECOMPOSE
    1-22-91 PJL transferred to sun/unix, added PARCHECK
    6-19-91 PJL cleaned up; tested on SUN and VAX; updated prolog
    6-28-91 RWT increase to 10 parameters
    7-18-91 RWT increase to 15 parameters & replace parameter SKIP with
            keywords SL and LL.
    9-13-91 RWT add keyword NEL.
   12-17-91 PJL corrected typo in prolog
    3-02-92 RWT correct parcheck parameter to allow specifying just
            1 output parameter (as reported by PJL).
   12-04-92 RWT allow sl to be > 32768 (i.e., make J a longword integer)
    7-07-93 RWT Correct error that occurs when 11 parameters are specified

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/asc_read.pro)


ASC_WRITE

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    ASC_WRITE 

*PURPOSE:

    Creates an ASCII table file in which each column represents one
    of the specified input vectors. Up to 15 parameters are allowed.

*CALLING SEQUENCE:

    ASC_WRITE,FILENAME,P1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15

*PARAMETERS:

    FILENAME  (REQ) (I) (0) (S)
        Output file name. If no extension is specified, .txt is used.

    P1  (REQ) (I) (1) (F)
        first input vector to be converted to an ASCII file. The
        number of elements in P1 determines the size of the ASCII table.

    P2-P15  (OPT) (I) (1) (F)
        input vectors to be converted to an ASCII file. Each vector will
        be stored as a column in an ASCII table. Vectors must have the
        same number of elements as P1 (or more). 

*PROCEDURE:

    ASC_WRITE uses the number of parameters in the procedure call
    to determine the number of entries to write to each line in
    the output ASCII file. Parameters are written out using the PRINTF
    command, in the same order as they are specified in the procedure 
    call.

*EXAMPLE:

    ASC_WRITE,'MOD1',W,F
         writes vectors to file MOD1.txt with two parameters per line
         (i.e., a wavelength and a flux value).

*SUBROUTINES:

    DECOMPOSE
    PARCHECK

*NOTES:

    Up to 15 parameters can be written to each row or record.
    There is currently no limit to the size of the input vectors,
     and there is no checking of the input vector sizes. The number
     of records written is determined solely from the number of elements
     in P1. If any other input vector is smaller than P1, an error will 
     occur. Vectors larger than P1 will be truncated in the output file.
    The default formats defined by IDL are used to determine the number
     of significant figures. Therefore, some numbers may be rounded-off.

    tested with IDL version 2.1.0 (sunos sparc)	13 Sep 91
    tested with IDL version 2.1.0 (vms vax)    	13 Sep 91
    tested with IDL version 2.1.0 (ultrix mipsel)	N/A
    
*MODIFICATION HISTORY:

    written by RWT 12/28/90 
    1/15/91 RWT use DECOMPOSE
    1/22/91 PJL transferred to SUN/UNIX, added PARCHECK
    6/19/91 PJL cleaned up; tested on SUN and VAX; updated prolog
    7/01/91 RWT increase to 10 parameters
    7/18/91 RWT increase to 15 parameters and add format keyword for
            compatibility with IDL version 2. tested on VAX and SUN
    8/22/91 RWT add a blank between parameters to avoid numbers running
            together
    9/13/91 RWT make internal parameter i a longword integer to be
            compatible with new keyword NEL allowed in ASC_READ.

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/asc_write.pro)


ASSESS

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

       ASSESS       (RDAF General Production Library)       (18-DEC-83)

*CLASS:

       History

*CATEGORY:

*PURPOSE:

       List IUESIPS software changes to the terminal which may affect the
          input image file
 
*CALLING SEQUENCE:

       ASSESS,IMAGET

*PARAMETERS: 

       IMAGET   (REQ) (I) (1) (S)
          Required input string for disk file name of processed IUE data file, 
          i.e. 'SWP25787L'
 
*EXAMPLES:

       ASSESS,'SWP25787L'

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

SUBROUTINES CALLED:

	PARCHECK
	LABEL
	IPDATA
	HISSORT1
	JULDATE

*FILES USED:

     IMAGET  (I)
     !iuer.dat histgraph.tab  (I)
          (opened by HISSORT1 subroutine)
     !iuer.dat bargraph.tab   (I)

*SIDE EFFECTS:
 
*NOTES

     ASSESS relies on the header label to determine date of processing and type
     of processing performed. Missing label information will result in a less
     accurate listing of relevant configurations. Note that some configuration
     entries only refer to changes to the header label and some may only
     pertain to a small number of images. The user however, should make sure
     that the listed software changes do not affect their interpretation
     or analysis of the IUE data.
     Input image files which were processed after the end date of the
     latest configuration entry stored in HISTORY.DAT will (of course) not
     show any pertinent entries.

     	tested with IDL Version 2.1.0 (sunos sparc)	16 Jul 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
     	tested with IDL Version 2.1.0 (vms vax)		16 Jul 91
 
*PROCEDURE:

     Lines of the header label are written out using the routine LABEL. The
     camera, station number, and image number are then extracted using the
     subroutine IDTYPE. Procedure IPDATA is called to extract information
     from the history portion of the header label including: processing date,
     scheme name and aperture type. Procedure JULDATE converts date to julian
     date. The julian date is then compared to entries in the BARGRAPH.TAB
     file (created by BARGRAPH.PRO) to determine valid configuration entries.
     A further sorting is done by procedure INSTRUCT which uses the header
     label information and entries from the HISTGRAPH.TAB file to determine
     entries to be output to the users terminal. See documentation for
     BARGRAPH.PRO and HISTGRAPH.PRO for format of implicit input files.
 
*MODIFICATION HISTORY:

      Written by S. Heap, 18-DEC-83
      History file updated, modified to handle multiple entries for
        one configuration and uses Histgraph.Tab instead of History.Dat
        by R. Thompson  added to [210021] on 12-19-83
      Modified to set 'ENTRY' array for Vilspa images and not list any
         entries with an 'X' flag.  RWT 6-15-84
      Modified 9-2-84 RWT to update array ENTRY in accord with changes
         made to BARGRAPH.TAB and HISTGRAPH.TAB
      Modified 12-28-84 RWT remove compile of COMPOSE, changes references
         from [210,23] to [210,3] and implement in IUER_PROD:.
      Modified 4-26-85 RWT to correct search of scheme name due to
         inadvertent error in IUESIPS processing schemes
      Configuration entries updated in [210,23] RWT 4-28-85
      Modified to use external routine IPDATA to replace subroutines
         ITYPE & IPDATA RWT 5-16-85
      Configuration entries updated with information received from
         VILSPA RWT 9-17-85
      DIDL modified - remove REORDER and use # for @ RWT 11-1-85
      Increase ENTRY array to handle 1986 & later images RWT 5-9-86
      Modified 6-15-84 RWT to allow processing of images not containing the
         processing date in header label 
      Correct problem with 1978 images & use VAX assignment
         statements RWT 4-3-87
      Remove JULDATE and INSTRUCT subroutines and change
         INSTRUCT procedure to HISSORT1  RWT 6-19-87
      Add Rdaf prolog HAA 3-8-88
      Add procedure call listing RWT 6-9-88
      1-2-90 RWT UNIX mods: file access updated, convert to lower case. 
      4-10-91 KBC modify filename structure based on operating system type
      5-29-91 PJL added PARCHECK and updated prolog
      7-16-91 PJL changed logical; tested on SUN and VAX; updated prolog
     2 Sep 94 LLT replace getenv(IUER_DAT) with !iuer.dat

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/assess.pro)


ATRD

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    ATRD 

*PURPOSE:

    To convert FITS ASCII table entries to correct data types 

*CALLING SEQUENCE:

    ATRD,BYTE_EQ,TYPE,VARIABLE

*PARAMETERS:

    BYTE_EQ (REQ) (I) (1) (B) 
        The byte equivalent vector of the data variable to be converted.
        (BYTE_EQ must be a vector.)

    TYPE (REQ) (I) (0) (S)
        Data type of VARIABLE described as a single character. Allowed
        data types are: integer 'I', floating point 'E' or 'F', double 
        precision 'D', and string 'A'. 

    VARIABLE (REQ) (O) (01) (BILFD)
        Converted output vector.

*SIDE EFFECTS:

*SYSTEM VARIABLES USED:


*SUBROUTINES CALLED:

	PARCHECK

*EXAMPLE:

*RESTRICTIONS:

*NOTES:

       Data types are based on those allowed in the TFORM FITS keyword.
       One element output vectors are converted to scalars.

	tested with IDL Version 2.1.2 (sunos sparc)    08 Nov 91
	tested with IDL Version 2.3.2 (vax vms)        19 Oct 92
       tested with IDL Version 2.1.2 (ultrix mipsel)  08 Nov 91
       tested with IDL Version 2.2.0 (ultrix vax)     08 Nov 91

*MODIFICATION HISTORY:

	Randy Thompson 2/8/91 (based on FITSCON)

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/atrd.pro)


BARKER

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

	BARKER

*CLASS:

	Spectral Data Reduction

*CATEGORY:

*PURPOSE:

	To derive the ripple parameters K and alpha for orders
       m1 to m2 for IUE high dispersion data. The algorithm
       used is based on the Barker ripple correction algorithm
       A.J. 89, 899 (1984), which relies upon minimizing the 
	flux differences in order overlap region.

*CALLING SEQUENCE:

	BARKER,IMAGET,AIR,VRAD,M1,M2,A,K1,K,DK,ER,NCAM,ISN

*PARAMETERS:

	IMAGET  (REQ) (I)
		IUE G.O. file name

       AIR     (REQ) (I)
		flag for supressing conversion to vacuum wavelengths
                  AIR=1 will keep air wavelengths
                  AIR=0 will go to vacuum wavelengths (w>2000. only)

       VRAD    (REQ) (I)
		Radial velocity specified to correct SIPS wavelength
               scale. This parameter should be non-zero only for
               IUE G.O. files processed under the "old" software,
               for which no heliocentric velocity correction was 
               applied. 

       M1      (REQ) (I)
		starting order number

       M2      (REQ) (I)
		final order number N.B. code assumes M2>M1

	A       (REQ) (O)
		Ahmad ripple fudge factor for IUE

       K       (REQ) (I)
		ripple parameters for orders M1 to M2

       DK     	(REQ) (O)
	  	increment in K (in units of K)

       ER      (REQ) (O)
		 
       NCAM    (REQ) (I)
		camera number

       ISN     (REQ) (I)
		image sequence number

*EXAMPLES:

*SYSTEM VARIABLES USED:

	!PI

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	FILETYPE
	RIPGET

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

	The SIPS implementation of the ripple correction assumes
       (see SIPS V. 2. 6.4.2) that the heliocentric velocity correction
       has been done before the ripple correction. At this time, the
       wavelength scale is still in vacuum wavelengths. RDAF applications
       of the ripple correction work from the G.O. files which have
       all wavelengths longward of 2000 A converted to AIR wavelengths.

*NOTES:

	tested with IDL Version 2.1.0 (sunos sparc)  	23 Jul 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
	tested with IDL Version 2.1.0 (vms vax)      	23 Jul 91

*PROCEDURE:

	The Ahmad ripple parameter A is held constant for each
       camera, and the K parameter is allowed to vary.

*I_HELP nn:

*MODIFICATION HISTORY:

	Programmer: T.B. Ake (1983)
	Version 0 (IUE Calibration) T.B. Ake 1983
       Version 1 CAG transfer to VAX, add documentation
                   add error checking.                       
       Version 2 
	 1-09-91 PJL modified to sun/unix; included removing !ERR
	 7-23-91 PJL cleaned up; added PARCHECK; tested on SUN and VAX;
		     updated prolog
  	 9-30-91 PJL corrcted typo effecting lwp's a

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/barker.pro)


BARKER3

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

	BARKER3

*CLASS:

	Spectral Data Reduction

*CATEGORY:

*PURPOSE:

	Procedure to extract 3 spectral orders and plot result.

*CALLING SEQUENCE:

	BARKER3,IMAGET,M0,H,WAVE,FLUX,EPS,K1         

*PARAMETERS:

	IMAGET	(REQ) (I)
		file name where eshi file is stored

	M0	(REQ) (I)
		starting (highest) order no  (60 to 120)
             	or wavelength (in angstroms)

	H	(REQ) (I)
		header record

	WAVE	(REQ) (O)
		wavelength vector

	FLUX	(REQ) (O)
		flux vector

	EPS	(REQ) (O)
		epsilon (error) vector

       K1	(REQ) (I)
		echelle constant

*EXAMPLES:

*SYSTEM VARIABLES USED:

	!x.range
	!y.crange

*INTERACTIVE INPUT:
	
*SUBROUTINES CALLED;

	PARCHECK
	PCHECK
	FILETYPE
	IUEGET
	BARKER
	RIPPLE
	IUEMERGE
	IUEPLOT

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	tested with IDL Version 2.1.0 (sunos sparc)  	23 Jul 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
	tested with IDL Version 2.1.0 (vms vax)      	23 Jul 91

PROCEDURE:

*I_HELP NN:

*MODIFICATION HISTORY:

  VERSION 2 F.H. SCHIFFER 3RD  11-MARCH-1982
           splice orders at overlap of ripple correction
  VERSION 3 N. R. EVANS 7 DEC. 1983  NEW RIPPLE CONSTANTS: AKE, 1982, 
           IUE NEWSLETTER #19,37.  URP #162                    
           C. A. GRADY 20-NOV-1984 IMPLEMENT AKE'S LWP CNSTS. 
           RWT 12-12-84 USE NEW IUEMERGE
           RWT 12-19-84 LWP alpha value changed from .85 to .896
  MODIFIED GSFC RDAF 19APR85 - TO BE COMPATIBLE WITH XIDL - /ERROR 
  MODIFIED TO USE NEW IUEGET WITH INTRINSIC MEDIAN COMMAND 5-13-86 RWT
  12-31-86 RWT VAX mods: use subscript notation, N_ELEMENTS, DECOMPOSE
           for COMPOSE
   4-15-87 RWT add PARCHECK and remove EXTRACTs
  10-29-87 CAG modified code to check for file type based on the contents
           of the H record, rather than the file name.
  10-30-87 CAG added printing of the calling sequence when the procedure
           is executed without parameters.
  12-03-87 CAG replaced SIPS ripple by call to BARKER algorithm, and 
           renamed the file. Error checking is now done by subprocedure
           FILETYPE
   1-09-91 PJL replaced previous version of BARKER with BARKER3;
           incorporated BARKER3 into IUEHI3; modified for sun/unix idl
   7-23-91 PJL cleaned up; tested on SUN and VAX; updated prolog
  10- 1-91 PJL ncleaned up xyouts calls

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/barker3.pro)


BASEREM

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

   	BASEREM     30 SEPTEMBER 1980
  
*CLASS:
  
*CATEGORY:
  
*PURPOSE:

   	To fit a polynomial of order NDEG to a user-specified
   	spectral region for removing a baseline from a spectral feature.
  
*CALLING SEQUENCE:

   	BASEREM,X,Y,NDEG,XL,XR,A,YBF,CHIS
  
*PARAMETERS:

    	X	(REQ) (I) (1) (I L F D)
		Array of independent variables.

    	Y	(REQ) (I) (1) (I L F D)
		Array of dependent variables.

    	NDEG	(REQ) (I) (1) (I)
		Degree of polynomial used to approximate baseline.

	XL,XR   (REQ) (I/O) (0) (I L F D)
		Scalar values which if non-zero are used as the left & right
         	coordinates of the excluded region. If zero, the user is 
		prompted for these values via terminal cursor positions.
               The values are returned as the array indicies of the
               baseline points just outside the excluded region.

    	A	(REQ) (I/O) (1) (F)
		Floating point array with at least NDEG+1 elements .
        	(polynomial coefficients are written into the last NDEG+1 
		elements).
  		Input vector A with added coefficients as described above
		(output).
 
    	YBF	(REQ) (O) (1) (I L F D)
		Values of Y produced by polynomial.
		
    	CHIS	(REQ) (O) (0) (I L F D)
		Variance of the fit (as calculated by WPOLYFIT without 
		weighting).
  
*INTERACTIVE INPUT:

    	User is prompted for cursor positions of spectral feature region not 
    	to be included in baseline calculation (if XL & XR are initially 
	zero).
  
*FILES USED:
  
*SYSTEM VARIABLES USED:

	!d.name
	!d.x_ch_size
	!d.y_ch_size
	!d.y_size
  
*SUBROUTINES CALLED:

    	WPOLYFIT
    	PARCHECK
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

  -  	BASEREM will prompt user for cursor positions until the number of points
    	between the limits is greater than the number of elements in vector A
    	plus NDEG-2. 
  -  	BASEREM is used by GAUSSFIT for removing a baseline of a Gaussian 
       feature. In GAUSSFIT, the vector A has NDEG + 1 + 3*NCOMP elements
    	where NCOMP is the number of Gaussian components in the input array.
  -  	The points selected by the user to designate the edges of the feature
    	can be specified in any order. These points are INCLUDED in the baseline
    	fit.
  -  	When BASEREM is used to fit the background of a region in which several
    	Gaussians are to be fit, the user still specifies one set of endpoints.
    	The endpoints should represent the leftmost and rightmost sides of the
    	features. 
  -  	BASEREM use to be restricted to fits of less than 3rd order when
    	used on the PDP computer. Higher fits are now possible but depending on 
    	the magnitude of the input X and Y arrays, problems may occur. 
       Scaling the input Y array will have no effect as BASEREM now
       does this before calling WPOLYFIT.

	tested with IDL Version 2.1.2 (sunos sparc)	08 Aug 91
	tested with IDL Version 2.1.2 (vms vax)    	08 Aug 91
	tested with IDL Version 2.1.2 (ultrix mispel)	08 Aug 91
  
*PROCEDURE:

    	BASEREM extracts the  region excluding that described by the cursor
    	positions (or XL and RL), and uses WPOLYFIT to calculate a polynomial 
    	fit, the YBF values, and the reduced chi square.If NDEG = 0, BASERERM
    	returns 1 element in the vector A simply representing the average value
    	of the baseline region. Since the weighting vector passed to WPOLYFIT
    	is set to ones, the CHIS parameter is simply the variance of the fit.
  
*INF_1:
  
*EXAMPLES:

    	To fit a baseline with a 5th order polynomial:
      	A = FLTARR(9)     ; 6 for baseline, 3 for a possible Gaussian feature
      	BASREM,W,F,5,0,0,A,YBF,CHISQ
  
*MODIFICATION HISTORY:

     	PDP VERSION: I. DEAN AHMAD (modified VAX version: R. Thompson)
     	7-16-84 RWT updated documentation & made user interaction optional
     	8-8-84  RWT defined FXL & FXR for non-interactive mode 
     	11-8-85 RWT RETALL used for 1st RETURN & NELEMENTS & # added for DIDL
      	4-13-87 RWT VAX mods: add PARCHECK, replace TEKDATA with CURSOR, 
		replace TKPLOT & XYOUT with PLOTS, XYOUTS, & SCTODC, use 
		assignment statements.
     	10-28-87 RWT remove restriction of NDEG being <3, allow sides of 
		feature to be specified in any order, add procedure call 
		listing, add PLOT,Y, add endpoints to baseline array, remove 
		FXR, FXL, YL & YR calculations, and remove oplot and listing 
		of CHIS.
        8-22-89 RWT Unix mods: remove SCTODC & HARDCOPY, store coords.
               in arrays, add get_kbrd
	 3-04-91 PJL corrected upper limit test for XC
	 6-19-91 PJL cleaned up; tested on SUN and VAX; updated prolog
        8-07-91 GRA added /down keyword to cursor calls
        8-08-91 GRA added section to identify region containing the 
                    feature and reduce the x axis range to 40 angstroms
                    if the input array spans more than 40 angstroms; 
                    included the x vector in calls to plot, and used
                    tabinv to return x array indicies; added else
                    clause so baserem can be called with xl and xr
                    (wavelength values) defined; scaled the y vector
                    before calling WPOLYFIT; marked cursor selected
                    points with an 'x'; tested on SUN, DEC, VAX;
                    updated prolog. 
	10-10-91 LLT removed 40A limit to allow CRSCOR to work, features
		\PJL separated by more than 40A to be examined. and other
		     units to be used

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/baserem.pro)


BBCMP

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

	BBCMP     30-MAR-83
  
*CLASS:
  
*CATEGORY:
  
*PURPOSE:

	To compute the rms and average deviations of an observed spectrum from
	Planck curves calculated at user-specified temperatures.
  
*CALLING SEQUENCE:

	BBCMP,WAVE,FLUX,TEMP,AVGD,RMS
  
*PARAMETERS:

    	WAVE	(REQ) (I) (0 1) (B I L F D)
		Wavelength vector for the spectrum.

    	FLUX	(REQ) (I) (0 1) (B I L F D)
		Flux vector for the spectrum.

    	TEMP	(REQ) (I) (0 1) (B I L F D)
		Scalar or vector of temperature of comparison blackbody 
		curves.

    	AVGD	(REQ) (O) (0 1) (F D)
		Scalar or vector of average deviations of observed spectrum .
               from blackbody curves.

    	RMS	(REQ) (O) (0 1) (F D)
		Scalar or array of root-mean-square deviation of spectrum .
               from optimally scaled blackbody of temperature TEMP.
  
*INTERACTIVE INPUT:

	none
  
*FILES USED:

	none
  
*SYSTEM VARIABLES USED:

        !NOPRINT
  
*SUBROUTINES CALLED:

	PCHECK
	PARCHECK
	PLANCK
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

       The blackbody curves are calculated on the wavelength grid of WAVE.
	The blackbody fluxes are scaled by

		BBFLUX = BBFLUX*TOTAL(FLUX*BBFLUX)/TOTAL(BBFLUX*BBFLUX)

       before the average and rms deviations are calculated.

*PROCEDURE:

       Input arrays are verified by PCHECK. WAVE and FLUX must be of the same
	size and type.  If TEMP is scalar, it is forced to be a 1-element
	floating-point array.  PLANCK returns black body fluxes which are
	normalized and then scaled as described above.  AVGD and RMS are
	calculated as follows:

       		F = input flux array
       		BBF = scaled black body flux array
       		DIFF = BBF - F
       then
       		AVGD = TOTAL(ABS(DIFF))/NELEMENTS(F)-1
       		RMS = SQRT(TOTAL(DIFF*DIFF)/NELEMENTS(F)-1

       Reference:  Bevington, P.R. 1969, Data Reduction and Error Analysis for
		    the Physical Sciences, McGraw-Hill (New York), p. 14- 19.
  
*INF_1:
  
*EXAMPLES:

       To test several temperatures:

		bbcmp,w,f,[20000,40000,60000],avgd,rms
  
*MODIFICATION HISTORY:

       Programmer: R.J. Panek 30 March 1983
        7-30-86 CAG corrected error in rms deviation calculation, added
		     average deviation calculation, and scaled BBFLUX by its
		     maximum value to avoid floating point overflow errors.
       12-17-86 RWT change print format, use !MODE for !VAR5, and remove
		     FORMAT for VAX conversion
        4-13-87 RWT VAX mods: add PARCHECK
        7-24-87 RWT use !NOPRINT
        4-26-88 RWT add procedure call listing and remove USAGE
        7-18-90 RWT update prolog & fix error when multiple temperatures are
		     specified.
        3-04-91 PJL mofified for unix/sun
        6-19-91 PJL cleaned up; tested on SUN and VAX; updated prolog
       11-27-91 PJL corrected typo in prolog
	13 Sep 93  PJL  allow wave and flux to be of different data types, but
			they still must have the same number of elements

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bbcmp.pro)


BBDRAW

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

   	BBDRAW     6-JAN-83
  
*CLASS:
  
*CATEGORY:

*PURPOSE:

   	Draw blackbody curves over data through a given point.
  
*CALLING SEQUENCE:

   	BBDRAW,WAVE,FLUX,WPICK,TEMP,DILUTION,WBB,FBB,q=q,sigma=sigma
  
*PARAMETERS:

   	WAVE	(REQ) (I) (1) (I L F D)
		Wavelength scale.

   	FLUX	(REQ) (I) (1) (I L F D)
		Flux to be fit.

   	WPICK	(REQ) (O) (0) (F)
		Wavelength of the point through which the blackbody curve is
		forced to pass.

   	TEMP	(REQ) (O) (0) (F)
		Blackbody temperature last chosen by user.

   	DILUTION   (REQ) (O) (0) (F)
		Dilution factor at point chosen by user for blackbody with
		temperature temp.
	
     	WBB	(REQ) (O) (1) (F)
		Array of final blackbody wavelengths.

    	FBB	(REQ) (O) (1) (F)
		Array of final blackbody fluxes.

	Q	(KEY) (I) (1) (I L F D)
	        Data quality flags (IUESIPS or NEWSIPS).

	SIGMA	(KEY) (I) (1) (R)
		The NEWSIPS sigma vector (or other fitting error, e.g., GEX).
  
*INTERACTIVE INPUT:

       User selects a point through which the blackbody curve must pass, 
  	then user inputs guesses for temperature until he or she gets tired.
  
*FILES USED:

	User may create BBDRAW.PS if desired.
  
*SYSTEM VARIABLES USED:

	!d.x_ch_size
	!d.y_ch_size
	!d.y_vsize
  
*SUBROUTINES CALLED:

	PARCHECK    Checks that the number of parameters entered is acceptable.
    	PLANCK      Calculates black body curve
	NSPLOT      Plots data (with quality flags/sigmas if given)
       plotopen    Creates PS file and redirects plot output to PS device
       plotclose   Closes PS file and resets plot device 
       plotprint   Executes PLOTCLOSE and send PS file to printer, if desired
  
*SIDE EFFECTS:

       If a PS file is created, a title is put on the plot, overriding the
       value of !p.title.
  
*RESTRICTIONS:
  
*NOTES:

    	Uses PLANCK to calculate the bb curves.

*PROCEDURE:

	The input parameters are plotted.  The user must then mark the fit
	point.  Then the user enters tempertures at the propmt.  To exit,
	enter 0.
  
*INF_1:
  
*EXAMPLES:


	General data:

		bbdraw,w,f,wp,tp,dil,wbb,fbb

	IUESIPS data:

		bbdraw,w,f,wp,tp,dil,wbb,fbb,q=e

	NEWSIPS data:

		bbdraw,w,f,wp,tp,dil,wbb,fbb,q=n,sigma=s
		bbdraw,w,f,wp,tp,dil,wbb,fbb,sigma=s
		bbdraw,w,f,wp,tp,dil,wbb,fbb,q=n
  
*MODIFICATION HISTORY:

     	26-JAN-83 BY RJP= correction of a program by I. Ahmad based on a
             	          program by S. Heap
     	 6-21-85 RWT add WBB and FBB output parameters, use new IUEPLOT
             	     and remove unnecesssary compiles
    	10-22-85 RWT DIDL change: use # for @
      	 5- 6-87 RWT VAX mods: add PARCHECK, plot titles, and use 
             	     CURSOR for TEKDATA
     	 9-24-87 CAG corrected dilution factor to reflect IUE calibration
             	     wavelength scale units of per Angstrom instead of per cm
             	     (as given in Allen, Astrophysical Quantities). URP #275.
    	10-12-87 RWT add procedure call listing
       05-oct-89  jtb @gsfc modified for sun/unix idl
	08 Apr 91  pjl@gsfc  modified PLANCK to return result in units per
			     ANGSTROM
	19 Jun 91  PJL  cleaned up; tested on SUN and VAX; updated prolog
	 5 Aug 93  PJL  clean up; remove EPS parameter; add EPS, NU, and SIGMA
			keywords; add NSPLOT
       28 Sep 93  LLT  fix a few typos in prolog
       27 Dec 94  LLT  Remove IUEPLOT, change prompting for non-TEK devices,
                       remove IF block for plotting since new NSPLOT can
                       ignore undefined parameters, add option to print/make
                       PS file of final results.
        3 Jan 94  LLT  use lower case for plot file name

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bbdraw.pro)


BCOMP

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

     	BCOMP       (RDAF General Production Library)      5 September, 1986
 
*CLASS:

      	Resampling

*PURPOSE:  

      	To resample high dispersion IUE data onto a uniformly spaced
      	wavelength grid. Data is averaged in each wavelength bin.
 
*CALLING SEQUENCE:

      	BCOMP,FILENAME

*PARAMETERS:

	FILENAME (REQ) (I)
		 The name of the data file containing the compression
		 parameters (output from PRECOMP) to be used as input to
		 BCOMP.  If blank or null the default name 'comp.dat' is
		 used.  In batch mode on the VAX, this must be 'comp.dat'.

*EXAMPLES

	To run BCOMP using comp.dat as the input file:
	   bcomp,'0'
	   bcomp,''
	   bcomp,' '
	   bcomp,'comp.dat'

	processes all files (max 10) whose information is
       described in the file COMP.DAT

	To run BCOMP using mycomp.dat as the input file:
	   bcomp,'mycomp.dat'

	To run BCOMP in the background (UNIX) outside of IDL on a file named
	'myfile.dat':
		if IUER_EXE defined (from earlier IDL session),
			$IUER_EXE/compress.bat 'myfile.dat'
		if IUER_EXE is not defined,
			/home/iuerdaf/iuelib/exe/compress.bat 'myfile.dat'
	To run BCOMP as a batch job (VMS) [filename must be 'comp.dat']:
		submit/noprint IUER_EXE:compress.bat

	processes all files (max 10) whose information is
       described in the file MYCOMP.DAT 

	To create the input file run PRECOMP.

*SYSTEMS VARIABLES USED:

      	!NOPRINT    -   set to 1 temporarily, to suppress printout in BINS
       !err_string

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    	PARCHECK
    	IUESAVE
    	TEMPCOR
    	COMBALL
    
*FILES USED:

    	filename (defaults to comp.dat)    (I)
       	File produced from PRECOMP.PRO which can contain information 
		for up to ten files maximum to be resampled.  In batch mode on 
		the VAX, this must be 'comp.dat'.

    	'imagetcm.sav'   (O) 
       	 Disk files of compressed spectra and splice points in SAV 
		 format, where filename is the original image name without the 
		 H at the end.  The standard epislon vector is replaced by
                the weight (WGT) vector obtained from the RDAF procedure BINS.

       'imagetsp.sav'   (O)
                The .SAV file of splice points.

*SIDE EFFECTS:

	!NOPRINT could be reset

*RESTRICTIONS:

	In batch mode on the VAX, the filename must be COMP.DAT.

*NOTES:

  	1) BCOMP uses the disk file COMP.DAT (or name chosen by user),
	   created by PRECOMP, for all processing information (see
	   PRECOMP.PRO's documentation for more information).  In batch
	   mode on the VAX, the disk file must be named COMP.DAT.
  	2) On SUN, execution time can take at least 2 minutes per image.
	   On VAX, execution time can be 7 to 8 minutes per image.
	3)  To run BCOMP in the background (UNIX) outside of IDL:
		if IUER_EXE defined (from earlier IDL session),
			$IUER_EXE/compress.bat filename
		if IUER_EXE is not defined,
			/home/iuerdaf/iuelib/exe/compress.bat filename
	    To run BCOMP as a batch job (VMS):
		submit/noprint IUER_EXE:compress.bat

	tested with IDL Version 2.2.0 (sunos sparc)	22 Nov 91
       tested with IDL Version 2.2.0 (ultrix mipsel)	22 Nov 91
       tested with IDL Version 2.2.0 (vms vax)		22 Nov 91
 
*PROCEDURE:

    	PRECOMP.PRO must be run first to produce the disk file COMP.DAT (or 
	filename chosen by user, although the file name must be COMP.DAT if
	BCOMP is to be run in batch mode on the VAX) which BCOMP reads in 
	order to determine image files, wavelength interval to extract, and 
	bin sizes.  Orders are merged into one array, ripple corrected, 
	absolutely calibrated (if exposure time > 0), and resampled.  Final 
	array is corrected for THDA sensitivity variations if requested.  
	Final arrays are saved as disk files using IUESAVE.  In the
       'imagetcm.sav' file, the E vector contains data quality information -
	the weight (WGT) vector obtained from the RDAF procedure BINS.  A
	separate SAV file, 'imagetsp.sav', is created of the splice points used.

*MODIFICATION HISTORY:

     	Written by R.J. Panek (SCRUNCH), G. Sonneborn (SCRUNCH3) 
     	         & C. Grady (COMPRESS)
    	11-21-85 RWT modified for batch processing
    	12-17-85 RWT correct for monotonicity error and modify ripple
    	        parameters to agree with QIUEHI3 
    	8-24-86 RWT use ABCAL for CALIB, use version numbers in file name,
    	        add TEMPCOR subroutine, and use new IUESAVE
   	12-18-86 RWT VAX mods added: N_ELEMENTS, OF changed to OFL, add 
   	         IUER_USERDATA: to disk files, use array subscripts, 
   	         input VNUM, & fix !MODE add PARCHECK, and remove INSERT 
   	         & EXTRACT commands
     	5-4-87 RWT change WBINS reference to BINS
     	6-9-87 RWT remove REBIN subroutine (name conflict)
    	7-24-87 RWT use !NOPRINT for !MODE and add GET_LUN for unit numbers
    	8-12-87 RWT use new file naming convention
    	1-15-88 RWT add fix for image numbers > 32767 and for new LWP ITF
    	2-19-88 RWT separate subroutines into individual modules & rename
    	3-08-88 HAA add RDAF Prolog.
	3-01-91 PJL unix/sun modifications; parameters changed from
		version number to filename
	4-08-91 PJL directed input from user's home directory
       4-11-91 GRA added branch for fname processing in vms
	7-22-91 PJL cleaned up; changed logical; tested on SUN and VAX;
		    updated prolog
	8-19-91 PJL modified to accept file names with sm and lg in them
		    and made the input file ascii; tested on SUN and VAX; 
		    updated prolog
      10-23-91 PJL added to prolog
      10-28-91 PJL added to prolog
     22 Nov 91 GRA removed IUER_USERDATA logical; tested.
     16 Dec 91 PJL corrected number of files equal 10 case
     17 Dec 91 PJL changed number of points limit from 4000 to 10000;
		    LWR and LWP no longer have to be split into two
		    two files
      7 Jan 92 PJL added to documentation

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bcomp.pro)


BFIT

[Previous Routine] [Next Routine] [List of Routines]

*NAME:

      bfit

*CALLING SEQUENCE:

      BFIT,W,F,Q,B,lines=lines,nfirst=nfirst

*PURPOSE:

      To create a background vector from the SILO image using the same method
      as SWET (the extraction step of NEWSIPS).

*PARAMETERS:

         W (req) (i) (1) (f)
           Wavelengths from SILO file.

         F (req) (i) (2) (f)
           Fluxes from SILO file.
   
         Q (req) (i) (2) (i)
           Quality flags from SILO file.

         B (req) (o) (1) (f)
           Output background vector.

     lines (key) (i) (1) (i)
           Indices of lines to be used for background.

    nfirst (key) (i) (0) (i)
           The first NFIRST elements of LINES will be considered part of the
           FIRST swath; remaining LINES will be part of the SECOND swath.
           Default is seven.

*SUBROUTINES CALLED:

       parcheck

*FILES USED:

       None.

*NOTES:

       Although this code has been optimized in the sense that unused
       variables and oversized arrays appearing in the FORTRAN code 
       have been dispensed with (and the capabilities of IDL are used),
       the logic is the same as in the original.  One place this might
       lead to problems is in the patching of bad points in column 1 of
       the background array.  If the very first point in either swath
       is bad, it is replaced with its neighbor in the previous row---
       without checking that point first.  Bad points in other columns 
       are replaced with the point in the preceding column.  This could
       theoretically propagate a bad pixel along the row if there were
       many bad pixels next to each other.

*PROCEDURE:

       This is an IDL version of the subroutine IUEBKG (which is a subroutine
       of SWET---Signal Weighted Extraction Technique, used by NEWSIPS to 
       create the MXLO file).  It first replaces points in the two background
       swaths with the value of the closest (shortward) good point.  The two
       regions of patched fluxes are summed separately and then individual
       points in the difference spectrum (region 1 minus region 2) are assigned
       tiny weights if they differ from the mean value (of the d. spectrum) by
       more than 2*sigma.  (Points outside the target ring---i.e., all of the
       contiguous bad region at the edge of the spectral lines, are also given
       low weights.)  Then a Chebyshev fit is done to the average of all the
       patched background lines.  There are comments in this code showing
       which sections are analogous to which of IUEBKG's subroutines.

*MODIFICATION HISTORY:
       Written by LLT.
        2 Dec 94  LLT fix smoothing, background patching, weighting.

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bfit.pro)


BGEX

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    	BGEX       (RDAF Production Library)     DEC. 12, 1986
 
*CLASS:

    	Spectral Extraction

*CATEGORY:

*PURPOSE: 

     	Procedure to run GEX1 and GEX2 procedures without user interaction.
     	Parameters are input implicitly via the disk file GEX.TXT created
     	by the routine PREGEX.PRO. For further information see GEX1 and
     	GEX2 procedures.
 
*CALLING SEQUENCE:

     	BGEX,FILENAME
 
*PARAMETERS:

     	FILENAME   	(REQ) (I) (0) (S) 
                   a string corresponding to the name of
                   the data file containing image names and
                   gex parameters (output from PREGEX) to be used
                   as input to BGEX. If blank or null the default
                   name 'gex.txt' is used.

*EXAMPLES:

     	To run bgex using gex.txt as the input file:
     	   bgex,' '

     	To run bgex using mygex.dat as the input file:
     	   bgex,'mygex.dat'

     	To create gex.txt with pregex (after displaying valid input files)
      	and then running bgex:
      	   pregex,0
          bgex,' '

	To run BGEX in the background (UNIX) outside of IDL on a file named 
	'myfile.dat':
	    if IUER_EXE defined (from earlier IDL session),
		$IUER_EXE/gex.bat 'myfile.dat'
	    if IUER_EXE is not defined,
		/home/iuerdaf/iuelib/exe/gex.bat 'myfile.dat'
	To run BGEX as a batch job (VMS) [the filename must be 'gex.txt']:
		submit/noprint IUER_EXE:gex.bat

*SYSTEM VARIABLES:

	!err_string

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

      	GEX2
      	GEX1
      	PARCHECK

*FILES USED:

    	FILENAME  [defaults to gex.txt] (I)
    	        Input file of parameters created by PREGEX.  When running
		BGEX on the VAX in batch mode, filename must equal gex.txt.

    	IMAGET.TAB  (I/O)
    	         Intermediate data set created by GEX1 and input to GEX2 in a
    	         disk file with up to 200 records of 7 data pts;
    	         data record 0 - header record contains 3 floating pt. values:
    	                 1 - number of parameters per record (i.e., 7)
    	                 2 - number of data points (i.e., NPT)
    	                 3 - bin size (i.e., DELS)
    	         data records 1 to NPT contain (in order):
    	                  wavelength, center position, width (of fitted 
			  Gaussian function), height, YINT (y-intercept for 
			  linear background fit where F(bckgnd)=YINT+SLOPE*
		 	  order #), SLOPE (slope for linear background fit 
			  above), SIGMA (standard deviations from linear 
			  background fit).

    	IMAGET+'GX.SAV' (O)
    	          (from GEX2) disk SAV file containing 2 records where record 1
    	          contains the number of points in the H, W, F and E vectors
    	          and record 2 contains the actual H, W, F, & E vectors.
			

*RESTRICTIONS:   

	modified to run using unix/sun idl version 1.2

		For batch mode on the VAX, the filename of the file created
	by PREGEX must be gex.txt.  Also, all files must be in the user's
	home directory.

*SIDE EFFECTS:

*NOTES:

    	N output files are created for N input images.

       For more information on "gex" routines see iuerdaf/manuals/gex.txt.

	To run BGEX in the background (UNIX) outside of IDL:
	    if IUER_EXE defined (from earlier IDL session),
		$IUER_EXE/gex.bat filename
	    if IUER_EXE is not defined,
		/home/iuerdaf/iuelib/exe/gex.bat filename
	To run BGEX as a batch job (VMS):
		submit/noprint IUER_EXE:gex.bat

	tested with IDL Version 2.2.0 (sunos sparc)	22 Nov 91
	tested with IDL Version 2.2.0 (ultrix mispel)	22 Nov 91
	tested with IDL Version 2.2.0 (vms vax)    	22 Nov 91

*PROCEDURE:

	Disk file - for which the default name is gex.txt - is used to input 
	image file names, wavelength limits, and bin sizes. These parameters 
	are displayed on the users terminal. Each image file is then submitted
	to GEX1 and GEX2 producing the standard disk files output by these 
	procedures.
	
 
*MODIFICATION HISTORY:

     	Programmer:   R. Thompson
     	4-13-87 RWT VAX mods: add PARCHECK
     	7-27-87 RWT modified to use new file name convention
     	8-19-87 RWT use GET_LUN command
     	1-15-88 RWT make IMN array longword integers
     	3-08-88 HAA add RDAF Prolog
     	5-09-88 RWT add reading CORDER parameter from GEX.DAT file
       dec-19-89 jtb@gsfc modified for unix/sun idl
       4-10-91 KBC modify filename structure based on operating system type
	16- 7-91 PJL cleaned up; logical; tested on SUN and VAX; updated prolog
 	16- 8-91 PJL modified to accepted files names with sm and lg in them
		     and made the input file ascii; tested on SUN and VAX;
		     updated prolog
       23-10-91 PJL added to prolog
       28-10-91 PJL corrected and added to prolog
      22 Nov 91 GRA removed IUER_USERDATA logical; tested.
      16 Dec 91 PJL corrected error in number of files equals 10 case
      11 Mar 94 LLT Add code so this procedure can execute output of BATGEX.
      29 APR 94 RWT use gex.txt as new default file name

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bgex.pro)


BIMAGE

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    BIMAGE     (General IDL Library 01) 12 DECEMBER, 1986

*CLASS: 

    Resampling

*CATEGORY:

*PURPOSE:  

    To bin a vector or a two dimensional array in either or both directions.
 
*CALLING SEQUENCE: 

    BIMAGE,IMAGE,SWIDTH,LWIDTH,OUT,NNS,INDEX
    BIMAGE,IMAGE,SWIDTH,LWIDTH,OUT
    BIMAGE,IMAGE,SWIDTH,LWIDTH,OUT,NNS

*PARAMETERS:

    IMAGE   (REQ) (I) (1 2) (B I L F D)
            Required input image vector or array which is to be binned.
  
    SWIDTH  (REQ) (I) (0) (I L F D)
            Required input scalar giving the bin width in the sample (x)
            or column direction.

    LWIDTH  (REQ) (I) (0) (I L F D)
            Required input scalar giving the bin width in the line (y)
            or row direction.
    
    OUT     (REQ) (O) (1 2) (F)
            Required output vector or array containing the binned data
            in floating point format.

    NNS     (OPT) (O) (0) (I)
            Optional output scalar giving the number of points in the
            sample direction.

    INDEX   (OPT) (O) (1) (I F)
            Elements from input image corresponding to bin centers in the
            sample direction. Centers for even bin widths will be half an
            element too high.

*EXAMPLES:

     To bin an LBLS file (read in to array FILE using READFILE) with a bin
     size of 10 in the sample direction and 2 in the line direction:
        BIMAGE,FILE,10,2,OUT   or,
        BIMAGE,FILE,10,2,OUT,NNS,INDEX

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

     PARCHECK

*FILES USED: 

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

    1) OUT is truncated in line and sample direction to be a multiple
    of LWIDTH and SWIDTH respectively.
    2) Any width specified as less than or equal to 1 defaults to 1.
    3) If IMAGE is a vector, the value of LWIDTH is ignored. However,
       it must still be specified.
    4) Bin centers described in INDEX will be half an element too high
       when SWIDTH is an even number. For example, if SWIDTH = 8, the
       first element of INDEX will be 5, not 4.5.
    5) Specifying BIMAGE with no parameters will display the procedure
       call statement

	tested with IDL Version 2.1.0 (sunos sparc)	19 JUN 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
	tested with IDL Version 2.1.0 (vms vax)    	19 Jun 91
 
*PROCEDURE:

    BIMAGE is basically a driver for the new intrinsic IDL command
    REBIN. Because REBIN requires that the dimensions of the input array
    be a multiple of the bin size, BIMAGE calls REBIN with an appropriately
    truncated input array. BIMAGE also calculates the dimensions of the 
    output array as required by REBIN, and calls REBIN with the appropriate
    number of parameters depending on whether IMAGE is a vector or an array.
 
*INF_1:

*MODIFICATION HISTORY:

            87 SRH HRS   wrote COMPRESS
     Apr 13 87 RWT GSFC  renamed procedure, added PARCHECK, and removed 
                         INSERT
     Jun  5 87 RWT GSFC  rewrite to use REBIN, make INDEX and NNS optional,
                         and allow IMAGE to be a vector.
     Aug 19 87 RWT GSFC  add listing of procedure call statement
     Mar  7 88 CAG GSFC  add VAX RDAF-style prolog
     Jun 19 91 PJL GSFC  cleaned up; tested on SUN and VAX; updated prolog

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bimage.pro)


BINLAB

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

       BINLAB

*CLASS:

*CATEGORY:

       NEWSIPS

*PURPOSE:

       Converts lines of the binary portion of the IUESIPS Vicar label that
       are stored in hexadecimal notation in the NEWSIPS fits header back
       into binary.

*CALLING SEQUENCE:

       BINLAB,HEADER,STARTLINE,ENDLINE,BINPART

*PARAMETERS:

       HEADER  (REQ) (I) (1) (S)
               NEWSIPS fits header - including IUESIPS Vicar label (in COMMENT
               portion.

       STARTLINE (REQ) (I) (0) (I)
               The IUE Vicar label line number to start converting hexadecimal
               to binary.  Binary lines are 38 to 82 and 86 to 100.

       ENDLINE (REQ) (I) (0) (I)
               The IUE Vicar label line number to stop converting hexadecimal
               to binary.  Binary lines are 38 to 82 and 86 to 100.

       BINPART (REQ) (O) (1) (B)
               The binary portion of the IUESIPS Vicar label.

*EXAMPLES:

       fitslab,'swp24787r.lab',lab,flab
       binlab,lab,86,100,binpt

*SYSTEM VARIABLES USED:

       none

*INTERACTIVE INPUT:

       none

*SUBROUTINES CALLED:

       PARCHECK
       HEXTODEC

*FILES USED:

       none

*SIDE EFFECTS:

*RESTRICTIONS:

       Only for use with binary lines of IUE Vicar label.

*NOTES:

       Double check which lines are considered binary??????

       Line number an 'C' are not "translated" - left as zeroes.

       Leading 0 difference between RDAF format and output of BINLAB.

       STARTLINE and ENDLINE may be changed by the procedure.

*PROCEDURE:

       If HEADER parameter is not a string array, procedure retalls.  The IUE
       Vicar label is located in the fits header.  If the phrase, "IUE-VICAR
       HEADER START" is not found, the procedure retalls.  The end of the
       IUE Vicar label is located in the fits header.  If the phrase,
       "IUE-VICAR HEADER END" is not found, the procedure assumes the end of
       the HEADER array is the end.  The label is separated from the fits
       header.

       The provided line numbers are checked.  If the starting line must be
       less than or equal to 82 and greater than or equal to 38, or greater
       than or equal to 86 and less than or equal to 100.  The ending line
       must be greater than or equal to the starting line and less than or
       equal to 82, or 100.  The numbers will be reset accordingly.
       The number of lines is calculated.

       If the starting line munber is not found, the procedure retalls.  Each
       line number in the binary portions of the IUE Vicar label occurs twice.
       Each line is read, the hexadecimal portion is passed to HEXTODEC, and
       the returned value is place in the correct half of the line in the
       working array.  The first line in the label is placed in elements 0
       through 32.  The second line in the label is placed in elements 33
       through 65.  The line number and 'C' are not included.

       The working array is converted to byte and returned.
       

*I_HELP  nn:

*MODIFICATION HISTORY:

       16 Feb 94  PJL  started
       22 Feb 94  PJL  make more general - add start and end line numbers

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/binlab.pro)


BINS

[Previous Routine] [Next Routine] [List of Routines]
*NAME: 

    BINS     (General IDL Library 01) 6-JAN-83

*CLASS:

    Resampling

*CATEGORY

*PURPOSE:  

    To bin flux data on a specified wavelength grid with or without weights. 

*CALLING SEQUENCE:

    BINS,WAVE,FLUX,WEIGHT,WCENTER,WIDTHS,WMEAN,WSIGMA,WGT,$
         file=file,/silent,/overwrite

*PARAMETERS:

    WAVE    (REQ) (I) (1) (I L F D)
            Required input vector giving the wavelength scale for the
            flux data which are to be binned.

    FLUX    (REQ) (I) (1 2) (I L F D)
            Required input vector or array giving the flux data to be binned.
            If flux is an array (e.g. an ELBL file) the binning is only
            performed in the wavelength direction

    WEIGHT  (OPT) (I) (1 2) (F D)
            Optional input vector or array giving point by point weights
            for the flux vector. If specified as a scalar, WEIGHT =
            FLUX * 0 + WEIGHT; otherwise, WEIGHT must have same dimensions
            as FLUX.

    WCENTER (REQ) (I/O) (0 1) (I L F D)
            Required input scalar or vector giving the centers for
            the wavelength bin(s). The units MUST be the same as for
            the WAVE vector. This vector is recomputed for output to the
            actual value used (i.e. to describe any edge effects).

    WIDTHS  (REQ) (I/O) (0 1) (I L F D)
            Required input scalar or vector giving the full width in the
            same units as the WAVE array for each bin. This is 
            recomputed to the actual value used (i.e. to describe bins 
            truncated at ends of array).

    WMEAN   (REQ) (O) (0 1 2) (F D)
            Required scalar, vector or array output variable containing the
            (weighted) mean value of the FLUX array in each bin.

    WSIGMA  (REQ) (O) (0 1 2) (F D)
            Required scalar, vector or array output variable containing the 
            (weighted) rms standard deviation from the WMEAN in each bin.   

    WGT     (REQ) (O) (0 1) (F D)
            Required scalar or vector output variable containing the
            new weight values in each bin. If weight is not specified,
            WGT equals the number of points in each bin.
 
    FILE    (KEY) (i) (0) (IS)
            This keyword allows you to write your results to a file.  You
            set it equal to a filename (e.g., file='mybins.txt') or use a
            default filename BINS.TXT by setting this keyword to 1 
            (i.e., file=1 or /file).

    silent  (key) (i) (0) (i)
            If set, results will not be displayed on the screen.

    overwrite (key) (i) (0) (i)
            If set, and the results are to be written to a file, the program
            will not check for prior existence of the file before writing.

*EXAMPLES:

    with WEIGHT assigned by procedure WEIGHT, 
      BINS,WAVE,FLUX,WEIGHT,WCENTER,WIDTHS,WMEAN,WSIGMA,WGT

    For uniform weighting:
      BINS,WAVE,FLUX,WCENTER,WIDTHS,WMEAN,WSIGMA,WGT

    For weighted binning of a 2-D line-by-line file using 50 A
      bins from 1150 to 1600 angstroms:
      READFILE,IMAGET,LABEL,H,W,FIMAGE,EIMAGE    ;create image array
      WEIGHT,EIMAGE,WEIGHT                       ;use epsilons for weight
      WIDTHS = 50                                ;specify constant width
      WCENTER = 1150 + INDGEN(10)*50             ;generate wavelength centers
      BINS,W,FIMAGE,WEIGHT,WCENTER,WIDTHS,WMEAN,WSIGMA,WGT   ;run bins

*SYSTEM VARIABLES USED:

    !NOPRINT if=0, the results are printed in tabular form
               >0, the results are not printed.

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    TABINV
    PARSHIFT
    cpychk  (Checks for prior existence of file and queries user if nec.)

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

        modified for sun/unix idl version 1.1

*NOTES:

        Actually uses (WEIGHT>0) for weights.
        All inputs may be an array, vector or scalar.
          If WEIGHT is a scalar then all points have this weight.
          If WIDTHS is a scalar then all bins have this width.
        The results are printed out if !NOPRINT = 0.
        WCENTER and WIDTHS are recomputed to be the actual values used.
        Typing BINS without parameters will display the procedure call
          statement.
        FLUX and WEIGHT may be specified as arrays so that line-by-line
          type files can binned using weights.

	tested with IDL Version 2.1.0 (sunos sparc)	19 Jun 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
	tested with IDL Version 2.1.0 (vms vax)    	19 Jun 91

*PROCEDURE:

        Treats original data rigorously as binned data. 

*MODIFICATION HISTORY:

   Jan  6 1983 RJP GSFC Modified BINS to allow weights
   Apr 17 1987 RWT GSFC Added PARCHECK, made WEIGHT optional
   May  8 1987 RWT GSFC Fix PARSHIFT
   Jul 23 1987 RWT GSFC Use !NOPRINT to suppress tabular printout 
   Aug 25 1987 RWT GSFC correct calculation of N for scalar WCEN,
                        and add listing of procedure call statement
   Mar  7 1988 CAG GSFC Add VAX RDAF-style prolog
   5-23-88 RWT fix scaling factor error in printout format
   7-28-88 RWT allow FLUX to be an array
   1-17-89 RWT remove recalculation of total weight (IWGT)
   5-16-89 RWT & jtb remove LOOKUP commands, use N_ELEMENTS,
                     and use vector subscripts in TOTAL commands
   sep 13 1989 jtb @gsfc correct calculation of npoints and weights
                         for 'end effects'
   sep 18 1989 jtb @gsfc modifications for unix/sun idl
   apr 23 1990 rwt & jtb correct error for epsilon weighting and
                         improve iwsigma, iwmean, and pwgt calculation
   Jun 19 1991 PJL GSFC  cleaned up; tested on SUN and VAX; updated prolog
   10 Mar 1992 LLT       print out j+1 instead of j (so line numbers for
                         line-by-line files are correct)
    6 Feb 1995 LLT add file, silent, and overwrite keywords.

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bins.pro)


BITLIS

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    BITLIS       AUG. 28, 1989

*CLASS:

    data display

*CATEGORY:

*PURPOSE:  

    To display bit pattern for byte, integer or longword integer scalars or
    vectors.

*CALLING SEQUENCE:

    BITLIS,A,B

*PARAMETERS:

    A   (REQ) (I) (0,1) (B,I,L)
         Input scalar or vector 

    B   (REQ) (O) (1,2) (B)
         Output vector or array of 0's (off) and 1's (on) representing 
         bit patterns of input vector A.

*EXAMPLES:

    a=bindgen(5)
    bitlis,a,b
    print,b
    0 0 0 0 0 0 0 0 0
    1 0 0 0 0 0 0 0 0
    0 1 0 0 0 0 0 0 0
    1 1 0 0 0 0 0 0 0
    0 0 1 0 0 0 0 0 0

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

    PARCHECK
    BITTEST

*FILES USED:

	none

*SIDE EFFECTS:

*RESTRICTIONS:
       Input parameter must be scalar or vector and either
       byte, integer or longword integer data type.

*NOTES:
       When integers are stored in two's complement, the bit pattern
       for negative numbers will be different than for positive numbers.

	tested with IDL Version 2.1.0 (sunos sparc)	- 
	tested with IDL Version 2.1.0 (ultrix mispel)	- 
	tested with IDL Version 2.1.0 (vax vms)		01 Apr 93

*PROCEDURE: 

      BITTEST is called for each bit in the input parameter.
      If the input parameter is a integer vector with N elements, 
      the output parameter will be an array with 16xN elements, with
      the first bit status contained in the first column 0, second bit in
      the second column, etc. A scalar byte value would produce a 8
      element vector.
      Note when the output parameter is displayed, the bit order will be 
      opposite that normally used for displaying bit patterns (i.e., 
      the least significant bit is on the left and the most significant
      is on the right).

*MODIFICATION HISTORY:

        3/30/93 rwt allow byte data

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bitlis.pro)


BITTEST

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    BITTEST       (General IDL Library 01) 30-MAR-83

*CLASS: 

    Utilities

*CATEGORY:

*PURPOSE:

    TO TEST BIT N IN FIX(X)

*CALLING SEQUENCE:

    BITTEST,X,N,YESNO

*PARAMETERS:  

    X      (REQ) (I) (0 1) (I  F)
           X is the variable to be tested
   
    N      (REQ) (I) (0) (I)
           The bit of X to be tested

    YESNO  (REQ) (O) (0 1) (I)
           The result of the test. 1(true) if bit N is set, 0(false)
           otherwise.

*EXAMPLES:

        BITTEST,!X.STYLE,4,YESNO
        IF YESNO THEN PRINT,'X-axis suppressed' $
                 ELSE PRINT,'Draw X-axis'

        To find points in NEWSIPS which are outside calibrated region:
        BITTEST,ABS(NU),1,YESNO             ; look for nu flag = -2
        IND = WHERE (YESNO EQ 0)            ; keep points where yesno = 0
        PLOT,W(IND),F(IND)                  ; plot calibrated points
        
*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT: 

*SUBROUTINES CALLED:

    PARCHECK

*FILES USED:

*SIDE EFFECTS: 

*RESTRICTIONS:

*NOTES:

     Note that negative integers are stored in twos complement form.
     Therefore, the left-most bits are ON rather than OFF as they are for 
     positive numbers. Input the absolute value of X is negative numbers 
     to avoid this problem. 

     This procedure can be used to check the values of complex
     IDL system variables such as ![XYZ].STYLE.

	tested with IDL Version 2.1.0 (sunos sparc)  	19 Jun 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
	tested with IDL Version 2.1.0 (vms vax)      	09 Mar 93
  
*PROCEDURE:

     Checks whether (FIX(X) OR (NOT 2^N)) = -1 to set the output
     flag YESNO.

*MODIFICATION HISTORY:

     Mar  6 1983 RJP GSFC initial program
     Aug 24 1987 RWT GSFC add PARCHECK
     Mar  7 1988 CAG GSFC all VAX RDAF-style prolog
     Jul 13 1990 RWT GSFC Sun mods: use examples pertinent to SUN IDL
                 and add listing of procedure call statement
     Jun 19 1991 PJL GSFC cleaned up; tested on SUN and VAX; updated prolog
     Mar  8 1993 RWT GSFC modify to allow X & YESNO to be vectors and 
                 add documentation about negative numbers.

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bittest.pro)


BLEMISH

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

  BLEMISH     (General IDL Library 01) August 13, 1986

*CLASS: 

    Data Editing

*CATEGORY:

*PURPOSE:  

    To interactively remove blemishes in a flux vector by linear
    interpolation between the flux values on each side of the 
    blemish. (Based on BLEMISH by D. Lindler.)

*CALLING SEQUENCE: 

    BLEMISH,WAVE,FLUX,bsize,FCOR

*PARAMETERS:

    WAVE   (REQ) (I) (1) (F D)
           Required input vector containing the wavelength data associated
           with the FLUX data which are to be edited.

    FLUX   (REQ) (I) (1) (F D)
           Required input vector containing the flux data which are to be
           edited.

    BSIZE  (OPT) (I) (0) (F D)
           Optional input scalar parameter specifying the interval, in the same
           units as WAVE, over which the FLUX data are to be averaged 
           on either side of the blemish, before interpolating across the
           blemish. 

    FCOR   (REQ) (O) (1) (F D)
           Required output vector giving the edited FLUX array.

*EXAMPLES

    To linearly interpolate across a blemish, using the adjacent good 
    data points:
    BLEMISH,WAVE,FLUX,FCOR

    To linearly interpolate across a blemish using an average of the 
    data points within BSIZE wavelength units of the edges of the blemish,
    BLEMISH,WAVE,FLUX,BSIZE,FCOR

*SYSTEM VARIABLES USED:

    !d.name
    !ERR
    !NOPRINT

*INTERACTIVE INPUT:

    Flux versus wavelength is plotted and the user is requested
    to indicate with the verticle cross-hairs the extent of the
    blemish.  The procedure then fills those points within the
    blemish with values interpolated between the endpoints of the
    blemish. 
    This process is repeated until the user types 0 (zero) or presses
    the right mouse button when asked to position the crosshairs.

*SUBROUTINES CALLED:

    BINS
    TABINV
    PARCHECK
    PCHECK

*FILES USED:

*SIDE EFFECTS:

    Aborting the procedure may result in !ERR and !NOPRINT being 
    altered. 
    
*RESTRICTIONS:

    Device Dependent - This procedure requires a terminal equipped 
                       with a graphics cursor.
    (modified to run under unix sun idl version 1.2)

*NOTES:

        Order of specifying endpoints is not important.

	tested with IDL Version 2.1.0 (sunos sparc)  	19 Jun 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
	tested with IDL Version 2.1.0 (vms vax)      	19 Jun 91
 
                
*PROCEDURE: 

    For each pair of positions marked by the user the wavelengths
    at those points are computed by CURSOR. The subscripts
    associated with those wavelengths are computed with TABINV.
    BINS is called to calculate binned flux if BSIZE is specified.
    Let IMIN and IMAX be the pair of subscripts.  For each value
    of I, IMIN < I < IMAX, a new flux is computed for FCOR(I):
         
    FCOR(I) = FCOR(IMIN) + S*(WAVE(I)-WAVE(IMIN))
    where:
    S = (FCOR(IMAX)-FCOR(IMIN)) / (WAVE(IMAX)-WAVE(IMIN))
    or, if BSIZE is specified,
    S = (MEAN(1) - MEAN(0))  / (WC(1) - WC(0))
    where MEAN is the average flux values and WC is the bin center
    positions.

        
*MODIFICATION HISTORY:

                 D. Lindler  GSFC  initial version
    Oct 31 1985  JKF         GSFC  DIDL compatible (indirect compilation)
    Jul 25 1986  CLI         GSFC  add BSIZE parameter to take average flux
                                   on either side of the specified points.
    Aug 13 1986  RWT         GSFC  use N_ELEMENTS and CURSOR commands
    Feb 19 1987  RWT         GSFC  VAX Mods: make BSIZE optional, account
                                   references, @ for #, remove one GOTO
                                   statement and DO loop, improve calculation
                                   of subscripts, allow points to be 
                                   specified in any order.

    Mar 14 1987  RWT         GSFC  add PARCHECK
    May  6 1987  RWT         GSFC  fix error with N_PARAMS(0)=3 mode
    Mar  8 1988  CAG         GSFC  VAX RDAF-style prolog, add disabling
                                   of tabular printout from BINS.
    jan  1 1990  jtb         gsfc  modified for sun/unix idl.
    Jun 19 1991  PJL         GSFC  cleaned up; tested on SUN and VAX;
				    updated prolog

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/blemish.pro)


BOXCAR

[Previous Routine] [Next Routine] [List of Routines]

*NAME:

      boxcar

*CATEGORY:

      NEWSIPS, IUESIPS

*CALLING SEQUENCE:

      BOXCAR,IMAGET,object,bckgd,h,w,g,b,n,f,q,/extended,/small,$
             medianw=medianw,meanw=meanw,expt=expt,/melo,/fits,/chebyshev

*PURPOSE:

      To extract a calibrated single spectrum from a line-by-line file.

*PARAMETERS:

      IMAGET  (req) (i) (0) (s)
              Name of SILO, ELBL, LBLS, or ESSR file to be processed.

      object  (opt) (i) (0,1) (ifldb)
              This should be a two-element vector giving the starting and
              ending line numbers, INCLUSIVE, of the object slit.  To use
              defaults it can be left out, but if you want to use defaults
              and specify the background slit explicitly, you can enter zero.
              You may, if you wish, specify more than two elements, in which
              case they are considered to be the EXACT lines to include in 
              the boxcar (this allows you to exclude lines).  You can also
              specify one non-zero number which will be considered the central
              line of the slit, with a default width depending on the image.

          NOTE:  Line numbers start with ONE!

       bckgd  (opt) (i) (0,1) (ifldb)
              This is normally a four element vector giving the starting and
              ending line numbers, INCLUSIVE, for two background regions.  If
              there are more than four elements, they are considered to be the
              EXACT lines to include.

           h  (opt) (o) (1) (si)
              This will either be a FITS header (SILO file) or the scale
              factor record (IUESIPS files).  If the FITS keyword is set,
              the IUESIPS scale factor record will be converted to a FITS
              header.

           w  (opt) (o) (1) (f)
              Wavelengths.

           g  (opt) (o) (1) (f)
              Gross fluxes in object slit.

           b  (opt) (o) (1) (f)
              Background fluxes.

           n  (opt) (o) (1) (f)
              Net fluxes.

           f  (opt) (o) (1) (f)
              Calibrated fluxes.

           q  (opt) (o) (1) (i)
              Quality flags.  If the input file was IUESIPS, these will be 
              the minimum epsilon values in the object slit.  If the input 
              file was NEWSIPS, these will be coalesced nu flags (from the
              object slit).

    extended  (key) (i) (0) (i)
              If set, the object is assumed to be an extended source.  Default
              is point source. This only matters if you are using default
              values for object slit for IUESIPS data.

       small  (key) (i) (0) (i)
              If set, small aperture is assumed.  Default is large aperture.
              This only matters if you are using defaults for object and/or
              background slits for NEWSIPS data.

     medianw  (key) (i) (0) 
              Median filter width.  Default is 63 for ELBL file, 31 for 
              ESSR files, and 1 for SILO files
              

       meanw  (key) (i) (0)
              Mean filter width.  Default is 31 for ELBL files, 15 for 
              ESSR files, and 1 for SILO files.

   chebyshev  (key) (i) (0)
              If set, no median and mean filtering will be done.  Instead,
              a sixth order Chebyshev polynomial will be fit to the background.

        expt  (key) (i) (0)
              Exposure time in seconds (IUESIPS).  If not given, h(39:41)
              will be used.  Ignored for NEWSIPS (since newcalib uses
              the effective exposure from the input FITS header).

        melo  (key) (i) (0) 
              If input file was IUESIPS, "melo" format output files will
              be written (.DAT and .LAB).  Ignored for NEWSIPS.

        fits  (key) (i) (0)
              Regardless of input file type, a FITS file will be written, with
              filename cam+image.B+ap+F (e.g., swp12345.b1f) where ap will be
              1 for the large aperture and 2 for the small aperture.  The H
              parameter returned will be the FITS header.  Note that, for 
              IUESIPS data, if there are entries missing from the scale factor
              record, the user may be prompted for such things as exposure 
              times, THDA values, etc, since the full range of corrections
              (as done by IUESPEC) will be done.


*EXAMPLES:

      Extract a SILO file with default slit dimensions (but without background 
      smoothing):
               boxcar,'swp1234.silo',0,0,h,w,g,b,n,f,q

      Same as above but use a 6th-order chebyshev fit to background and
      write results to a FITS file:
               boxcar,'swp1234.silo',0,0,h,w,g,b,n,f,q,/chebyshev,/fits

      Change object (i.e., gross) slit length to extract lines 41 to 53 
      (instead of default lines 45 to 57):
               boxcar,'swp1234.silo',[41,53,0,h,w,g,b,n,f,q

      extract an iuesips file and output a melo-like file using an exposure
      time of 28,400 seconds:
               boxcar,'swp1234llg',0,0,h,w,g,b,n,f,q,/melo,expt=28400
  

*FILES USED:

      IMAGET:  SILO, ELBL, LBLS, or ESSR file to extract data from.  SILO
               files are the NEWSIPS line-by-line files; the others are from
               various incarnations of IUESIPS.  Generally, ELBL files have
               110 lines and LBLS/ESSR have 55.  ESSR files have half as
               many samples as the others in addition to only having 55 lines.
               IUESIPS files are expected to be in RDAF (.dat and .lab) format.

*SUBROUTINES CALLED:

      parcheck   (checks for proper number of parameters in calling sequence)
      decompose  (separate file name into components)
      chkfits    (tests to see if input file is in FITS format)
      within     (tests to see if values are in range)
      readfile   (reads IUESIPS data files)
      readsi     (reads NEWSIPS data files)
      calib      (Absolute calibration---IUESIPS data)
      newcalib   (Absolute calibration---NEWSIPS data)
      stpar      (get FITS keyword---NEWSIPS data)
      addpar     (add keyword to FITS header)
      iuedaf     (create "iuedac" section in FITS header)
      copuf      (copies input .lab file to output .lab file without spawning)

    The following is used if the CHEBYSHEV keyword is set:

      bfit       (fits background with sixth order Chebyshev polynomial)

    The following are used if the FITS keyword is set:

      ifitswrt   (write output file)
      intime     (get exposure time---IUESIPS data)
      lti        (set THDA correction flag---IUESIPS data)
      tempcor    (THDA correction---IUESIPS data)
      sdc        (set LWR sensitivity degradation flag---IUESIPS data)
      keygen     (convert scale factor record to FITS keywords---IUESIPS data)
      fitslab    (convert VICAR label to FITS keywords---IUESIPS data)

    The following are used if the MELO keyword is set (IUESIPS data):

      labmod     (add line to bottom of .lab file)
      scaling    (get j,k,r scaling factors)

*NOTES:

               Default centers, slits, widths, and filters:

                                  SLITS            WIDTHS DISTANCE*
 File  Aperture Source   Cen Object   Background   Ob  Bk  c-c c-e  Median Mean
 
 SILO   Small             25 [19,31] [11,17,33,39] 13   7        8
 SILO   Large   point     51 [45,57] [32,38,64,70] 13   7       13     1   1 ?
 SILO   Large   extended  51 [40,63] [32,38,64,70] 23   7       13

 ELBL   Small             55 [47,64] [35,44,67,76] 18  10   16         63   31
 ELBL   Large   point     54 [47,64] [29,38,73,82] 18  10   22         63   31
 ELBL   Large   extended  54 [41,70] [29,38,73,82] 30  10   22         63   31

 LBLS   Small             28 [24,32] [18,22,34,38]  9   5    8         63   31
 LBLS   Large   point     28 [24,32] [15,19,37,41]  9   5   11         63   31
 LBLS   Large   extended  28 [21,35] [15,19,37,41] 15   5   11         63   31

 ESSR   Small             28 [24,32] [18,22,34,38]  9   5    8         31   15
 ESSR   Large   point     28 [24,32] [15,19,37,41]  9   5   11         31   15
 ESSR   Large   extended  28 [21,35] [15,19,37,41] 15   5   11         31   15
     
     NOTE:   Line numbers start with ONE!!!!

    *Distances:  Center-to-center (center of object to center of background)
                 is given for IUESIPS files.  Center-to-edge (center of object
                 to edge of background) is given for SILO files.

     Slits for SILO files are based on the assumed regions that SWET 
     (Signal Weighted Extraction Technique) uses when the MXLO file is
     created.  Slits for ELBL/LBLS/ESSR files are based on the defaults
     used in the older program EXMELO.  Median and Mean filters are based
     on those used by EXMELO (note that ESSR files have fewer 
     samples and therefore they have smaller filter values).

          File Types:
                                       Goddard               VILSPA
     File  SIPS   #Lines #Samples   Start      End       Start     End

     SILO NEWSIPS    80    <640      
     ELBL IUESIPS   110   <1022    01-Oct-85  present
     LBLS IUESIPS    55   <1022    04-Nov-80 01-Oct-85 
     ESSR IUESIPS    55    <600    22-May-78 04-Nov-80 14-Jun-78 10-Mar-81
          IUESIPS    32    <600    03-Apr-78 22-May-78 17-Apr-78 14-Jun-78
     
     Dates for ESSR files (and before) taken from Turnrose, Thompson, & Gass,
     IUE NASA Newsletter #25.

*PROCEDURE:

     First some preliminary checking is done on the file.  If no extension
     was given, the default is assumed to be .DAT (i.e., IUESIPS data file).
     But nevertheless the file will be checked to see whether it is in FITS
     format or not; if so, it is assumed to be a NEWSIPS SILO file.  The file
     is then read.

     If the OBJECT parameter has two elements, they are considered to be the
     starting and ending lines (inclusive) and an array containing the line
     numbers is created.  If OBJECT has more than two elements, OBJECT will
     be used directly as the array containing the line numbers to use.  If
     OBJECT has one parameter, it is considered to be a central line number,
     and a slit is assigned based on the width given in the table given in the
     NOTES section of this prolog.  If OBJECT is zero, then the center line in
     the table and the slit are used.

     The resulting array of line numbers is checked to make sure it is in
     range (based on the number of lines in the file).  Then, the gross flux
     and quality flag vectors are computed.  Lines given by the line number
     array are added up (fluxes) to generate the gross flux.  For IUESIPS,
     the worst quality flags are kept.  For NEWSIPS, all quality flags at a
     given sample are coalesced with logical OR.

     If bckgd has one element, defaults based on the center lines and the
     values given in the table are used.  If bckgd has two elements, they
     are considered to be the central lines of two regions with widths given
     in the table.  If bckgd has four elements, they are considered to be the
     starting and ending line numbers, inclusive, of two background regions.

     An array of line numbers will be generated, and this will be tested to 
     see if all lines are in range, and do not overlap with the object slit.
     If all is well, all specified lines will be added (where their quality
     flags are non-negative) and the resulting array divided by an array which
     contains the number of samples (non-negative flags) which were included.

     If the filter keywords were not set, defaults (as given in the table) are
     used.  A copy of the background array is padded on both ends so that the
     number of elements is increased by twice the value of the largest filter.
     (This is from EXMELO.)  This is smoothed first with a median filter and
     then twice more with a mean filter and subtracted from the gross fluxes
     to get the net fluxes.

     If the CHEBYSHEV keyword is set, no median or mean filtering is done---
     instead, subroutine BFIT is used to fit the background with a Chebyshev
     polynomial (sixth order).  Background lines on either side of the object
     region (defined by the first and last object lines) constitute the two
     background swaths (whether or not the actual background lines in each
     swath are contiguous).

     For NEWSIPS, the FITS header is updated and NEWCALIB is run on a copy of
     the net fluxes to produce calibrated fluxes.

*MODIFICATION HISTORY:

       Written by LLT summer 1994.
        2 Dec 94 LLT fix error in center index (NEWSIPS large aperture)
        6 Mar 95 RWT define center if nob = 2 or > 2, fix aperture test,
                     use string(ap) in file name, add spaces in keyword
                     comments, list median and mean filter widths for
                     SILO files as 1, output filtered (not unsmoothed)
                     background fluxes, and replace spawns with call to
                     copuf

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/boxcar.pro)


BSPOT

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

     	BSPOT       (RDAF General Production Library)      Jan 30, l983
 
*CLASS:

     	Data Editing

*CATEGORY:

       IUESIPS         NEWSIPS

*PURPOSE:  

    	To interactively flag or linearly interpolate over bright spots or
       cosmic ray hits in an IUESIPS LBLS or NEWSIPS SILO file so that the
       background is not contaminated and on-order hits will be flagged in
       low dispersion spectra.
 
*CALLING SEQUENCE:    

    	BSPOT,IMAGI,IMAGO,mode
 
*PARAMETERS:

    	IMAGI  	(REQ) (I) (1) (S)
           	For IUESIPS:  Input LBLS (or ELBL) file specified as a string
               (e.g. 'swp7654s').
               For NEWSIPS:  Input SILO file specified as a string (e.g.,
               'swp17549.silo').

    	IMAGO  	(REQ) (O) (1) (S)
           	Output file name for modified IUESIPS LBLS or NEWSIPS-like SILO
               file.  If specified as a string, the input file will be copied
               into a new file which BSPOT can then modify.

               For IUESIPS, user flagged points are given an EPS value of
               -325, and interpolated points are assigned an EPS of -210.

               For NEWSIPS, user flagged and interpolated points are assigned
               a nu flag with bit 6 (-32) set (in addition to the NEWSIPS nu
               flags that were set).

               - for VMS implementation -
            	If specified as a blank (i.e. ' ') or 0, output file will
               have same name as IMAGI with version number incremented.  

               - for Unix implementation -
            	If specified as a blank (i.e. ' ') or 0, output file is 
               created with same name as input file (replacing previous 
               version).

     	MODE   	(OPT) (I) (0) (I)
            	Determines type of interpolation to be used when user selects
               interpolation.  If not specified, MODE is set to 0.  The
               following values are allowed:
              	   0 - the interpolation step is performed using the nearest
                      good points (i.e. those just above and below the
                      endpoints specified by the x-coordinate of the verticle
                      crosshair). 
                 >0 - the flux values used in the interpolation are taken to
                      be the y-coordinates of the horizontal crosshair at the
                      user specified interpolation limits.
                 >1 - IUEPLOT/NSPLOT is called to display the modified line of
                      the LBLS/SILO file. Since each blemish is displayed
                      individually, this step is not necessary.  A 10 second
                      pause is issued before the IUEPLOT/NSPLOT figure is
                      erased, and the user is prompted for the next line.

*EXAMPLES:

       (Optional parameter Mode default is 0)


       For IUESIPS:

          bspot,'swp7654s','ssss'    ; swp7654s is copied into the file 'ssss'
                                     ; and all BSPOT corrections are made to
                                     ; ssss.
 
          bspot,'swp7654s',' '       ; swp7654s is copied into a new file with
               or                    ; the same name (and the version number
          bspot,'swp7654s',0         ; incremented - on VMS systems) and all
                                     ; BSPOT changes are made to this file.
 

	For NEWSIPS:

          bspot,'swp17549.silo','ssss'   ; swp17549.silo is copied into the
                                         ; file 'ssss.silo' and all BSPOT
                                         ; corrections are made to ssss.silo.
 
          bspot,'swp17549.silo',' '      ; All BSPOT changes are written to
                  or                     ; new versions of swp17549.silo.  On
          bspot,'swp17549.silo',0        ; VMS systems, the version number is
                                         ; incremented.
 
*SYSTEM VARIABLES USED:

       !d.name
       !stime

*INTERACTIVE INPUT:

    	User is prompted for the following:
      	   - line number to be edited, or 0 to exit,
      	   - cursor position of each blemish to be flagged,
      	   - cursor positions of endpoints of region to be flagged, or cursor
            positions of region to have user-specified flags removed, or
            cursor positions of region to have ALL flags removed, or cursor
            positions of region to interpolate over, or C to continue, or 0 to
            exit procedure.
      	   - 0 to continue, 1 to redisplay last plot with changes removed, or 2
            to redisplay last plot with all changes included,
          - new line number, or 0 to exit.
 
*SUBROUTINES CALLED:

       IUEFTYPE
    	IUEPLOT
       NSPLOT
    	READFILE
       READSI
       ADDPAR
       STPAR
    	TABINV
    	PARCHECK
    	COPUF
    	GETBLEMW
    	FLAGBLEM 
    	BS_UPDATE

*FILES USED:

     	IMAGI  	(I) 
          Input/output IUESIPS LBLS or NEWSIPS SILO file (output file only if
          specified by user).

     	IMAGET 	(O)
          Output IUESIPS LBLS or NEWSIPS-like SILO file.

*SIDE EFFECTS:

       For VMS systems, BSPOT creates a new file each time the information 
       is saved. There will possibly be mutiple copies of similar files
       just with different version numbers.  On Unix systems, the file is
       overwritten.

*RESTRICTIONS:

       - only for use with tektronix style plot device (!d.name = 'TEK')

*NOTES:

     	1) For IUESIPS, the file is edited one line at a time, and updated each
          time a line is modified.  For NEWSIPS, a file is written after each
          line is modified.  This means that the procedure can be exited
          without losing any modifications made to previously modified lines.
          If the routine is exited during the prompt for flagging endpoints of
          a blemish however, the changes in that particular line will not be
          saved.
     	2) If the system crashes while the file is open, the file may not be
          recoverable.
     	3) BSPOT flags or unflags regions of pixels by having the user input
          the cursor postions of the endpoints.  The endpoints specified are
          INCLUDED in the pixels to be flagged.
     	4) For IUESIPS, BSPOT flags bad points by setting epsilons > 0 to -325.
          Interpolated points are assigned epsilons values of -210.  Both flag
          are removed by replacing epsilons with a value of 100 in the X mode.
          In the R mode, epsilons less than zero are given the value
          abs(eps)/10.
          For NEWSIPS, BSPOT flags bad points and interpolated points by
          setting bit 6 (-32) of the nu flag.  The nu flag is removed by
          unsetting bit 6 of the nu flag in the X mode.  In the R mode, nu
          flags less that zero are given the value 0.
   	   NOTE that in the R MODE, the ORIGINAL IUESIPS or NEWSIPS FLAGGING is
          REMOVED AND is NOT EASILY RECOVERABLE.
       5) The user should identify the bright spots from inspection of the
          display of the IUESIPS LBLS or NEWSIPS SILO data.  See SRPLOT for
          display.

*PROCEDURE:

     	For IUESIPS, BSPOT first reads the IUESIPS line-by-line input file into
       memory using READFILE.  BSPOT checks the IMAGO parameter to decide
       whether a new LBLS file is to be created or whether the modifications
       are to be made directly to the input file.  If IMAGO is specified as a
       string, new .DAT and .LAB files are created from the input IMAGI files.
       The type of file (i.e. LBLS or ELBL) is determined from the header
     	and is used to determine the range of allowed line numbers.  The user
       is prompted for the line number (i.e. order) in the LBLS file to be
       edited.  The appropriate line is extracted from the file and displayed. 

       For NEWSIPS, BSPOT first reads the NEWSIPS resampled image (SILO) input
       file into memory using READSI.  The filename for the output file is
       determined.  The range of allowed line numbers is determined from the
       fits header.  The user is prompted for the line number of the SILO
       image to be edited.  The appropriate line is displayed. 

       The user is then asked to position the cursor on each blemish in the
       line which he wishes to examine (up to 10 blemishes can be specified
       per order).
	
       BSPOT then plots an expanded region (i.e. 50 points) centered 
       about each of the selected hits.  For each region, the user can either
      	   1) flag a range of pixels by positioning the cursor at the 
             left-most and right-most points to be flagged,
          2) type 0 to exit routine,
          3) type C to go on to next blemish or line to be examined,
          4) type X to undue users flagging between (& including) endpoints
          5) type R to remove ALL flagging between (& including) endpoints, or
          6) type I to linearly interpolate over the specified region.

    	After the above prompt, the new IUESIPS epsilon flags or NEWSIPS nu
       flags are displayed and the user is asked to type 0 to continue, 1 to
       redisplay the expanded region with all changes removed, or 2 to
       redisplay region keeping all changes.

    	After all the specified blemishes for the current line have been
    	displayed, BSPOT displays the entire line (IF MODE > 1).  For IUESIPS, 
       the output file is modified if any changes were made by the user.  For
       NEWSIPS, a new fits file is written if any changes were made by the
       user.  The program continues by prompting the user for either the next
       line number to edit, or 0 to exit.

*I_HELP nn:

*MODIFICATION HISTORY:

     	Programmer: R.J. Panek 30-Jan-1983
     	8-2-85 GAR allow user to not flag points after choosing a
            	wavelength
     	6-13-85 RWT compress code, replace IUEIM with HSWATH, replace
            	READCRS with TEKDATA, reformat main routine, test user
            	input after 1st cursor read, add R option, add DECOMPOSE, 
            	position cursor ON blemish (not outside blemish)
     	6-19-85 RWT add subroutine INOUT, rewrite DOC file
     	6-24-85 RWT delete subroutines DELFLAG & ADDFLAG and simplify
            	coding of user-specified epsilon flags.
    	10-22-85 RWT DIDL changes (i.e., use #, NELEMENTS, and new INDGEN)
            	and truncate EPS values at 100 rather than 1
     	6-25-86 RWT & JKF modify for ELBL files, use SETXY, replace TEKDATA
            	with new CURSOR command, allow interpolation of bad points,
            	and flag interpolated points with EPS = -210.
    	12-29-86 RWT VAX mods: use !MODE for !VAR5, SET_XY for SETXY, use
                READFILE, and remove HSWATH & GETNLS.
     	4-13-87 RWT add PARCHECK, axes titles, remove INSERT and EXTRACT 
               commands
     	6-22-87 RWT remove redundant reextraction of W, F, and E arrays
               and fix location of user prompts
     	8-25-87 RWT use GET_LUN, add optional parameter MODE to replace
            	!MODE, and allow procedure call listing
     	1-28-88 RWT display correct order and write corrected line into
            	correct record of output file
     	2-23-88 RWT separate (& rename) subroutines
     	3-09-88 HAA add RDAF Prolog
       jan-10-90 jtb @gsfc modified for unix / sun idl
	jul-22-91 pjl @gsfc cleaned up; tested on SUN and VAX; updated prolog
       aug-23-91 jg  corrected prolog
       nov-22-91 pjl corrected typo in ne 'tek' message
         7-22-92 LLT check size of IEPS vector to avoid oplot of nonexistant
                     epsilon vectors.
       apr-06-94 PJL added NEWSIPS compatibility including IUEFTYPE and
                     NSPLOT; removed 'goto'; updated prolog
       mar-02-95 RWT replace bs_inout with copuf, remove capability to
                     overwrite vms iuesips files, move writesi from
                     bs_update to main routine (so newsips file is updated 
                     once, not once for each line), and call new writesi
                     with scale option.
       

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bspot.pro)


BS_FLAG

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

     	BS_FLAG        (RDAF General Production Library)        JUNE 18, 1985
 
*CLASS:

       Data Editing

*CATEGORY:

       IUESIPS         NEWSIPS

*PURPOSE:  

     	Sets IUESIPS epsilon flags or NEWSIPS nu flags and/or interpolates over
       blemish when called by FLAGBLEM.
 
*CALLING SEQUENCE:

       BS_FLAG,WAVE,FLUX,EPS,INX,NFLAG,MODE,ER1,NEWSIPS

*PARAMETERS:

     	WAVE	(REQ) (I) (1) (R)
            	Wavelength vector in Angstroms.

       FLUX  	(REQ) (I) (1) (R)
            	The slit-integrated flux vector.

       EPS   	(REQ) (I) (1) (R)
            	For IUESIPS, the epsilon vector quality flags to mark
               questionable data at each wavelength.  For NEWSIPS, the nu
               flags.
        
   	INX   	(REQ) (I) (1) (R)
            	Expanded window around blemished region.

   	NFLAG 	(REQ) (I) (0) (I)
            	Determine if any user flagging was performed.

   	MODE  	(REQ) (I) (0) (I)
            	Used to key interpolation step:
                  0 = use nearest good data points for interpolation.
                  1 = use cursor (horizontal) to set flux level.

   	ER1  	(REQ) (O) (0) (L)
            	Checks !err in program to determine error flags.

       NEWSIPS (REQ) (I) (0) (I)
               Equals 0 for IUESIPS data.  Equals 1 for NEWSIPS data.

*EXAMPLES:

     	See documentation for BSPOT.PRO.    

*SYSTEM VARIABLES USED:

     	!err	-   !err = 48, then exits program immediately
		-   !err not equal 67 or not equal to 99 (C not hit)
		         then the program runs

*INTERACTIVE INPUT:

    	Positioning of cursor - see documentation for BSPOT.PRO 
 
*SUBROUTINES CALLED:

	PARCHECK
     	TABINV

*FILES USED: 

     	Those established by BSPOT.PRO

*SIDE EFFECTS:

*NOTES:

     	MODE -  used to key interpolation step:
          0 = use nearest good data points for interpolation.
          1 = use cursor (horizontal) to set flux level.

       For IUESIPS, an eps is set to -210 for a user flagged point and -325
       for linear interpolation.

       For NEWSIPS, a nu flag is set to -32 (bit 6).

*PROCEDURE:

     	User's input (screen positions and/or character) are read, the
     	subscripts for the area specified are computed, user flagging is
     	deleted if user typed X, linear interpolation over bad regions 
     	performed using nearest good points (MODE = 0) or cursor Y positions
     	(MODE = non-zero), and data quality EPS vector updated.

*I_HELP nn:

*MODIFICATION HISTORY:

     	30-Jan-83   Programmer R.J. Panek
     	26-Apr-88   HAA add RDAF Prolog
       jan-10-90 jtb @gsfc modified for unix / sun idl version 1.2
	jul-22-91 pjl @gsfc cleaned up; added npar equals 0 print and
			    PARCHECK; tested on SUN and VAX; updated prolog
     	See BSPOT.PRO modification history for futher details     
        6 Apr 94  PJL  added newsips parameter

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bs_flag.pro)


BS_INOUT

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

      	BS_INOUT       (RDAF General Production Library)     Jan 30, 1983
 
*CLASS: 

      	Data Editing

*CATEGORY:

       IUESIPS         NEWSIPS

*PURPOSE:  

      	Create an output IUESIPS LBLS or NEWSIPS-like SILO disk file based on
       the input parameters, IMAGI and IMAGO when called by BSPOT.PRO
 
*CALLING SEQUENCE:

      	BS_INOUT,IMAGI,IMAGO,IMAGET,NEWSIPS

*PARAMETERS:

      	IMAGI   (REQ) (I) (1) (S)
               Input LBLS (or ELBL) file specified as a string.
 
      	IMAGO  	(REQ) (I) (1) (S)
           	Any String  - Becomes name of output disk file and IMAGI is
                             copied into IMAGO.
           	' ' (blank) - On vms, output file has same name as input file 
                             with version number incremented and IMAGI is 
                             copied into it. On unix, same as 0 below.
               0   - write over input file.

      	IMAGET  (REQ) (O) (1) (S)
               Name of output file.

       NEWSIPS (REQ) (I) (0) (I)
               Equals 0 for IUESIPS data.  Equals 1 for NEWSIPS data.

*EXAMPLES:

      	See BSPOT.PRO prolog.

*SYSTEM VARIABLES USED:    

       none
 
*INTERACTIVE INPUT:

       If the output file already exists (and is not the input file), the user
       will be asked if they wish to continue.

*SUBROUTINES CALLED:

	PARCHECK
      	DECOMPOSE      
       YESNO
	PLATFORM

*FILES USED:

      	IMAGI   (I)
          	Input required IUESIPS LBLS or NEWSIPS SILO disk file.

      	IMAGO   (O)
          	Output disk file.

      	IMAGET  (O)
          	Output disk file.

*SIDE EFFECTS:

      	Note the option that input file may be written over.  (See Parameter
       List.)

*NOTES:

*PROCEDURE:

      	IMAGI input IUESIPS LBLS or NEWSIPS SILO file is either copied into
       IMAGO, or copied into output file of same name but version number (VMS
       only) incremented, or is written over depending upon value of input
       parameter IMAGI as entered by the user.  (See Parameter List.)

*I_HELP nn:

*MODIFICATION HISTORY:

      	30-JAN-83 written by R.J. Panek
      	10-MAR-88 HAA add RDAF Prolog
       jan-10-90 jtb @gsfc modified for unix / sun idl version 1.2
       4-10-91 KBC spawn correct system call based on operating system type
                   for compatibility on SUN/VAX/DEC
	7-22-91 PJL cleaned up; added npar equal 0 print and PARCHECK;
		    tested on SUN and VAX; updated prolog
       7-28-92 RWT correct error for imago=` ' for vms systems
        4 Mar 94  PJL  added NEWSIPS are required parameter; added YESNO
       29 Apr 94  PJL  set imaget equal to imago if no additions needed
	 8 Jun 94  PJL  replaced !version with PLATFORM
       11 Oct 94  PJL  add code for ncopy = 'NA'
       29 Jan 95  REB  corrected error with imago=0, will now overwrite
                       imagi as stated in documentaion
       10 Feb 95  REB  NEWSIPS section: corrected imago=0 problem
                       and made the imput extension the output extension

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bs_inout.pro)


BS_PLOTFLAG

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    	BS_PLOTFLAG     (RDAF General Production Library)    Jan 30, l983

*CLASS: 

    	Data Editing

*CATEGORY:

	IUESIPS          NEWSIPS
    
*PURPOSE:

    	Overplot IUESIPS or NEWSIPS flagged data, overplot flagged interpolated
       data, and overplot user flagged data when called indirectly by BSPOT
    	through a call from FLAGBLEM.

*CALLING SEQUENCE:

    	BS_PLOTFLAG,WAVE,FLUX,EPS,NEWSIPS

*PARAMETERS:

    	WAVE 	(REQ) (I) (1) (R)
           	Input wavelength vector in Angstroms from input IUESIPS LBLS or
               NEWSIPS SILO file originally read by BSPOT and then passed into
               FLAGBLEM.

    	FLUX 	(REQ) (I) (1) (R)
           	Input flux vector obtained from input IUESIPS LBLS or NEWSIPS
               SILO file as above WAVE vector.

    	EPS  	(REQ) (I) (1) (R)
           	Input IUESIPS epsilon vector quality flags or NEWSIPS nu flags
               to mark questionable data at each wavelength obtained from
               input IUESIPS LBLS or NEWSIPS SILO file as above FLUX vector.

       NEWSIPS (REQ) (I) (0) (I)
               Equals 0 for IUESIPS data.  Equals 1 for NEWSIPS data.

*EXAMPLES:

    	See BSPOT.PRO

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

    	See BSPOT.PRO

*SUBROUTINES CALLED:

	PARCHECK

*FILES USED:

*SIDE EFFECTS:

*NOTES:

    	See BSPOT.PRO

*PROCEDURE:    

*I_HELP nn:

*MODIFICATION HISTORY:

    	27-APR-88  HAA add RDAF Prolog
       jan-10-90 jtb @gsfc modified for unix / sun idl version 1.2
	jul-22-91 pjl @gsfc cleaned up; added npar equal 0 and PARCHECK;
			    tested on SUN and VAX; updated prolog
        6 Apr 94  PJL  added newsips parameter

(See /host/bluemoon/usr2/idllib/iuedac/iuelib/pro/bs_plotflag.pro)


BS_UPDATE

[Previous Routine] [Next Routine] [List of Routines]
*NAME:

    	BS_UPDATE            (RDAF Production Library)       June 18, l985
 
*CLASS:

    	Data Editing

*CATEGORY:

	IUESIPS         NEWSIPS
    
*PURPOSE:  

    	For IUESIPS, updates IMAGET output file with corrected data for line
       when called by BSPOT.

       For NEWSIPS, writes IMAGET output file with corrected data for line
       when called by BSPOT.
 
*CALLING SEQUENCE:

     	BS_UPDATE,IMAGET,FLUX,EPS,LINE,NLS,header,wave,fimage,eimage

*PARAMETERS:

    	IMAGET  (REQ) (I/O) (1) (S)
        	Output file name for modified IUESIPS LBLS or NEWSIPS-like
               SILO file.

    	FLUX    (REQ) (I) (1) (R)
        	Modified input flux vector obtained from BSPOT to be updated
               in the IUESIPS LBLS imaget file or written in the NEWSIPS-like
               SILO imaget file.

    	EPS     (REQ) (I) (1) (R)
        	For IUESIPS, modified input IUESIPS epsilon vector obtained
               from BSPOT to be updated in the IUESIPS LBLS imaget file.
               For NEWSIPS, modified input IUESIPS epsilon vector obtained
               from BSPOT to be written in the NEWSIPS-like SILO imaget file.

    	LINE    (REQ) (I) (0) (I)
        	For IUESIPS, line number in IUESIPS LBLS file to be edited.
               For NEWSIPS, line number that was modified.

    	NLS     (REQ) (I) (0) (I)
        	Total number of lines in IUESIPS LBLS or NEWSIPS SILO file able
               to be modified.  Used as a check on the value of the LINE
               parameter.

	HEADER	(OPT) (I/O) (1) (S)
		Not for use with IUESIPS data.  Required for NEWSIPS data.
               The main fits header.

       WAVE    (OPT) (I) (1) (R)
               Not for use with IUESIPS data.  Required for NEWSIPS data.
               The wavelength vector.

       FIMAGE  (OPT) (I/O) (2) (R)
               Not for use with IUESIPS data.  Required for NEWSIPS data.
               The image array