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.

       EIMAGE  (OPT) (I/O) (2) (R)
               Not for use with IUESIPS data.  Required for NEWSIPS data.
               The nu flags array.

*EXAMPLES:

    	See BSPOT.PRO

*SYSTEM VARIABLES USED:

       none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
       ADDPAR
       WRITESI

*FILES USED:

     	IMAGET (I/O)    
        	Output IUESIPS LBLS or NEWSIPS SILO file.

*SIDE EFFECTS:

     	See BSPOT.PRO documentation

*NOTES:

	See BSPOT.PRO documentation

*PROCEDURE:

     	For IUESIPS, the IMAGET file is opened and for each line to be updated
       the modified flux and epsilon vectors are inserted.

       For NEWSIPS, a new file is written via the procedure WRITESI.

*I_HELP nn:

*MODIFICATION HISTORY:

     	29-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
        6 Apr 94  PJL  added NEWSIPS compatibility (included header and wave
                       parameters and procedures ADDPAR and WRITESI)
        7 Apr 94  PJL  added fimage and eimage parameters for NEWSIPS
        2 Feb 95  RWT  remove writesi command (add to end of BSPOT)

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


CALIB

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

    	CALIB        (RDAF General Production Library)         JUNE 8, 1981

*CLASS:

    	Spectral Calibration

*CATEGORY:

	IUESIPS

*PURPOSE:  

    	To apply an absolute calibration to IUE low and high dispersion
    	spectral data and the LWR sensitivity degradation correction
    	to IUE low dispersion data only.

*CALLING SEQUENCE:    

    	CALIB,H,WAVE,FNET,EXPS,FABS
 
*PARAMETERS:

        H     	(REQ) (I) (1) (L)
        	Spectral header record.

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

        FNET   (REQ) (I) (1) (R)
        	Net flux in IUE flux units.

        EXPS   (REQ) (I) (1) (R)
        	Exposure time in seconds.
          	If EXPS <= 0 then the total flux in absolute units is 
          	returned in the output FABS (i.e. FABS=FNET*SINV).
         
        FABS 	(REQ) (O) (1) (R)
        	Flux in erg/sec/cm2/A.
         
*EXAMPLES:

*SYSTEM VARIABLES USED:

	!iuer (.dat and .inf)

*INTERACTIVE INPUT:

      	None.

*SUBROUTINES CALLED:

    	PARCHECK
	IFITSRD
    	QUADTERP 
    	SENSCOR

*FILES USED:

    	!iuer.DAT IUECAL.FIT   (I)
    	Data set containing the absolute flux calibration tables.
	See !iuer.INF IUECAL.INF for more information.

    	!iuer.DAT IUECAL2.FIT  (I)   (no longer used)
    	File as above containing LWP data appropriate for LWP ITF file #2.
	See !iuer.INF IUECAL2.INF for more information.

	!iuer.DAT IUECAL3.FIT  (I)
	File as above containing the new high dispersion C values as
	implemented in IUESIPS on 12/22/90 (replaces IUECAL2).
	See !iuer.INF IUECAL3.INF for more information.

    	!iuer.DAT DEGRAD.FIT   (I)
    	Data set containing the sensitivity degradation tables (currently 
	only LWR).  See !iuer.INF DEGRAD.INF for more information.
         
*SIDE EFFECTS:

*RESTRICTIONS:

	This procedure should only be used with IUESIPS data.

*NOTES:

       Tables containing the inverse sensitivity function are available
	for LWP, LWR and SWP low dispersion and high dispersion.  The values
	stored for both SWR dispersions are set to 1.0.  The actual values
	used and the references are listed in the CALIB.INF file stored in
	!iuer.INF.  Information on the sensitivity degradation tables is
	listed in !iuer.INF DEGRAD.INF.  Currently only LWR low dispersion
	images are corrected for sensitivity degradation.

	Header record element 90 is used to flag absolute calibration.  
	Uncalibrated data has h(90) = 0.  For low dispersion calibrated data
	h(90) = 1.  High dispersion calibrated data is either 10, for data
	calibrated with prelimimary C values, or 11, for data calibrated
	using C values implemented in IUESIPS on 12/22/90.

*PROCEDURE:

	The inverse sensitivity table is read from IUECAL3.FIT (or
	IUECAL.FIT) for the camera specified in the header record, and,
	if the header record specifies a low dispersion LWR image , the 
    	sensitivity degradation table is read from !iuer.DAT DEGRAD.FIT.
    	The two arrays are multiplied together and the corrected fluxes 
    	for each wavelength are computed using quadratic interpolation in
	the log of the convolved function.  The absolute flux in
	erg/sec/cm2/A is computed by:
                
           fabs = (inverse sens. * sens. degrad.) * fnet/(exposure time)

I_HELP nn

*MODIFICATION HISTORY:

    	VERSION 1 BY SALLY HEAP      25 FEB 1981
    	VERSION 2 BY SALLY HEAP      8 JUNE 1981
    	    INCORPORATES HIGH DISPERSION CALIBRATION
    	    OF CASTELLA ET AL.  PUTS EXPOSURE TIME INTO HEADER
    	VERSION 3 20-Oct-1981 by F.H. Schiffer 3rd
    	    Eliminate extra points from WTAB and STAB before
    	    interpolating
    	    Round exposure time to nearest 1/2 Millisecond
    	    Return total flux for EXPS <= 0.
    	VERSION 4 15-Dec-1981 by F.H. Schiffer 3rd
    	    Correct for station id in camera number.
    	VERSION 5 12-12-84 RWT leave H(90) = 0 until LWP high dispersion
    	    calibration is adopted.
    	VERSION 6 4-19-85 RWT use new IUECAL.DAT file and use bytes
    	    per record to determine old or new processing
    	    11-1-85 RWT modify for DIDL (i.e. use # & remove REORDER)
    	    11-26-85 RWT add LWP high dispersion inverse sensitivity
    	    function based on Cassatella (private communication, 1985).
    	VERSION 7 5-14-86 RWT add subroutine SENSCOR for sensitivity
    	    degradation correction.
    	4-13-87 RWT VAX mods: add PARCHECK
    	8-11-87 RWT use GET_LUN & FREE_LUN, and make SENSCOR a separate routine
    	    and move IUECAL to !iuer.PRODROOT:[DAT]
    	1-6-88 RWT use IUECAL2.DAT file for new LWP ITF and add 
    	           procedure call listing
    	5-10-88 HAA add RDAF Prolog
       7-17-89 RWT mod. for SUN IDL
	3-04-91 PJL use IUECAL3.DAT file (replaces IUECAL2.DAT); updated
		prolog; modified to lowercase
       4-10-91 KBC modify filename structure based on operating system type
                   for compatibility on SUN/DEC/VAX
      23July91 LLT new logicals; tested on VAX
      23July91 PJL cleaned up; tested on SUN; updated prolog
	 5 Nov 93  PJL	changed IUECAL.DAT, IUECAL2.DAT, and IUECAL3.DAT to
			fits format - IUECAL.FIT, IUECAL2.FIT, and IUECAL3.FIT;
			added IFITSRD
        2 Sep 94  LLT  replace environment variables with !iuer structure

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


CAMTRACE

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

    	CAMTRACE     (RDAF General Production Library)       January 28, 1987
  
*CLASS:

	Graphics
  
*CATEGORY:
  
*PURPOSE:

    	Set up default tracings for large or small aperture spectra when called
       by MISDAT.
  
*CALLING SEQUENCE:

    	CAMTRACE,NC,APNAME
  
*PARAMETERS:

    	NC      (REQ) (I) (1) (I)
    		Camera number, i.e. for LWP = 1, LWR = 2, and SWP = 3.

    	APNAME  (REQ) (I) (1) (S)
    		Aperture type, i.e. 'LARGE'.
  
*EXAMPLES:

    	camtrace,2,'large'

*SYSTEM VARIABLES USED:

	None.
   
*INTERACTIVE INPUT:

       none
  
*FILES USED:

       none
  
*SUBROUTINES CALLED:

       PARCHECK

*SIDE EFFECTS:
  
*NOTES:
  
*PROCEDURE:
  
*I_HELP nn:

*MODIFICATION HISTORY:

      	See MISDAT.PRO
      	5-10-88 HAA add RDAF Prolog
       7-21-88 RWT correct error in LWP large aperture labels
       1-09-90 RWT UNIX mods: lower case used and XYOUTS command modified
       8 July 1991  LLT clean up, add parcheck, update prolog
       15 Feb 94  PJL  update prolog;  remove '&'

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


CHISQ

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

    CHISQ    (General IDL Library 01)  JUNE,1984
 
*CLASS: 

    Statistics

*CATEGORY
  
*PURPOSE:   

    To evaluate reduced chi-squared for a fit to data.
 
*CALLING SEQUENCE: 

    CHISQ,Y,WEIGHT,YFIT,NFREE,CHISQ
 
*PARAMETERS:

    Y       (REQ) (I) (1) (F D)
            Required input vector containing the measured data.

    WEIGHT  (REQ) (I/O) (1) (F D)
            Required input vector containing the data point weights:
              for instrumental uncertainties use WEIGHT=1/sigmay^2,
              for statistical uncertaintities use WEIGHT=1/Y,
              if WEIGHT=1 then value returned = variance of fit,
              see BEVINGTON for further information.

    YFIT    (REQ) (I) (1) (F D)
            Required input vector containing the calculated data based
            on some model or least squares fitting.

    NFREE   (REQ) (I) (0) (I L F D)
            Required input scalar containing the number of degrees of 
            freedom.  This is equal to:
               number of data points - degree of polynomial - 1

    CHISQ   (REQ) (O) (0) (F D)
            Required ouput scalar giving the reduced chi-squared statistic.

*EXAMPLES:

    To compute the chi-squared statistic for observed data YDATA and
    computed data YFIT, with uniform data weighting,

       weight = 0 * ydata + 1.
       chisq,ydata,weight,yfit,nfree,chisq

    To compute the reduced chi-squared statistic for observed data Y and
    computed data YF, where the weight = abs(1./y), Y has 100 points, YF
    is a third degree polynomial [i.e., yf = a(0) + a(1) * x + a(2) * x^2 +
    a(3) * x^3}:

       chisq,y,abs(1./y),yf,n_elements(y)-3-1,chisq

*SYSTEM VARIABLES USED:

    none

*INTERACTIVE INPUT:

    none

*SUBROUTINES CALLED:

    PARCHECK
    PCHECK

*FILES USED:

    none

*SIDE EFFECTS:

    If WEIGHT

*PROCEDURE: 

    The procedure computes total(weight(y-yfit)^2)/nfree
                 (See Bevington [1969] p. 193-195 for weighting methods)
   
*NOTES:

    If NFREE is < 0  or NPTS is < NFREE then CHISQ is set to 0
    and an error message will appear.
    Typing CHISQ without any 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)      	21 Jun 91
 
*MODIFICATION HISTORY:

    July,  1981  TBA  GSFC add weighting
    June,  1984  NRE  GSFC change to 1/SIGMA^2 weighting, document
    Jul  5 1984  RWT  GSFC correct error in using WEIGHT and modify
                          documentation
    Sep  9 1987  RWT  GSFC add procedure call listing 
    Mar  8 1988  CAG  GSFC add VAX RDAF-style prolog.
    Jun 21 1991  PJL  GSFC cleaned up; tested on SUN and VAX; updated prolog
     6 May 94  PJL  added to prolog
    11 May 94  PJL  print a warning if any of the weights are negative

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


CHKFITS

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

	CHKFITS

*CLASS:

*CATEGORY:

*PURPOSE:

	Reads the first 80 bytes of a file.  Based on the values of the
       first six and 30th bytes, CHKFITS determines if the file is a FITS file.

*CALLING SEQUENCE:

	CHKFITS,FILENAME,RESULT,silent=silent

*PARAMETERS:

	FILENAME  (REQ) (I) (0) (S)
		  The filename (including path if necessary) of the file to be
		  inspected.

	RESULT	(REQ) (O) (0) (I)
		The result of the file inspection with the following 
               definitions:
                  0 - file is not a standard FITS file
                  1 - file is a standard FITS file
                  2 - file is not found 
                  3 - file exists but can not be opened and/or read.

	SILENT  (KEY) (I) (0) (I)
		Keyword to prevent messages from being printed to the screen.
		If not set or set equal to 0, then messages are printed to the
		screen.  Otherwise, the messages are not printed.

*EXAMPLES:

	chkfits,'swp32525.silo',res

*SYSTEM VARIABLES USED:

	!err_string

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK

*FILES USED:

	filename in calling sequence

*SIDE EFFECTS:

	none

*RESTRICTIONS:

	none

*NOTES:

       - Although SIMPLE = 'F' can represent a valid FITS format, it is 
       considered non-standard and RESULT is set to 0.
       - RESULT = 3 can occur if the input file is already opened, or
       the file protection prevents read access.

*PROCEDURE:

	The file is opened and the first 80 bytes are read.  The first six (6)
	characters are compared to 'SIMPLE'.  If they are equal, then the 30th
	character is compared to 'T'.  If both tests are passed, then the file
	is a FITS file, and result is set to 1.  If either test is failed, or 
       an unexpected end-of-file is encountered, then the file is NOT a 
       (simple) FITS file, and result is set equal to 0.  
       If the file can not be found, result is set equal to 2, and if any
       other error occurs during the reading of a file (known to exist), 
       then result is set to 3. If the keyword silent is set and not equal 
       to 0, then the error messages are not printed. 

*I_HELP  nn:

*MODIFICATION HISTORY:

	 3 Mar 93  PJL  wrote
        6 Aug 93  LLT  added code so that program won't bomb for files whose
                       formats aren't compatible with OPENR and ASSOC stmts.
       23 Sep 93  RWT  set result = 2 if file is not found
       13 Jan 94  PJL  replace use of assoc with readu  (assoc has problems
			with VMS variable length records)
       11 Apr 94  PJL  added findfile
       28 Sep 94  PJL  correct silent bug when no files found;  free_lun after
                       on_ioerror error
       30 Sep 94  RWT  add result = 3 if file exists but is already open 
                       and/or can't be read to determine file format

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


COADD

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

	COADD        (RDAF General Production Library)          July, 1986

*CLASS:

	correction

*CATEGORY:

	IUESIPS		NEWSIPS
 
*PURPOSE:  

    	To coadd IUESIPS RDAF .SAV formatted files OR NEWSIPS fits formatted
	files.  For IUESIPS data, a .SAV file is generated as output containing
	the coadded results.  For NEWSIPS data, a fits file is generated as
	output containing the coadded results.  See FILES USED: category below.

*CALLING SEQUENCE:

    	COADD,SPEC,ELIM,WOPT,CNAME,/newsips
 
*PARAMETERS:

    	SPEC	(REQ) (I) (0 1) (I S)
         	Number of spectra to be coadded, 0 = user is prompted for
		input.  Can also be an array of IUESIPS .SAV filenames OR
		NEWSIPS fits filenames, or an argument for FINDFILE.

    	ELIM   	(REQ) (I) (0) (I)
         	If IUESIPS data:
		   Cutoff epsilon value for weighting purposes.  If ELIM < 0
		   only points with epsilons > ELIM will be considered good
		   points. 
           		< 0 = largest EPS value to be treated as bad data
           		  0 = user is prompted for input
           		> 0 = all points are considered good (none excluded)

         	If NEWSIPS data:
		   Nu flag value(s) for weighting purposes.  Multiple nu flags
		   may be set.  If ELIM < 0 points with the absolute value nu
		   flags bit settings that match the absolute value of ELIM's
		   bit settings are considered bad points.
           		< 0 = absolute value bit settings used to determine bad
			      points
           		  0 = user is prompted for input
           		> 0 = all points are considered good (none excluded)

    	WOPT   	(REQ) (I) (0) (I) 
        	Exposure weighting option
            		0 = prompt user for input
            		1 = use SQRT(exposure time) for weighting
            		2 = use exposure time directly for weighting
            		3 = ignore exposure times
            		4 = user will specify a constant for weighting
            		5 = use sigmas - NEWSIPS only (can not be used when
			    interpolation is necessary)

    	CNAME  	(REQ) (I) (1) (S)
        	Name of output file; may include path information. 
        	(user is prompted for name if null string or blanks are 
		specified).

	NEWSIPS	(KEY) (I) (0) (I)
		If the number of spectra to be coadded is given, the files
		involved will be assumed to be IUESIPS RDAF .SAV files unless
		the NEWSIPS flag is set to indicate that the files are NEWSIPS
		fits files.
 
*EXAMPLES:

     	coadd,0,0,0,' '            ; For IUESIPS data.  Prompt user for all
				   ; necessary input.

	coadd,0,0,0,' ',/newsips   ; For NEWSIPS data. Prompt user for all
				   ; necessary input.

     	coadd,2,-350,2,'favg'      ; For IUESIPS data.  Coadd 2 spectra, delete
				   ; points with EPS values < or equal to -350.
				   ; Weight by exposure times and save results
				   ; in file favg.sav

     	coadd,2,-4160,2,'favg',/newsips
			           ; For NEWSIPS data.  Coadd 2 spectra, delete
				   ; points with nu flags values of -4096 and
				   ; -64 (thus -4160).  Weight by exposure
				   ; times and save results in file favg.fit

     	coadd,5,1,1,'favg5'        ; For IUESIPS data.  Coadd 5 spectra, do not
				   ; exclude any points, weight by the square
				   ; root of the exposure time and store
				   ; results as favg5.sav

     	coadd,5,1,1,'favg5',/newsips
			           ; For NEWSIPS data.  Coadd 5 spectra, do not
				   ; exclude any points, weight by the square
				   ; root of the exposure time and store
				   ; results as favg5.fit

       file = findfile('swp*.sav')
       COADD,file,1,3,'swpcoadd'
				   ; For IUESIPS data.  Create an array of .sav
				   ; file names.  Coadd all SWP .sav files in
				   ; the user's current directory with equal
				   ; weighting and including all points.
				   ; Results will be saved in swpcoadd.sav

       file=findfile('swp*.mxlo')
       COADD,file,1,3,'swpcoadd',/newsips
				   ; For NEWSIPS data.  Create an array of
				   ; .mxlo file names.  Coadd all SWP .mxlo
				   ; files in the user's current directory with
				   ; equal weighting and including all points.
				   ; Results will be saved in swpcoadd.fit

       COADD,'swp*.sav',1,3,'add' ; For IUESIPS data.  Find all files of the
				   ; form swp*.sav and coadd them with equal
				   ; weighting and including all points.
				   ; Results will be saved in add.sav

       COADD,'swp*.mxlo',1,3,'add',/newsips
				   ; For NEWSIPS data.  Find all files of the
				   ; form swp*.mxlo and coadd them with equal
				   ; weighting and including all points.
				   ; Results will be saved in add.fit

*SYSTEM VARIABLES USED:

       !iuer.dat
       !iuer.inf

*INTERACTIVE INPUT:

	Besides above input prompting, user is prompted for names of IUESIPS
	RDAF .sav OR NEWSIPS fits files to be coadded, unless the user has
	entered an array of IUESIPS RDAF .sav OR NEWSIPS fits filenames to use.
	The filenames may also include path specifications.  For IUESIPS data,
	wavelengths from the first file entered will be used as a reference for
	resampling all subsequent spectra.

*SUBROUTINES CALLED:

	PARCHECK
	PCHECK
	CHKFITS
	IUETERP
	READMX
	IUESAVE
	IUEFETCH
	INTIME
	NUFLAGS
       SHOWTXT

*FILES USED:

    	!iuer.inf EPSILON.DOC  (I)
    	   File describing IUESIPS data quality flag assignments (displayed if
    	   ELIM = 0).

    	!iuer.inf NUFLAGS.DOC  (I)
	   File describing IUE NEWSIPS data quality flag assignments
	   (displayed if ELIM = 0).

       CNAME.SAV or CNAME.FIT  (O)
	   RDAF SAV or fits file of coadded spectrum generated from the
	   resulting header, wavelength, average weighted flux, and weight
	   arrays described above.  The E vector describes the fraction of
	   points used at each wavelength in the coadded spectrum.  If no good
	   points were found at a particular wavelength, the E vector entry is
	   set to -1000.

*SIDE EFFECTS:

*RESTRICTIONS:

	Weighting option 5 (NEWSIPS only) can not be used if the vectors must
	be interpolated.

*NOTES:

    	COADD assumes that the user has corrected for wavelengths shifts
	between spectra (e.g. see CRSCOR.PRO). 

    	If ELIM = 0, the files are IUESIPS RDAF .sav files, or the NEWSIPS
	flag is not set, the disk file IUER_INF EPSILON.DOC or
	IUER_INF NUFLAGS.DOC is displayed.

*PROCEDURE:

	COADD begins by prompting the user to input each of the first 3
	parameters which were specified as 0 in the procedure call. Once these
	options are set, the user specifies the name of each of the IUESIPS
	RDAF sav or fits files to be coadded (this step is skipped if the user
	entered a string or an array of filenames).

	The wavelengths in the first file named will be used as a reference to
	which all subsequent spectra will be compared.  If the wavelength
	sampling for any succeeding file differs from that of the first
	spectrum, IUETERP will be called to resample the wave, flux, and
	IUESIPS eps or NEWSIPS nu flags vectors.

	Depending on the weighting option specified, an array WGT is generated
	in which 0s designate bad points and 1s designate good points.  The sum
	of the WGT arrays (called NGOOD),is used to describe the fraction of
	good data points used at each wavelength of the coadded spectrum.  If
	no points are used at a particular wavelength, the entry in NGOOD is
	set to -1000, and the flux value is set to zero.  The WGT array is then
	scaled according to the users choice of WOPT and the calculated
	exposure times (if so requested).  The average weighted flux is
	calculated by dividing the sum of the weighted fluxes (i.e. FLUX*WGT),
	by the sum of the weights.  A plot is displayed of average weighted
	flux versus wavelength with X's drawn at points where no good points
	were found.

	The final vectors H,W,FAVG, & NGOOD are stored in a RDAF .sav file or
	a fits file.

*I_HELP nn
 	
*MODIFICATION HISTORY:

     	Written by J. K. Feggans for Dr. Bergstahl 7/85.
     	Updated for Dr. J. Neff 10/85.
     	Updated for use by Dr. Nousek 11/1/85
     	Documentation C. Grady 12/85
     	Further revisions J.K. Feggans and C. Grady 1/86
     	 2-28-86  RWT  remove EOPT parameter, update prolog, and improved
		       parameter definitions
     	Optimized JKF 3/86.
     	 3-10-86  RWT  use NGOOD to generate final array of weights
     	 4-15-86  RWT  prompt user for ELIM & WOPT before SAV file names
     	 5-13-86  RWT  add PCHECK for CNAME and comments about quotes 
     	 3-14-87  RWT  VAX mods: add PARCHECK, & use N_ELEMENTS
     	10- 7-87  RWT  add procedure call listing, replace IUESTOR with new
		       IUESAVE, and remove EPSWGT & EXPWGT subroutines
     	 2-19-88  RWT  make GETEXP a separate routine called CO_GETEXP
     	 4-18-88  RWT  rename COADD_GETEXP
      	 5-11-88  HAA  add RDAF Prolog
        1-03-90  RWT  UNIX mods: convert to lower case, change logical name
		       references, remove routine COADD_GETEXP, change format
		       statements
        4-10-91  KBC  spawn appropriate system call based on operating system
		       type for compatibility on SUN/DEC/VAX
       27 Jun 91  LLT  add call to GRIDTERP, changed logical; clean up; 
		        tested on VAX; updated prolog
       12 Jul 91  PJL  corrected error with wopt = 5; tested on SUN and VAX;
		        updated prolog
       21 Nov 91  GRA  removed IUER_USERDATA and 16 character name limit
                       from IUESAVE, updated prolog; tested.
       30 Jan 92  LLT  GRIDTERP when wavelength vectors are of unequal size,
                       even if the existing elements all match; add ability to
                       input an array of filenames.
        4 Feb 92  LLT  add call to FINDFILE when a scalar string is given
			(SPEC).
       22 Jun 93  EER  (JPL) to put total exposure time into header.
	30 Jun 93  PJL	changed !version.os if to case; replaced GRIDTERP with
			IUETERP
	26 Jul 93  PJL	compatibility with NEWSIPS - including READMX and
			NUFLAGS procedures; NEWSIPS keyword
	 5 Aug 93  PJL  use IUETERP on NEWSIPS data when necessary - except for
			weighting option 5
       14 Mar 94  LLT  if newsips keyword not set and no extension in filename
                       assume .SAV
       15 Jun 94  RWT  allow respecifying file name, add print message so 
                       "files not found" is distinguished from "incorrect 
                       file type", correct telescop keyword value, store
                       NEWSIPS wavelengths as single-precision rather than 
                       double-precision, allow nu flag description to be
                       read before screen is erased, and allow cname to include
                       extension.
       23 Jun 94  PJL  replaced !version with PLATFORM
       18 Oct 94  PJL  added code for cat command equals 'NA'
       21 Oct 94  PJL  replace environment variables with system structure
       24 Jan 95  RWT  replace spawn with call to showtxt routine

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


CODEMX

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

	CODEMX

*CLASS:

*CATEGORY:

	NEWSIPS

*PURPOSE:

	To determine if the variable is scalar, a vector of numpts points, or
	neither.

*CALLING SEQUENCE:

	CODEMX,VARIABLE,NAME,NUMPTS,ERR

*PARAMETERS:

	VARIABLE  (REQ) (I) (0 1) (I L R D)
		The data that is to be check.  It should be a scalar (err will
		equal 1), or a vector with numpts points (err will equal 0).
		If it is neither, err will equal -1.

	NAME	(REQ) (I) (0) (S)
		The name of the data in the variable, such as 'net flux'.

	NUMPTS	(REQ) (I) (0) (I L)
		The number of points that should be in the variable vector.

	ERR	(REQ) (O) (0) (I)
		The flag.  If 1, variable is a scalar.  If 0, variable is a
		vector of numpts points.  If -1, variable is neither.

*EXAMPLES:

	readmx,'swp17851.mxlo',main,wave,flux,flags,sigma
	codemx,flux,'flux',n_elements(wave),err

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK

*FILES USED:

	none

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	subroutine for WRITEMX

*PROCEDURE:

	The size of the variable is used to determine if it is a scalar or
	vector.  If it is neither, err is set to -1.  If it is a scalar, err
	is set to 0.  If it is a vector, the number of points is compared to
	numpts.  If equal, err is set to 0, else it is set to -1.

*I_HELP  nn:

*MODIFICATION HISTORY:

	14 Jun 93  PJL	wrote

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


COMBALL

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

    	COMBALL          (RDAF General Production Library)          Sep, l986
 
*CLASS:

    	Resampling

*CATEGORY:    

*PURPOSE:  

    	Combines high disp orders into a single vector < 10000 points long.

*CALLING SEQUENCE:

    	COMBALL,IMT,WA1(I),WA2(I),DEL(I),H,W,FAB,E,SPLICE   
 
*PARAMETERS:
	
	IMT	(REQ) (I) (0) (S)
		Camera and image identifier.

       MINW	(REQ) (I) (0) (F D)
		Minimum wavelength for resampling.

       MAXW	(REQ) (I) (0) (F D)
		Maximum wavelength for resampling.

       DEL 	(REQ) (I) (0) (F D)
		Increment in wavelength units for the resampling.

 	H   	(REQ) (O) (1) (I)
		Header vector.

       WAVE	(REQ) (O) (1) (F)
		Resampled wavelength vector.

       FLUX	(REQ) (O) (1) (F)
		Resampled flux vector.

       EPS 	(REQ) (O) (1) (F)
		Resampled data quality vector.  The weight (WGT) vector
		obtained from the RDAF procedure BINS.

       SPL	(REQ) (O) (1) (F)
		Array of splice wavelengths for each order.

*EXAMPLES:

*SYSTEM VARIABLES USED:

	!STIME 	-   system's time and date are printed

*COMMON BLOCKS:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	COM_HIA
    	BINS

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	Used by BCOMP.PRO

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

*PROCEDURE:

		The procedure first initializes variables and output vectors. 
       Next, the procedure reads the header record and leaves the file open 
       for IUEGET. The procedure then determines the K0 and ALPHA from the 
	camera number and stores ALPHA in the header. Next, actual scrunching
	begins, and continues until it runs out of 10 A chunks of spectrum. 
       The scrunching will consist of extraction, reduction, and resampling 
       onto the specified wavelength grid.  
       	The procedure then reads in data, subtracts background from 
       gross spectrum, performs ripple correction, and does an absolute 
       calibration.  This is accomplished by calling COM_HIA.PRO. Next the 
       procedure loads wavelengths of splice points into a splice array. 
       The procedure then assigns weights; it ignores reseaux and saturated 
       pixels, but retains extrapolated pixels. 
	         Further, the program resamples onto a uniformly spaced 
       wavelength scale with spacing = DEL.  Then it inserts the new 
       resampled datapoints into the output data arrays.  Finally, the 
       procedure will print the time after loading all the datapoints 
       into output arrays and returning.

*I_HELP nn:

*MODIFICATION HISTORY:

     Programmer: R. Panek, G. Sonneborn
     5-24-85 CAG Overhaul to add linear interp. across reseaux,
             better ripple correction & documentation
     11-14-85 RWT combine COMBI1, COMBI2 & COMBI3 into COMBALL
      3-01-91 PJL unix/sun modifications; added PARCHECK and 
	       call print; removed !ERR
      7-22-91 PJL cleaned up; tested on SUN and VAX; updated prolog
      8-27-91 jg  corrected prolog
     12-17-91 PJL changed number of points limit from 4000 to 10000
      1-07-92 PJL added documentation
      1-08-92 PJL changed clearing splice points range to include h(96)

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


COM_ABCAL

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

	COM_ABCAL
  
*CLASS:

	Spectral Calibration
  
*CATEGORY:

	IUESIPS
  
*PURPOSE:

 	Procedure to apply IUE absolute calibration to high dispersion 
	spectra being processed by BCOMP.
  
*CALLING SEQUENCE:

	COM_ABCAL,H,WAVE,FNET,EXPS,FABS
  
*PARAMETERS:

	H	(REQ) (IO) (1) (I)
		Header record.  Entries are updated to describe the
               approppriate calibration used.

	WAVE	(REQ) (I) (1) (F D)
		Wavelength vector.

	FNET	(REQ) (I) (1) (F D)
		Net flux in IUE flux units.

	EXPS 	(REQ) (I) (1) (F D)
		Exposure time in seconds.

	FABS	(REQ) (O) (1) (F D)
		Flux in ergs/s/cm2/A.

*EXAMPLES:

*SYSTEM VARIABLES USED:

	!iuer.dat

*COMMON BLOCKS:

	none
  
*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK
	IFITSRD
	QUADTERP

*FILES USED:

      !iuer.dat IUECAL3.FIT
      !iuer.dat IUECAL.FIT
  
*SIDE EFFECTS:
  
*RESTRICTIONS:

	This procedure should only be used with IUESIPS data.
  
*NOTES:

*PROCEDURE:
  
	This procedure applies IUE absolute calibration to high dispersion
	spectra.  The procedure uses either !IUER.DAT IUECAL3.FIT or 
	!IUER.DAT IUECAL.FIT as calibration files. The procedure uses quadratic 
	interpolation in the tables to get inverse sensitivity for each 
	element of wave.  The calibration is applied and the procedure returns.
	
*I_HELP nn:
  
*MODIFICATION HISTORY:

       2/25/91 RWT replace IUECAL2 with IUECAL3 & UPDATE PROLOG
	3-01-91 PJL unix/sun modification; added PARCHECK and 
		call print
       4-10-91 KBC branch pathname strings based on operating system type
	7-22-91 PJL cleaned up; changed logical; tested on SUN and VAX;
		    updated prolog
	 8 Nov 93  PJL  replace IUECAL.DAT with IUECAL.FIT and IUECAL3.DAT with
			IUECAL3.FIT; added IFITSRD; IUESIPS only restriction
      2 Sep 94 LLT replace environment variables with system structure !iuer

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


COM_HIA

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

	COM_HIA
  
*CLASS:

	Spectral Data Reduction
  
*CATEGORY:
  
*PURPOSE:

 	Procedure to get next order for COMBALL (from QIUEHI3 & IUEHI)
  
*CALLING SEQUENCE:

  	COM_HIA,UNIT,K0,A,ER,CAM,M0,OFL,W1,W2,NET1,NET2,E1,E2,NP1,NP2,H,W,F,E

*PARAMETERS:

	UNIT	(REQ) (I) (0) (I)   
		Unit number for input image file.

       K0	(REQ) (I) (0) (F D) 
		Ripple constant.

	A	(REQ) (I) (0) (F D)   
		Ripple constant.

       ER	(REQ) (I) (0) (I L)     
		Record size of image file.

       CAM	(REQ) (I) (0) (I)    
		Camera number.

       M0	(REQ) (I) (0) (I)     
		Central Order number.

       OFL	(REQ) (I) (0) (I)    
		Flag for 1st order.

       W1	(REQ) (I/0) (1) (F D) 
		Wavelength vector for M0 from last call.

	W2	(REQ) (I/0) (1) (F D) 
		Wavelength vector for M0-1 from last call.

       NET1	(REQ) (I/O) (1) (F D)
		Net flux from last call.

	NET2	(REQ) (I/O) (1) (F D)
		Net flux from last call.

       E1	(REQ) (I/O) (1) (I L F D)
		Epsilon vectors from last call.

	E2	(REQ) (I/O) (1) (I L F D)
		Epsilon vectors from last call.

       NP1	(REQ) (I) (1) (I)
		Number of points in vector.

	NP2	(REQ) (I) (1) (I)
		Number of points in vector.

        H	(REQ) (I/O) (1) (I)     
		Header record.  

       W1,W2,H,NET1,NET2,E1,E2 are modified and passed to calling
	procedure to save them for the next call to HIA.

*EXAMPLES:

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:
  
	PARCHECK
	IUEGET
    	COM_SPL
    	COM_ABCAL
	RIPPLE

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

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

	This procedure extracts three orders from a high dispersion file.
	The orders are then ripple corrected and trimmed. They are then 
	spliced together using COM_SPL.PRO. Finally, using COM_ABCAL.PRO,
	the orders are spliced together.
  
*I_HELP nn:
  
*MODIFICATION HISTORY:

	5-24-85 C. Grady modified for DIDL
	3-01-91 PJL unix/sun modifications; removed !ERR; added
		    PARCHECK and call print
	7-22-91 PJL cleaned up; tested on SUN and VAX; updated prolog

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


COM_SPL

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

	COM_SPL
  
*CLASS:

	Spectral Data Reduction
  
*CATEGORY:
  
*PURPOSE:

	Creates a new wavlength vector composed of those wavelengths of wave1 
	less than or equal to wavel, and those of wave2 greater than or equal 
	to wavel. Creates a new flux vector by splicing flux1 and flux2 at 
	the same indices at which wave1 and wave2 were joined.
  
*CALLING SEQUENCE:

	COM_SPL,WAVE1,FLUX1,EPS1,WAVE2,FLUX2,EPS2,WAVEL,WAVE3,FLUX3,EPS3
  
*PARAMETERS:

	WAVE1	(REQ) (I) (1) (F D)
		Wavelength vector to be merged.

	WAVE2	(REQ) (I) (1) (F D)
		Wavelength vector to be merged.

       FLUX1	(REQ) (I) (1) (F D)
		Flux vector to be merged.

	FLUX2	(REQ) (I) (1) (F D)
		Flux vector to be merged.

       EPS1	(REQ) (I) (1) (F D)
		Data quality vector to be merged.

	EPS2	(REQ) (I) (1) (F D)
		Data quality vector to be merged.

       WAVEL	(REQ) (I) (1) (F D)
		Wavelength for splicing.

	WAVE3	(REQ) (O) (1) (F D)
		Merged wavelength vector.

       FLUX3	(REQ) (O) (1) (F D)
		Merged flux vector.

       EPS3	(REQ) (O) (1) (F D)
		Merged data quality vector.

*EXAMPLES:
  
*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:

	PARCHECK
  
*FILES USED:

*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

	tested IDL Version 2.1.0 (sunos sparc)  	19 Jul 91
	tested IDL Version 2.1.0 (ultrix mispel)	N/A
	tested IDL Version 2.1.0 (vms vax)      	22 Jul 91
  
*PROCEDURE:
  
	The procedure first collects the points where wave1 is less than 
	wavel and wave2 gt wavel. After which, the splicing is done. Finally,
	the splice index in array replacing splice point is returned.

*I_HELP nn:
  
*MODIFICATION HISTORY:

	 3-01-91 PJL unix/sun modifications; added PARCHECK and
		     call print
	 7-22-91 PJL cleaned up; tested on SUN and VAX; updated prolog
	 8- 9-91 PJL corrected PARCHECK call

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


CONFIND

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

     CONFIND   (General IDL Library 01) 
  
*CLASS:

     User i/o; curve fitting
  
*CATEGORY:
  
*PURPOSE:

     Procedure to select continuum points in a spectrum. CONFIND is a
     modified version of the front end of NORM which uses the interactive
     graphics cursor to pick out points for later continuum fitting.
  
*CALLING SEQUENCE:

     CONFIND,WAVE,FLUX,WCONT,FCONT
  
*PARAMETERS:

     WAVE   (REQ) (I) (1) (F D)
            Required input vector containing the wavelength data for the
            spectrum of interest.

     FLUX   (REQ) (I) (1) (F D)
            Required input vector containing the flux data.

     WCONT  (REQ) (O) (1) (F D)
            Required output vector containing the wavelengths of the
            selected points.

     FCONT  (REQ) (O) (1) (F D)
            Required output vector containing the fluxes of the selected
            points.

*EXAMPLES:

     To pick central wavelengths for continuum bandpasses:
     CONFIND,WAVE,FLUX,WCONT,FCONT
     then specify widths of bandpasses in vector WIDTHS
     BINS,WAVE,FLUX,WCONT,WIDTHS,WMEAN,WSIG,WGT

     To select continuum points for normalization:
     CONFIND,WAVE,FLUX,WCONT,FCONT

*SYSTEM VARIABLES USED:

     !ERR
     !d.x_ch_size
     !d.y_ch_size
     !d.y_size
     !d.name
  
*INTERACTIVE INPUT:

     User is prompted for rescaling plot of wave vs flux
     The user also selects the continuum points via the graphics cursor.

*FILES USED:
  
*SUBROUTINES CALLED:

     PARCHECK
     YESNO

*SIDE EFFECTS:

     If aborted, some system variables may be reset.
  
*RESTRICTIONS:

     Device Dependent - This procedure requires a graphics cursor.
  
*NOTES:

     !FANCY should be =0 before beginning this procedure, as the
     fancy graphics conflict with cursor commands.

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

*PROCEDURE:

     The user views the spectrum, and is given the opportunity to
     rescale the plot. This is done iteratively until the user indicates
     satisfaction by typing 0 (no more rescaling).

     Next, while viewing the spectrum, the users marks points corresponding
     to the continuum with the graphics cursor. Points can be added until
     the user types 0. The data x and y coordinates of the points are 
     calculated from the screen locations of the cursor.
  
*INF_1:
  
*MODIFICATION HISTORY:

     May    1985  CAG GSFC wrote procedure based on NORM
     Jun  6 1985  RWT GSFC allowed exit from CONFIND
     Jun 11 1985  RWT GSFC modified user prompt for continuum points
     Apr 13 1987  RWT GSFC use vector assignment statements, remove
                           INSERT and EXTRACT commands, and use XYOUTS
                           for XYOUT.
     May 22 1987  RWT GSFC improve sorting 
     Mar  1 1988  RWT GSFC make CONFIND a separate procedure
     Mar  8 1988  CAG GSFC added VAX RDAF-style prolog, printing calling
                           sequence if no parameters are specified, and
                           check for minimum number of parameters.
     1/08/90 RWT UNIX mods: convert to lower-case,
     2-20-91 PJL  updated prolog
     Jun 21 1991  PJL GSFC cleaned up; tested on SUN and VAX; updated prolog
     Jul  1 1991  GRA CASA substantially modified; so that continuum is
                           properly displayed if contiuum points are
                           entered in non-ascending wavelength order,
                           and the last *entered* point can be properly
                           rejected if so desired.
     Jul 10 1991  PJL GSFC corrected xmin, xmax, ymin, and ymax initialization;
			    tested on SUN and VAX; updated prolog
     May  4 1992  PJL GSFC corrected placement of tek "abort" option

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


CONMENU

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

       CONMENU

*CLASS:

*CATEGORY:

*PURPOSE:

       If no translation mode is requested, inform the user of the available
       options and request a translation mode.  Determine if the requested
       translation mode is a valid request.

*CALLING SEQUENCE:

      CONMENU,CPUPAR,cpustr,next_flag=next_flag,from_vms_system=from_vms_system

*PARAMETERS:

      CPUPAR	(REQ) (I/O) (0) (I)
               Parameter to identify data translation mode. 

                  ULTRIX/VAX  to  VMS/VAX
                            or
                  ULTRIX/MIPSEL  to VMS/MIPSEL  0   (VMS only)

                  VAX     to  MIPSEL            1
                  MIPSEL  to  VAX               2

                  VAX     to  SPARC             3
                  SPARC   to  VAX               4

                  MIPSEL  to  SPARC             5
                  SPARC   to  MIPSEL            6

               Supported Data Types:

                  VAX    - VAXstations, MicroVAX
                  MIPSEL - DECstations, IBM 386  (IEEE little-endian)
                  SPARC  - SparcStations, Sun 4##, Macintosh  (IEEE big-endian)

              No Conversion is required between like data types when the
              destination machine uses stream files (SUNOS, ULTRIX, and DOS).

              Conversion is required for like data types only when the
              destination machine is using the VMS operating system (see 0
              option above)

              If CPUPAR is not given in the call, the user will be prompted
              for it.

              Note that only modes in which the final data format is
              compatible with the host operating system are allowed.

	CONSTR	(OPT) (O) (0) (S)
		Architecture file is being converted from.

	NEXT_FLAG  (KEY) (O) (0) (I)
               Flag set according to the architecture of the system.  VAX = 1,
		SPARC, Mac (IEEE big-endian) = 2, and MIPSEL or 386 (IEEE
               little- endian) = 3.

	FROM_VMS_SYSTEM  (KEY) (O) (0) (I)
               For the cases when RMS equals 1, FROM_VMS_SYSTEM is set to 1
		for an Ultrix system and 0 for a VMS system.

*EXAMPLES:

*SYSTEM VARIABLES USED:

       none

*INTERACTIVE INPUT:

       If CPUPAR is not given in the call, the user will be prompted for it.

       If the value of CPUPAR is not valid, the user will be prompted for a
       new value or to quit.

*SUBROUTINES CALLED:

       PARCHECK
       PLATFORM

*FILES USED:

       none

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

       Used with CON_DB, CON_RDAF, CON_SAV, and CONVERT.

*PROCEDURE:

       PLATFORM is used to determine the internal data format and if the
       Record Management Services (RMS) format needs to be considered.
       Based on the values from PLATFORM, the allowable options are
       determined.  If CPUPAR was not given, then the user is prompted for
       it.  The CPUPAR value is checked to see if it is allowed.  If it is,
       the procedure returns it.  If it is not, then the user is prompted for
       a valid value - or to quit.

*I_HELP  nn:

*MODIFICATION HISTORY:

        9 Jun 94  PJL  wrote - based on sections in CON_DB, CON_RDAF, CON_SAV,
                       and CONVERT
       20 Oct 94  PJL  added reference to Macintosh

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


CONVERT

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

      CONVERT

*CLASS:

*CATEGORY:

      IUESIPS

*PURPOSE:  

      To convert IUE .dat and .lab files to a format compatible
      with the host operating system. CONVERT supports IUE RDAF-format
      file conversions between SunOs (Sun-3s, Sun-4s, and SPARCStations),
      ULTRIX (DECStation 3100), DOS (386-class PC), and VMS (VAX).

*CALLING SEQUENCE:

      CONVERT,IMAGEN,cpupar

*PARAMETERS:

      IMAGEN	(REQ) (I) (S) (0)
      		String name for IUE image file copied from VAX
        	If no extension is specified, program assumes that both
        	a .dat and a .lab file exists and both are to be converted.

      CPUPAR  (OPT) (I) (I) (0)
              Parameter to identify data translation mode.

                 ULTRIX/VAX  to  VMS/VAX
                               or
                 ULTRIX/MIPSEL  to VMS/MIPSEL  0   (VMS only)

                 VAX     to  MIPSEL            1
                 MIPSEL  to  VAX               2

                 VAX     to  SPARC             3
                 SPARC   to  VAX               4

                 MIPSEL  to  SPARC             5
                 SPARC   to  MIPSEL            6

              Supported Data Types:

                 VAX    - VAXstations, MicroVAX
                 MIPSEL - DECstations, IBM 386
                 SPARC  - SparcStations, Sun 4##

            No Conversion is required between like data types when
            the destination machine uses stream files (SUNOS, ULTRIX
            and DOS). Conversion is required for like data types only
            when the destination machine is using the VMS operating 
            system (see 0 option above).

            If CPUPAR is not given in the call, the user will be prompted
            for it.

            Note that only modes in which the final data format is
            compatible with the host operating system are allowed.

*EXAMPLES:

     convert,'swp32199s.lab'        ; convert .lab file
     convert,'swp32199s'            ; converts both .dat and .lab files

*SYSTEM VARIABLES USED:

     !err_string

*INTERACTIVE INPUT:

     If CPUPAR is not given in the call, the user will be prompted for it.

*SUBROUTINES CALLED:

     PARCHECK
     IUE_PARSE
     CHKFITS
     SWAP_BYTES
     CONMENU

*FILES USED:

     imxgen given in calling sequence.

*SIDE EFFECTS:

*RESTRICTIONS:

     - files must be transferred between hosts in binary (image) mode.
     - CONVERT must be executed on the "destination" machine.
     - imaget must use standard RDAF file naming conventions 
       (e.g. swp 32199s) 
     - Valid file types include RI, PI, MELO, ELBL, FES, and MEHI, although
       FES images must have at least 18 byte records.
     - Not for use on fits formatted files.

*NOTES:

     - All files are truncated to have record lengths which agree
       with value listed in the header record.

*PROCEDURE:

     Before converting files, CONVERT uses the procedure CONMENU to define
     the allowed conversion modes and next_flag.  Once an allowed conversion
     mode has been selected, the value of cpupar is used to set the variable
     swap_flag and last_flag.  The input file variable imagen is parsed and
     the presence on a file extension (*.lab or *.dat) is used to determine
     which file types to convert.  First the input file is checked to
     determine if it is a fits formated file.  If the input file is in fits
     format, no conversion is done and the procedure returns.  The input file
     is then opened, and a temporary header vector is obtained, and converted
     to the requested output format according to the value of swap_flag.  The
     conversion flag (flag) is read from this header vector and used for error
     checking. The variables flag, last_flag, and next_flag take on values
     according which machine architecture the file was or will be converted
     to. These variables take on the values:

         !version.arch    flag value
             VAX             1
             SPARC           2
             MIPSEL          3
             386             3

     The value of flag is compared to the value last_flag to insure that the
     correct conversion option was selected.  Upon successful file conversion,
     the conversion flag is set to the value of next_flag.  Once the
     conversion options and input file are checked, conversion parameters are
     obtained from the temporary header and the fstat function.  The file is
     then associated with a 2-d array (bytes per record, number of records),
     and the entire file is read into a single 2-d array.  Label files are
     truncated to 74 byte records, and written to disk with a converted header
     vector.  Data files are truncated to a record length in agreement with
     the value given by h(0). An additional conversion flag swap_all is set
     depending on the data file type. The values of swap_flag and swap_all are
     used to determine how the data is converted.  On VMS systems, the output
     file is written to a higher version number.  On Unix systems, the output
     file is written over the input file.
     
     CONVERT is written to be called by CON_RDAF so that multiple files can be
     converted in one execution of CON_RDAF.  For this reason, returns are
     executed rather than retalls.

*MODIFICATION HISTORY:

     6/28/89  RWT  version 1  
     8/09/89  RWT  modify for converting FES images 
                   and remove superfluous bytes from .lab & .dat files
     8/14/89  RWT  remove need for bflag parameter & compress code
     8/17/89  RWT  truncate records to value listed in h(0)
     6/07/90  RWT  modify for handling DECstation format
     2/18/91  GRA  modified to allow file conversion between
                   SunOs, DEC and VAX machines. Do all swap
                   operations on byte variable BEFORE they are
                   read as any other type.
     3/28/91  PJL  added PARCHECK; modified to allow output 
		    record size > 32768 bytes
     4/30/91  RWT  add support for DOS
     5/20/91  GRA  modified last_flag to reflect DOS support
                   allow h(7) or h(587) flag to be zero for
                   files that originate on any cpu type
     6/12/91  GRA  merged vms and sun versions, corrected error
                   checking sections and comments to reflect
                   additional values of cpupar.
     6/21/91  GRA  fixed syntax error in the section which defines
                   cpustrarr, updated prolog.
     7/25/91  PJL  cleaned up; tested VAX to SUN and SUN to VAX options; 
		    updated prolog
     10/4/91  GRA  cleaned up print statements in label conversion
                   section.
     10/9/91  GRA  globally changed all references to "syspar" to "cpupar",
                   changed cpupar to reference data formats as specified by
                   the !version.arch system variable; used /block keyword
                   when opening input file on a vms machine so that the
                   rms information can be bypassed; condensed vms and unix
                   branches; updated prolog; tested on ultrix/vax,
                   ultrix/mipsel, vms/vax, sunos/sparc.
     10/31/91 GRA  cleaned up print statements.
     11/01/91 PJL  changed CON_GO reference to CON_RDAF
      8/16/93 RWT  add version number to .dat file name, fix error in
                   listing .dat file name, remove begin & ends for single 
                   commands, and reduce printout
     11/15/93 PJL  added CHKFITS; update prolog
      5/24/94 RWT  read minimum number of bytes in temporary header (to 
                   allow conversion of fes images with < 600 byte records)
    24 May 94 LLT  compare expected number of bytes per record to total bytes
                   in file divided by expected number of records (image data
                   only) to check for spurious records at end of file.
    30 Jun 94  PJL  replaced !version with CONMENU

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


CON_DB

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

	CON_DB

*PURPOSE:

	Converts database files to a format compatible with the host
	operating system.  CON_DB can convert files created with IDBCREATE
	to the appropriate format for the host operating system.
     
*CALLING SEQUENCE:

	CON_DB,NAME,cpupar

*PARAMETERS:

	NAME     (REQ) (I) (0) (S)  
	         File name of .dbd file (without .dbd extension)
	         Corrected data is written over original file on 
	         unix systems.

	CPUPAR   (OPT) (I)  (I)     (0)
	         Parameter to identify data translation mode.

			no conversion        0

			VAX     to  MIPSEL   1		not available
			MIPSEL  to  VAX      2		not available

			VAX     to  SPARC    3
			SPARC   to  VAX      4

			MIPSEL  to  SPARC    5		not available
			SPARC   to  MIPSEL   6		not available

	         Supported Data Types:

			VAX    - VAXstations, MicroVAX
			MIPSEL - DECstations, IBM 386		not available
			SPARC  - SparcStations, Sun 4##

		 Note: No Conversion is required between like data types,
		       such as DECstations and IBM 386s.

		 If CPUPAR is not given in the call, the user will be
		 prompted for it.

		 Note that only two modes are allowed for a given machine.
		 The allowed modes are those in which the final data format
		 is compatible with the host operating system.

*RESTRICTIONS:

	Conversion to/from MISPEL systems are not available.

	Not for use with fits forrmatted files.

*SUBROUTINES CALLED:

	PARCHECK
	CHKFITS
	IDBSUNTOHOST
	IDBVAXTOSUN
	IDBCREATE
	IDBOPEN
	IDBCLOSE
	IDBINDEX
	CONMENU
       MULDIRFF
       DECOMPOSE

*SYSTEM VARIABLES USED:

	!iuepriv
       !iuer.database

*EXAMPLES:

	to convert the IUELOG database:
		!iuepriv = 2
		con_db,'iuelog'
       The system variable !iuer.database must have been set to point to the
       current directory.

*NOTES:

       Before execution copy the .dbd and .dbf files
       from the VAX to the SUN or from the SUN to the VAX.

*PROCEDURE:

	CON_DB uses the CONMENU procedure to determine the host 
       operating system and cpu architecture. The allowed conversion 
       options are then defined based on the operating system and cpu
       type.  The user is asked to select from the allowed conversion
       options.

*MODIFICATION HISTORY:

	 4 Sep 92  PJL  wrote CON_DB based on CON_SAV
	20 Oct 92  PJL  added indexing for SUN to VAX conversion;  added
			resetting !iuepriv to 1
	27 Oct 93  PJL  SunOS to Dec Ultrix conversion permitted
	15 Nov 93  PJL  added CHKFITS
	 9 Jun 94  PJL  replaced !version with CONMENU
        2 Sep 94  LLT  replace IUER_MLOG with !iuer.mlog
        2 Nov 94  PJL  added MULDIRFF;  changed !iuer.mlog to !iuer.database

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


CON_RDAF

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

    CON_RDAF 

*CLASS:

*CATEGORY:

    IUESIPS

*PURPOSE:

    To convert IUE RDAF-format .dat and .lab files between SunOs
    ULTRIX, DOS, and VMS formats, using FINDFILE and CONVERT.

*CALLING SEQUENCE:

    CON_RDAF,IMAGET,cpupar

*PARAMETERS:

    IMAGET  (REQ) (I) (S) (0)
            Name of IUE file(s) to be converted.  Wildcards can be used.  

    CPUPAR  (OPT) (I) (I) (0)
            Parameter to identify data translation mode. 

               ULTRIX/VAX  to  VMS/VAX
                            or
               ULTRIX/MIPSEL  to VMS/MIPSEL  0   (VMS only)

               VAX     to  MIPSEL            1
               MIPSEL  to  VAX               2

               VAX     to  SPARC             3
               SPARC   to  VAX               4

               MIPSEL  to  SPARC             5
               SPARC   to  MIPSEL            6

            Supported Data Types:

               VAX    - VAXstations, MicroVAX
               MIPSEL - DECstations, IBM 386
               SPARC  - SparcStations, Sun 4##

           No Conversion is required between like data types when the
	    destination machine uses stream files (SUNOS, ULTRIX, and DOS).
	    Conversion is required for like data types only when the
	    destination machine is using the VMS operating system (see 0
	    option above).

           If CPUPAR is not given in the call, the user will be prompted
           for it.

           Note that only modes in which the final data format is
           compatible with the host operating system are allowed.

*EXAMPLES:

    To convert all MELO files without aperture designations (i.e., 'lg' and
    'sm') in users account:

       con_rdaf,'*l'

    To convert all MELO files with aperture designation 'lg' in users account:

       con_rdaf,'*llg'

    To convert all MELO files with aperture designation 'sm' in users account:

       con_rdaf,'*lsm'

    To convert all .dat and .lab files in users account:

       con_rdaf,'*'

    To convert swp32199l .dat and .lab files:

       con_rdaf,'swp32199l'

*SYSTEM VARIABLES:

    none

*INTERACTIVE INPUT:

    If CPUPAR is not given in the call, the user will be prompted for it.

*SUBROUTINES CALLED:

    PARCHECK
    DECOMPOSE
    CONVERT
    CONMENU

*FILES USED:

    imaget given in calling sequence.
    
*SIDE EFFECTS

*RESTRICTIONS:

    Not for use with fits formated files.

*NOTES:

    User must be in account in which files are to be converted
    (i.e. the path is not included in the file name)
    If no extension is specified, .dat and .lab files are assumed.
    If .dat is specified, only .dat files are converted.

*PROCEDURE:

    Before converting files, CON_RDAF uses the procedure PLATFORM to define
    and check the allowed conversion modes.  Decompose is used to check for
    file extensions in imaget.  If none are specified, findfile is called
    using imaget+'.dat' and imaget+'.lab' as input.  Otherwise findfile is
    run on imaget.  If any files are found, CONVERT is called for each entry
    in the string array.  If no extensions are specified, all *.dat and *.lab
    files present will be converted. 

*MODIFICATION HISTORY:

    Version 1 R. Thompson 3/1/90
    3/14/90 RWT fix bug when no files are found using count keyword
            in findfile
    2/18/91 GRA modified for use on VAX, DEC, and SUN machines.
                modified so that all *.lab and *.dat files will 
                be converted, by using *.lab and *.dat as inputs
                to FINDFILE, and using the larger of the two
                stringarrays. CONVERT was modified to return
                gracefully from an IO_ERROR.
    3/28/91 PJL added PARCHECK
    4/30/91 RWT add support for DOS
    6/13/91 GRA merged vax and sun versions, changed "dos" to "DOS"
    7/25/91 PJL cleaned up; tested VAX to SUN and SUN to VAX options;
		 updated prolog
    10/9/91 GRA globally changed all references to "syspar" to "cpupar",
                changed cpupar to reference data formats as specified by
                the !version.arch system variable; tested on ultrix/vax,
                ultrix/mipsel, vms/vax, sunos/sparc; changed name from
                CON_GO to CON_RDAF.
   10/31/91 GRA cleaned up print statements.
	15 Nov 93  PJL  update prolog
	18 Nov 93  PJL  "syspar" to "cpupar"
        9 Jun 94  PJL  replaced !version with CONMENU

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


CON_SAV

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

	CON_SAV

*CLASS:

*CATEGORY:

	IUESIPS

*PURPOSE:

	Converts RDAF *.sav files to a format compatible with the host
	operating system.  CON_SAV can convert files created with IUESAVE
	under VMS IDL version 1 or version 2, and files created under DEC
	or SunOS IDL version 2 to the appropriate format for the host
	operating system.  Output files are written using IDL FORTRAN
	compatible unformatted write statements of the form
	WRITEU,UNIT,H,W,F,E. 
     
*CALLING SEQUENCE:

	CON_SAV,IMAGET,cpupar

*PARAMETERS:

	IMAGET   (REQ) (I) (0) (S)  
	         File name of .sav file (without .sav extension).
	         Corrected data is written over original file on 
	         UNIX systems.  Wildcards are accepted.

	CPUPAR   (OPT) (I) (I) (0)
	         Parameter to identify data translation mode.

			no conversion        0

			VAX     to  MIPSEL   1
			MIPSEL  to  VAX      2

			VAX     to  SPARC    3
			SPARC   to  VAX      4

			MIPSEL  to  SPARC    5
			SPARC   to  MIPSEL   6

	         Supported Data Types:

			VAX    - VAXstations, MicroVAX
			MIPSEL - DECstations, IBM 386
			SPARC  - SparcStations, Sun 4##

		 Note: No Conversion is required between like data types,
		       such as DECstations and IBM 386s.

		 If CPUPAR is not given in the call, the user will be
		 prompted for it.

		 Note that only two modes are allowed for a given machine.
		 The allowed modes are those in which the final data format
		 is compatible with the host operating system.

*EXAMPLES:

	to convert swp1234cii.sav:
	   con_sav,'swp1234cii'

	to convert all .sav files in users account:
	   con_sav,'*'

*SYSTEM VARIABLES USED:

	!err_string

*INTERACTIVE INPUT:

	If CPUPAR is not given in the call, the user will be  prompted for it.

*SUBROUTINES CALLED:

	TRANS_BYTES
	PARCHECK
	DECOMPOSE
	CHKFITS
       CONMENU
       PLATFORM

*FILES USED:

	imaget given in calling sequence.

*SIDE EFFECTS:

*RESTRICTIONS:

	Program requires that the .SAV files be transferred to the host 
	CPU verbatim (e.g., using the -v option in DNICP or binary mode 
	in FTP).  Files transferred as ascii files (e.g., without the -v 
	option in DNICP) appear to be corrupted in that the 1st 2 bytes 
	are removed(?) and end-of-record bytes are added.

	SAV files created using the IDL routine SAVLIST are not properly 
	converted by this program.

	Not for use with fit formatted files.

*NOTES:

*PROCEDURE:

	CON_SAV uses the procedure PLATFORM to determine the host operating
       system and cpu architecture.  The allowed conversion options are then
       defined based on the operating system and cpu type.  The user is asked
       to select from the allowed conversion options and may also be asked if
       the input file was created on a VMS system.  Findfile is used to expand
       wildcard filename inputs to a string array.  Each input file is checked
       to determine if it is in fits format.  If it is, the file is not
       converted.  Then each input file is opened, and read into a byte array
       of length determined by the FSAT command. 

	The IUESAVE files consist of a record containing a four integer 
 	vector which gives the number of elements in the H, W, F, & E 
	vectors, followed by a record containing the H, W, F, & E vectors. 
	Under VMS IDL version 1, the second record usually consists of 
       several blocks.  Under VMS IDL version 2, the H, W, F, & E vectors 
	are contained in a single block unless the number of bytes in the 
	second record exceeds 32767 bytes.  Under Unix or Ultrix IDL, the
	second record always consists of a single block.  In addition to 
	the bytes which contain the data, extra bytes are included at the 
	beginning and end of each block.  VMS FORWRT and WRITEU commands 
	add a 4 byte longword at the beginning of each record, and a 2 
	byte integer (the block size) at the beginning and end of each 
	block.  If the number of bytes in the second record of a VMS 
       IDL Version 2 file exceeds 32767 bytes, the 4 inter-block bytes
       are preceeded by one "garbage" byte, which must also be removed.
       Unix or Ultrix WRITEU commands add a 4 byte longword 
	(the blocksize) at the beginning and end of each block. 
  
       Varible-length record files transferred from vms using the binary 
       mode of Multinet FTP are slightly different in format.  Multinet 
       removes the dcl-added bytes during the file transfer.  If the vms 
       file had carriage-return, carriage-control file attributes however, 
       Multinet adds a byte 10 (i.e., a cntl-J or line feed) at the end 
       of each block or record.  VMS users are therefore prompted for 
       whether Multinet was used.  Note that a new version of Multinet is 
       expected in the fall of 93 which will offer other modes for binary 
       file tranfer.

	The number of elements in the H, W, F, and E arrays, and the
	blocksize of the second record containing the H, W, F, and E
	arrays are determine from the first 12 to 20 bytes in the input
	file.  The block size is determined from the 2 byte integer 
	(files created on the VAX) or 4 byte longword (files created on 
	a UNIX machine) present at the start of the second record.  The 
	non-data bytes are removed, and the data portion of the second
	record is concatenated into a single array.  The bytes 
	representing the H, W, F & E vectors are extracted from this 
	array and converted to a format compatible with the host 
	operating system by TRANS_BYTES.  The byte vectors are converted 
	to the proper type, and written out to disk using WRITEU.  If 
	the host cpu is a VMS system, a new version of the output file 
	is opened using the /SEGMENTED keyword.  On a UNIX machine, the 
	output file is opened with the /F77_UNFORMATTED keyword and 
	written over the old input file.

*MODIFICATION HISTORY:

       8/21/89  RWT version 1
	9/14/89  RWT uses FINDFILE to allow use of wildcards 
	6/07/90  RWT modify to be compatible with both UNIX and ULTRIX
	2/27/91  GRA modify to allow conversions between VMS version 1
		     or version 2 *.sav files, ULTRIX, and SunOS *.sav
		     files. Input is accomplished by associating the 
		     entire input file with a single byte array of length
		     status.size. Added ERROR keyword to OPENR statments.
	4/1/91   PJL added  PARCHECK; updated prolog
	5/1/91   RWT add support for DOS
	6/13/91  GRA merged vms and sun versions, changed "dos" to "DOS"
	7/25/91  PJL cleaned up; tested VAX to SUN and SUN to VAX options; 
	  	     updated prolog
       10/25/91 GRA globally changed all references to "syspar" to 
		     "cpupar", changed cpupar to reference data formats as
		     specified by the !version.arch system variable; used 
		     /block keyword when opening the input file on a VMS 
		     machine so that the rms information can be bypassed; 
		     corrected error in blocksize byte removal from large
		     data records for files created under VMS IDL version 
		     2; condensed VMS and Unix branches; updated prolog; 
		     tested on ultrix/vax, ultrix/mipsel, vms/vax, 
		     sunos/sparc.
       10/29/91 GRA changed blocksize byte removal for large VMS IDL V2
                    files so that "extra" byte is removed before blocksize
                    bytes rather than after; cleaned up print statements;
                    tested on ultrix/vax, ultrix/mipsel, vms/vax, 
                    sunos/sparc; updated prolog.
       4/27/93  RWT add option for vms files transferred via Multinet FTP 
                    and replace trans_bytes calls for integer conversion
                    with intrinsic byteorder commands.
	15 Nov 93  PJL added CHKFITS
        9 Jun 94  PJL replaced !version with CONMENU and PLATFORM
       28 Sep 94  RWT add support for Multinet block mode

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


COPUF

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

    	COPUF
  
*CLASS:

	Disk File Utility 
  
*CATEGORY:

	IUESIPS  NEWSIPS
  
*PURPOSE:
  
    	Copies unformatted or formatted data from the input file to the 
       specified output file using IDL read and write commands (i.e., 
       without spawning to systems commands). If /nocopy is specified, 
       copuf only returns the full output file name. 

*CALLING SEQUENCE:

    	COPUF,IMAGI,IMAGO,nocopy=nocopy,form=form
  
*PARAMETERS:
  
    	IMAGI  (REQ)  (I)  (0) (S)
             	Name of input file (string). If no extension is given, 
               copuf assumes both an iuesips .dat and a .lab file are to
               copied.

    	IMAGO   (REQ) (I/O) (0) (S)
             	Name of output file (string).
               - For systems with version numbers (e.g., VMS), if 
               IMAGO is blank (i.e. ' '), or any number, then the output 
               file will have the same name as the input file with the version 
               number incremented. 
               - For systems without version numbers (e.g., unix),
               and IMAGO is blank or a number, the file is not copied, 
               but IMAGO is set to IMAGI. 

       NOCOPY  (OPT) (KEY) (0) (S)
               keyword specifying no file copy should be performed.
               COPUF will only return the full output file name.

       FORM    (OPT) (KEY) (0) (S)
               keyword specifying formatted file to be copied (i.e. 
               an ASCII text file). If not specified, unformatted files 
               are assumed.
 
*EXAMPLES:

    	copuf,'swp25303s.dat','modt.dat'   ; copy SWP 25303 ELBL file into
    	                            ; MODT.DAT file (note for running
    	                            ; these renamed output files with other
    	                            ; RDAF procedures, it may be necessary
    	                            ; to use the standard naming conventions
    	                            ; (e.g., LWPnnnnS.DAT or SWPnnnS.DAT).
 
    	copuf,'modt.dat',' '       ; (VMS) copy MODT.DAT file
                                  ; into new file with same name
                                  ; (unix) nothing is done

       imago = 0
       copuf,'swp12345.mxlo',imago  ; (unix) no copy is performed, but imago is
                                    ; set to imagi
                                    ; (vms) new version is created

       copuf,imagi,imago,/nocopy    ; no copy is performed (on any system)
                                    ; but imago is defined or expanded to 
                                    ; full path name

*SYSTEM VARIABLES USED:

       none
  
*INTERACTIVE INPUT:

	If IMAGO already exists on a system not supporting version numbers, 
       then the user is prompted before continuing.
  
*SUBROUTINES CALLED:
  
    	PARCHECK
    	DECOMPOSE
       PLATFORM
       YESNO
 
*FILES USED:

   	IMAGET & OUTPUT FILE (IMAGO)
  
*SIDE EFFECTS:
  
*RESTRICTIONS:

        - For VMS systems, unformatted files must have fixed-length records.
        - Formatted files must have less than 5000 lines.
  
*NOTES:
  
    	 - If no extension is specified with imagi, COPUF assumes both 
          the .dat and .lab iuesips files are to be copied.
        - If no extension is specified with imago, the extension(s) for imagi
          are assumed.
        - If IMAGO already exists (on systems without version numbers), the
          user is prompted to continue before the file is overwritten.
        - If imago is blank or a number, and the system does not allow version
          numbers, then copuf only creates the output file name. 
        - Version numbers are left off IMAGO name so on vms systems output 
          file is always assigned the highest version number.
        - In programs like BSPOT that are modifying either IUESIPS or
          NEWSIPS files, the NEWSIPS files may need the /nocopy option 
          because FITS files can not be updated like iuesips files.
        - COPUF is compatible with all IUESIPS and NEWSIPS data sets.
 
*PROCEDURE:
  
       File is read and then written out to disk with new name.
 	
*I_HELP nn:
  
  
*MODIFICATION HISTORY:

       Written by R. Thompson 2/95 (based on modlbl and bs_inout)
       3 Mar 95 RWT add /nocopy option (for defining NEWSIPS file names
                    without copying file)
       3 Mar 95 RWT remove version numbers from output file
       7 Mar 95 RWT add support for formatted files
       7 Mar 95 RWT increase formatted file limit from 900 to 5,000 lines

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


CPYCHK

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

     cpychk

*PURPOSE:

     To check for existence of a file to be written.

*CALLING SEQUENCE:

     cpychk,file,cpy,/update,/qsupersede

*PARAMETERS:

     file (req) (i/o) (0,1) (s)
          File(s) to check for.  The user may enter new file name(s) if
          the update keyword is set.

     cpy  (req) (i/o) (0,1) (i)
          Flag(s):  0=the user does not wish to proceed with creating file.
                    1=the user wishes to create the file regardless of the
                      existence of file(s) of the same name(s).
          CPY can be set ahead of time to indicate the default value of CPY.

     update (key) (i) (0) (i)
            If set, the user may enter new filenames.

     qsupersede (key) (i) (0) (i)
            If set, the program will query the user even if the current
            operating system merely creates a new version number rather
            than overwriting existing files.


*SUBROUTINES CALLED:

     platform (to get proper term for current operating system)

*FILES USED:

     This procedure does not open any files.

*SYSTEM VARIABLES USED:

     none

*PROCEDURE:

     For each file, a FINDFILE is done to check for pre-existing file with 
     the same name.  If any are found, the user is asked if the new file
     should be created anyway.  If the update keyword is set, the user can
     enter a new name for each file.

*MODIFICATION HISTORY:

      6 Feb 95 LLT wrote.

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


CRSCOR

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

    	CRSCOR        JUNE,1984

*CLASS:

    	Cross-correlation

*CATEGORY:
 
*PURPOSE:     

    	To derive the normalized cross correlation function for two 
       spectra (using either linear wavelengths or velocity units), and 
       to calculate its maximum by Gaussian fitting or finite differences.
       The location of the maximum represents the apparent shift of spectrum
       1 with respect to spectrum 2.
 
*CALLING SEQUENCE:

     	CRSCOR,W1,F1,W2,F2,BEGL,ENDL,delta,vinc=vdel,ccf=ccf
 
*PARAMETERS:

     	W1,F1	(REQ) (I) (0) (S)
             	Required wavelength and flux vectors to be analyzed for
               first spectrum.

     	W2,F2   (REQ) (I) (0) (S)
             	Required wavelength and flux vectors to be analyzed for
               reference spectrum. 
               Calculated shifts are with respect to these wavelengths.

     	BEGL    (REQ) (I) (0) (F)
             	Beginning wavelength for the cross-correlation, in the
             	same units as the files to be correlated (default Angstroms)

     	ENDL    (REQ) (I) (0) (F)
             	Ending wavelength for the cross-correlation, in the same
             	units as BEGL.

     	DELTA   (OPT) (O) (0) (F)
             	Output parameter giving the apparent shift between 
               the two spectra in the same units as the wavelength scale.
               Note, if more than one Gaussian component is specified, only
             	the first center value is output to DELTA although all
             	values are listed on the display.

     	VINC    (KEY) (I) (0) (F)
               If specified, cross correlation is performed in velocity
               space using the specified value for the incremental velocity 
               spacing. (3 - 10 km/sec is recommended for IUE high dispersion).
               If not specified, linear wavelengths are used.

     	CCF     (KEY) (O) (1) (F)
               optional keyword for outputting the normalized cross correlation
               function.
 
*EXAMPLES:  

     	CRSCOR,W1,F1,W2,F2,2680,2760,DEL,vinc=10
         	cross correlates order 85 of spectrum 1 with spectrum 2
               using the wavelength range from 2680 to 2760 angstroms, and
         	producing the cross correlation function every 10 km/sec.

       CRSCOR,W1,F1,W2,F2,2400,2600,del
               correlation function is derived for wavelength region from
               2400 to 2600 angstroms using linear wavelengths. 
               (typical use for IUE low dispersion spectra).

       N1 = INDGEN(N_ELEMENTS(F1))
       N2 = INDGEN(N_ELEMENTS(F2))
       CRSCOR,N1,F1,N2,F2,0,N_ELEMENTS(F1)-1,CCF=CROSS
               cross correlates two arrays using indices instead of 
               wavelengths, and outputs cross correlation function as cross.

  
*INTERACTIVE INPUT:  

     	The programs first presents the user with a graph of
     	the two input files. It then computes the 
     	normalized cross correlation function and displays 31 pts. over
     	the interval +/- 15*VDEL (or +/- 15*delw). The user is prompted 
       with the following options: 
       1) if a well-defined maximum is present the
     	program can locate it automatically and determine its position
     	by means of interpolation to zero in the first differences
     	(finding the point of zero slope); 2) if it appears that a
     	maximum exists outside the searched range, the range can be
     	doubled and the function replotted; 3,4,..) if Gaussian fitting
     	is desired, (e.g. if more than one real maximum appears present)
     	then the cross-correlation function may be fit interactively
     	with 1,2,.. components (as determined by GAUSSFIT). GAUSSFIT
     	removes a constant baseline before fitting the Gaussians using
     	the region outside the region specified by the user as the
     	feature to be fitted.  The user indicates with the cursor the 
     	approximate location and height of each component to be fit.

*SYSTEM VARIABLES USED:

	!d.x_ch_size
	!d.y_ch_size
	!d.y_size

*FILES USED:

     	none

*SUBROUTINES CALLED:

	PARCHECK
    	IUEFETCH
       XYREADS
       IUETERP - resamples spectrum 1 to agree with spectrum 2 (if required)
    	CRSPROD - computes a normalized cross-correlation function
    	CRSMAX - determines maximum of cross-correlation function
 
*PROCEDURE: 

     	While for most IUE applications the range (ENDL - BEGL) is
     	much less than the wavelengths involved, it is more precise
     	in high dispersion to find the shift in log lambda space instead 
       of lambda directly (since dL/L = cnst). If velocity spacing is
       requested, the two arrays of wavelengths and fluxes are
     	interpolated using QUADTERP to a common set of equally spaced
     	log lambda points, with spacing corresponding to a velocity VDEL
     	at the midpoint wavelength (BEGL+ENDL)/2. In either case, the mean 
       flux for each spectrum is subtracted from that flux array, and the 
       resulting arrays of positive and negative values are shifted with 
       respect	to each other to find the sum of the products at each shift.
     	The array of product sums vs. shift is normalized to become the
     	'normalized cross-correlation function'. If the user wants to
     	fit several Gaussians to the cross correlation function, 
     	GAUSSFITS fits the heights, widths, and central velocities for the
     	specified number of components. It also computes the standard 
     	deviations of these parameters using the value computed from the
     	baseline portion of the correlation function as the standard
     	deviation of a single point. For correlation functions with
     	a single well-defined maximum, the velocity shift can be 
     	calculated automatically by a weighted least squares fit to the
     	1st differences and interpolating to the point of zero slope.
     	The weighting gives higher weight to points close to the midpoint
     	of the correlation function.
     	The output includes a plot of the cross correlation function,
     	and the velocity shift determined from the maximum of the cross
     	corrrelation function. If Gaussian fitting is used, the standard
     	deviation of a single point is printed as are the values for
     	the Gaussian parameters and their errors. A plot shows the data,
     	the individual Gaussians, the sum of all components, and the
     	deviations.
 
*NOTES: 

       - When a Gaussian fit is made to the cross correlation
     	function, GAUSSFITS uses the following symbols for output:
     	        - histogram: data points
     	        - solid line: the total fit, the sum of all Gaussian 
     	                components and the baseline
     	        - dots: individual Gaussian components
     	        - plus signs: O-C deviations from the fit
  
     	- Before execution one should check IUE high dispersion
       spectra to be sure that the heliocentric velocity correction 
       has been applied.
     	  For images processed before 10 Nov. 1981, the user should
     	determine the orbital velocity corrections (see IUEVEL).
     	Corrections may also be needed for velocity-like shifts due to
     	IUE camera effects (see ASSESS). In any case, users may want to
       run IUEVEL for the most accurate velocity corrections.

       - Smoothing of the data might improve the fits. 

     	- Execution time for CRSCOR depends on the size of
     	the arrays. It is recommended that no more than half of the 
     	wavelength interval covered by 3 IUE high dispersion orders be 
       correlated at one time.

     	- If a reasonable amount of correlation exists between the 2
     	spaectra, a well-defined maximum will be present, often
     	Gaussian in character but often with asymmetrical wings and
     	secondary inflections which may or may not have significance.
     	Note: if a spectrum has a strong slope, this can distort the
     	function relative to what would be obtained from spectral
     	lines with a flat continuum; a procedure such as NORM should
     	be used in this case before running crscor. 
     	  The precise maximum of the function can be found either by
     	fitting a Gaussian function in the vicinity of the peak or by
     	locating the shift value for which the slope of the function
     	is zero. It was found that the procedure using the
     	first differences of the function, locates this value with
     	a precision better than 0.1*VDEL or about 1 km/sec generally.

       Program assumes velocity units are km/sec and wavelength units
       are in angstroms.

	tested with IDL Version 2.1.0 (sunos sparc)  	25 Jun 91
	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
	tested with IDL Version 3.0   (vms vax)      	09 Jul 93
  
*MODIFICATION HISTORY:

       Sept. 1981   S. Parsons    CSC   initial program, adapted from
                                        a FORTRAN program by M. Slovak
                                        of the University of Texas.
       Apr.  1982   F.H. Schiffer GSFC  program brought into agreement
                                        with RDAF standards
       Jun.  1984   N.R. Evans    GSFC  to test, document, alter output,
                                        permit fitting of the correlation
                                        function by Gaussian(s), and to
                                        determine the errors for fitting
                                        parameters.
      18  Jul.  1984   RWT        GSFC  replaced subroutine PLPARM with
                                        call to PLTPARM, use LINFIT in
                                        first difference calculation, and 
                                        update documentation.
       8  Aug.  1984   RWT        GSFC  modified to use new version of 
                                        LINFIT.
       8  Nov.  1985   RWT        GSFC  DIDL modifications, NELEMENTS,
                                        FINDGEN, and indirect compilation
      14  Mar.  1987   RWT        GSFC  VAX mods: add PARCHECK, use 
                                        SET_XY, remove some EXTRACs
      23  Sept. 1987   RWT        GSFC  compile RDAF version of GAUSSFIT,
                                        not IDL user's library procedure
                                        of the same name, and add listing
                                        of procedure call.
       8  Oct.  1987   CAG        GSFC  Alter GAUSSFIT call to GAUSSFITS,
                                        to reflect change of procedure 
                                        name. Convert BEGL and ENDL to
                                        be floating point, and correct one
                                        format statement. 
      14  Oct.  1987   RWT        GSFC  remove subroutine NETVEL, and
                                        compilation for PARCHECK.
      16  Nov.  1987   RWT        GSFC  improve plot annotation.
      19  Jan.  1988   RWT        GSFC  correct error for image numbers
                                        larger than 32767.
       5  May   1988   CAG        GSFC  add VAX RDAF-style prolog.
      23  Aug   1989   RWT        GSFC  Unix mods.
      25  Jun.  1991   PJL        GSFC  cleaned up; tested on SUN and VAX;
				         updated prolog
      23  Feb.  1993   LLT        GSFC  Removed style and range keywords
                                        in OPLOT (not allowed in V. 3)
      7/15/93 RWT GSFC  remove ctstrim subroutine, allow linear wavelengths,
                        make vdel an optional parameters, and use vectors 
                        as input rather than SAV files.
      7/21/93 RWT GSFC  add IUETERP to resample data in linear wavelength mode,
                        and add ccf keyword
     10/25/93 RWT GSFC  write user prompts to text window instead of plot 
                        window (for x-window sessions), allow < 15 points
                        in correlated wavelength region, and test for number 
                        of points available when search area is increased.

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


CRSMAX

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

    CRSMAX (IUE Production Library) (01 April 1988)

*CLASS:

    cross-correlation

*CATEGORY:

*PURPOSE:

    DETERMINE THE MAXIMUM OF THE CROSS CORRELATION FUNCTION

*CALLING SEQUENCE:

    CRSMAX,CROSS,VSPACE,INP,DELV,SIGY
 
*PARAMETERS:

   CROSS    (REQ) (I) (1)  (F)
            Required input vector giving the cross-correlation function 
            to be fit.

   VSPACE   (REQ) (I) (1)  (F)
            Required input vector specifying the velocity spacing for
            the cross-correlation function.
   
   INP      (REQ) (I) (0)  (I)
            Required input scalar specifying the number of Gaussian
            components to be fit to the cross-correlation function.
            If this parameter is zero, the cross-correlation function
            will be fit using a least squares fit to the first difference
            function, and the point of zero slope identified. 

   DELV     (REQ) (O) (0)  (F)
            Velocity difference (in km/s) of the two spectra as
            determined from the maximum of the cross-correlation function.
            This quantity is determined either by the centroid of the 
            fitted gaussian, or via the first difference technique. 

   SIGY     (REQ) (O) (0)  (F)
            Required output variable giving the rms deviation
            of the gaussian fit from the cross-correlation function.
            This variable will be non-zero if and only if a gaussian
            fit to the cross-correlation function is requested.

   XPOS     (REQ) (IO) (0) (F)
            x position to start writing output in device units.
            
   YPOS     (REQ) (IO) (0) (F)
            y position to start writing output. Returned value
            designates position of last line of output.

   LIN      (KEY) (I) 
            if set, assumes linear wavelengths

*SYSTEM VARIABLES USED:

	!d.y_ch_size

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

      GAUSSFITS
      LINFIT
      PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

     See CRSCOR

*PROCEDURE:

     The normalized cross-correlation function can be fit either
     with one or more gaussian profiles, or if the function has a single
     well-defined maximum, via a least squares fit to the first differences,
     and interpolating to the point of zero slope. 

*EXAMPLES:

     To fit a normalized cross-correlation function with one Gaussian,
     CRSMAX,CROSS,VSPACE,1,DELV,SIGY

     To fit the same cross-correlation function by finding the local
     extremum,
     CRSMAX,CROSS,VSPACE,0,DELV,DUMMY
   
*MODIFICATION HISTORY:

     for earlier history, see CRSCOR
     05  May 1988   CAG     GSFC   add VAX RDAF-style prolog, PARCHECK
     8/25/89 RWT GSFC Unix mods: add xpos & ypos parameters, remove !c,
         use xyouts instead of print,
     25  Jun 1991   PJL  GSFC  cleaned up; added 0 parameters print;
				tested on SUN and VAX; updated prolog
     23  Feb 1993   LLT  GSFC  Print vel. shift below plot, instead of upon it.
     7/15/93 rwt  add /LIN keyword for linear wavelengths 
    10/25/93 rwt  shift final line of text to avoid overlap with plot
                  annotation in x-windows

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


CRSPROD

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

      CRSPROD (IUE Production Library) (01 April 1988)

*CLASS:

     cross-correlation

*CATEGORY:

*PURPOSE:

   To compute a normalized cross correlation for two spectral segments
   which are sampled on the same linear or log(lambda) scale. 

*CALLING SEQUENCE:

   CRSPROD,FFIR,FSEC,NSPR,CROSS,CRMIN,CRMAX

*PARAMETERS:

   FFIR    (REQ) (I)  (1) (F)
           Required input vector giving the flux data for the first
           spectrum.

   FSEC    (REQ) (I)  (1) (F)
           Required input vector giving the flux data for the second 
           spectrum.

   NSPR    (REQ) (I)  (0) (F)
           Required input parameter specifying the spectral range to
           be considered in the cross-correlation function.

   CROSS   (REQ) (O)  (1) (F)
           Required output vector containing the cross-correlation 
           function.

   CRMIN   (REQ) (O)  (0) (F)
           Required output vector containing the minimum of the 
           cross-correlation function. 

   CRMAX   (REQ) (O)
           Required output vector containing the maximum of the 
           cross-correlation function. 

*EXAMPLES:

    To compute the cross-correlation function for two spectra, FIRST
    and SECOND, using the recommended initial spectral range from CRSCOR,

    CRSPROD,FIRST,SECOND,15,CROSS,CRMIN,CRMAX

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:
       Assumes same number of elements in both spectra. (Both fluxes are
       divided by the number of elements in the first spectrum.)

*PROCEDURE:

     CROSS is determined for (2*nspr + 1) tags or shifts going from -15
     to +15 shifts from the starting locations. 
     After subtracting the average flux from each spectrum, the cross
     correlation function is computed as follows for each point in 
     the spectra, 
      TEMP = (second spectrum) * SHIFT(first spectrum,ns)
      CROSS(L) = TOTAL(TEMP(ls:us)/nele) 


*MODIFICATION HISTORY:

	25 Jun 1991  PJL cleaned up; added PARCHECK and parameter eq 0
			 print; tested on SUN and VAX; updated prolog

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


CRSTRIM

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

      CRSTRIM (IUE Production Library) (01 April 1988)

*CLASS:

      cross-correlation, spectral extraction, resampling

*CATEGORY:

*PURPOSE:

   To extract the spectral data within the user-specified wavelength
   range, and to interpolate the spectral data to a common log(lambda)
   scale. 

*CALLING SEQUENCE:

   CRSTRIM,BEGLAM,ENDLAM,FILEN,W,F,N,RWLOG,FF,M,JUMP

*PARAMETERS:

   BEGLAM  (REQ) (I)  (0)   (F)
           Beginning wavelength for the extraction, given in the same
           units as the spectral data.

   ENDLAM  (REQ) (I)  (0)   (F)
           Ending wavelength for the extraction, given in the same
           units as the spectral data.

   FILEN   (REQ) (I)  (0)   (S)
           Required input string variable giving the name of the .SAV
           formatted file to be extracted and resampled.

   W       (REQ) (I)  (1)   (F)
           Required input vector giving the wavelength data for the 
           spectrum of interest.

   F       (REQ) (I)  (1)   (F)
           Required input vector giving the flux data for the spectrum of
           interest.

   N       (REQ) (I)  (0)   (I)
           Required input parameter giving the number of data points
           in the spectrum.

   RWLOG   (REQ) (I)  (1)   (F)
           Required input vector giving the log(lambda) grid for the
           spectral data to be resampled onto.

   FF      (REQ) (O)  (1)   (F)
           Required output vector containing the resampled flux data

   M       (REQ) (O)  (0)   (I)
           Required output scalar giving the number of points in the
           extracted and resampled spectrum.

   JUMP    (REQ) (O)  (0)   (I)
           Required output error flag. If JUMP=0, the data are O.K..
           If JUMP=1 then the spectral data do not include the 
           wavelength range specified by the user for the cross-correlation.

*EXAMPLES:

  To trim and resample a spectrum from wave1 to wave2 onto a log(lambda)
  grid given by RWLOG,

  CRSTRIM,wave1,wave2,'SWP33315FE3',wave,flux,N_elements(wave),RWLOG,ff,m1,JUMP

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

      TABINV
      QUADTERP
      PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

     Used by procedure CRSCOR

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

*PROCEDURE:

     see documentation for CRSCOR

*MODIFICATION HISTORY:

     for earlier modification history, see CRSCOR
     05  May 1988  CAG   GSFC   add VAX RDAF-style prolog, PARCHECK
     25  Jun 1991  PJL   GSFC   cleaned up; lowercase; added parameters
				 eq 0 print; tested on SUN and VAX; 
				 updated prolog

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


CURESTR

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

	CURESTR

*CLASS:

*CATEGORY:

	NEWSIPS

*PURPOSE:

	Determine if the image's camera and dispersion are permitted.  This
	is useful as different cameras and dispersions will be released at
	different times.  Once all data has been release, this procedure will
	no longer be necessary.

*CALLING SEQUENCE:

	CURESTR,MAIN,FLAG

*PARAMETERS:

	MAIN	(REQ) (I) (1) (S)
		The main fits header (may include the vicar label and fits
		history portion).

	FLAG	(REQ) (O) (0) (I)
		Set to 1 is image is of a supported camera and dispersion.
		Set to 0 is image is not of a supported camera or dispersion.

*EXAMPLES:

	iuefhrd,filename,params,main,/silent,/full
	curestr,main,flag

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK
	STPAR

*FILES USED:

	none

*SIDE EFFECTS:

	none

*RESTRICTIONS:

	Must be updated as different cameras and dispersion become available.

*NOTES:


*PROCEDURE:

	Uses STPAR to obtain the CAMERA and FILENAME keywords.  The dispersion
	is obtained from the extension given in the FILENAME keyword.  The
	CAMERA keyword value and dispersion are checked.  If acceptable, then
	flag = 1, else flag = 0.

*I_HELP  nn:

*MODIFICATION HISTORY:

	 3 Jun 93  PJL  wrote
        6 Sep 94  RWT  set flag for LWP low dispersion data

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


DATAREC

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

	DATAREC

*CLASS:

	File Transfer
  
*CATEGORY:

	IUESIPS
  
*PURPOSE:

	Procedure to convert IUESIPS GO-format tape or disk files to
	RDAF-format disk files - deals with data records.
  
*CALLING SEQUENCE:

	DATAREC,UNIT,IMAGET,NCAM,NIMAGE,NL,NB,LUNI,ITFN,NBLOCKS
  
*PARAMETERS:

	UNIT    (REQ) (S) (0) (I)
		Input disk or device file name (e.g. on UNIX systems 'nrmt0',
		on VMS systems an integer)

	IMAGET  (REQ) (I) (0) (S)
		IUE file name using standard RDAF notation (e.g. 'LWP12345l')

	NCAM    (REQ) (I) (0) (I)
		IUE camera number

	NIMAGE  (REQ) (I) (0) (I L)
		IUE image sequence number

	NL      (REQ) (I/O) (0) (I L)
		Number of lines (records) to be read in IUE file

	NB      (REQ) (I) (0) (I L)
		Number of bytes per record

	LUNI    (REQ) (I) (0) (I)
		Logical unit number of input device file (from LLDISK.PRO)
  
	ITFN    (REQ) (I) (0) (I)
		ITF number to be inserted into scale factor record

	NBLOCKS  (REQ) (I) (0) (B I)
		 Number of 360-byte blocks found in label

*EXAMPLES:
  
*SYSTEM VARIABLES USED:

	!err_string

*INTERACTIVE INPUT:

	none
  
*SUBROUTINES CALLED:

	PARCHECK
       PLATFORM
  
*FILES USED:

	GO format file - input.  Already opened by VICAR.PRO

	IMAGET + '.dat' - output disk file

*SIDE EFFECTS:
  
*RESTRICTIONS:

	- GO file must be open and positioned at the beginning of the scale
	  factor record (e.g., VICAR has been run)

	- VICAR returns the logical unit of the device file being read 
	  (sequentially) and this is needed by this procedure.

	- Only for use with IUESIPS files.
  
*NOTES:

	File format not checked.

*PROCEDURE:

	First the procedure modifies NIMAGE to handle numbers > 32767.  The
	next step is to determine the dimensions of the output file.  For
	extracted data files, each record is preceded with an extra 2 bytes
	which represent (1) record number, and (2) number bytes in record.
	These are removed.  Next, the output file is opened and the spectral
	file data extracted.  A header record like that on extracted spectra
	files is constructed for images.  The header is updated and saved and
	the results of the procedure are printed to the screen.
  
*I_HELP:
  
*MODIFICATION HISTORY:

    Written by LLT based on DDISK.
   30 Apr 92 rwt modified to handle go disk files with truncated data
                 records
   24 Feb 93 LLT Fix problem with converting raw images read from tape.
   22 Nov 93 PJL update documentation
   10 Jun 94 PJL replaced !version with PLATFORM
   20 Oct 94 PJL added code for tapectrl.device equal 'NA'
   27 Apr 95 RWT add offset definition when tapectrl.device='NA'

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


DATECONV

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

*CLASS:
       Data Conversion

*CATEGORY:

*PURPOSE:
	Procedure to perform conversion of dates between any of 5 possible
	formats:
	format 1: real*8 scalar encoded as:
		(year-1900)*1000 + day + hour/24. + min/24./60 + sec/24./60/60
		where day is the day of year (1 to 366)
	format 2: Vector encoded as:
		date(0) = year (on output, year will be full year (e.g., 1987)
                               but as input, can be specified as 1987 or 87)
		date(1) = day of year (1 to 366)
		date(2) = hour
		date(3) = minute
		date(4) = second
	format 3: string (ascii text) encoded as
		DD-MON-YEAR HH:MM:SS.SS
		(eg.  14-JUL-1987 15:25:44.23)
               Format 3 can also be output in a FITS-compatible format as
               dd/mm/yy (e.g., 22/07/93)
	format 4: three element vector giving spacecraft time words
               from ST telemetry packet.
       format 5: integer number in form yymmdd

*CALLING SEQUENCE:
	DATECONV,DATE,TYPE,OUT

*PARAMETERS:
	DATE (REQ) (I) (0,1) (DSIL)
            input date in one of the allowed formats.

	TYPE (REQ) (I) (0) (S)
            type of output format desired.  
	     valid values:
			'REAL'	- format 1
			'VECTOR' - format 2
			'STRING' - format 3
                       'FITS'  - modified format 3 
                       'INTEGER' - format 5
            TYPE can be abbreviated to the single character strings 'R',
            'V', 'S', 'F', or 'I'.
            Nobody wants to convert TO spacecraft time (I hope!)

       OUT  (REQ) (O) (0,1) (BILFDS)
            Converted date in specified format.

*PROCEDURE:
       Input date format is determined using SIZE information.
       Year, day, hour, minute, and second are calculated and reformatted
       as specified by TYPE. 

*SYSTEM VARIABLES USED:

*SUBROUTINES CALLED:
       IUEGETTOK - Procedure version of gettok
       PARCHECK

*SIDE EFFECTS:

*RESTRICTIONS:

*PROCEDURE:

*EXAMPLES:
       To generate current date in a format suitable for a FITS keyword:
          dateconv,!stime,'fits',out

       To convert 1994 day 152 to yymmdd:
          dateconv,94152.0,'I',out
       out will equal 940601 (i.e., 1994, June 01)

*NOTES:
       Format 3 can be EITHER a string in a format identical to that 
          used by IDL system variable !STIME, or that used in FITS headers.
       Format 5 actually produces a longword integer.

*MODIFICATION HISTORY:
	version  1  D. Lindler  July, 1987
       adapted  for IDL version 2  J. Isensee  May, 1990
       8/06/93  rwt convert function to a procedure, update prolog, use
                IUEGETTOK instead of GETTOK, and add FITS option
       8/03/94  rwt add format 5 option.
      11/01/94  rwt fix bug when input date is in format 5
      11/02/94  rwt allow FITS format strings as input, set internal year
                parameter to be consistently 2 digits (i.e., 92 instead of 
                1992),
               and only use full year in output formats 'R' and 'S'.
      02/10/95 tmw added check in the interger output block to allow for
               leap years.

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


DCCOR

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

       DCCOR

*CLASS:

       Data correction, reprocessing, and calibration.

*CATEGORY:

	IUESIPS

*PURPOSE:

       Corrects wavelengths for low or high dispersion LWR and SWP images
       taken after 1984 which were processed with dispersion constants
       originally implemented in IUESIPS in either 1984 or 1988.

*CALLING SEQUENCE:

       DCCOR,H,DELTAW,wave

*PARAMETERS: 

       H       (REQ) (I) (1) (I)
		IUE header record.

       DELTAW  (REQ) (O) (01) (R D)
		Correction factor (in angstroms) to be SUBTRACTED from old
		wavelength array.

       WAVE    (OPT) (I/O) (1) (R)
		Optional wavelength array with correction included
		(i.e. WAVE = WAVE - DELTAW).  Required parameter for high
		dispersion.

*EXAMPLES:

       To correct wavelengths for low dispersion SWP 32100.

            iuespec,'swp32100l',h,w,f,e
            dccor,h,deltaw,w

       To correct wavelengths for high dispersion LWR 18399.

            iuespec,'lwr18399h',h,w,f,e
            wn = w             ; to save old wavelength array
            dccor,h,deltaw,wn

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

       PARCHECK

*FILES USED:

	none

*SIDE EFFECTS:

*RESTRICTIONS:

       Correction is only valid for SWP and LWR low or high dispersion
       images obtained and processed after June 20, 1984 at GSFC and
       September 14, 1988 at Vilspa.

	Only for use on IUESIPS data.

*NOTES:

       - Correction is only appropriate for SWP and LWR low or high dispersion
       images obtained between the dates given above.  Suitability of data
       for correction is determined by checking the value of the A2 dispersion 
	constant, thus making this determination independent of processing
	station.

       - Corrections are based are data obtained through August, 1991. 
       Extrapolating for images obtained much beyond this date 
       (i.e. > a couple of years(?)) may be inaccurate.

       - The greatest improvements in wavelength assignements are seen 
       in SWP data obtained in 1987 and after 1991. For mid-1991, the 
       SWP high dispersion correction is ~ 10 km/sec.

       - No significant time dependence has been observed for the LWP 
       camera and therefore it is not subject to the errors described above.

       - To recover the original wavelength array, add DELTAW to the
       corrected wavelength array.

       - See articles in IUE Newsletter #35 and #46.

*PROCEDURE:

       Software was written to calculate the difference between the low or
	high dispersion dispersion constants implemented in 1984 and 1988 with
	those described in Newletter #46 as a function of time.  Average THDA
	and wavelength values were used but analysis showed that the correction
	varied by less than 0.2 angstroms for the entire range of THDA and
	wavelengths in low dispersion, while high dispersion data indicated a
	correction variation of around 0.5 km/sec (i.e. less than one
	resolution element in either case).  Line and sample differences were
	calculated and then converted to differences along and perpendicular
	to the dispersion.  The average velocity shift is printed for high
	dispersion data.  The coefficients used below were calculated using
	WPOLYFIT to fit a 2nd order polynomial to the resulting arrays of
	differences along the dispersion versus time. 

       DCCOR simply extracts the observation time from record 0 and 
       calculates the wavelength shift (to be subtracted from the wavelength 
       array in question) using the appropriate coefficients.  The camera
       and dispersion are both determined from the header record as well.
       A flag is set in Record 0 [h(579)] to indicate that the image was
       used to derive a DELTAW correction factor [h(579)=1] or that 
       the correction was actually applied to the wavelength vector [h(579)=2].

*I_HELP nn:

*MODIFICATION HISTORY:

    writen by R. Thompson 6-29-88
    10-7-88 GS correct error in date calculation and add double precision
    5-22-89 RWT make DELTAW real (not double precision)
    7-10-90 GS  use dispersion constants to check for appropriate data
    9-5-90  GS  use flag in header to indicate that correction was applied
    11-8-90 RWT add dispersion constant test for LWR spectra, remove
            test for high dispersion (unnecessary), and set h(579)=1
            only if a valid image is specified.
    7-7-92  MPG add second correction for post 1988 data
    7-21-92 RWT update prolog
    7-27-92 MPG add correction for high dispersion data
    8-04-92 PJL corrected h(505) case statements to allow for "no valid case"
    4-06-93 MPG update corections using latest dispersion constants
    8-23-93 RWT reword correction messages
	22 Nov 93  PJL  update documentation;  check header

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


DECIPHMX

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

	DECIPHMX

*CLASS:

*CATEGORY:

	NEWSIPS

*PURPOSE:

	Decipher IUE merged extracted spectrum image fits files and return the
	aperture.  The wavelengths, calibrated flux, NEWSIPS flags, sigmas,
	background flux, and net flux might be returned.

*CALLING SEQUENCE:

	DECIPHMX,FILENAME,ROW,APERTURE,wave,abs_flux,flags,sigma,bkgrd,net

*PARAMETERS:

	FILENAME  (REQ) (I) (0) (S)
		The filename - including extension.

	ROW	(REQ) (I) (0) (I)
		The row for IFITSRD.

	APERTURE  (REQ) (I) (0) (S)
		The aperture extracted.  If an error occurs, it is set equal to
		'ERROR'.

	WAVE	(OPT) (O) (1) (D)
		The wavelength vector.

	ABS_FLUX  (OPT) (O) (1) (R)
		The absolute flux vector.

	FLAGS	(OPT) (O) (1) (I)
		The NEWSIPS error flags vector.

	SIGMA	(OPT) (O) (1) (R)
		The sigma vector.

	BKGRD	(OPT) (O) (1) (R)
		The background flux vector.

	NET	(OPT) (O) (1) (R)
		The net flux vector.

*EXAMPLES:

	deciphmx,filename,1,aper

	deciphmx,filename,1,aper,wave,flux,flags,sigma,bkgrd,net

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	CHKFITS
	STPAR
	IFITSRD

*FILES USED:

	filename given in calling sequence

*SIDE EFFECTS:

*RESTRICTIONS:

	only tested with SWP data
	not tested with high dispersion data

*NOTES:

*PROCEDURE:

	Determines if file exists and if it is a fits file.  IFITSRD is used
	to read the data.  The number of fields is found via STPAR and the
	TFIELDS keyword.  The data is assigned to the appropriate variable.

*I_HELP  nn:

*MODIFICATION HISTORY:

	14 Jun 93  PJL  wrote
	15 Jun 93  PJL  set no values to defaults;  changed IFITSREAD to
			IFITSRD
	12 Aug 93  PJL  add /silent keyword to IFITSRD call

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


DECOMPOSE

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

	DECOMPOSE     (General IDL Library 01) 19-JUL-81

*CLASS:

	PARSING
 
*CATEGORY:

*PURPOSE:

	Break file name into component parts, using VMS and RSX11 punctuation
	rules.
 
*CALLING SEQUENCE:

	DECOMPOSE,FILE,DISK,PATH,NAME,EXTN,VERSION
 
*PARAMETERS:

	FILE	(REQ) (I) (0) (S)
		Required input string variable giving the file name in RSX11
		and VMS file description format, e.g.
		diska:[myaccount]file.ext;vers
 
	DISK	(REQ) (O) (0) (S)
		Required output string giving the name of the disk.  If not 
		specified in FILE, the value returned will be a null string.

	PATH	(REQ) (O) (0) (S)
		Required output string giving the path name.  If not specified
		in FILE, the value returned will be a null string.

	NAME	(REQ) (O) (0) (S)
		Required output string giving the name of the file. 

	EXTN	(REQ) (O) (0) (S)
		Required output string giving the extension, or file type, 
		associated with FILE.

	VERS	(REQ) (O) (0) (S)
		Required output string giving the version number for FILE.

*EXAMPLES:

	in VMS to break up 'DISKA:[IUERDAF.IUELIB.DAT]EBCASC.FIT'

	   decompose,'DISKA:[IUERDAF.IUELIB.DAT]EBCASC.FIT;1',d,path,name,e,v

	where,
		d = 'DISKA:'
		path = '[IUERDAF.PRODUCTION.DAT]'
		name = 'EBCASC'
		e = '.FIT'
		v = ';1'


	in UNIX or ULTRIX to break up '/home/iuerdaf/production/dat/ebcasc.fit'

	   decompose,'/home/iuerdaf/production/dat/ebcasc.fit',d,path,name,e,v

	where,
		d =''
		path = '/home/iuerdaf/production/dat/'
		name = 'ebcasc'
		extn = '.fit'
		vers = ''
 
*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK
       PLATFORM

*FILES USED:

	none

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	All parameters are strings; default parameters are null strings.
	On UNIX systems, disk and version will always be null strings.

*PROCEDURE: 

	DECOMPOSE looks for the '/' and '.' marks used as delimeters in UNIX
	file names, and through string manipulations, breaks down the filename
	into its component parts.

*MODIFICATION HISTORY:

    Jul 19 1981  FHS 3rd  GSFC program written
    Apr 15 1987  RWT      GSFC add PARCHECK and STRUPCASE
    Mar  8 1988  CAG      GSFC add VAX RDAF-style prolog
    ?/89   SUN IDL version written at Univ. of Michigan ?
    8/31/89 RWT correctly calculates path name 
    11/21/90 GRA merged vms and unix decompose programs using !version.os 
     4/10/91 GRA added parcheck to unix section
     6/21/91 PJL cleaned up; tested on SUN and VAX; updated prolog
	16 Aug 93  PJL  updated example; changed !version.os if to case
       14 Jun 94  PJL  replace !version with PLATFORM
        5 Dec 94  LLT  fix error when null filename entered.

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


DELCRCC

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

    	DELCRCC   Jul. 22, 1994
  
*CLASS:

       VMS File utility
  
*CATEGORY:
  
*PURPOSE:

       To create a new version of the specified input file with 
       the "carriage return carriage control" record attribute
       changed to "none" (for vms disk files only).
  
*CALLING SEQUENCE:

	DELCRCC,FILE_NAME
  
*PARAMETERS:

	FILE_NAME	(REQ) (I) (0) (S)
       File name with extension (and version if needed).
       Wild cards accepted.
  
*EXAMPLES:

       delcrcc,'lwp12345llg.lab'   ; corrects a .lab file
       delcrcc,'swp*.dat'          ; corrects all swp .dat files in directory

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

  	
*FILES USED:

	DELCRCC.COM  

*SIDE EFFECTS:

  
*RESTRICTIONS:

	For VMS files only.
  
*NOTES:

       A new version of the original file is generated.

	tested with IDL Version 2.1.0 (sunos sparc)	18 Jun 91
	tested with IDL Version 2.1.0 (vms vax)		N/A	
	tested with IDL Version 2.1.0 (ultrix mipsel)	21 Jun 91

*PROCEDURE:

       DELCRCC.PRO simply calls DELCRCC.COM which uses analyze, edt,
       and convert to change the record attribute from "CRCC" to
       "none".

*I_HELP nn:
  
*MODIFICATION HISTORY:

       July 22, 1994 RWT version 1

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


DELPAR

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

	DELPAR

*PURPOSE:

	Procedure to delete a keyword parameter(s) from a FITS header

*CALLING SEQUENCE:

	DELPAR,H,PARNAME

*PARAMETERS:

	H (REQ) (IO) (1) (S)
          - Fits header

	PARNAME (REQ) (I) (01) (S)
          - string or string array of keyword name(s) to delete

*SUBROUTINES CALLED:

	PARCHECK

*NOTES:

	tested with Idl Version 2.1.0 (sunos sparc)	 7 Aug 91
	tested with Idl Version 2.1.0 (vms vax)    	 7 Aug 91

*MODIFICATION HISTORY:

	version 1  D. Lindler Feb. 1987
       9/17/90 RWT rename DELPAR and modify prolog
	27 Mar 1990	PJL modified for unix/sun; added PARCHECK;
			strings for header must be declared as 80 bytes

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


DETERM

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

    DETERM   (General IDL Library 01)  July 25 1984

*CLASS: 

    Matrix Arithmetic

*CATEGORY:

*PURPOSE:  

    TO CALCULATE THE DETERMINANT OF A SQUARE MATRIX

*CALLING SEQUENCE:

    DETERM,ARRAY,DET,darr
 
*PARAMETERS:

    ARRAY  (REQ) (I) (2) (I L F D)
           Required input square array for which the determinant is
           to be calculated.

    DET    (REQ) (O) (0) (F D)
           Determinant of square matrix.

    DARR   (OPT) (O) (2) (I L F D)
           optional diagonalized array (note off-diagonal elements
           not zeroed)

*EXAMPLES: 
 
*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    PARCHECK
    PCHECK
 
*FILES USED: 

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

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

    DETERM is an IDL version of Bevingtons routine by the same name (p.293)
    As explained in Bevington, the determinant is calculated from the product
    of the diagonal elements of a diagonalized matrix.
 
 
*MODIFICATION HISTORY:

    Jul 25 1984 RWT GSFC incorporated into RDAF library, based on a 
                         procedure by I. Ahmad and documentation updated.
    Apr 13 1987 RWT GSFC add PARCHECK
    Mar  8 1988 CAG GSFC add VAX RDAF-style prolog, add printing of the
                         calling sequence if no parameters have
                         been specified.
    Apr 21 1988 RWT GSFC make working set array double precision and make it
                         an optional output parameter to avoid changing input 
                         array 
    Jun 21 1991 PJL GSFC cleaned up; lowercase; tested on SUN and VAX; 
			  updated prolog

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


DFCORR

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

  	DFCORR  3-21-90
  
*CLASS:

	IUE Absolute Calibration Correction
  
*CATEGORY:

	IUESIPS

*PURPOSE:

       To apply David Finley's absolute calibration correction to IUE data
	sets.

*CALLING SEQUENCE:

       DFCORR,W,F,FCORR

*PARAMETERS:

	W     (REQ) (I) (1) (I)
             Wavelength vector (in angstroms).

	F     (REQ) (I) (1) (I)
             Vector of absolutely calibrated fluxes (ergs/cm*cm/sec/A).

	FCORR (REQ) (O) (0) (I)
             Vector of corrected absolutely calibrated fluxes.

*SYSTEM VARIABLES USED:

	!iuer.dat
  
*INTERACTIVE INPUT:

	none
  
*SUBROUTINES CALLED:

    	PARCHECK
       IFITSRD
       TABINV
  
*FILES USED:
    
       !iuer.dat DFCOEFF.FIT
		File containing correction factors as a function of wavelength
		in a fits file format (see IUER_INF DFCOEFF.INF for more
		information).
  
*SIDE EFFECTS:
  
*RESTRICTIONS:

	For use with IUESIPS data ONLY.
  
*NOTES:

	The long wavelength corrections are based on the LWR camera.

	LWP data should not be corrected with this procedure.

*PROCEDURE:

	DFCOEFF.FIT is read to obtain vectors of wavelength, correction
	factors, number of good points used to calculate each correction
	factor, and the standard deviation of the mean.  The correction is
	applied using the nearest neighbor value from the correction vector.
	The correction is applied as FCORR = F / CORR.
  
*I_HELP nn:
  
*EXAMPLES:

	dfcorr,w,f,fcorr
  
*MODIFICATION HISTORY:

      	Written by Jennifer Sokolowski & RWT 4-26-89
       3/30/90 RWT update prolog, rename DFCORR, and convert CORFILE.TXT
               to DFCOEFF.SAV for easier access.
	1/18/91 PJL transferred to sun/unix and added PARCHECK
       4/11/91 GRA added branch for filename processing in vms
	7/22/91 PJL cleaned up; changed logical; tested on SUN and VAX; 
		    updated prolog
	27 Aug 93  PJL  replaced IUEFETCH with IFITSRD; converted dfcoeff.sav
			to dfcoeff.fit
      2 Sep 94 LLT replace IUER_DAT with !iuer.dat

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


DIRLIST

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

  	DIRLIST
  
*CLASS:

	File Display
  
*CATEGORY:
  
*PURPOSE:

       To create directory listings without spawning to system commands
       (i.e., to partially emulate vms DIR or unix ls commands).
  
*CALLING SEQUENCE:

  	DIRLIST,FNAME,slist,num,out=ofn,nopath=nopath,noprint=noprint
  
*PARAMETERS:

       FNAME (REQ) (I) (0) (S)
               file name (with or without wildcards). 

       SLIST (OPT) (O) (01) (S)
               string array of found files.

       NUM    (OPT) (O) (01) (S)
               number of files found. 

       out   (OPT) (I) (1) (S)
               Optional name for writing directory listing to an output 
               file. If specified, listing is not displayed on terminal.

       nopath   (OPT) (I) (1) (S)
               Optional keyword for removing the full path name from the
               directory listing. Only name and extension are output.

       noprint   (OPT) (I) (1) (S)
               Optional keyword for preventing display of directory 
               listing.

*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:

    	PARCHECK
  
*FILES USED:
  
        OFN - optional output file containing directory listing
              (default extension is .lis)
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

*PROCEDURE:

        Uses findfile to locate files.
  
*I_HELP nn:
  
*EXAMPLES:

  
*MODIFICATION HISTORY:

      	Written by R. Thompson 3/15/95

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


DISPCON

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

	DISPCON     6-MAY-81 	PROGRAMMER:   T.B. AKE

*CLASS:
  
*CATEGORY:

	IUESIPS
  
*PURPOSE:

	Extracts dispersion constants from an IUE extracted spectral file
       header label.
  
*CALLING SEQUENCE:

	DISPCON,IMAGET,B,A
  
*PARAMETERS:

    	IMAGET	(REQ) (I) (0) (S)
		Image name and version only; '.lab' is filled in by the 
	      	procedure. 

    	B	(REQ) (O) (1) (D)
		Array of B (line direction) and A (sample direction) 
		dispersion constants (9-element double precision array). 
		These constants describe the line and sample positions as a 
		function of order number and wavelength in geomd space 
		(i.e., in a reference frame in which the geometrical image 
		distortion has been corrected).  See Version 2.0 of the 
		IUESIPS Information Manual for more information.
  
	A	(REQ) (O) (1) (D)
		Sample direction.

*EXAMPLES:

	dispcon,'swp30307l',b,a

*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:
  
  	None.
  
*SUBROUTINES CALLED:
  
	PARCHECK
	DECOMPOSE
	CHKFITS
	EBCDIC
  
*FILES USED:
  
  	imaget.lab
  
*SIDE EFFECTS:
  
*RESTRICTIONS:

	Not for use with fits formatted files.
  
*NOTES:

    	Input file can not be a RI or PI image file (their labels do not 
	contain the dispersion constants). 

    	Note:  To determine the original coordinates of the spectral format
	or a particular spectral feature, 2 additional steps are required:
    	         1) The transformation must be made from 'geomd space' (which
		    the dispersion constants refer to) to 'raw image space'
		    using the IUESIPS tables of displacement values, and
    	         2) compensation must be made for additional corrections made
		    to the wavelength assignments such as the heliocentric
		    velocity correction in high dispersion, and the
		    vacuum-to-air correction above 2000 angstroms.
        
*PROCEDURE:

     	0) Use DECOMPOSE to separate parts of input file name.
     	1) Open label file and get total number of lines in the label.
     	2) Prints an appropriate error message if it cannot find the '.lab'
	   file, closes logical unit 3 and does a RETALL.
     	3) Find location of dispersion constants by searching for a B & A in
     	   column 1 (if it can't find them, it prints an appropriate message).
     	4) Extract values for B and A.
     	5) Closes open files, and ends.
  	
*I_HELP nn:
  
*MODIFICATION HISTORY:

    	1-28-86 RWT remove search for @ symbol, use double precision variables
    	  	    and update DOC file.
  	1-19-87 RWT correctly handle current image labels & use double 
		    precision 
  	4-13-87 RWT VAX mods: add PARCHECK, and remove INSERT
      12-06-89 RWT modify code to handle label changes in exponent
               sign and sign location introduced in SIPS, and use GET_LUN
       1-9-90 RWT UNIX mods: use lower-case, 
     23July91 LLT clean up, update prolog, add parcheck, tested on VAX
     25July91 PJL tested on SUN; updated prolog
	29 Nov 93  PJL  update prolog; clean up;  added CHKFITS

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


DOSPLAT

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

       DOSPLAT

*CLASS:

       system dependancies - DOS

*CATEGORY:

*PURPOSE:

       Set system dependant items such as system commands that will be
	spawned, internal data formats, etc.
       DOS/WINDOWS types - { windows 3.1 3.6.1b }

*CALLING SEQUENCE:

       DOSPLAT,NCOPY,ICOPY,COPYMES,NDELETE,IDELETE,PDELETE,NPURGE,RENAME,  $
	   PAGE,CAT,SUBMIT,AWK,KEYST,PRINTCMD,DIRLIS,FIND,SECURITY,   $
          QUOTA,SYNTAX,FONT,SYSLOGIN,TRMLDEV,NULLDEV,TAPECTRL,TAPECOPY,TMPLOC

*PARAMETERS:

       NCOPY	(REQ) (O) (0) (S)
               The copy command without conformation (non-interactive).

       ICOPY	(REQ) (O) (0) (S)
               The copy command with conformation (interactive).

       COPYMES (REQ) (O) (0) (S)
               Message related to copy command.
                  copymes.present - present tense of the word.
                  copymes.past - past tense of the word.

       NDELETE	(REQ) (O) (0) (S)
               The delete command without conformation (non-interactive).

       IDELETE (REQ) (O) (0) (S)
               The delete command with conformation (interactive).

	PDELETE	(REQ) (O) (0) (S)
		Print file and then delete file.

       NPURGE  (REQ) (O) (0) (S)
               The purge command without conformation (non-interactive).
       
	RENAME  (REQ) (O) (0) (S)
		To give a file a different name (rename or move).

       PAGE	(REQ) (O) (0) (S)
               The page command for displaying a file.

       CAT     (REQ) (O) (0) (S)
               The cat or type command.

       SUBMIT  (REQ) (O) (0) (S)
               The command to submit a batch job.
                  submit.cmd - the submit command
                  submit.notify - the notify option
                  submit.noprint - the noprint option

       AWK     (REQ) (O) (0) (S)
               The awk command information.
                  awk.cmd - the command
                  awk.file - the file of awk commands

	KEYST	(REQ) (O) (0) (B)
		The keystroke value for carriage return.

	PRINTCMD (REQ) (O) (0) (S)
		The default print command.

	DIRLIS	(REQ) (O) (0) (S)
		Directory listing.
                  dirlis.cmd - the basic directoty listing command.
                  dirlis.sec - the option to see security settings
                  dirlis.col - listing in one column
                  dirlis.output - output file
                  dirlis.nohead - only filenames (no extra "stuff" printed)
                  dirlis.since - limit output to ust files changed in past
                                 24 hours

       FIND    (REQ) (O) (0) (S)
               The find command.
                   find.cmd - the command
                   find.ctime - how many days since file changed
                   find.prune - prune search tree
                   find.type - type of file
                   find.name - filename to be searched for
                   find.print - output filenames found

	SECURITY (REQ) (O) (0) (S)
		Reset secuity permissions on a file.
                  security.set - decline other users from readi write, or
                                 execute privilege.
		   ecurity.unset - allow everyone read permission and group
		                      execute privilege.

	QUOTA	(REQ) (O) (0) (S)
		Show disk quota command.

       SYNTAX  (REQ) (O) (0) (S)
               Structure of different syntax notations.
                  syntax.redirect - redirect output to a file
                  syntax.addon - attached information to end
                  syntax.pipe - pipe output to another command
                  syntax.background - put process in background
                  syntax.execute - execute character
                  syntax.allver - all versions (when versions available)
                  syntax.disksep - separates disk name from path
                  syntax.startpath - separates the disk from the start of the
                                     path
                  syntax.midpath - separates the directory and subdirectory
                  syntax.endpath - separates end of path from filename
                  syntax.versep - separates filename from version number
                  syntax.extsep - separates filename extension from the rest
                                  of the file name
                  syntax.listsep - separate names in a list of filenames
                  syntax.pdelim - separate list of files to print command
                  syntax.pathlist - separate directory names in !path

       FONT    (REQ) (O) (0) (S)
               The fixed width font available.

       SYSLOGIN  (REQ) (O) (0) (S)
               The system login logical.

	TRMLDEV	(REQ) (O) (0) (S)
		Terminal device name.

       NULLDEV (REQ) (O) (0) (S)
               The null device (garbage maybe piped to it).

       TAPECTRL (REQ) (O) (0) (S)
               Magnetic tape control for skipping files - Unix and Ultrix
               systems.  tape.device = '' is assumed to be a VMS or VMS-like
               system.  No suppost for DOS PCs.
                  tapectrl.device - the device directory.
                  tapectrl.mt - the tape control command.
                  tapectrl.back - back up on the tape.
                  tapectrl.forward - go forward on the tape.
                  tapectrl.bandf - back and then forward one.
                  tapectrl.fspace - forward space on a tape.
                  tapectrl.bspace - back space on a tape.
                  tapectrl.status - print status information about the tape
                                    unit.
                  tapectrl.rewind - rewind the tape.
                  tapectrl.weof - write EOF marker
                  tapectrl.eom - goto end of recorded media
                  tapectrl.eom - goto end of recorded media

	TAPECOPY (REQ) (O) (0) (S)
               Tape copy commands.
                  tapecopy.cmd - command.
                  tapecopy.infile - input file marker.
                  tapecopy.outfile - output file marker.
                  tapecopy.ibs - input block size marker.
                  tapecopy.obs - output size marker.
                  tapecopy.num - number of files to copy before ending marker.
                  tapecopy.qic - block size for QIC tapes (must be 512).
                  tapecopy.nonqic - block size for non-QIC tapes.
                  tapecopy.conv - conversion to take place
                  tapecopy.sync - with tapecopy.conv, pad every input record
                                  to ibs

	TMPLOC (REQ) (O) (0) (S)
                  string describing the path for storing temporary scratch 
                  files (set to '\tmp' for windows)

*EXAMPLES:

*SYSTEM VARIABLES USED:

	!version.os

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

       PARCHECK

*FILES USED:

       none

*SIDE EFFECTS:

*RESTRICTIONS:

	If !version.os is not 'windows', the procedure retalls.

*NOTES:

       Please see the file platform.txt in the iuerdaf/manual subdirectory
       for information on how to customizing this procedure.

	Additional systems may be added by contacting IUEDAC staff.  However,
       please note that they will be UNsupported.  Please include the
       information requested in the platform.txt file.

*PROCEDURE:

	Keywords are set based on !version.os.  If !version.os is not 
       'windows', the procedure retalls.

*I_HELP  nn:

*MODIFICATION HISTORY:

       22 Sep 94  PJL  wrote based on VMSPLAT - not all commands set up yet
       20 Oct 94  PJL  finished what commands I could determine;  added
                       syntax.midpath
       28 Nov 94  PJL  added font
       20 Mar 95  RWT  add tmploc parameter

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


DTRANS

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

      DTRANS

*PURPOSE:  

      To convert homogeneous data files to a format compatible with the
      current operating system. DTRANS supports data file conversions between
      SPARC (Sun-4s and SPARCStations), MIPSEL (DECstation 3100 and IBM
      386-class PCs) and VAX (VAXstation 3100 and MicroVAX).

*CALLING SEQUENCE: 

      DTRANS,IMAGET,vartyp,cpupar,recl

*PARAMETERS:

      IMAGET     (R) (I) (S) (0)
          String name for file copied to host machine.
      
      VARTYP     (O) (I) (I) (0)
          Type of data, where:

                 byte              1
                 integer           2
                 longword integer  3 
                 floating point    4
                 double precision  5

          If vartyp is not included in the calling statement, 
          DTRANS will prompt the user.
          
      CPUPAR   (OPT) (I)  (I)     (0)
          Parameter to identify data translation mode. 

              no conversion        0

              VAX     to  MIPSEL   1
              MIPSEL  to  VAX      2

              VAX     to  SPARC    3
              SPARC   to  VAX      4

              MIPSEL  to  SPARC    5
              SPARC   to  MIPSEL   6

          Supported Data Types:

              VAX    - VAXstations, MicroVAX
              MIPSEL - DECstations, IBM 386
              SPARC  - SparcStations, Sun 4##

          Note: No Conversion is required between like data types,
                such as DECstations and IBM 386s.

          If CPUPAR is not given in the call, the user will be prompted
          for it.

          Note that only two modes are allowed for a given machine.
          The allowed modes are those in which the final data format
          is compatible with the host operating system. 
          
      RECL (O) (I) (IL) (0)
          Logical record length in bytes. Required for all transfers
          to the VMS system, so that the output record length may be
          defined. If not included in the call in this situation,
          DTRANS will prompt the user. This parameter is not required
          for conversion to SunOs, ULTRIX, and DOS formats.


*FILES USED:

         Output file of converted data is stored as:
             imaget;highest-version-number (VMS) or,
             imaget.new (all others)

*PROCEDURE:

       Before converting files, DTRANS uses the procedure CONMENU to determine
       the allowed conversion modes. The input file is opened, and the total 
       number of input bytes is determined via the FSTAT command.  The input
       parameters to the conversion process (vartyp, cpupar, and recl (vax
       only)) are obtained from user input if these parameters were not
       included in the call to DTRANS.  When selecting the vartyp, the value
       of tbyt mod vbyt is used to detect errors due to non-binary data file
       transfer, or errors in the selection of vartyp. On vms systems, tbyt
       mod recl, and tbyt mod vbyt are used to detect errors.  If an error is 
       detected, the user may choose to respecify the vartyp or recl, or abort
       the procedure. Once valid conversion parameters are defined, DTRANS
       proceeds to convert the data file to the new machine format. 

       VMS systems:

          The record length used for input and output associated
          variables is given by the user. Single records are read
          into a holding variable, translated to the proper format
          by the routine TRANS_BYTES, and written out to a higher
          version number. 

       UNIX systems:

          The value of tbyt determined from the FSTAT command is 
          used to generate a list of factors of the total input
          file size in bytes. The factor nearest to 2048 bytes
          is used as a holding array size. Data is then read into 
          the holding array from the input file, converted to the
          new machine format, and written to disk. The output file
          is named imaget + '.new' 

*RESTRICTIONS:

       - Files must be transferred between hosts in binary (image) mode.

       - Files must have fixed length records 

       - All values in data files must have the same data type.

       - TRANS_BYTES does not currently convert complex data types.

*SUBROUTINES CALLED:

	PARCHECK
       TRANS_BYTES 
       DECOMPOSE
       CONMENU
       PLATFORM

*SYSTEM VARIABLES USED:

	none

*NOTES:

       - IUE GO files should be converted using con_rdaf or convert.

       - IUE SAV files should be converted using con_sav.

       - To convert files between computer systems which do not store
         data as on a SUN, DECstation, DOS, or VAX, the subroutine
         TRANS_BYTES should be modified.

       - DTRANS checks for incompatibility between the total number 
         of input bytes and requested data type and record length.
         Such incompatibility results from data file transfer in
         ASCII or other non-binary modes, or from errors in data
         type or record length selection. If an error is detected,
         the user has the option of reselecting the appropriate
         parameter, or aborting the procedure. Not all errors
         resulting from non-binary mode data file transfer will
         be detected. To avoid possible undetected errors, always
         transfer data files in binary mode.

         Additionally, if a file is originally on a VMS system and has the
         record attribute of "Carriage return carriage control" the following
         steps BEFORE transferring the file are necessary:

               $ anal/rms/fdl file.dat
               $ edit/fdl file.fdl
                   This puts you into an editor with a menu interface.  Type:
                       mod
                       rec
                       carr
                       none
                       
                       exit
               $ convert file.dat newfile.dat /fdl=file.fdl

         where file.dat is the orginial file and newfile.dat is the corrected
         file.

	tested with IDL Version 2.1.2 (sunos sparc)     14 Oct 91
	tested with IDL Version 2.1.2 (ultrix mispel)   14 Oct 91
       tested with IDL Version 2.2.0 (ultrix vax)      14 Oct 91
	tested with IDL Version 2.1.2 (vms vax)         14 Oct 91

*EXAMPLES:

*MODIFICATION HISTORY:

     6/28/89  RWT  version 1  
     7/6/89 RWT modified to handle files with and without
       end-of-record bytes.
     2/28/90 RWT correct typo in longword conversion assoc command
       and expand prolog.
     5/30/90 RWT replace vtos with vtou so program runs on both
       SUNs and DECstations.
     2/18/91 GRA include further modifications to enable file format
       conversion between VMS, SunOs, and ULTRIX formats.
     3/18/91 GRA renamed vtou to trans_bytes
     4/30/91 RWT add support for DOS 
     6/13/91 GRA changed "dos" to "DOS"
     6/26/91 PJL cleaned up; added PARCHECK; tested SUN/VAX combinations;
		  updated prolog
     10/3/91 GRA Numerous modifications; removed sections of code which
                 compensated for ASCII mode transfer; condensed and
                 streamlined error checking and data translation 
                 sections; tested on SUN, DEC, and VAX systems;
                 updated prolog.
     10/9/91 GRA globally changed all references to "syspar" to "cpupar",
                 changed cpupar to reference data formats as specified by
                 the !version.arch system variable; used /block keyword
                 when opening input file on a vms machine so that the
                 rms information can be bypassed; condensed vms and unix
                 branches; updated prolog; tested on ultrix/vax, 
                 ultrix/mipsel, vms/vax, sunos/sparc.
    10/31/91 GRA cleaned up print statements.
    11/01/91 PJL changed CON_GO reference to CON_RDAF
    29 Apr 94  PJL  added notes about "Carriage return carriage control"
    10 Jun 94  PJL  replaceed !version with CONMNEU and PLATFORM

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


EBCDIC

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

	EBCDIC    (General IDL Library 01)   June 26, 1980

*CLASS: 

	format conversion, i/o

*CATEGORY:

*PURPOSE: 

	Converts a 1-D byte array of EBCDIC code to a 1-D byte array of ASCII
	code.

*CALLING SEQUENCE:

	EBCDIC,A

*PARAMTERS:

	A	(REQ) (I/O) (1) (B)
		Required input and output vector containing the data to be
		converted. At input, the code are assumed to be EBCDIC.  The
		vector is returned with a vector byte array containing the
		ASCII equivalents of the input vector.

*EXAMPLES:

	ebcdic,a

*SYSTEM VARIABLES USED:

	!iuer.dat

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PCHECK
	PARCHECK
	IFITSRD

*FILES USED: 

	!iuer.dat EBCASC.FIT 

*SIDE EFFECTS:

	The original byte array is modified.

*RESTRICTIONS: 

*NOTES:

*PROCEDURE

	Each EBCDIC character is converted to its ASCII equivalent.

*MODIFICATION HISTORY:

    Jun 26 1980  K.G. Wilber  GSFC  initial program 
    Apr 19 1985  JKF GSFC  modified to be compatible with XIDL /ERROR
    Jun  7 1987  RWT GSFC  use vector assignment statement to remove
           DO loop
    Mar  9 1988  CAG GSFC  add VAX RDAF-style prolog, add
           printout of calling sequence if executed without parameters,
           and add check for parameters.
    Sep  8 1989  RWT GSFC   Unix mods: change reference to ebcasc.dat
           file, and use /get_lun 
    4-10-91 KBC modify filename structure based on operating system type
                for compatibility on SUN/DEC/VAX
    6-21-91 PJL new directory structure environment variable with getenv;
		 tested on SUN and VAX; updated prolog
	16 Aug 93  PJL  access fits formated data file; added IFITSRD
   2 Sep 94 LLT  replace IUER_DAT with !iuer.dat

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


ERRBAR

[Previous Routine] [Next Routine] [List of Routines]
*NAME:
    	ERRBAR     1 June, 1982   (in file ERRBAR.PRO)
  
*CLASS:
  
*CATEGORY:
    	PROCEDURE TYPE: Graphics
  
*PURPOSE:
    	To plot error bars at specified data coordinates.
    	Single or multiple error bars may be plotted at the same
    	time.
  
*CALLING SEQUENCE:
    	ERRBAR,X,Y,DELTAX,DELTAY
  
*PARAMETERS:
    	X	(REQ) (I) (0 1) (I L F D)
		An array or scalar variable containing the X coordinates of 
		the data.

      	Y	(REQ) (I) (0 1) (I L F D)
		An array or scalar variable containing the Y coordinates of 
		the data.

     	DELTAX	(REQ) (I) (0 1) (I L F D)
		An array or scalar variable containing the error for each X 
		point.

     	DELTAY	(REQ) (I) (0 1) (I L F D)
		An array or scalar variable containing the error for each Y 
		point.

*INTERACTIVE INPUT:
   	The error bars are printed on the terminal screen 
  
*FILES USED:
  
*SYSTEM VARIABLES USED:
  
*SUBROUTINES CALLED:
    	IUER_SOFTDISK:PARCHECK
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:
    	A plot must be made before calling ERRBAR to insure that
    	the plotting parameters are set.
 
    	If the input parameters are not arrays of the same length
    	an error message results.
 
*PROCEDURE:
  
*INF_1:
  
*EXAMPLES:
  
*MODIFICATION HISTORY:
   	Programmer: D. Lear
       12-84 CAG Add option to plot single error bar if desired
       8-26-86 CAG move IDL prompt at end of execution out of
               middle of plot (URP #197) 
       10-7-86 RWT add compile of GFBOUT
       12-29-86 RWT add VAX mods: !ACMD for !OUT, vector subscripts
                modify indirect compilations
       3-14-87 RWT add PARCHECK
       6-11-87 strip device dependent code, and enhance documentation
       6-9-88 RWT add procedure call listing
       2-17-93 RWT add to IDL version 2 experimental library

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


EXMELO

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

    	EXMELO       (RDAF General Production Library )      DECEMBER 15, 1981

*CLASS:

      	Spectral Extraction
 
*CATEGORY:

*PURPOSE:  

      	Procedure to extract flux data from a line-by-line spatially
      	resolved IUE image file.
 
*CALLING SEQUENCE:    

      	EXMELO,IMAGET,PARAM,H,WAVE,GROSS,BACK,NET,ABSCAL,EPS
 
*PARAMETERS:

       IMAGET 	(REQ) (I) (1) (S)
          	The input file name (e.g. swp1234s). May include path.

       PARAM   (REQ) (I) (0/1) (I)
          	Scalar or vector:
          	    Scalar: Default parameters
          	        = 2 : Point source small aperture
          	        = 1 : Point source large aperture
          	        = 0 : Extended source 

              	Vector: Param(0) = center line number
              	    Param(1) = gross width
              	    Param(2) = background width
              	    Param(3) = distance between gross & background
              	    Param(4) = median filter width
              	    Param(5) = mean filter width
	
        H     	(REQ) (O) (1) (L)
          	Vector containing the header scale factor record (0).

        WAVE  	(REQ) (O) (1) (R)
          	Vector containing the wavelengths.

        GROSS 	(REQ) (O) (1) (R)
          	Vector containing the gross flux data.

        BACK  	(REQ) (O) (1) (R)
          	Vector containing the background flux data.

        NET   	(REQ) (O) (1) (R)
          	Vector containing the derived net flux data.

        ABSCAL (REQ) (O) (1) (R)
          	Vector containing the absolute calibrated net flux data.

        EPS    (REQ) (O) (1) (R)
           	Vector containing the quality flags.

*EXAMPLES:

    	To customize an extraction:
 
        	P=FLTARR(6)  ;DEFINE ARRAY
        	READ,P       ;ENTER VALUES
        	? 28 5 5 15 60 30  
        	EXMELO,'SWP11225S',P,H,WAVE,GROSS,BCKGRD,NET,ABS,EPS

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	PCHECK
     	CALIB

*FILES USED:

     	The data is extracted from an ELBL (LBLS) file with the name IMAGET.

*SIDE EFFECTS:

*NOTES:

    	The defaults for an LBLS file (processed prior to 1 October 
    	1985) for a scalar PARAM in lines are:
    	        Parameter          0        1        2
    	         gross center     28       28       28
    	         gross width      15        9        9
    	         bkg width         5        5        5
    	         bkg distance     11       11        8
	
    	The default values of a scalar PARAM for ELBL (after 1 October 
    	1985) are:

             	Parameter         0        1        2
             	 gross center    56       56       56
             	 gross width     30       18       18
             	 bkg width       10       10       10
             	 bkg distance    22       22       16

    	The default values for the median and mean filter widths are 
    	derived from the length of the vector.  If the data vector
    	is 600 or less samples long the defaults are median width
    	of 31 and mean width of 15.  Longer vectors give defaults
    	of 63 for the median and 31 for the mean filter widths.
    	The background vector has been extended by the first and last
    	value by an amount equal to the largest filter width before
    	either filtering is done.

       When widths are specified as even numbers, the extraction
       slit is centered half an order below the specified center.

	tested with IDL Version 2.2.0 (sunos sparc)  	22 Nov 91
	tested with IDL Version 2.2.0 (ultrix mispel)	N/A
	tested with IDL Version 2.2.0 (vms vax)      	22 Nov 91
 
*PROCEDURE:

    	Extract the appropriate data from the
      	ELBL file:
      	           Wavelength
      	           Gross Flux
      	           Background Flux
      	           Epsilon vector
      	   
    	Calculate the NET flux by smoothing the background with both a
    	MEDIAN and a BOX filter and subtracting the result from the 
    	gross flux.
    	Calculate the ABSCAL flux using CALIB with an assumed exposure
    	time of one second.
 
*MODIFICATION HISTORY:

     	Version 0 F.H. Schiffer 3rd 15-Dec-1981  derived from MAKEESLO
     	Copied into IUER_PROD: BY RWT 1-16-84 (SEE SMR#5) version 3
     	12-March-1982 F.H. Schiffer 3rd  ER#012 Correct default values
     	26-May-1982   F.H. Schiffer 3rd  CR#035 Extend background
     	     ER#022 Exposure time
     	Modified GSFC RDAF 19APR85 - to be compatible with XIDL -variable
     	     TIME changed to ITIME and reference to MEDIAN changed to GMEDIAN.
     	30-Oct-1985   C.A. Grady  Modified default values to handle 
     	     extended line by line data.
     	 4-24-87 RWT add PARCHECK, remove INSERT and EXTRACTs, & use vector
     	     assignment statements.
     	 1-20-88 RWT add procedure call listing and use GET_LUN
     	 2-23-88 RWT remove subroutine ESPARAM
     	 5-12-88 HAA add RDAF Prolog
        1-24-89 RWT expand prolog info	
        8-16-89 RWT rename EXMELO
        9-07-89 RWT Unix mods: replace GMEDIAN with intrinsic MEDIAN,
            remove LOOKUP commands, correct prolog info,
       4-10-91 KBC modify filename structure based on operating system type
                   for compatibility on SUN/DEC/VAX
	 7-24-91 PJL cleaned up; changed logical; tested on SUN and VAX; 
		     updated prolog
	 9-13-91 PJL corrected file equals statement for SUN; updated 
		     prolog; tested on SUN and VAX
      22 Nov 91 GRA removed IUER_USERDATA logical; added decompose so
                    imaget may include path; tested; updated prolog.

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


EXPLIB

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

    	EXPLIB   July 22, 1994
  
*CLASS:

*CATEGORY:
  
*PURPOSE:

       To add !iuer.expr (the IUEDAC experimental library) to the beginning
       of the IDL search path, or remove it, or tell user if it's present.
  
*CALLING SEQUENCE:

	EXPLIB,D
  
*PARAMETERS:

	D     (REQ) (I) (0) (S)
             If D is positive, !iuer.expr will be placed at the beginning of
             !path. 
             If D is negative, !iuer.expr will be removed (if present) from
             !path, regardless of its position in !path.
             If D is zero, the user will be told if !iuer.expr is present in
             !path, and if so, where it is.
             
  
*EXAMPLES:

       explib,1     Adds !iuer.expr to !path
       explib,-1    Deletes !iuer.expr from !path
       explib,0     Tells user whether !iuer.expr is present in !path

*SYSTEM VARIABLES USED:

       !iuer.expr
       !path is modified.

*INTERACTIVE INPUT:

       none

*SUBROUTINES CALLED:

       PLATFORM

*FILES USED:

       none

*SIDE EFFECTS:

       !path is modified.
  
*RESTRICTIONS:

*NOTES:

*PROCEDURE:

       If D gt 0:
       !path = !iuer.expr + syntax.pathlist + !path

       If D lt 0:
       The pieces of !path on either side of !iuer.expr are concatenated.

       If D eq 0:
       If strmid(!path,!iuer.expr) ge 0, !iuer.expr is in !path.  Its 
       position in the list of libraries is determined by counting the
       number of delimiters prior to its first character.

*I_HELP nn:
  
*MODIFICATION HISTORY:

       July 22, 1994 RWT version 1
       25 Jul 94  PJL  add Unix support
        2 Sep 94 LLT replace IUER_EXPR logical with !iuer.expr
       23 Nov 94 LLT add D zero or negative options.

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


EXPOFIN

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

      EXPOFIN

*CALLING SEQUENCE:
      
      EXPOFIN,LABEL,MIDT,EXP,rr

*PURPOSE:

      This procedure will extract the midtime and duration of an exposure
      from the science image header.

*PARAMETERS:

      LABEL  (REQ) (I) (0) (S/I)
             Either the imaget (filename without extension) in which the
             science image header or label resides, or a unit number for
             for the header file.  In the latter case, the procedure will
             assume the file has been already been opened by a calling
             procedure.

       MIDT  (REQ) (O) (1) (D)
             Julian date of the calculated midtime of exposure.

        EXP  (REQ) (O) (0) (F)
             Exposure time in seconds.

         RR  (OPT) (I) (0) (I)
             Round-robin flag - get the exp. time from the round robin
             regardless of whether it can be determined by other means.
             This is a logical - nonzero values equal 'true'.

*SYSTEM VARIABLES USED:


*PROCEDURE:

      If a filename is passed to expofin, that file will be opened.  
      The camera and image sequence numbers will be extracted from line 1.
      The scheme name will be located in the image processing portion of the
      header, and the aperture designation extracted from it.  If the image
      was neither trailed nor double aperture, then the exposure time will
      be extracted from line 2.  Then, the image processing portion of the
      header will be searched for the midtime of the exposure.  If found,
      and if the round-robin flag was not set, then the program will return. 
      Otherwise, lines 11 through 32 (the event round robin) will be read
      into an array, and this array will be sorted by time.  The sections of
      the round robin between the two READ or READPREP commands for the
      given camera will be kept; the rest discarded.  For double aperture
      exposures, the label will be searched for the *DATA FROM ... APERTURE
      line, and times from all EXPOBC commands and MODTIME commands for that
      camera BETWEEN the 'target in ... ' and 'target from ... ' commands.
      The user is given a chance to set the aperture, which is helpful if
      the image was serendipitous.
      Otherwise, all EXPOBC and MODTIME commands are taken into account.
      Once an exposure time and mid-time are determined, a year and day must
      be associated with them.  This is done by comparing the mid-time to
      the read time in line 10. If the read time is later than the mid-time,
      the day and year of read will be considered the day and read of mid-
      time.  Otherwise, the previous day is used, the year remaining the 
      same unless the read day is 1 January and the mid-time was on 31 Dec.
      

*SUBROUTINES CALLED:

      decompose
      PARCHECK
      EBCDIC

*FILES USED:

      label (I)
             label file designated by first input parameter

*NOTES:

      The user may enter a different aperture than the one the data pertains
      to, allowing the program to extract the correct commands for images
      that are serendipitous or otherwise simultaneous.

      tested with IDL version 2.1.0 (sunos sparc)	11 Jul 1991
      tested with IDL version 2.1.0 (ultrix mipsel)	N/A
      tested with IDL version 2.1.0 (vms vax)        	28 Jun 1991

*MODIFICATION HISTORY:

      20 Dec 1990 - Written by LLT.
     January 1991 - Modifications - MODTIME, etc.  
     7 March 1991 - Converted to sun by LLT
      10 May 1991 - PJL corrected prolog format
     28 June 1991 - LLT add parcheck, cleaned up; tested on VAX; updated prolog
     11 July 1991 - PJL tested on SUN; updated prolog
     19 Sept 1991 - LLT revised treatment of blank lines in round robin.
     20 Sept 1991 - LLT revise treatment of target aperture.
     26 Sept 1991 - LLT add decompose.

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


EXTFITS

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

  	EXTFITS         8/30/90
  
*CLASS:

	File Conversion 
  
*CATEGORY:

	IUESIPS
  
*PURPOSE:

       Converts IUESIPS extracted files (i.e., MEHI & MELO files) to FITS 
       files. MODE = 1 (default) creates a binary table file containing 
	order number (M), number of good data points (NPT), wavelength vector
       (W), gross (G), background (B), net (N), and abnet (A) flux vectors and 
       epsilons (E) (written in that order) for each spectral order requested.
       MODE = 2 is similiar except wavelengths are linearized so W (above) is 
       replaced by the startig wavelength (W0) and wavelength increment 
       (DELTAW) in the binary table. In MODE = 3, the wavelengths are 
       linearized and stored as FITS keywords, and a single abnet vector is 
       written as a primary array FITS file (this is the IRAF-compatible mode).
  
*CALLING SEQUENCE:

  	EXTFITS,IMAGET,ORDER,mode,header
  
*PARAMETERS:

	IMAGET	(REQ) (I) (0) (S)
		Input IUESIPS file name (without .dat extension).

       ORDER   (REQ) (I) (0,1) (B I)
               Order number(s) to be extracted.  For low dispersion images,
		ORDER should be set to 1. For high dispersion, ORDER can
               be a vector with up to 60 entries (not recommended).
   
       MODE 	(OPT) (I) (0) (B I)
               MODE = 1 (default) - creates a binary table file with
		   M,NPT and vectors W,G,B,N,A,E (written in that order) for
		   each spectral order requested.
               MODE = 2 - wavelengths are linearized so W (above) is replaced
		   by W0 and DELTAW in the 3D table.
               MODE = 3 - wavelengths are linearized, and a single abnet
		   vector is written as a primary array (this is the
		   IRAF-compatible mode)

       HEADER  (OPT) (O) (1) (S)
               If specified, FITS header is output as a string array.

*SYSTEM VARIABLES USED:

	!iuer.dat

*INTERACTIVE INPUT:

	none
  
*SUBROUTINES CALLED:

    	PARCHECK
       PCHECK
       DECOMPOSE
       GETIUE
       ADDPAR  - adds a keyword to FITS header
       KEYGEN  - converts header to FITS keywords
       FITSLAB - converts IUE label to FITS HISTORY keywords
       TABINV
	TRANS_BYTES
	PLATFORM
  
*FILES USED:
  
        MAIN_HD.TXT - input file: basic main fits header
        3DMEHI.TXT  - input file: basic FITS extension header for mode 1
        3DMELO.TXT  - input file: basic FITS extension header for mode 1 (low)
        3DMEHI2.TXT - input file: basic FITS extension header for mode 2
        3DMELO2.TXT - input file: basic FITS extension header for mode 2 (low)
        IMAGET.FIT  - output file: FITS data with header (currently written 
                      to same directory as input file)
  
*SIDE EFFECTS:
  
*RESTRICTIONS:

       For modes = 2 & 3, input file wavelengths must be monotonic.
       For mode = 3 and if more than one order is specified, only the
          first one listed is used.

	Fits formatted files should not be used as input files.

*PROCEDURE:

       Calls KEYGEN to convert header record entries to FITS keywords 
       and stores them in a string array containing 80-byte rows.
       For mode 1, reads 3DMELO.TXT or 3DMEHI.TXT for table extension
       header.  Additional keywords are created from H vector using
       ADDPAR.  Vectors (i.e., W,G,B,N,A,E) are then extracted using GETIUE.
       For mode 2, 3DMELO2.TXT or 3DMEHI2.TXT is used for extension
       header.  GETIUE is used as above.  The wavelength array is checked 
       for monotonicity, and, if monotonic, the remaining vectors are 
       resampled to linear wavelengths (i.e. w0 = min(w) and deltaw =
       max(w)-min(w)/npts).  Flux values are derived using simple linear 
       interpolation.  Data vectors are then converted to proper format 
       and written to disk.  For mode =3, the abnet (or rnet) vector is 
       extracted and written to a primary array file after values are 
       resampled to produce linear wavelengths.
  
*I_HELP nn:
  
*EXAMPLES:

	extfits,'swp32199l',1,2            ; convert MELO file to FITS 3D table
					    after linearizing wavelengths
       to read above file:
           ifitsrd,'swp32199l.fit',1,hd,ext,m,npt,w0,dw,g,b,n,a,e
           w = w0 + findgen(npt)*dw       ; wavelength array
           plot,w,a                       ; plot data
     

	extfits,'lwp3415h',[90,91,92],1,h  ; extract orders 90-92 and store as
					     a 3D table with non-linear W
					     keywords are also written as
					     string array H.
       to read order 91 (2nd row) data from above file:
           ifitsrd,'lwp3415h.fit',2,hd,ext,m,npt,w,g,b,net,rnet,eps
           w = w(0:npt-1)                 ; remove padded zeroes
           f = rnet(0:npt-1)              ; remove padded zeroes
           plot,w,f                       ; plot data (note f=rnet not abnet
                                            flux for early MEHI file)


       extfits,'lwr15248llg',1,3          ; write just abnet vector to primary
                                            array FITS file for compatibility
                                            with IRAF
       to read data in above example:
           ifitsrd,'lwr15248llg.fit',-1,hd,ext,flux
           plot,flux

*NOTES:
        
       In low dispersion, the number of non-zero points in each vector is
	equal to the number of extracted data points.  In high dispersion,
       all vectors are padded with zeroes to have 1000 elements. The number
       of good points is stored in the 2nd field of each row. (See examples
       above for how to remove padded zeroes.)

	GETIUE and FITSLAB check the file format of the .dat and .lab input
	files.  If they are in fits format, a retall is performed.

       In low dispersion, the flux vector stored in the output FITS file 
       will have units of ergs/cm^2/A representing time-integrated fluxes. 
       This is identical to how data is stored in the IUESIPS melo files. 
       IUEDAC routines however (such as IUESPEC) produce fluxes in units of 
       ergs/cm^2/A/sec by dividing the IUESIPS fluxes by the user-specified 
       exposure time. 

       In high dispersion, the absolutely-calibrated data will NOT be
       included IF the IUESIPS file was processed before ~ 1990. 
       For these older files, EXTFITS writes out the ripple-corrected net flux
       vector (RNET) instead of the the ABNET vector.

       Additional differences between EXTFITS fluxes and IUESPEC fluxes 
       include the following:
         - IUESPEC may apply additional corrections such as sensitivity
           degradation correction and THDA sensitivity corrections.
         - EXTFITS wavelength coverage is slightly smaller (i.e. fluxes
           at end points are set to 0).
         - resampling in EXTFITS may cause slight changes in fluxes.
         - The interpolation used by IUESPEC is slightly different than
           that used by IUESIPS causing additional small differences in flux.

*MODIFICATION HISTORY:

      	Written by R. Thompson 8/30/90
	 4-16-91 PJL removed vtos
        5-17-91 GRA added vers to DECOMPOSE call statement
        5-17-91 GRA added branch for VMS file name processing
        7-24-91 rwt rename temporary variable A to ATMP to avoid
                setting abnet vector to 0 when mode=2, and replace vtos
                with dtrans for compatibility with ultrix, vms, & dos.
        8-5-91 rwt allow version numbers (for vms), make all string
               keywords at least 8 characters, correct numrec for multiple
               orders, and correct starting index value (st).
        8-7-91 rwt correct values for numrec and index parameters (again).
       11/7/91 gra defined cpupar = !version.arch for trans_bytes
               parameter; tested on sun, vax, and dec.
      11/12/91 gra removed h(3) test for vector length and padded
               all vectors to 1000 elements; cleaned up; tested.
      11/14/91 gra padded output row for high dispersion orders to
               a multiple of 2880 bytes; each order begins on a file
               record boundry; tested on sun, vax, dec.
       3/06/92 rwt add /none to openw statements to prevent vms carriage
               control commands from being added to output data.
       3/10/92 rwt remove change made on 11/14/91 to comply with proposed
               binary table proposal.
       4/10/92 rwt check for valid order numbers
	2/24/93 PJL added version.os branch to handle Version 3 UNIX/Ultrix
		problem with the /none keyword
       9/14/93 rwt add mode=3 for IRAF-compatibility
      10/07/93 rwt correct mode=3 when converting < 1 full data record 
      11/29/93 PJL update prolog
       2/17/94 rwt send output to fname + '.fit' not prefix + '.fit'.
               This will write FITS file to working directory not the 
               directory of the input file. Also updated prolog, and commented
               out code to create the .hhh file.
       6/07/94 rwt fix bug when multiple rows are written, write header
               after data is read (for possibly modifying keywords), properly
               write RNET rather than ABNET vector for early MEHI files and 
               expand prolog information.
       8 Jun 94 PJL replaced !version with PLATFORM
       2 Sep 94 replace IUER_DAT with !iuer.dat
       2 Apr 95 RWT subtract 1 in denominator of delta w calculation

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


FDATE

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

	FDATE

*PURPOSE:

	FDATE converts day-of-year to Gregorian date in a format
       required by FITS conventions (i.e. dd/mm/yy).
	Works on cumulative day from 1-JAN-1979 (for instance),
	as well as more well-mannered days-of-year.

*CALLING SEQUENCE:

	FDATE,YEAR,DAY,D_STRING

*PARAMETERS:

	YEAR (REQ) (I) (0) (I)
       Years after 1900 may either be written out in full
	(e.g. 1986) or with just the last two digits (e.g. 86)

       DAY  (REQ) (I) (0) (I)
       number of days after Jan 1 of the specified year

	D_STRING (REQ) (O) (0) (S)
       String giving date in format 'DD/MM/YY' (e.g., 256,1990
       returns 13/03/90).

*SUBROUTINES CALLED:

	PARCHECK

 RESTRICTIONS:

	Will only work for years after 1900.

*NOTES:

	tested with IDL Version 2.1.0 (sunos sparc)	 7 Aug 91
       tested with IDL Version 2.1.0 (ultrix mipsel)	N/A
       tested with IDL Version 2.1.0 (vms vax)		 7 Aug 91

 MODIFICATION HISTORY:

       D.M. fecit  24 October,1983
       09/13/90 RWT modify output format to give date as DD/MM/YY
       12/13/90 RWT add '0' to MONTH if MONTH LE 9 not LAST_MONTH LE 9
	03/27/91 PJL modified for unix/sun; changed from a function 
                to procedure; added n_param(0) check and PARCHECK
       05/06/94 RWT add '0' to day if < 10

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


FDMX

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

	FDMX

*CLASS:

*CATEGORY:

	NEWSIPS

*PURPOSE:

	Decipher IUE merged extracted spectrum fits files and return data.

*CALLING SEQUENCE:

	FDMX,FILENAME,ROW,SREC,EXTHD,APERTURE,wave,abs_flux,flags,sigma, $
            bkgrd,net

*PARAMETERS:

	FILENAME  (REQ) (I) (0) (S)
		The filename - including extension.

	ROW	(REQ) (I) (0) (I)
		The row to be read from binary table

	SREC    (REQ) (I) (0) (I)
		The starting data record for IUE3DRD

	EXTHD 	(REQ) (I) (1) (S)
               FITS header for binary table extension

	APERTURE  (REQ) (O) (0) (S)
		The aperture extracted.  

	WAVE	(OPT) (O) (1) (D)
		The wavelength vector.

	ABS_FLUX  (OPT) (O) (1) (R)
		The absolute flux vector.

	FLAGS	(OPT) (O) (1) (I)
		The NEWSIPS error flags vector.

	SIGMA	(OPT) (O) (1) (R)
		The sigma vector.

	BKGRD	(OPT) (O) (1) (R)
		The background flux vector.

	NET	(OPT) (O) (1) (R)
		The net flux vector.

*EXAMPLES:

       iuefhrd,filename,p,head,lab,exthd
       srec = total(p(0:2))
	rdmx,filename,1,srec,exthd,aper,wave,...

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	STPAR
       IUE3DRD

*FILES USED:

	filename given in calling sequence

*SIDE EFFECTS:

*RESTRICTIONS:

	only tested with SWP data
	not tested with high dispersion data

*NOTES:
       - Parameters for which no data are found are set to 0.
       - Assumes first 4 fields are (in order) aperture,npts,
         starting wavelength, and wavelength increment.

*PROCEDURE:

	IUE3DRD is used to read the data.  The number of fields is found 
       via STPAR and the TTYPE keywords.  The data is assigned to the 
       appropriate variable.

*I_HELP  nn:

*MODIFICATION HISTORY:

	14 Jun 93  PJL  wrote DECIPHMX
	15 Jun 93  PJL  set no values to defaults;  changed IFITSREAD to
			IFITSRD
	12 Aug 93  PJL  add /silent keyword to IFITSRD call
       27 Dec 94  RWT  wrote FDMX (based on DECIPHMX) to speed up READMX 

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


FEATURE

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

     FEATURE     (General IDL Library 01) 9 JANUARY 1981
 
*CLASS: 

     spectral lines, measurement

*CATEGORY:

*PURPOSE:  

    To measure the essential attributes of a spectral feature
 
*CALLING SEQUENCE:

    FEATURE,WAVE,FLUX,W0,comment,noprint=nop
 
*PARAMETERS:

    WAVE   (REQ) (I) (1) (I L F D)
           Required input vector containing the wavelength array associated
           with the spectrum.

    FLUX   (REQ) (I) (1) (F D)
           Required input vector containing the flux data for the spectrum.

    W0     (REQ) (I/O) (0 1) (F D)
           Upon input, this parameter is a required scalar containing the
           laboratory wavelength of the feature.
           The procedure converts this parameter to a vector containing 
           the results of the measurement.
           If W0 is a variable the results are returned in an array
           of the same name.
                  W0(0)= the original value for W0. 
                  W0(1)= short wavelength limit to integration
                  W0(2)= extremum of spectral line
                  W0(3)= long wavelength limit to integration
                  W0(4)= radial velocity for short wavelength limit
                         to integration.
                  W0(5)= radial velocity for extremum of spectral line
                  W0(6)= radial velocity for the long wavelength limit
                         to integration.
                  W0(7)= flux at the short wavelength limit to the
                         integration.
                  W0(8)= flux at the spectral line extremum
                  W0(9)= flux at the long wavelength limit to the 
                         integration.
                  W0(10)=continuum flux
                  W0(11)=residual flux at extremum
                  W0(12)=equivalent width
                  W0(13)=total flux in the feature. 
                  W0(14)=flux weighted wavelength for feature.
                  W0(15)=flux weighted sigma, which for a 
                         gaussian profile can be related to the full
                         width at half maximum.
                  W0(16)=net flux in feature
                  W0(17)=flux weighted wavelength, with continuum
                         not included
                  W0(18)=flux weighted sigma for net flux only.

    COMMENT (OPT) (I)
           Title for output.

    NOPRINT (KEY)
           If set, FEATURE will not offer you the option of sending your
           output to the laser printer.

*EXAMPLES:

     In this example, several carbon features of a high-dispersion 
     spectrum, SWP 3353, are acquired and measured:
         
                openr,un1,'swp3353h',/get_lun
                iueget,un1,89,h,wave,flux,eps  ; CIV 1550
                feature,wave,flux,1548.20
                feature,wave,flux,1550.77
                close,un1

     In this example, the user elects not to be offered the option to send
     the final plot to the laser printer:

                feature,w,f,1548.20,/noprint

*SYSTEM VARIABLES USED:

	!d.name
	!x.range
	!x.crange
	!y.crange
	!d.x_ch_size
	!d.y_ch_size
	!d.y_vsize
	!err
	!iueprint.type

*INTERACTIVE INPUTS:

        Upon prompting, the user sets the crosshairs
        and hits the left mouse button (sunview) or
        carriage-return key (tek) three times,
        thereby measuring:
         
        Vertical crosshair at:      Horizontal crosshair at:
        ______________________      ________________________
        1) left edge of 
            feature (W1)           continuum (F1)
         
        2) center of
           feature (W2)            extremum(F2) of feature
         
        3) right edge of
          feature (W2)             continuum (F3)
 
        These three positions may be entered in any order.
 
*SUBROUTINES CALLED:

    TABINV
    PCHECK
    PARCHECK
    FMEAS
    FEATURE_OUT
    XYREADS
    YESNO
    PLOTOPEN
    PLOTPRINT

*FILES USED:

*SIDE EFFECTS:

    IF W0 is a variable, the dimension and values will be changed
    by the procedure.

    The file idl.ps may be created.  It is a postcript print file
    and will automatically be output using the command "lpr idl.ps".

*RESTRICTIONS:

    Device Dependent - The terminal must be equipped with a graphics 
                       cursor.
                       This procedure is not suitable for batch submission.

                     - This procedure was modified to support
                       remote terminals using tektronix 4014 emulation 
                       or sunview graphics devices
*NOTES:

        The user may change the plot scaling using the system
        variable !x.range(1).  If this variable is
        is defaulted to zero then FEATURE will plot 50 points
        on each side of the laboratory wavelength.  If more or
        fewer points are desired the user should set !x.range
        to the desired min. and max. wavelengths.

        Program assumes IDL is to read 6 characters when accepting
        GIN (graphics input) report in TEKTRONIX mode.

        The Display: wavelengths (W), radial velocities (RV),
           and fluxes (F) at the three points indicated by
           user; continuum flux (FCONT); residual intensity 
           at the extremum (RESI2); equivalent width of the
           feature in milli-Angstroms (EW-MA) or in Angstroms
           (EW-A);
           The moments of the total flux distribution
           (including underlying continuum).
                FTOT = Total Flux
                WTOT = Flux weighted wavelength
                WIDTOT= Flux weighted sigma (width)
           The same values are printed for the flux minus continuum.
           (FNET, WNET and WIDNET.)
             Note: for a Gaussian line profile, FWHM = 2.354 * WIDNET
           If FLUX is in absolute units (erg/sec/A) then FCONT
           has units (erg/sec).
        2) Plot of feature with area of feature filled in by
           vertical lines.

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

*PROCEDURE:

        Let (W1,F1), (W2,F2), and (W3,F3) be the user measured
        points:  The following computations are performed:
 
          RVn = (Wn-W0)*2.99792E5/W0
          Continuum = (WAVE-W1)*(F3-F1)/(W3-W1)+F1
          FCONT = integral(Continuum)/(W3-W1)
          RESI2 = F2/FCONT
          FTOT = integral(FLUX)
          WTOT = integral(FLUX*WAVE)/integral(FLUX)
          WIDTOT = SQRT(integral(FLUX*WAVE*WAVE)/integral(FLUX))
          FNET, WNET and WIDNET are computed replacing FLUX with
                FLUX-Continuum.
          Equivalent width = integral(1.-FLUX/continuum)
 
        All integrals are done with respect to wavelength form W1 to
        W2 using the trapezoidal rule.
 
*MODIFICATION HISTORY:

     Feb 12 1981  SRH  GSFC  initial program
     Apr 22 1981  SRH  GSFC  re. change request No. 4 to support
                             Tektronix 4025 terminals
     Apr 30 1981  SRH  GSFC  uses TEKPLOT for drawing characters on 
                             the graph.
     Jul 13 1981  DL   GSFC  per requests #65, 66, 21, 69
                             allow user to specify !XMIN, !XMAX,
                             !YMIN, !YMAX
                             Do not cut fluxes off at 0.0
                             Compute a flux weighted wavelength.
                             Input points reordered if entered out of 
                             order.
     Oct  3  1981 FHS3 GSFC  Computer EW correctly, compute flux 
                             weighted widths and return results array
                             CR#015.
     Jul  1  1985 CAG  GSFC  Force WIDNET to be greater than or equal 
                             to zero (URP's 146, 179 & 217).
     Oct 21  1985 RWT  GSFC  modify for DIDL (i.e., use NELEMENTS, new 
                             INDGEN, replace @'s with #'s, and remove REORDER)
     Aug 29  1986 CAG  GSFC  modified overplot to use !PSYM=0 (URP #158)
     Oct  6  1986 RWT  GSFC  replace TEKDATA with CURSOR, and @ with #
     Feb 11  1987 RWT  GSFC  VAX mods: use PLOTS for TKPLOT, XYOUTS & 
                             SCTODC for XYOUT, replace INSERT and EXTRACT 
                             with assignment statements,
                             replace sub. FSORT with IDL SORT
     Apr 13  1987 RWT  GSFC  add PARCHECK and PLTPARM
     Feb 29  1988 RWT  GSFC  make FMEAS a separate procedure
     Mar  9  1988 CAG  GSFC  add VAX RDAF-style prolog
     aug. 28, 1989 jtb @gsfc extensive modifications for unix/sun idl
     Feb 26, 1991 PJL  GSFC  added an optional parameter - comment - for
			      plot title
     Apr 09, 1991 GRA  CASA  added section to prompt for the name of a
                             vms postscript print queue.
     Jun 17, 1991 PJL  GSFC  changed hardcopy section to use new versions
			      of PLOTOPEN and PLOTPRINT; tested on VAX and
			      UNIX; updated prolog
     Jun 21, 1991 PJL  GSFC  cleaned up; tested on SUN and VAX; 
			      updated prolog
     Jun 28, 1991 PJL  GSFC  added check for existence of printer; tested on 
			      SUN and VAX; updated prolog
     Jul 08, 1991 GRA  CASA  added 'feature' as name parameter to calls
                             to PLOTOPEN and PLOTPRINT. Removed branch
                             based on !d.name eq 'PS' in output
                             section.
     Jul 10, 1991 PJL  GSFC  corrected a comment and a prompt; tested on 
			      SUN and VAX; updated prolog
     Nov 11, 1991 PJL  GSFC  added /down to tek branch cursor call and wait
			      to non-tek branch
     Nov 22, 1991 GRA  CASA  removed reference to IUER_USERDATA from prolog.
     Dec 11, 1991 PJL  GSFC  modified example in prolog
     Feb 12, 1993 LLT  GSFC  Added keyword to suppress option to send plots to
                             laser printer, added warning when fluxes in the
                             selected range change sign, mark chosen points
                             on printouts (and use the "x" symbol always),
                             and add time-tag to printouts.
     Sep 30, 1993 RWT  GSFC  modify for new plotopen and plotprint routines
     Jun 27, 1994 RWT  GSFC  add "device,gin_chars=6", flush, 
                             "device,/tek4010" commands in TEK mode

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


FEATURE_OUT

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

    FEATURE_OUT  AUG. 28, 1989

*CLASS:

    formatted text output for feature.pro

*CATEGORY:

*PURPOSE:  

    To output the results of the feature procedure measurements to
    text and graphics windows

*CALLING SEQUENCE:

    FEATURE_OUT, R,comment

*PARAMETERS:

    r    (REQ) (I) (1) (F)  
         Required input vector of argument values
             r(0)= the original value for W0 (rest wavelength). 
             r(1)= short wavelength limit to integration
             r(2)= extremum of spectral line
             r(3)= long wavelength limit to integration
             r(4)= radial velocity for short wavelength limit
                         to integration.
             r(5)= radial velocity for extremum of spectral line
             r(6)= radial velocity for the long wavelength limit
                         to integration.
             r(7)= flux at the short wavelength limit to the
                         integration.
             r(8)= flux at the spectral line extremum
             r(9)= flux at the long wavelength limit to the 
                         integration.
             r(10)=continuum flux
             r(11)=residual flux at extremum
             r(12)=equivalent width
             r(13)=total flux in the feature. 
             r(14)=flux weighted wavelength for feature.
             r(15)=flux weighted sigma, which for a 
                         gaussian profile can be related to the full
                         width at half maximum.
             r(16)=net flux in feature
             r(17)=flux weighted wavelength, with continuum
                         not included
             r(18)=flux weighted sigma for net flux only.

    com  (OPT) (I)
         Optional parameter for identifying comment.  Limited to 20
         characters; it will be truncated if it is longer.

*EXAMPLES:

     Load the result array (fltarr(19)) with the appropriate values
     and call feature_out.

                       feature_out, result

*SYSTEM VARIABLES USED:

     !d.name
     !d.x_ch_size
     !d.y_ch_size
     !d.y_size

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

         This procedure calls the graphics routine "xyouts" with
    the key words " font=0,/device ", and outputs text to the
    left side of the graphics window.

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

*PROCEDURE: 

        This procedure uses "xyouts" for sending text to the
    graphics window and "print" for text output to the text
    window.


*MODIFICATION HISTORY:

     aug. 28, 1989 jtb @gsfc  version 1 for unix/sun idl
     Feb. 26, 1991 PJL @GSFC  added an optional identifying comment to plot
     Jun. 17, 1991 PJL @GSFC  changed test of TEK and PS to lowercase;
		    tested on UNIX and VAX systems; updated prolog
     Jun. 21, 1991 PJL @GFSC  cleaned up; tested on SUN ans VAx; 
			       updated prolog

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


FESCALC

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

     	FESCALC.PRO     (IUE Production Library)

*CLASS:

	FES magnitude procedure

*CATEGORY:

*PURPOSE:

	To calculate a target's V magnitude, based on its color index and FES
	counts, using the Fireman and Imhoff (1989) calibration for the former
	FES reference point (-16,-208).  To calculate a target's V magnitude, 
	based on its color index, FES counts, and focus step, using Perez 
	(1991) calibration for the current FES reference point (-144,-176).  
	The new FES reference point was implemented on January 22,1990 at GSFC 
	and on July 23, 1990 at VILSPA.

*CALLING SEQUENCE:

	FESCALC,COUNTS,FLAP,FESTSR,BMV,DATE,VFES,fstep,obsst

*PARAMETERS:

	COUNTS	(REQ) (I) (0) (I)
               FES counts at current reference point 
               (i.e. out of aperture)
	
	FLAP	(REQ) (I) (0) (I)
  	        FES overlap/underlap flag.  Overlap = 0, underlap = 1.

	FESTSR	(REQ) (I) (0) (I)
        	FES track scan rate.  Fast Track = 0, Slow Track = 1.

	BMV 	(REQ) (I) (0) (F)
               B-V color index.

	DATE	(REQ) (I) (0) (F)
               Date of observation in decimal years.  Beware of dates near 
		the chenge of reference points.  If the observing station is 
		GSFC and the date is 1990.0602 (January 22, 1990) or greater
		OR if the observing station is VILSPA and the date is 1990.558 
		(July 23, 1990) or greater, then the calculation uses the 
		information for the new FES reference point.
	
	VFES	(REQ) (O) (0) (F)
               FES magnitude, corrected for FES degradation and dead 
               time, as well as B-V color correction.

	FSTEP	(OPT) (I)
		The focus step.  Required for new reference point data.  
		If not given, defaults to -2.653; thus, the corrected counts 
		equals the observed counts.

	OBSST	(OPT) (I)
		Observing station.  Required for new reference point
		data.  If not given, defaults to GSFC.  
		GSFC = 'G', Vilspa = 'V'.

*EXAMPLES:

	Calculate the FES magnitude for a target with 1000 counts, F/O, 
       on 1989 April 17, which has a B-V color index of 0.5.
		FESCALC,1000,0,0,0.5,1989.29,VFES


*SYSTEM VARIABLES USED:

	!NOPRINT

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

       PARCHECK - parameter checking

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

	This "calibration is NOT valid for FES data taken during the 'FES
	anomaly' experienced after January 22, 1991, where additional 
	background scattered light was detected in the FES mainly at high
	beta attitudes." As of February 1991, "this background has been
	reported to decrease substantially since its initial detection."
	(Perez 1991)

*NOTES:

	For the former FES reference point (-16,-208):
	   Assumes no degradation correction is needed until a specific "cutoff 
	date", after which, a linear degradation in used.  Separate 
	calibrations are used for underlap and overlap measurements.  The 
	overlap date is 1981.65, while it is 1980.60 for underlap. 
          Based on Imhoff (1986) IUE NASA Newsletter 29, p. 45.

	For the current FES reference point (-144,-176):
	   Assumes no degradation correction is needed.  Corrects for 
	focus step.
          Based on Perez (1991) IUE NASA Newsletter 45, p. 19.

	Beware of dates near the change of reference points.  If the observing 
	station is GSFC and the date is 1990.0602 (January 22, 1990) or greater
	OR if the observing station is VILSPA and the date is 1990.558 (July 
	23, 1990) or greater, then the calculation uses the information for 
	the new FES reference point.

       tested with IDL Version 2.1.0 (sunos sparc)	11 Jul 91
       tested with IDL Version 2.1.0 (ultrix mispel)	N/A
       tested with IDL Version 2.1.0 (vms vax)		8 July 1991

*PROCEDURES:

	For the former FES reference point (-16,-208):
	   An FES magnitude is calculated based on user supplied FES counts and 
	B-V color index.  The calculation uses the FES calibration of Fireman 
	and Imhoff (1989) to compensate for the FES's degradation with time.

	For the current FES reference point (-144,-176):
	   An FES magnitude is calculated based on user supplied FES counts, 
	B-V color index, focus step, and observing station.  The calculation 
	uses the FES calibration of Perez (1991) for the focus dependency.  
	Also, new K values are used. Default values for observing station 
	(GSFC) and focus step (-2.653) are used, if no values are given.

I_HELP nn:

*MODIFICATION HISTORY:

	Original version written 1989 Apr 17, by T. J. Teays.
	 2-21-91 PJL moved to sun/unix system; added warning concerning
		     the change of the reference point
	 3-12-91 PJL updated with Perez (1991) information
	 8- 7-91 LLT tested on VAX; updated prolog
	11- 7-91 PJL cleaned up; tested on SUN; updated prolog

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


FILECOPY

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

    FILECOPY     (General IDL Library 01) 22-FEB-81

*CLASS:

    i/o

*CATEGORY:
     
*PURPOSE:  

    On VMS system:  to copy one file from an input tape to an output tape
 
*CALLING SEQUENCE:    

    FILECOPY,IN,BUFSIZE,NTRIES,OUT
 
*PARAMETERS: 

    IN        (REQ) (I) (0) (I)
              Input unit number

    BUFSIZE   (REQ) (I) (0) (I)
              Maximum record length in bytes on tape file
              (This value may be larger than the actual length)

    NTRIES    (REQ) (I) (0) (I)
              Number of retries in the case of a tape read error

    OUT       (REQ) (I) (0) (I)
              Output tape unit number

*EXAMPLES:

    FILECOPY,0,50,3,1
    Where:          1=output unit
                  3=how many times to try the copy
               50=an over-estimate of the record length(in bytes on tape file)
             0=input unit

*SYSTEM VARIABLES USED:

    !err
    !err_string

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    PARCHECK
    TINIT
    PLATFORM
 
*FILES USED:

    The file corresponding to unit IN is copied directly to the
    output tape.

*SIDE EFFECTS:

*RESTRICTIONS:

    VMS systems only

    Device Dependent - Two tape drives must be available, allocated,
                        and tapes mounted on both drives.
                       This procedure is not suitable for batch operation,
                       or for use by remote users.

*NOTES:

    The output tape is positioned at a double EOF prior to copy.  (An
    empty tape should begin with an EOF.)  The output tape is left between
    a double EOF after the copied file.
    The input tape should be at the beginning of the file to be copied, and
    will be left after the EOF defining the file.

    Must have mounted two tapes: 
         MOUNT,n or SPAWN,'MOUNT MTn:/FOR
    Tape drives must be mounted before entering IDL Version 2.

	tested with IDL Version 2.1.2 (sunos sparc)    not used on
	tested with IDL Version 2.1.2 (ultrix mispel)  not used on
	tested with IDL Version 2.1.2 (vms vax)	       5 Nov 91
 
*PROCEDURE: 

    Uses TINIT to position output tape between double end-of-files.
    FILECOPY then copies the input file directly to the output
    tape, and will retry as many times as specified by NTRIES.  (If 
    no tries are successful, FILECOPY will print an appropriate message to
    the terminal, and rewind the output tape to the original EOF's. 
    After each unsuccessful try, the output tape is repositioned between
    the original EOF's.)
    Upon successful completion of the copy, FILECOPY prints a message to the
    terminal, indicating the number of records copied.
    Finally, the output tape is positioned between EOF marks, and the
    input tape will be left at the end of the copied file.
 
*MODIFICATION HISTORY:

    Feb 22 1981  FHS3  GSFC   initial program
    May  5 1987  RWT   GSFC   VAX Mods: use ON_IOERROR for handling tape 
                              errors and end-of-files, and add PARCHECK
    Jun 18 1987  RWT   GSFC   use TINIT for positioning output tape.
    May  8 1991  PJL   GSFC   modified for IDL Version 2 including
			       modifying use of !ERR
    Jun 20 1991  PJL   GSFC   cleaned up; updated prolog
    Aug 19 1991  GRA   CASA   cleaned up; tested on VAX (9-track Q-bus)
    Sep 11 1991  GRA   CASA   set on_ioerror to null in the event of
                              error writing to output tape; tested on
                              VAX; updated prolog.
    Sep 16 1991  PJL   GSFC   corrected typo in prolog
    Nov  4 1991  GRA   CASA   defined sys = !version.os for system
                              dependent branching.
    13 Jun 94  PJL  replaced !version with PLATFORM

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


FILETYPE

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

	FILETYPE

*CLASS:

*CATEGORY:

	IUE specific error checking and file name parsing

*PURPOSE:

	Procedure to verify that a file is on disk, and to
       parse the file name.

*CALLING SEQUENCE:

	FILETYPE,IMAGET,DISK,PATH,NAME,EXT,VERS,NCAM,TYPE,ISN

*PARAMETERS:

	IMAGET  (REQ) (I)
		string file name following IUE G.O. file convention

	DISK    (REQ) (O)
		string name of disk

       ACCOUNT (REQ) (O)
		string account for file

       NAME    (REQ) (O)
		string file name

       EXT     (REQ) (O)
		string file extension (e.g. .DAT)

       VERS    (REQ) (O)
		string version number

       NCAM    (REQ) (O)
		(integer) camera number

       TYPE    (REQ) (O)
		file type, e.g. 'H' for high dispersion

       ISN     (REQ) (O)
		image sequence number

*EXAMPLES:

*SYSTEM VARIABLES USED:

	!err_string

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	DECOMPOSE

*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:

	The file name is parsed, and the specified disk location
       is searched for the .DAT file of the given name. If it is
       not found, an error message is issued, and control is 
       returned to the calling procedure.

*I_HELP  nn:

*MODIFICATION HISTORY:

	Based on code in IUELO
       Version 0: CAG 2- DEC--87
	 1-09-91 PJL modified for sun/unix; included removing !ERR
	 7-23-91 PJL cleaned up; added if npar equals 0 print; tested
		     on SUN and VAX; updated prolog

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


FILTER

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

    FILTER  (General IDL Library 01)   MAY 31,1981

*CLASS:

    Smoothing

*CATEGORY:

*PURPOSE:  

    PERFORM AN ARBITRARY SYMMETRICAL FILTERING.

*CALLING SEQUENCE:

    FILTER,DATA,FILTR,RESULT

*PARAMETERS: 

    DATA   (REQ) (I) (1) (F D)
           required input vector containing the data to be smoothed

    FILTR  (REQ) (I) (0 1) (I L F D)
           if scalar, this parameter contains the width of the box filter.
           if vector, this parameter contains the filter values where
           FILTR(0)=center of filter.

    RESULT (REQ) (O) (1) (F D)
           Required output vector containing the filtered data.

*EXAMPLES:

        To filter data with a 5 point triangular filter
                FILTR = FLTARR(3)
                FILTR(0)= 3.0 & FILTR(1)= 2.0 & FILTR(2)= 1.0
                FILTER,DATA,FILTR,RESULT

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

     PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:
        The DATA array is effectively extended
        1/2 the filter width with the value of
        the first and last point of DATA before
        filtering in the case of vector filters.
             
        The scalar filters do not filter the 
        halfwidth of the filter at each end
        of the data.

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

*PROCEDURE: 

        For scalar FILTR, filtering done by
            RESULT = SMOOTH ( DATA, FILTR )
             
        For vector FILTR:
            (1) each data term is multiplied by 
                 the center of the filter: FILTR(0).
            (2) the previous (n-1) and next (n+1)
                 data terms are multiplied by the
                 filter value and summed with the
                 value calculated in (1).
            (3) filter is normalized by taking the
                 ratio of the summed values (2),
                 and twice the sum of the filter 
                 values. ( NOTE: center of filter
                 used only once )

*MODIFICATION HISTORY:

     May 31 1981  FHS3  GSFC  initial version
     Jun  8 1987  RWT   GSFC  add PARCHECK
     Mar  9 1988  CAG   GSFC  add VAX RDAF-style prolog
     jul 19 1989  jtb   gsfc  converted to sun/unix idl
     Jun 21 1991  PJL   GSFC  cleaned up; tested on SUN and VAX; 
			       updated prolog

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


FINDELT

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

      FINDELT

*CLASS:

*PURPOSE:
       
      This program will search the file ELEMENTS.LIS for the set of orbital
      elements appropriate for the given observation date.  If the image is
      too recent to have an appropriate set of elements in the list, or if
      there is an error opening the list file, the procedure ORBEL is called
      to extract the elements from the science image header, if an image was
      given in the first place.  Failing all else, the user will be prompted
      for the elements. 

*CALLING SEQUENCE:

      FINDELT,IMAGET,RJD,JD,A,E,I,O,W,M

*PARAMETERS:

  IMAGET (REQ) (I) (0) (S) - Image file name (cam+isn+type)

     RJD (REQ) (I) (0) (D) - Julian date of observation

      JD (REQ) (O) (0) (D) - Julian date - epoch of orbital elements

       A (REQ) (O) (0) (D) - Semi-major axis length of orbit in km

       E (REQ) (O) (0) (D) - Eccentricity of the orbit

       I (REQ) (O) (0) (D) - Inclination of the orbit

       O (REQ) (O) (0) (D) - Longitude of the ascending node

       W (REQ) (O) (0) (D) - Argument of pericenter

       M (REQ) (O) (0) (D) - Mean anomaly

*SYSTEM VARIABLES:

       !err
       !iuer.dat

*SUBROUTINES CALLED:

       PARCHECK
	ORBEL

*FILES USED:

       ELEMENTS.LIS
	TEMP.LIS

*NOTES:

       This program chooses the element set on or nearest in time to the 
       observation date where there is no intervening delta V manuever.
       Note that the element set chosen may not be consistent with the
       element set found in the science image header, which is the most
       recent previous set to the observation date, regardless of possible
       intervening delta V manuevers.  
       Images may be taken immediately following a delta V maneuver, when the
       old (and now invalid) set of elements is still loaded on the operations
       computer (and thus in the header).

       tested with IDL Version 2.1.0 (sunos sparc)	26 Jul 91
       tested with IDL Version 2.1.0 (ultrix mispel)	N/A
       tested with IDL Version 2.1.0 (vms vax)       	25 July 1991 by LLT

*MODIFICATION HISTORY:

       Written 25 January 1990 by LLT.
       4/9/90 LLT Prolog 
       10/90 LLT Modified 
       11/5/90 LLT Read elements from ELEMENTS.LIS 
       7-dec-90 LLT Change the way delta Vs are handled.
       19-dec-90 LLT Add call to ORBEL if date is too recent.  Remove option
                     of using RADCOR's elements.
       4-Jan-91 LLT Choose the nearest set instead of previous set.
       12-Mar-91 LLT Use temp file to read element set chosen; thus avoiding
                     tab characters and blanks in different versions of the
                     ELEMENTS.LIS file.
        4-11-91 GRA  added branch for file name processing on vms
       25July91 LLT  clean up, add parcheck, update prolog, change to new
                     logicals, fix branch to check science image header.
		      tested on VAX
	26July91 PJL  tested on SUN; updated prolog
       2 Sep 94 LLT  replace IUER_DAT with !iuer.dat

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


FITSCON

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

    FITSCON 

*PURPOSE:

    To convert FITS binary table data types (i.e. IEEE format)
    to format used on current cpu.

*CALLING SEQUENCE:

    FITSCON,BYTE_EQ,TYPE,VARIABLE,TDIM=S

*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: byte 'X', integer 'I', longword 'J', floating 
        point 'E', double precision 'D', and string 'A'. 

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

    TDIM (KEY) (I) (0) (S)
        If specified, contains the value of the TDIMn keyword
        describing the dimensions of a multi-dimensional array.

*SIDE EFFECTS:

*SYSTEM VARIABLES USED:

*SUBROUTINES CALLED:

	PARCHECK
       FLAG_NAN
       IUEGETTOK

*EXAMPLE:

*RESTRICTIONS:

*NOTES:

       Original version written for IDL version 1.
       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)    11 Mar 93
	tested with IDL Version 2.3.2 (vax vms)        11 Mar 93 
       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:

	Version 1 Randy Thompson 2/8/91 (based on VTOS by John Hoegy)
       3-13-91 RWT use algorithms derived by WTT in SUN2VAX procedure.
       3-14-91 RWT replace SWAP with routine called SWAP_BYTES
	3-27-91	PJL modified for unix/sun; renamed from FITSTOV to FITSSUN;
		added PARCHECK; deleted SWAP_BYTES
       4-23-91 GRA changed references to FITSTOV to FITSSUN (n_par eq 0)
       7-25-91 RWT rename FITSCON, use TRANS_BYTES to allow conversion
               to vms, Ultrix, unix, or DOS systems, and convert 1 element
               arrays to scalars.
      11/07/91 GRA defined cpupar = !version.arch for trans_bytes 
               parameter; tested on sun, vax, and dec.
       6/24/92 RWT change 383 to 386 for flagging IBM pcs
       7/6/92  RWT properly handle B, P, C, & M formats
      10/19/92 RWT add FLAGNAN to J,E,D,C, & M data types
       3/11/93 RWT replace TRANS_BYTES with intrinsic byteorder command
       9/22/93 RWT add multi-dimensional array support

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


FITSLAB

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

 	FITSLAB
  
*CLASS:

	Data Conversion
  
*CATEGORY:

	IUESIPS
  
*PURPOSE:

 	To convert the IUE label file to a set of FITS keywords. 
       Binary data is converted to hexadecimal notation.  Each line of the
	main header (including appendage) is written with a blank keyword.
	The HISTORY keyword is added to each line of the image processing
	history portion of the label.
  
*CALLING SEQUENCE:

 	FITSLAB,LAB_FILE,LABEL,FLAB
  
*PARAMETERS:

       LABFILE	(REQ) (I) (0) (S)
            	Imaget filename for IUE label (.LAB).

       LABEL   (REQ) (O) (1) (S)
   		String array containing IUE label in ASCII format.

       FLAB    (OPT) (O) (1) (S)
               LABEL with keywords '       ' & 'HISTORY' appropriately
               added at beginning of each line.
  
*EXAMPLES:

       To write ascii version of label into string array LABEL and FITS
       keyword version of label into string array FITSLABEL:

                fitslab,'swp32199l.lab',label,fitslabel
  
*SYSTEM VARIABLES USED:

	!iuer.dat

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK
	CHKFITS
	IFITSRD
  
*FILES USED:

	!iuer.dat EBCASC.FIT - - converts EBCDIC to ASCII

*SIDE EFFECTS:
  
*RESTRICTIONS:

	This procedure should only be used with IUESIPS data.
       
*NOTES:
 
       See the IUE IMAGE HEADER DOCUMENT (Version 2) for more 
       information on the contents of the IUE header label.
       Program currently assumes that main label ends in line 100.
       This will not be correct for images with truncated labels,
       or images with added label extensions.

*PROCEDURE:

       Reads through label converting each line depending on whether
       it is EBCDIC or binary information. According to the IUE Image
       Header Document (June 1986 version) binary portions in lines
       33-35, 38-45, and 47-50 were never used and are therefore
       simply treated as blank lines. 
  
*I_HELP nn:
  
*MODIFICATION HISTORY:

	written by R. Thompson 11/27/90 (based on routine READ_LAB).
	2/6/91	RWT add comments to FLAB as proposed by VILSPA for final 
		archive
	27 Mar 1991 PJL modified for unix/sun; added PARCHECK;
		    strings for header must be declared as 80 bytes
	16 Apr 1991 PJL path to data file
       23 Apr 1991 GRA added branch for vms file name processing
       7/24/91 RWT use new multi-cpu logical assignments
	16 Aug 93  PJL  added IFITSRD to read ebscasc.fit (replaces ebcasc.dat)
	11 Nov 93  PJL  added findfile and CHKFITS
       22 Feb 94  PJL  for binary section - uppercase and add leading 0's
        2 Sep 94  LLT  replace IUER_DAT with !iuer.dat

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


FLAGBLEM

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

 	FLAGBLEM       (RDAF General Production Library)      JAN 30, l983
 
*CLASS

 	Data Editing

*CATEGORY:

       IUESIPS         NEWSIPS

*PURPOSE:  

 	Plots expanded region around blemishes and prompts user for input
      	of user flagged points.  Then displays flags and unflags regions
      	specified by user.  Called by BSPOT.

*CALLING SEQUENCE

 	FLAGBLEM,WAVE,FLUX,EPS,mode,INX,NFLAG,NEWSIPS
 
*PARAMETERS:

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

    	FLUX 	(REQ) (I) (1) (R)
             	Input slit_integrated 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.

    	MODE 	(OPT) (I) (0) (I)
             	Determines type of interpolation to be used when user selects
               interpolation.  If not specified, MODE is set to 0.
             	Thus MODE is used to key interpolation step:
             	    0 = use nearest good data points for interpolation.
             	    1 = use cursor (horizontal) to set flux level.

    	INX  	(REQ) (I) (1) (I)
             	Expanded display window around blemished region. See BSPOT for
             	derivation.

   	NFLAG 	(REQ) (O) (0) (I)
             	Flag to determine whether new points flagged by user.

       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:

     	Prompts user to flag bright spots or blemishes

*SUBROUTINES CALLED:

	PARCHECK
    	BS_PLOTFLAG
    	BS_FLAG
 
*FILES USED:

    	Those established by BSPOT.PRO.

*SIDE EFFECTS:

*NOTES:

*PROCEDURE:

      	Instructions are printed for flagging bright spots, users input
      	(screen positions and/or character) is read and flagged points 
      	shown to user, episilon flags are set and/or blemishes interpolated
      	over.

*MODIFICATION HISTORY:

      	30-JAN-83 written by R.J. Panek
      	See BSPOT.PRO documentation for further modification history.
      	10_MAR-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
        6 Apr 94  PJL  added NEWSIPS parameter; removed gotos

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


FLAGNAN

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

    FLAGNAN

*CLASS:

*CATEGORY:

*PURPOSE:

    To flag and/or replace IEEE NaN values in an IDL array.

*CALLING SEQUENCE:

    FLAGNAN,ARRAY,IND,COUNT,nvalue

*PARAMETERS:

    ARRAY (REQ) (IO) (012) (RD)
       IDL array. 

    IND (REQ) (O) (1) (I) 
       indices of found NaN values

    COUNT (REQ) (O) (0) (IL)
       number of found NaN values. (0 if none found.)

    nvalue (OPT) (I) (0) (BILF)
       optional parameter specifying replacement value.
       If not specified, user is prompted for value.

*EXAMPLES:

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

   PARCHECK

*FILES USED:

*SIDE EFFECTS:

	If no NaN values are found, or if ARRAY is not of type float, double
	precision, or complex, then -1 is returned, and COUNT is set to 0.

*RESTRICTIONS:

	ARRAY must be of type float, double-precision, or complex.

*PROCEDURE:

	The bit patterns of the numbers being tested are compared against the
	IEEE NaN standard.

*INF_1:

*NOTES:

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

*MODIFICATION HISTORY:

	written by Bill Thompson 2/92
        8-14-92 rwt add nvalue option, change from a function to a 
               procedure & print out results
       10-19-92 rwt make ind and count required output parameters

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


FMEAS

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

    FMEAS  (General IDL Library 01)
  
*CLASS:

    spectral lines, measurement
  
*CATEGORY:
  
*PURPOSE:

    To numerically integrate across spectral features and determine
    common measurements and moments for the line profile.
  
*CALLING SEQUENCE:

    FMEAS,WAVEF,FLUXF,CONT,DATAPT,RESULT
  
*PARAMETERS:

    WAVEF  (REQ) (I) (1) (F D)
           required input vector containing the wavelength data 

    FLUXF  (REQ) (I) (1) (F D)
           required input vector containing the flux data

    CONT   (REQ) (I) (1) (F D)
           required input vector containing continuum flux data

    DATAPT (REQ) (I) (1) (F)
           required input vector containing the vector element numbers
           for the starting point for the integration, the extremum,
           and the stopping point.
           DATAPT(0)= element number corresponding to the laboratory
                      wavelength
           DATAPT(1)= element number corresponding to the shortwavelength
                      integration limit for the spectral feature
           DATAPT(2)= element number corresponding to the extremum of
                      the spectral feature (not actually used here).
           DATAPT(3)= element number corresponding to the long wavelength
                      integration limit for the spectral feature.

    RESULT (REQ) (O) (1) (F D)
           required output vector containing the results of the numerical
           integration.
           RESULT(0)= integrated continuum flux in A or mA.
           RESULT(1)= equivalent width of feature in A or mA.
           RESULT(2)= total flux between start and stop points 
           RESULT(3)= flux weighted wavelength for the feature,
                      including the continuum flux.
           RESULT(4)= flux weighted width (sigma) of the feature,
                      including the continuum.
           RESULT(5)= Net integrated flux in the feature.
           RESULT(6)= flux weighted wavelength for the feature,
                      using only the net flux.
           RESULT(7)= flux weighted width (sigma) of the net feature.

*EXAMPLES:

     See documentation for FEATURE

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

     PARCHECK
     INTEG
  
*FILES USED:
  
*SIDE EFFECTS:

*RESTRICTIONS:
  
*NOTES:

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

*PROCEDURE:

     The following integrals and moments are calculated numerically, 
     using the trapezoid rule.

     RESULT(0)=FCONT= Integral(CONT) from datapt(1) to datapt(3)
     RESULT(1)=EW   = Integral(1-FLUXF/CONT) from datapt(1) to datapt(3)
     RESULT(2)=FTOT = Integral(FLUXF) from datapt(1) to datapt(3)
     RESULT(3)=WTOT = Integral(FLUXF*WAVEF) from datapt(1) to datapt(3)
     RESULT(4)=WIDTOT=Integral(FLUXF*(WAVEF-WTOT)*(WAVEF-WTOT)) from
                       datapt(1) to datapt(3)
     RESULT(5)=FNET = Integral(FLUXF-CONT) from datapt(1) to datapt(3)
     RESULT(6)=WNET = Integral((FLUXF-CONT)*WAVEF) from datapt(1) to datapt(3)
     RESULT(7)=WIDNET=Integral((FLUXF-CONT)*(WAVEF-WNET)*(WAVEF-WNET))
                       from datapt(1) to datapt(3)
     
*INF_1:
  
*MODIFICATION HISTORY:

     See documentation for FEATURE
     Feb 29 1988   RWT   GSFC  Make FMEAS a separate procedure
     Mar 10 1988   CAG   GSFC  Add VAX RDAF-style prolog, printing
                               of calling sequence if no parameters
                               are used, and check for correct number
                               of parameters.
     Jun 21 1991   PJL   GSFC  cleaned up; tested on SUN and VAx; 
				updated prolog

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


G1BCKGND

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

   	G1BCKGND
  
*CLASS:
  
  	Spectral Fitting
  
*CATEGORY:

*PURPOSE:

    	Procedure to fit a linear baseline to data points.
  
*CALLING SEQUENCE:

    	G1BCKGND,X,Y,XL,XR,A,SIG
  
*PARAMETERS:

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

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

       XL	(REQ) (I) (1) (I)
		Indice of left signal edge.

      	XR	(REQ) (I) (1) (I)
		Indice of right signal edge.

   	A	(REQ) (I/O) (1) (F)
		Floating point array with 3+3*NCOMP elements where (input).
                NCOMP = # of features (1 for GEX1, see GAUSSFIT) (input).
		Vector of function parameters (output).

       SIG	(REQ) (O) (1) (F D)
		Standard deviation (i.e. total(y-yfit)^2/n-1 ).
  
  
  
*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:
  
	PARCHECK
    	LINFIT
  
*FILES USED:
  
*SIDE EFFECTS:
  
*RESTRICTIONS: 

	modified for unix/sun idl version 1.1
  
*NOTES:
  
       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:
  
    	Uses LINFIT to fit a straight line to region outside region of 
	feature.  Baseline parameters are stored in last 3 terms of vector A 
	(last term reserved for 2nd order fit).
  
*I_HELP nn:
  
*MODIFICATION HISTORY:

   nov-21-89 jtb@gsfc modified for unix/sun idl
   8 July 91 LLT add PARCHECK, updated prolog, cleaned up, tested on VAx.
   16 Jul 91 PJL tested on SUN and VAX; updated prolog
  

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


G1FIT

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

   	G1FIT
  
*CLASS:
  
  	Menu Procedure
	Spectral Fitting
  
*CATEGORY:

*PURPOSE:

    	Procedure to fit gaussians and a linear baseline to data points (from 
	GAUSSFIT.PRO)
  
*CALLING SEQUENCE:

	G1FIT,X,Y,NCEN,CENTER,A,SIGMA
  
PARAMETERS:

	X	(REQ) (I) (1) (I L F D)
		Vector of independent variable elements.

       Y	(REQ) (I) (1) (I L F D)
		Vector of dependent variable elements.

       NCEN	(REQ) (I) (0) (I)
		Number of orders in signal region.

       CENTER	(REQ) (I) (0) (I)
		Indice of central order (e.g. center order number - 1).

     	A	(REQ) (O) (1) (F)
		Vector of function parameters.

       SIGMA	(REQ) (O) (1) (F)
		Sigmas from background fit.

*SYSTEM VARIABLES USED:
  
  	NOPRINT	-   !NOPRINT

*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:
  
	PARCHECK
	G1BCKGND
  	WFIT
  
*FILES USED:
  
*SIDE EFFECTS:
  
*RESTRICTIONS:  

	modified for unix/sun idl version 1.1
  
*NOTES:

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

    	Procedure to fit gaussians and a linear baseline to data points (from 
	GAUSSFIT.PRO)	
  
*I_HELP nn:
  
*MODIFICATION HISTORY:
  
   nov-21-89 jtb@gsfc the vax/vms version was modified for unix/sun idl
   2 July 91 LLT cleaned up; tested on VAX; updated prolog
   15 Jul 91 PJL added PARCHECK; tested on SUN and VAX; updated prolog
   06 Aug 91 GRA removed unused parameter "0." fro, the WFIT calling
                 statements.
  

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


G2FIT

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

   	G2FIT
  
*CLASS:

	Menu Procedrue
	Spectral Fitting
  
*CATEGORY:
  
*PURPOSE:

   	Procedure to fit gaussians and a linear baseline to data points 
	(from GAUSSFIT.PRO).
  
*CALLING SEQUENCE:

   	G2FIT,X,Y,NCEN,CENTER,A,HTSIG,SIGMA
  
*PARAMETERS:

	X	(REQ) (I) (1) (I L F D)
		Vector of independent variable elements.

    	Y	(REQ) (I) (1) (I L F D)
		Vector of dependent variable elements.

    	NCEN	(REQ) (I) (0) (I)
		Number of orders in signal region.

    	CENTER	(REQ) (I) (1) (I)
		Indice of central order (i.e. central order - 1).

    	A	(REQ) (I/O) (1) (F D)
		Input/output vector in which A(0)= fixed width,
        	A(1)= fixed center position, A(3)= background y-intercept
        	and A(4)= background slope.
		Vector of function parameters.

     	HTSIG	(REQ) (O) (0) (F D)
		Uncertainty in gaussian height   
             	(calculated according to bevington chapter 8).

     	SIGMA	(REQ) (O) (0) (F D)
		Scatter about best gaussian fit.

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:

       PARCHECK
	GAUSS
  
*FILES USED:
  
*SIDE EFFECTS:
  
*RESTRICTIONS: 

       modified for unix/sun idl version 1.1
  
*NOTES:
  
       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:

   	Procedure to fit gaussians and a linear baseline to data points 
	(from GAUSSFIT.PRO).	
  
*I_HELP nn:
  
*EXAMPLES:
  
*MODIFICATION HISTORY:
   
   nov-21-89 jtb@gsfc modifications for unix/sun idl
   8 July 91 llt add parcheck, update prolog, clean up, tested on VAX.
   16 Jul 91 PJL tested on SUN and VAX; updated prolog

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


G2_ARCHECK

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

   	G2_ARCHECK
  
*CLASS:
  
  	Spectral Data Reduction
  
*CATEGORY:
  
*PURPOSE:

   	Procedure to check wcenter (WIG) and width (WID) vectors for bad
    	points & fix them (by removing elements or replacing values).
  
*CALLING SEQUENCE:

   	G2_ARCHECK,WAVE,WIG,WID,HR,WFIT,WGFIT,WDFIT,NKEPT
  
*PARAMETERS:

	WAVE	(REQ) (I) (1) (F D)

	WIG 	(REQ) (I) (1) (F D)

	WID	(REQ) (I) (1) (F D)

	HR	(REQ) (I) (1) (F D)

	WFIT	(REQ) (O) (1) (F D)

	WGFIT 	(REQ) (O) (1) (F D)

	WDFIT 	(REQ) (O) (1) (F D)

	NKEPT	(REQ) (O) (0) (I)
  
*SYSTEM VARIABLES USED:
  
  	NOPRINT	-   !NOPRINT

*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:
  
  	PARCHECK
  
*FILES USED:

*SIDE EFFECTS:
  
*RESTRICTIONS:  

	modified to run using unix/sun idl version 1.1
  
*NOTES:

       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:

   	Procedure to check wcenter (WIG) and width (WID) vectors for bad
    	points & fix them (by removing elements or replacing values).	
  
*I_HELP nn:
  
*EXAMPLES:
  
*MODIFICATION HISTORY:

      nov-21-1989 jtb@gsfc modifications for unix/sun idl
      8 July 1991 llt add parcheck, update prolog, clean up; tested on VAX.
      16 Jul 91  PJL tested on SUN and VAX; updated prolog

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


GAUSS

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

    GAUSS   (General IDL Library 01)  Aug 19, 1979 

*CLASS:

    numerical function

*CATEGORY:

*PURPOSE:  

    TO CALCULATE A GAUSSIAN FUNCTION
 
*CALLING SEQUENCE: 

    GAUSS,X,X0,DX,YMAX,Y
 
*PARAMETERS:

    X     (REQ) (I) (0 1) (I L F D)
          required scalar or vector containing the independent variable(s)

    X0    (REQ) (I) (0)   (F D)
          required scalar giving the center of the Gaussian function
          This parameter must have the same units as X.

    DX    (REQ) (I) (0)   (F D)
          required scalar giving the one sigma width of the distribution
          This parameter must have the same units as X.

    YMAX  (REQ) (I) (0)   (F D)
          the Gaussian value at the peak of the distribution
 
    Y     (REQ) (O) (0 1) (F D)
          required output scalar or vector giving the calculated value
          of the gaussian from the expression:
          Y = YMAX * EXP (-0.5 * ((X-X0)/DX)^2)
 
*EXAMPLES:

    To calculate a gaussian with center at 1545 A, sigma of 2 A, using the
    wavelength scale derived from an IUE spectrum, with amplitude 1.0,
 
     GAUSS,WAVE,1545.,2.,1.0,Y

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

     PARCHECK
     PCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

    Values for which (X-X0)/DX > 9 are set to zero.
    If DX = 0, the delta function is returned.

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

    GAUSS is similiar to Bevingtons program PGAUSS (p.45)

*MODIFICATION HISTORY:

    Aug 19 1979  I. Ahmad  initial program
    Jul  7 1984  RWT GSFC  updated documentation
    Sep 25 1984  RWT GSFC  changed limit from 12 sigma to 9 sigma due to
                           problems in WFIT. Also compiles PCHECK.
    Apr 13 1987  RWT GSFC  add PARCHECK
    Aug 19 1987  RWT GSFC  add procedure call listing
    Mar  9 1988  CAG GSFC  add VAX RDAF-style prolog
    Jun 25 1991  PJL GSFC  cleaned up; lowercase; tested on SUN and VAX;
			    updated prolog

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


GAUSSFITS

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

    GAUSSFITS     JUNE,1984
  
*CLASS:
  
*CATEGORY:
  
*PURPOSE:

    To fit Gaussians and a polynomial baseline to data points
  
*CALLING SEQUENCE:

       GAUSSFITS,X,Y,NDEG,NCOMP,A,YFIT,SIG,comment,prnt=prnt
  
*PARAMETERS:

    	X	(REQ) (I) (1) (I L F D)
		Independent variable vector.

    	Y	(REQ) (I) (1) (I L F D)
		Dependent variable vector.

    	NDEG	(REQ) (I) (1) (I)
		Degree of polynomial to be fit to baseline, 0 signifies no 
		fit is to be made to baseline.

    	NCOMP	(REQ) (I) (1) (I)
		Number of Gaussian components.
 
	A	(REQ) (O) (1) (I L F D)
		Vector of function parameters.
                 	A(3I-3) is the center of the Ith Gaussian
                     	A(3I-2) is the 1 sigma width of the Ith Gaussian
                     	A(3I-1) is the height of the Ith Gaussian above
                     	        the baseline
                     	A also stores the parameters of the baseline fit
                     	in the last NDEG+1 elements.

    	YFIT	(REQ) (O) (1) (I L F D)
		Vector of calculated Y values.

    	SIG	(REQ) (O) (1) (I L F D)
		Vector of 1 sigma errors in fitted parameters of Gaussians 
		(ordered like A).

      COMMENT   (OPT) (I) (0) (S)
               Optional input parameter containing a string to print at
               top of plot.

       PRNT    (KEY) (I) 
               If set, Gaussfits will offer option of sending final plot
               to the default printer (as specified in !IUEPRINT). If not
               set, no print option is offered.
  
*INTERACTIVE INPUT:

     	The user specifies the boundary of the feature to be fitted
     	and the approximate location of the Gaussians with the
     	cursor.
       If keyword PRNT is set, user is prompted for whether final plot
       should be sent to the laser printer.
  
*FILES USED:
  
*SYSTEM VARIABLES USED:

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

	PARCHECK
    	BASEREM
    	GAUSS
    	WFIT
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*PROCEDURE:

     	The routine uses BASEREM to fit the baseline with a
     	polynomial or makes no baseline fitting as specified 
     	by the user.  The procedure uses the standard  
     	deviation of a single point in the baseline section of the 
     	data to create an equal-weight vector for all data points.   
     	The user inputs the approximate location and height of each 
     	Gaussian with the cursor.  The procedure uses WFIT to solve for 
     	the center, dispersion, and height of all Gaussian components, 
     	and their 1 sigma errors.  Absolute errors for the Gaussian 
     	parameters are calculated using the 1 sigma errors of a point
     	in the baseline fit. GAUSSFITS outputs a plot showing the data, 
       the individual Gaussian components, the sum of all components, 
       and the deviations. The symbols used are shown below:
          - histogram: vector of data points Y
          - solid line: the total fit (sum of all Gaussians & baseline)
          - dots: individual Gaussian components
          - plus signs: difference between data points and total fit
  
*INF_1:
  
*EXAMPLES:
     Fit 2 Gaussians to features around 2800 angstroms using a first
     order fit to the continuum (after trimming wavelength and flux
     arrays to 2400 to 3100 angstroms):
         TRIM,2400,3100,W,F,E
         GAUSSFITS,W,F,1,2,A,YFIT,SIG
  
*NOTES:
     - The polynomial fit to the baseline is based on ALL the POINTS in the 
       input arrays minus the region spcified by the user. Users may 
       therefore want to TRIM the input X and Y arrays if noise spikes, 
       artifacts, etc. exist that could distort the baseline fit. (See 
       program TRIM).
     - When multiple Gaussians are fit (i.e. NCOMP > 1), the baseline fit 
       excludes points lying between the features.
     - When fitting multiple Gaussians, the user must specify the left most
       edge of the 1st feature, and the right-most edge of the 2nd feature.
     - Input Y array is scaled before baseline and gaussian fitting.
     - Input X and Y arrays should be specified as real numbers 
       (i.e., not integers) to avoid errors in precision.

	tested with IDL Version 2.1.2 (sunos sparc)  	23 Dec 91
	tested with IDL Version 2.1.2 (ultrix mispel)	08 Aug 91
	tested with IDL Version 2.1.2 (vms vax)      	23 Dec 91
  
*MODIFICATION HISTORY:

     	PDP VERSION: I. D. AHMAD
     	VAX mods: R. Thompson & C. Grady
     	June, 1984: N. R. Evans: to correct WFIT calling error,
             	introduce sigma squared weighting, use sigma from 
             	baseline fit to determine absolute errors, correct
             	plotting, and document.
     	7-7-84 RWT modified WT value passed to WFIT, moved YFIT
             	routine to WFIT and updated documentation.
     	9-20-84 RWT deleted unnecessary code, corrected code for extracting
             	feature from input array (i.e. backgnd subtraction) and uses new
             	version of WFIT.
     	4-13-87 RWT VAX mods: add PARCHECK & PLTPARM, remove INSERT, and use
             	SET_XY
     	9-21-87 RWT correct error in DELTAA(IN) calculation
     	10-7-87 CAG rename procedure as GAUSSFITS, and alter order of plotting
             	so that plot autoscales correctly for observed data.
      11-16-87 RWT VAX mods: remove restrictions of baseline
             	polynomial, improve plot annotation, compress code, 
             	use new BASEREM, and change name to GAUSSFITS
       8-24-89 RWT Unix mods: 
       6-25-91 PJL cleaned up; added /down to cursor command; tested on
		    SUN and VAX; updated prolog
       7-30-91 GRA removed unused parameter "0." from the WFIT calling
                   statements.
       8-08-91 GRA added tek branch for prompt strings; added section
                   in final output to limit x axis range; scaled yg
                   vector before calling WFIT; modified BASEREM to
                   scale the ybase 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; prevent PXLIM error
      12-20-91 RWT correct PXLIM estimate, scaling of final plot,
                   and expand documentation.
     23 Feb 93 LLT Remove xrange/yrange keywords from OPLOT commands
                   (not allowed in IDL Version 3).
     11 Oct 93 RWT offer print option and comment line

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


GAUSSPSF

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

*PURPOSE:
	Return a point spread function having Gaussian profiles,
	as either a 1D vector, a 2D image, or 3D volumetric-data.

*CALLING SEQUENCE:
       GAUSSPSF,NPIX,GARRAY,params=gpar, ndim=ndim, fwhm=fwhm,  $
        centroid=cntrd, stdev=stdev, xy_correl=xy_corr, normalize=normalize
 or:
	GAUSSPSF,NPIX,GARRAY,params=gpar

*PARAMETERS:
	npix   (REQ) (I) (012) (BILF)
             number of pixels for each dimension, specify as an array,
	      or just one number to make all sizes equal.

       garray  (REQ) (O) (123) (FD)
             output Gaussian profile as either a 1-, 2- or 3-dimensional
             array

	params   (OPT) (KEY) (2) (BILF)
             a 3 x ndim array giving for each dimension:
             [ maxval, center, stdev ],  overrides other keywords.

	ndim (OPT) (KEY) (0) (BIL)
             dimension of result: 1 (vector), 2 (image), or 3 (volume),
	      default = 2 (an image result).

	fwhm  (OPT) (KEY) (0) (BIL)
             the desired Full-Width Half-Max (pixels) in each dimension,
	      specify as an array, or single number to make all the same.
             (Must be specified if params or stdev is not included.)

	centroid (OPT) (KEY) (0) (BIL)
              pixels numbers of PSF maximum ( 0.5 is center of a pixel ),
	       default is exact center of requested vector/image/volume.

	stdev (OPT) (KEY) (0) (BIL)
              optional way to specify width by standard deviation param.
              Must be specified if params or fwhm is not specified.

	xy_correl (OPT) (KEY) (0) (BIL)
               scalar between 0 and 1 specifying correlation coefficient
		Use this keyword, for example, to specify an elliptical 
		gaussian oriented at an angle to the X,Y axis

	normalize (OPT) (KEY) (0) (BIL)
               causes resulting PSF to be normalized so Total( psf ) = 1.


*EXAMPLE:
	Create a 31 x 31 array containing a normalized centered gaussian 
	with an X FWHM = 4.3 and a Y FWHM = 3.6

	IDL> gausspsf,31,array,fwhm=[4.3,3.6],/normal
  or
       IDL> p = fltarr(3,2)
       IDL> p(0) = [1,15.5,4.3,1,15.5,3.6]
	IDL> gausspsf,31,array,params=p,/normal

*SUBROUTINES USED:
       gauss

*NOTES:
       - Either fwhm or stdev must be specified if params is
       not included.
       - Specifying xy_correl only affects profiles with ndim = 2.
    

*MODIFICATION HISTORY:
       PSF_GAUSSIAN Written by Frank Varosi NASA/GSFC 1991.
       11/30/94 RWT converted to procedure gausspsf, and replaced
                    gaussian function with gauss procedure
       

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


GETBLEMW

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

       GETBLEMW       (RDAF General Production Library)      JAN 30, l983
 
*CLASS:

       Data Editing

*CATEGORY:

*PURPOSE:  

     	Prompts user for wavelength positions of blemishes that are to be
	plotted in the expanded regions when called by BSPOT.
 
*CALLING SEQUENCE:

       GETBLEMW,BSWAVE,NWAVE   
 
*PARAMETERS:

       BSWAVE  (REQ) (O) (1) (I)
               Wavelength of blemish (only 10 max entries allowed).

       NWAVE   (REQ) (O) (0) (I)
               Number of blemishes marked.

*EXAMPLES:

       See BSPOT.PRO

*SYSTEM VARIABLES USED:

        !err

*INTERACTIVE INPUT:

	Prompts user for wavelengths of blemishes
 
*SUBROUTINES CALLED:

	PARCHECK
        
*FILES USED:

*SIDE EFFECTS:

*NOTES:

*PROCEDURE

   	Promts user for wavelengths of blemishes when called from BSPOT and
       returns these wavelengths in the parameter BSWAVE.
 
*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
	jul-22-91 pjl @gsfc cleaned up; added npar equals 0 print and 
			    PARCHECK; tested on SUN and VAX; updated prolog
        6 Apr 94  PJL  update prolog

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


GETIUE

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

   	GETIUE     9 SEPTEMBER 1981
  
*CLASS:
  
*CATEGORY:

	IUESIPS
  
*PURPOSE:

   	Extract data from IUESIPS spectrum format.
  
*CALLING SEQUENCE:

   	GETIUE,IMAGET,TYPE,ORDER,H,WAVE,FLUX,EPS,unit
  
*PARAMETERS:

        IMAGET	(REQ) (I/O) (0) (B I L F D S)
		String = file name containing the data.
               Value  = record length (bytes) of open file (input).
		Record length of file in bytes (output).

        TYPE	(REQ) (I) (0) (B I L F D)
		Type of the flux record desired. For ESLO/MELO files, valid
               values are 1 = Gross, 2 = Background, 3 = Net, 4 = Abscal.
               For high dispersion data, 4 = ripple-corrected net flux 
               and, for data processed at GSFC after 8/30/90 or at VILSPA
               after 12/21/87, 5=abscal data.

        ORDER	(REQ) (I/O) (0) (B I L F D)
		Wavelength or order number (input).
		Order number for the data (output).

        H	(REQ) (O) (1) (I)
		IUESIPS header record (record 0 in file).

        WAVE	(REQ) (O) (1) (F D)
		Wavelength Vector in Angstroms.

        FLUX	(REQ) (O) (1) (F D)
		Scaled flux vector.

        EPS	(REQ) (O) (1) (I L F D)
		Quality vector.
      
        UNIT   (OPT) (I/O) (0) (BIL)
               Logical unit number assigned to input file.
               If UNIT is specified, and IMAGET is not a string parameter,
               GETIUE uses UNIT as the logical unit number and assumes 
               the file is already open. This is useful for multiple reads
               of the same file.

*EXAMPLES:

       order = 1550 & img = 's14071h'    ; Get C IV Ripple Corrected 3 Orders
       getiue,img,4,order,h,w1,f1,e1,un
       getiue,img,4,order-1,h,w2,f2,e2,un
       getiue,img,4,order+1,h,w0,f0,e0,un
	free_lun,un
                
       getiue,'s14586s',1,100,h,w,f,e  ; Center of Line-by-Line
	close,/all

       For multiple orders of high dispersion absolute fluxes:

        	nam = 'swp39095hlg'
        	getiue,nam,5,100,h,w,f,e,un     ; order 100
        	getiue,nam,5,99,h,w1,f1,e1,un   ; order 99
        	getiue,nam,5,98,h,w2,f2,e2,un   ; order 98
        	free_lun,un

*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:

	none
  
*SUBROUTINES CALLED:

	PARCHECK
	PCHECK
    	DECOMPOSE
	CHKFITS
    	TABINV
  
*FILES USED:

       Data is taken from file imaget.DAT when a string is input.
  
*SIDE EFFECTS:
  
	Does not close the file it opened - must be done in the
	calling program (or manually) using the FREE_LUN command.

*RESTRICTIONS:

	Not for used with fits formatted files.
  
*PROCEDURE:

       Imaget is used to open the file or assumes the file is open for
       a non-string input.  The binary header record (record 0) is used
       to derive the record number of the desired order and type of 
       data.  The wavelength and epsilon records are extracted.
       The flux type is extracted and scaled according to the scaling
       factors in the binary header.  All extracted vectors except the
       H vector are timmed to the valid number of data points recorded
       in the binary header.  In addition to the vectors, the imaget
       is returned as the record size in bytes of the file; the order
       number as the order number; and the file is left open to 
       facilitate repeated calls to the procedure without requiring
       repeated OPENs of the file.
  
*I_HELP nn:

*NOTES:

	- The range of valid types is derived from the header record and
	invalid values are limited to the valid range with a warning
	message.  When a wavelength is requested, the record number is 
	determined by looking at the zero point wavelengths stored in 
	the header.  The order number selected is returned.  Any invalid 
	order number is interperted as a wavelength.  Wavelength scaling 
	uses the value in the header record unless that value is zero.  
	In the case of zero, the zero point wavelength is examined. If 
	the zero point wavelength is zero the data is assumed to be LOW 
	dispersion otherwise HIGH dispersion.  Any file having the IUESIPS 
	extracted spectrum format can be accessed with this procedure.  
	The binary header (record 0) is assumed to be integer and have the 
	format defined by IUESIPS and the RDAF documents.  The other records 
	may be byte, integer, or floating as determined by the number of 
	bytes per record and the number of samples per record (H(1)).

       - For recent high dispersion data, the ABSCAL record is all 0's
       for orders outside the wavelength range of the inverse sensitivity
       function. For example, for SWP orders 125 to 112 are 0's.

*MODIFICATION HISTORY:

    F.H.SCHIFFER 3RD  VERSION 1  9 SEP 1981
    Modified GSFC RDAF 19APR85 - to be compatible with XIDL - /ERROR 
    4-24-87 RWT VAX mods: add PARCHECK, & remove INSERT and Extracts
    1-03-89 RWT add procedure call listing
    4-16-91 PJL removed !ERR, passes the unit number to allow the 
	     calling program to close the file
    4-23-91 GRA Added parameters ext and vers to call to decompose
    7-30-91 RWT use version number in file name and remove redundant 
            close and openr commands.
    7-19-93 RWT modify for new high dispersion absolute flux vector and
            update prolog
	16 Nov 93  PJL  added CHKFITS;  correct PARCHECK call

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


GETLIST

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

    GETLIST    (General IDL Library 01)  October 3, 1980

*CLASS:

    i/o

*CATEGORY:

*PURPOSE:

     Procedure to read variables previously written by procedure SAVLIST.

*CALLING SEQUENCE:

     GETLIST,FILNAM,DATA

*PARAMETERS:

     FILNAM  (REQ) (I) (0) (S)
             Required input string containing the name of the .SAV 
             file created by SAVLIST

     DATA    (REQ) (O) (1 2) (B I L F D)
             Required output parameter containing the data stored in
             FILNAM.SAV

*EXAMPLES:

*SYSTEM VARIABLES USED:

    none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    DECOMPOSE
    PARCHECK
    PLATFORM

*FILES USED:

      FILNAM.SAV is read

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

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

*PROCEDURE:

    The presence of the file on disk is verified.
    The initial record of the file is read to determine the 
    number of dimensions in the data stored, as well as the data type.
    The next record is read to find the number of elements in each
    dimension.
    The output variable is defined with appropriate dimension and type,
    and the data are read into it. 

*INF_1:

*MODIFICATION HISTORY:

    Oct  3 1980  D.Lindler  GSFC  initial version
    Mar 10 1988  CAG  GSFC  add VAX RDAF-style prolog, printout of calling 
                            sequence when no parameters are given, and 
                            check for correct number of parameters.
    6-24-88 RWT correct call to PARCHECK and use GET_LUN 
    3-04-91 PJL modified for unix/sun; removed !ERR; replaced FORRD with
		 READU; updated type codes (NTYPE)
    4-09-91 GRA added vms branch and /segmented keyword for file open
                statement.
    6-21-91 PJL cleaned up; tested on SUN and VAX; updated prolog
    8- 7-91 PJL added version number; tested on SUN and VAX; updated prolog
    8 Jun 94  PJL  replace !version with PLATFORM

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


GETNUM

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

    	GETNUM

*CLASS:

	Input/output

*CATEGORY:
 
*PURPOSE:  
	
	Routine to extract numbers from a string with various delimiters
	between the numbers.  The delimiters can be anything and in any
	quantity except plus and minus sign and decimal points (+ - .)'s.
 
*CALLING SEQUENCE:

	PRO GETNUM,INPUT,NUMBERS,CT
 
*PARAMETERS:

	INPUT	(REQ) (I) (0 S)
		The string that is to be searched for numbers.

	NUMBERS	(REQ) (O) (0 F)
		The returned array of numbers that where found in
		the string.

	CT	(OPT) (O) (0 F)
		The count of numbers found in the string.
 
*EXAMPLES: 

	x = ' 12, 34 % 56.9, 23.5'
	GETNUM,x,n,ct
	n will equal [12.0,34.0,56.9,23.5]
	ct will equal 4.0
  
*SYSTEM VARIABLES USED:

*COMMON BLOCKS:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
 
*EMBEDDED SUBROUTINES:

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	Tested with IDL version 3.5.1 (VMS VAX)   1 JUN 1994
	Tested with IDL version 3.5.1 (Sun)   1 JUN 1994
 	
*PROCEDURE:

	Convert the number into a BYTE array.  Replace anything that is
	not a number or a plus or minus sign or decimal point with a blank
	space.  Convert that back to a string and remove excess blanks.
	Convert this to a floating point array.
	
*I_HELP nn:
 
*MODIFICATION HISTORY:

      VERSION 1 Walker  16 JULY 1994

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


GETPRO

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

    	GETPRO   AUG. 28, 1989 
  
*CLASS:

       File copy utility
  
*CATEGORY:
  
*PURPOSE:

       To copy IDL procedure files to the current directory.
  
*CALLING SEQUENCE:

	GETPRO,PROC_NAME,OUT_NAME,LIBRARY
  
*PARAMETERS:

	PROC_NAME	(REQ) (I) (0) (S)
       Procedure name without the .pro suffix.
         
	OUT_NAME	(OPT) (I)
	New name for the procedure without the .pro suffix.
	If not given, PROC_NAME is used.

	LIBRARY		(OPT) (I)
	Specific directory (VMS or UNIX) or text library (VMS only)to search.
	If not given, defaults to directories (VMS and UNIX) and text 
	libraries (VMS only) in !path.
  
*EXAMPLES:

        To copy the procedure "iueplot" to the current directory
   use:
                getpro,'iueplot'

        To copy the procedure "iueplot" to the current directory
   and rename it to "myplot" use:
                getpro,'iueplot','myplot'

        To copy the procedure "myplot" from a specific directory 
   to the current directory use:
   VMS:         getpro,'myplot','','IUE$USER0:[USER#.SUBDIR]'
   UNIX:        getpro,'myplot','','/home/user/subdir'

        To copy the procedure "set_xy" from a specific directory (UNIX)/
   text library (VMS) to the current directory use:
   VMS:         getpro,'set_xy','','@IDL_DIR:[LIB]USERLIB.TLB'
   UNIX:        getpro,'set_xy','','/home/iueidl/lib/userlib'


*SYSTEM VARIABLES USED:

	!path
  
*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

       PARCHECK
	IUEGETTOK
       PLATFORM
       COPUF
  	
*FILES USED:

	LIBEXT.COM  (VMS only)

*SIDE EFFECTS:

	If file already exists,
	for VMS:  the new version will supersede the existing versions(s).
	for UNIX:  the user will be asked if the old version should be 
		   overwritten.
  
*RESTRICTIONS:

	Finds only the first occurrence of the procedure.
  
*NOTES:

       Not ready to be used on Macintosh.

	tested with IDL Version 2.1.0 (sunos sparc)	18 Jun 91
	tested with IDL Version 2.1.0 (vms vax)		N/A	
	tested with IDL Version 2.1.0 (ultrix mipsel)	21 Jun 91

*PROCEDURE:

		If no LIBRARY is specified, GETPRO searches the libraries 
	in the IDL system variable !path for the requested procedure.  
	If the procedure is not found in the directories (UNIX and VMS) or
	text library (VMS only) pointed to by !path, the IUERDAF's experimental
	library is searched.  If the procedure is still not found, the
	IUERDAF's copy of the CURDAF's experimental library is searched.
		If a LIBRARY is specified, only that directory is searched.
		If a text library is specified, only that library is searched.
		If the procedure is found during the search process, 
	the user is notified.  If an OUT_NAME is given, the file will
	be copied to thet name.  Otherwise, the PROC_NAME is used.  
		On VMS systems, the current directory is checked to see 
	if a version of the output name already exists.  If it does, the 
	user is warned that this version will supersede the old version(s).
		On UNIX systems, if the output file name already exists,
	the user is asked if the old version should be overwritten.

*I_HELP nn:
  
*MODIFICATION HISTORY:

    aug. 28, 1989 jtb version 1 for unix/sun idl
    4-10-91 KBC modify filename structure based on operating system type
                for compatibility on SUN/DEC/VAX
    5-23-91 PJL modified and tested VMS and UNIX versions; removed VMS
	         LIBEXT command file and UNIX GETPRO command file - procedure
	         no longer needs any command file; added IUEGETTOK and !path
    6-21-91 PJL added IUERDAF's copy of the CURDAF's experimental library 
		 to the search path; tested on SUN and VAX; updated prolog
    1-21-92 PJL added LIBEXT.COM to allow VMS text libraries to be searched
     9 Apr 92  PJL  added getenv to experimental and curdaf library branches
    14 Jun 94  PJL  replaced !version with PLATFORM and check for libext.com
    30 Aug 94  RWT  allow up to 30 libraries to be searched
    23 Nov 94  LLT  use !iuer and get rid of search of curdaf library
    24 Jan 95  LLT  get rid of one getenv command that was missed in Nov 94.
    23 Mar 95  RWT  use COPUF if icopy = 'na'

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


GETRADEC

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

    	GETRADEC
  
*CLASS:

	Data Manipulation
  
*CATEGORY:
  
*PURPOSE:

    	To extract the RA, DEC, and observation date from IUE disk files.
  
*CALLING SEQUENCE:

    	GETRADEC,IMAGET,RJD,RA,DEC
  
*PARAMETERS:

    	IMAGET	(REQ) (I) (0) (S)
		Standard file identification or file name,
               (e.g., 'SWP12345L')
         
       RJD     (REQ) (O) (0) (F)
               observation date in julian days - 240000.

       RA      (REQ) (O) (0) (F)
               target right ascension in decimal degrees

       DEC     (REQ) (O) (0) (F)
               target declination in decimal degrees

  
*EXAMPLES:

*SYSTEM VARIABLES USED:
  
  	!noprint
  
*INTERACTIVE INPUT:

       User is prompted for missing values of date, RA, or DEC.
  
*SUBROUTINES CALLED:

       IUE_PARSE
       PARCHECK
       PCHECK
       YESNO
       EXPOFIN
  	
*FILES USED:

     	IMAGET.DAT and/or IMAGET.LAB
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

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

       The appropriate values are extracted from the scale factor record.
       If not found, values are extracted from the label.
	If not found, the user is prompted for values.
  
*I_HELP nn:
  
*MODIFICATION HISTORY:

    VERSION 1 BY R. THOMPSON 12/28/89
   25 Jan 1991 Add call to EXPOFIN (llt)
   14 Mar 1991 Convert to sun (llt)
   25 Jul 1991 LLT convert to lowercase, clean up, update prolog, tested on VAX
   26 Jul 1991 PJL tested on SUN; updated prolog
    7 Aug 1991 PJL added version number; tested on SUN and VAX; updated prolog
   30 Sep 1991 RWT correct negative declination error for early IUE images

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


GETSAMP

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

     GETSAMP   (General IDL Library 01)  December 12, 1986

*CLASS:

     unit conversion

*CATEGORY:
 
*PURPOSE:  

     To convert wavelength limits to nearest sample numbers.
 
*CALLING SEQUENCE:

     GETSAMP,WMIN,WMAX,W,SMIN,SMAX
 
*PARAMETERS:

     WMIN  (REQ) (I) (0) (F D)
           Required input scalar containing the starting wavelength in
           the same units as W.

     WMAX  (REQ) (I) (0) (F D)
           Required input scalar containing the ending wavelength in the
           same units as W.

     W     (REQ) (I) (1) (F D)
           Required input wavelength vector.

     SMIN  (REQ) (O) (0) (F D) 
           Required output scalar containing the sample number corresponding
           to WMIN.

     SMAX  (REQ) (O) (0) (F D)
           Required output scalar containing the sample number corresponding
           to WMAX.

*EXAMPLES:

     To calculate the sample value equivalents of 1300 angstroms and 1500
     angstroms from the array W:
        GETSAMP,1300,1500,W,SMIN,SMAX

*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

     PARCHECK
     TABINV
 
*FILES USED:

*SIDE EFFECTS:

     If WMIN and WMAX are beyond the wavelength range of W, they are
     reset to be MIN(W) and MAX(W).

*RESTRICTIONS:

*NOTES:

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

*PROCEDURE:

     GETSAMP compares WMIN and WMAX to the actual min and max values of
     W. If either is out of the range of W it is reassigned as the real
     limit. TABINV is called to calculate the actual indice values.
 
*MODIFICATION HISTORY:

     Sep 23 1984  GAR  GSFC  initial program
     Jan 21 1985  RWT  GSFC  use TABINV for SMIN and SMAX calculation
     Nov 18 1986  RWT  GSFC  add W as an input parameter, and delete
                             opening file internally.
     Apr 13 1987  RWT  GSFC  VAX Mods: add PARCHECK
     Aug 19 1987  RWT  GSFC  add procedure call listing
     Mar 10 1988  CAG  GSFC  add VAX RDAF-style prolog.
     Jun 21 1991  PJL  GSFC  cleaned up; tested on SUN and VAX; 
			      updated prolog

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


GEX1

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

    	GEX1     JANUARY 29, 1985
  
*CLASS:

	Spectral Fitting
  
*CATEGORY:
  
       NEWSIPS/IUESIPS

*PURPOSE:

    	To fit cross-cuts of low dispersion spectra with a Gaussian 
	function in order to determine the width and center positions of a 
	spectral order from an IUE spacially resolved file, as a function of 
	wavelength. GEX1 was intended to be used with procedure GEX2.
       
  
*CALLING SEQUENCE:

    	GEX1,IMAGET,WMIN,WMAX,DELS,WAVE,WIDTH,WCENTER,centord,/silent,/aperture
 
*PARAMETERS:

    	IMAGET	(REQ) (I) (0) (S)
		Spatially resolved ELBL or LBLS file (e.g. 'SWP7654S'),
               or SILO file (e.g. 'swp12345.silo').

    	WMIN	(REQ) (I) (0) (F D)
		Minimum wavelength in angstroms of region to be studied. 

    	WMAX	(REQ) (I) (0) (F D)
		Maximum wavelength in angstroms.

    	DELS	(REQ) (I) (0) (F D)
		Bin size in sample numbers (i.e., number of extracted flux
		points to include in each bin).
 
    	WAVE   	(OPT) (O) (1) (F D)
		Array of wavelengths (from WMIN to WMAX).

    	WIDTH   (OPT) (O) (1) (F D)
		Array of widths of fitted Gaussians.

    	WCENTER	(OPT) (O) (1) (F D)
		Array of center positions of fitted.
               Gaussians in units of pseudo order numbers.

   	CENTORD	(OPT) (I) (0) (I L F D)
		Central order number. If not specified, 28 is used for LBLS
             	and 55 for ELBL files.  Default for SILO files will depend
               on aperture.

       SILENT  (KEY) (I) (0) (ILFDB)
               Keyword to turn on !NOPRINT for duration of the program.

       APERTURE(KEY) (I) (0) (S)
               Keyword to set aperture for NEWSIPS double-aperture images.
               Ignored for single aperture data and IUESIPS files.

*EXAMPLES:

    	To calculate width and center positions of low dispersion 
	spectrum SWP 1234 from 1230 to 1900 angstroms with 10 extracted data 
	points per bin:

              GEX1,'SWP1234S',1230,1900,10,W,WID,WC
  

       Specify central order number, don't return vectors to IDL session,
       and suppress verbiage:

              gex1,'swp12345s',1400,1500,10,/silent
*SYSTEM VARIABLES USED:

	NOPLOT	-   !NOPLOT
	NOPRINT	-   !NOPRINT
   	!x.crange
   	!y.crange
   	!p.ticklen
   	!version.os
   	!d.name
  
*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	DECOMPOSE
    	G1FIT  - fits Gaussian plus linear background to data points.

         G1FIT: G1BCKGND - extracts background segments and uses LINFIT to
                           calculate a linear fit of background flux as a
                           function of pseudo order number.

    	GAUSS
	READFILE
	GETSAMP
	BIMAGE
       readsi
       chkfits
       ifitswrt
       addpar
       iuedaf
       stpar

*FILES USED:
  
       IMAGET          (REQ) (I) (1) (I L F D)        
                Input data file name, to be read using READSPEC.

       cam+image.tab	(REQ) (O) (1) (F)

       FITS format file (binary tables extension) containing fit parameters:

                The rows contain:
               	   1) wavelength (angstroms)
               	   2) center position (order number) 
               	   3) width
               	   4) height (FN) 
               	   5) slope of linear background fit such that
               	      Bckgnd(FN) = y-intercept + slope*order number
               	   6) y-intercept for linear fit to background
               	   7) standard deviation from background fit.


*SIDE EFFECTS:   

	creates a FITS file for use by GEX2.
  
*RESTRICTIONS:   

	modified for unix/sun idl version 1.1
  
*NOTES:

    	1) To display every fifth plot set !NOPLOT = 0, to display diagnostics
    	   set !NOPRINT = 0.
    	2) Output disk file will accept up to 200 entries.
    	3) The bin size for high signal-to-noise images can be as small
    	   as 10 samples. Low signal-to-noise images may require bins
    	   sizes of 20 to 40 samples.
    	4) Execution time (including GEX2) can run about 5 minutes per 
          image.
    	5) Typing GEX1 with no parameters will display the procedure call
    	   statement.

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

       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:

      	Procedure READFILE is used to read the line-by-line file and
    	create a 2-dimensional image array, wavelength array and header.
       (For NEWSIPS data, READSI is used to read in the header and data.)
    	Using the procedure GETSAMP to convert the specified min and max 
    	wavelengths to sample numbers, the image array and wavelength 
    	arrays are truncated accordingly. If the specified min and max
    	values are outside the wavelength range contained in the LBL 
    	(or SILO) file, then new min and max values are calculated. 
    	Procedure BIMAGE then bins the image array data using the value
    	DELS for the bin size. The wavelength array is redefined and
    	corrected. (A wavelength correction is applied for even bin widths
    	since the center of the bins falls between array elements.)
    	  Subroutine G1FIT is called to fit a Gaussian plus a linear
    	baseline to a cross-cut of the image array. G1BCKGND is used to
    	calculate the background fit using points from orders 1-23
    	and 33-55 for LBLS files, or 1-45 and 65-110 for ELBL files.
    	Background points which are more than 2 sigma from the linear
    	fit are excluded. G1FIT goes on to subtract the bckgnd flux
    	from the feature and calculates a net signal level by averaging
    	the net flux in the central 5 orders. This average signal must
    	be greater than half the bckgnd sigma or else zeroes are returned
    	for the Gaussian parameters. Next, G1FIT uses the routine WFIT
    	to fit the Gaussian function to the feature. Data points more
    	than 2 sigma from the Gaussian fit are excluded and the remaining
    	points are re-fitted. If more than half of the data points were
    	discarded then the test above is repeated using larger cutoff
    	values until at least half the points are considered acceptable.
    	  The final set of Gaussian parameters are returned to the main
    	routine where they are stored in a record of the generated disk
    	file.
    	  The above process is then repeated for each bin until the last
    	full bin that is less than WMAX.
         A FITS file is written containing the parameters that will be 
       needed by GEX2.

*I_HELP nn:
  
*MODIFICATION HISTORY:

    	Written by G. REICHERT, M. URRY AND R. THOMPSON 1-29-85
    	3-6-85 RWT replace IUEIM with VSWATH
    	10-18-85 RWT modify for DIDL (use NELEMENTS ,!LO, # and
    	       remove REORDER), and compress code
    	11-26-86 RWT add READFILE, GETSAMP, & BIMAGE, replace COMPOSE with
    	       DECOMPOSE, modify for ELBL files (from JKF) and optimize
    	       code using VAX IDL features.
    	4-13-87 RWT VAX mods: add PARCHECK, remove INSERT and EXTRACTs,
    	       use PLOTS for TKPLOT, and add PLTPARM
    	8-19-87 RWT use !NOPRINT & !NOPLOT, add procedure call listing,
    	       and use GET_LUN
     	9-25-87 RWT plot every other plot (IUE VAX is too fast for terminals)
    	11-30-87 RWT remove compile of PARCHECK and add compile of PLTPARM
    	1-29-88 RWT add CENTORD optional input parameter, remove one pt.
    	  from bckgnd calculation (i.e. Y(XR) and X(XR)) and pass NCEN 
    	  SC, and CENTER parameters to output SAV FILE
    	5-6-88 RWT rename GPLT to GAUSSPLT, 
       9-19-88 RWT add command SET_XY,0,0,0,0 to avoid plot error in GAUSSPLT
         (URP # 302)
       nov-21-89 jtb@gsfc converted to unix/sun idl (and removed gaussplt)
       4-10-91 KBC include branch to open output file using standard record
                   length qualifier if operating system is VAX
       2-Jul-91  LLT update prolog, clean up, tested on VAX
	16- 7-91  PJL tested on SUN and VAX; updated prolog
	19-Feb-91 PJL '.tab' file is written in current directory
       31-Oct-93 LLT NEWSIPS compatibility; write output in FITS file
        7 Nov 93 LLT Fix bug, four plots per page.
       12 Dec 93 LLT Wave, width, wcenter optional.
       16 Dec 93 LLT aperture keyword
       27 Jan 94 LLT correctly label slope and y-intercept
        3 Mar 94 LLT include aperture for iuesips data
        7 Apr 94 llt make sure TAB filename is 8 characters or less,hardcode
                     plot margins.
       26 Apr 94 LLT fix potential problem with aperture keyword
       02 May 94 RWT modify print statements and apert keyword

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


GEX2

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

    	GEX2     APRIL 1, 1985
  
*CLASS:

	Spectral Fitting
  
*CATEGORY:
  
*PURPOSE:

    	To fit cross-cuts of low dispersion spectra with a Gaussian
    	function in which only the height parameter is allowed to 
    	vary. The width and center positions are determined by 
    	interpolation of arrays stored in the disk file CAM+IMAGE.TAB
    	created by the procedure GEX1.PRO.
  
*CALLING SEQUENCE:

    	GEX2,IMAGET,WMIN,WMAX,DELS,w,flux,err,q,/silent,/fwhm,/noplots,$
            outname=outname
  
*PARAMETERS:

    	IMAGET  	(REQ) (I) (0) (S)
			ELBL, LBLS or ESSR file (e.g. 'SWP20706S').
                       Or, for NEWSIPS, SILO file.

    	WMIN		(REQ) (I) (0) (F D)
			Starting wavelength in angstroms.
                       To use value used by GEX1, enter 0.

    	WMAX		(REQ) (I) (0) (F D)
			End wavelength in angstroms.
                       To use value used by GEX1, enter 0.

    	DELS		(REQ) (I) (0) (F D)
			Bin size in sample numbers.

    	WAVE		(OPT) (O) (1) (F D)
			Array of wavelengths.
	
    	FLUX		(OPT) (O) (1) (F D)
			Spectral fluxes determined by integrating over 
			the Gaussian function.

    	ERR		(OPT) (O) (1) (F D)
			Uncertainties in spectral fluxes.

       Q               (OPT) (O) (1) (I)
                       Quality flag vector (flags taken from signal region).
                       For NEWSIPS, "nu" flags are coalesced using logical OR.
                       For IUESIPS, the worst "epsilon" flag is kept.

       SILENT          (key) (i) (0) (bilfd)
                       Turn on !noprint for duration of the program.

       FWHM            (key) (i) (0) (bilfd)
                       If set, only quality flags lying within the FWHM of the
                       gaussian for each bin are considered.  Otherwise all of
                       the flags in the full signal region are included when
                       the Q vector is created.

       NOPLOTS         (key) (i) (0) (bilfd)
                       If set, !NOPLOT=1 for the duration of the program.

       OUTNAME         (key) (o) (0) (s)
                       Returns the name of the output FITS file.  Primarily
                       useful for running in batch.  It cannot be used to
                       set the name of the output file.

*EXAMPLES:

    To fit SWP 20706 spectrum from 1200 to 1900
    angstroms in 1 sample bins (assuming GEX1 was already run):
       GEX2,'SWP20706S',1200,1900,1,W,FLUX,ERR


    Run gex2 with same wavelength range as gex1, don't bother to return
    vectors to IDL session, turn off plotting and verbiage, return the name
    of the output FITS file written:

       gex2,'swp20706s',0,0,1,/noplots,/silent,outname=name

    Run gex2 with same wavelength range as gex1, return vectors to IDL session
    and save only those quality flags that fall within the FWHMs of the 
    gaussians generated:

       gex2,'swp20706s',0,0,1,w,f,err,q,/fwhm

    To run both GEX1 and GEX2 in batch mode (unix version runs in
    background):
       PREGEX,0     (will submit GEX.BAT in batch queue which in turn,
                     executes BGEX.PRO.  unix version runs startgex)

    To run GEX1 and GEX2 in near real-time (unix foreground):
       PREGEX,0     (user is prompted for input parameters)
       vms: BGEX,0       (runs GEX1 and GEX2)
      unix: bgex,' '     (runs gex1 and gex2)
    or
       GEX1,...
       GEX2,...
  
*SYSTEM VARIABLES USED:
  
	NOPLOT	-   !NOPLOT
	NOPRINT	-   !NOPRINT  
   	!d.y_vsize
   	!d.y_ch_size
   	!d.x_ch_size
  
*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	DECOMPOSE
    	WPOLYFIT
	GAUSS
	BIMAGE
	GETSAMP
	READFILE
    	LINTERP
	IUESAVE
    	G2_ARCHECK - checks vectors from IMAGET.SAV file for
    	          bad points and corrects them
    	G2FIT - fits Gaussian and linear baseline to 
    	        vertical swath from LBLS file
       readsi
       iuedaf
       addpar
       ifitsrd
       ifitswrt
       fitslab
       keygen

*FILES USED:

    	IMAGET.DAT/LAB  (req) (i) (1) (i l f d)
                       input line-by-line file
    	cam+is#.TAB     (req) (i) (1) (f)
                       implicit input file from GEX1
       cam+is#.g+ap+f  (req) (o) 
                       Output FITS file of results.  Can be read with IFITSRD.

*SIDE EFFECTS:
  
*RESTRICTIONS:  

	converted to run in unix/sun idl version 1.1
  
*NOTES:

  	To avoid plotting set !NOPLOT = 1 and to suppress printout, set
  	!NOPRINT = 1. This will cut down on execution time.
  	Execution time is about 15 to 40 minutes per image for both GEX1
  	and GEX2 on a vax 780 and about 3 - 5 minutes on a sun 4.
	Users should run GEX2 after each GEX1.
  	GEX1 and GEX2 can be run on up to 10 images at once using the 
	procedures PREGEX.PRO and BGEX.PRO.

       Since the Data Analysis Center's software is to be converted to
       run under DOS, and since DOS has strict limits on the length of
       filenames, it was decided to make the output of GEX conform to a
       new convention.  It was decided that the name should begin with
       the camera name and image sequence number (spelled out as they are
       for NEWSIPS data products, e.g., SWP12345), and that the extension
       should be a three character code describing (1) what data product
       the file contains, (2) what aperture was used, and (3) what format
       the file is in.  For GEX the first character will be G (data is the
       output of the GEX programs), and the third will be F (FITS format).
       The second is a number:  1 for large aperture, 2 for small aperture,
       0 if the aperture is undetermined (0 is not what one would normally
       see from Gex; if it occurs something strange happened).  The filename
       used is returned if the keyword OUT is used.

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

       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:

    	  The line-by-line file is read into memory using READFILE or READSI. 
    	GEX2 reads in the arrays from the disk file created by GEX1.
	The wavelength limits are converted to sample values using GETSAMP. 
	These values are then used to truncate the wavelength vector and 
	image array. BIMAGE is called to bin image array.
    	Subroutine G2_ARCHECK is used to evaluate the GEX1 calculated 
	parameters and discard bad entries. All entries with widths > 3.0*SC 
	are removed and center values more than + or - SC orders from the 
	central order are forced to those limiting values, where SC=1 for 
	LBLS files and 2 for ELBL and SILO type files (e.g., for an ELBL 
	file values below 54 are set to 54 and values above 58 are set to 58.)
    	A 2nd-order polynomial is fit to the width vector as a function of
    	wavelength. The center positions and background levels are 
	interpolated using the corrected set of values from GEX1. Rows of 
	the image array are fitted with a Gaussian plus linear background 
	with the Gaussian height as the only variable for the Gaussian fit. 
	More than half of the points must be less then N sigma or the test 
	is repeated for N+1 sigma The Gaussian is then refitted with the 
	acceptable points. The flux is calculated from integrating over the 
	fitted Gaussian. The error calculated is the uncertainty in the flux 
	calculation based on the error in calculating the height of the 
	Gaussian.  Results are written to a FITS file called IMAGET.GEX2 
       using IFITSWRT.  For SILO files the original SILO header is preserved
       (with additions); for ELBL and LBLS files a header is created using
       KEYGEN and FITSLAB.  The E vector represents the uncertainty in the
  	calculated flux value.  The Q vector is created from the epsilons
       (IUESIPS) or the nu flags (NEWSIPS).  
  
*I_HELP nn:
  
*MODIFICATION HISTORY:

   programmers: G. REICHERT, M. URRY AND R. THOMPSON
   11-21-86 RWT VAX mods: add READFILE, BIMAGE, GETSAMP, use vector 
       subscripts in assignment statements & optimize code
    4-13-87 RWT add PARCHECK and PLTPARM, remove INSERT and EXTRACTs,
       and use PLOTS for TKPLOT
    8-19-87 RWT use GET_LUN, add procedure call listing when no
       parameters are specified, and replace !LO with !NOPRINT & !NOPLOT.
    9-25-87 RWT plot every other plot if !NOPLOT = 0
   10-12-87 RWT replace GRVSAVE with new IUESAVE
   11-17-87 RWT change max. allowed width to 3.0*SC rather than 3.0.
    2-1-88 RWT read SC, CENTER and NCEN values from IMAGET.TAB file
       to allow CENTORD option in GEX1
    2-23-88 RWT make subroutines separate procedures
    5-6-88 RWT rename GPLT to GAUSSPLT
    6-14-88 RWT add .TAB extension to file name before calling G2_RDSAV
    6-15-88 RWT printout and save proper center position 
    9-19-88 RWT (URP #302) add SET_XY,0,0,0,0 to avoid plot error in GAUSSPLT
    dec-5-1989 jtb converted to unix/sun idl
    8 July 1991 llt clean up, update prolog, tested on VAX
    16- 7-91    PJL tested on SUN and VAX; updated prolog
    16 Dec 1993 LLT NEWSIPS compatibility, output FITS file, four plots
                    per page, /silent keyword, annotation changes, make
                    output parameters optional, use wmin/wmax from gex1
                    if desired.
    24 Jan 1994 LLT Add VICAR label to final FITS header (IUESIPS)
    28 Jan 1994 LLT Add Q, FWHM keyword, and code dealing with quality flags.
    31 Jan 1994 LLT Add NOPLOTS keyword, add ITF flag to header (IUESIPS)
     6 Mar 1994 LLT Change Q-flag comment to reflect lines used.
     7 Apr 1994 LLT Add SIPS keyword to IUEDAC section of header, change 
                    output file name (DOS filename length limits), hardcode
                    plot margins.
     2 May 1994 RWT make keywords 8 characters long, modify print 
                    statements, make extfile keyword uppercase, and delete 
                    adding of ITFFLAG to FITS header
     3 May 1994 LLT delete several keywords from SILO header, make sure
                    wavelengths are floating point, output file name lowercase.

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


GEXCAL

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

    	GEXCAL     2 OCTOBER 1987
  
*CLASS:

	Spectral Calibration
  
*CATEGORY:
  
*PURPOSE:

    	To calibrate low dispersion spectral data extracted using
    	the IUEDAC GEX routines with optional corrections for THDA
    	sensitivity variation and sensitivity degradation. 
  
*CALLING SEQUENCE:

       GEXCAL,IMAGET,hd,wave,flux,ecor,q,file=file,/noplots,row=row,$
               exps=exps,center=center,thda=thda
  
*PARAMETERS:

   	IMAGET	(REQ) (I) (0) (S)
		Disk file name for FITS file created by GEX2 or MGEX
             	containing low-dispersion spectral data (character string).

       HD      (OPT) (O) (1) (S)
               FITS header.

	WAVE	(OPT) (O) (1) (F D)
		Wavelength vector (Angstroms).

	FLUX	(OPT) (O) (1,2) (F D)
		Absolute flux vector (ergs/sec/cm2/A).  If the input data
               were processed with MGEX this may be a two dimensional array.

	ECOR	(OPT) (O) (1,2) (I)
		Corrected Error vector.  If the input data were processed with
               MGEX this may be a two dimensional array.

          Q    (OPT) (o) (1,2) (i)
               Quality flags from GEX2.  If the input data were processed with
               MGEX this may be a two dimensional array.

       FILE    (KEY) (I) (0) (IS)
               If set, output are written to a new FITS file.  Can be set
               to a file name; otherwise IMAGET is used.  The net fluxes 
               from GEX2 are included in the output file.  Non-VMS users
               may wish to explicitly include a filename different from that
               of the input file, to avoid destroying the original!  In VMS
               the original will be intact and a new version written.  Note
               that the output file is written in the current directory,
               regardless of where the input file resides.

       NOPLOTS (KEY) (I) (0) (I)
               If set, GEXCAL will not plot the results.

       ROW     (key) (i) (0) (i)
               Row number to read with FITS file.  Normally, data processed
               with GEX have one spectrum contained only in row 1 of the
               output FITS file.  However, data processed with MGEX will have
               multiple spectra, each in a separate row of the FITS file.
               The default is to calibrate all existing rows.  
               
       EXPS    (key) (i) (0,1) (f)
               Exposure time(s), in seconds, for each spectrum.

       CENTER  (key) (o) (0,1) (f)
               Central line numbers of extracted spectra, returned to user.

       THDA    (key) (i) (0) (if)
               THDA value to use (IUESIPS).  If 1, value in header is used.
               If -1, no THDA correction will be applied.  Otherwise, THDA
               is assumed to be the temperature to use.  If this keyword is
               not set, and no THDA value is found in the header, the user
               will be prompted for it.

*EXAMPLES:

    	To calibrate fluxes for SWP03373.G1F without writing results to a file
       but extracting them in vectors for use in one's IDL session
    	(after running GEX routines):
 
 	     GEXCAL,'SWP03373.G1F',h,w,f,err,q

       To calibrate the fluxes and write the results to a new file:

            gexcal,'swp03373.g1f',h,w,f,err,q,file='new.fit'

       To calibrate the fluxes and overwrite the file SWP03373.GEX2:

            gexcal,'swp03373.g1f',h,w,f,err,q,/file
  
       To read a file that has already been processed with GEXCAL (where
       the results were written to the .G1F file as in the last example):

            gexcal,'swp03373.g1f',h,w,f,err,q

       Note that the program will complain that the file has already been
       processed and that no further processing will be done---although no
       processing, plotting, or writing will be done, the data will be 
       retrieved.  Thus, GEXCAL is a reader for the output of GEXCAL.

*SYSTEM VARIABLES USED:
  
       !x.range  - set to [0,0] and reset after plot
       !y.range  -   "      "      "         "
  
*INTERACTIVE INPUT:

    	1)  Exposure time (in minutes,sec,ms), if the FITS header
    	    does not already contain these quantities.
    	    If the user types in zeros, then the net flux
    	    in IUE units is returned. Values may be integer or real
    	    but the total time must be less than 32767 minutes.
    	2)  Correction for THDA sensitivity variation, if THDA 
    	    is not found in the FITS header 
    	3)  Correction for sensitivity degradation, if observation date
    	    is not found in header.
  
*SUBROUTINES CALLED:

    	CALIB         Calibrates IUESIPS data
    	SDC           Sets flag for IUESIPS LWR degradation correction.
    	TEMPCOR       Corrects IUESIPS data for THDA variations.
    	INTIME        Prompts user for exposure time (IUESIPS, single spectrum)
       PARCHECK      Checks that the proper number of parameters was entered
       PCHECK        Checks data type of input parameters
       DECOMPOSE     Used to separate extension from filename
  	chkfits       Checks that the input file is in FITS format.
       nsplot        Plots data with errors and quality flags
       stpar         Extracts values from FITS header
       ifitsrd       Reads input FITS file
       ifitswrt      Writes output FITS file
       iuefhrd       Reads header of input FITS file
       addpar        Adds keywords/comments to FITS header
       newcalib      Calibrates NEWSIPS data

*FILES USED:

       1) The input FITS file created by GEX2 or MGEX.
    	2) The file, !iuer.dat: IUECAL.FIT, containing the calibration tables
	   used to convert fluxes from IUE units to absolute units, must be
	   resident on the system disk.  This file contains the data for the
	   LWP, SWP and LWR cameras. See !iuer.inf: CALIB.INF for documentation
    	   on the current inverse sensitivity functions.
    	4) If the LWR sensitivity degradation correction is requested, the
	   file !iuer.dat: DEGRAD.FIT must exist. (See documentation in
	   !iuer.inf: DEGRAD.INF.)
       5) If requested, an output file name can be designated.  The user may
          either overwrite the input file (from GEX2), or write the results
          to a new FITS file.

*SIDE EFFECTS:

       On operating systems without version numbers (e.g., UNIX), it is 
       easy to destroy the input file if /file is set, or if file=name
       and a file called name exists already.  Users on these systems 
       should choose a different filename if they do not wish to overwrite
       their input file.

*RESTRICTIONS:

       modified for unix/sun idl
  
*NOTES:

    	OUTPUT PLOTS:
         wavelength vs absolute flux is overplotted with
         dots designating flux +/- flux uncertainty.
       The flux uncertainties labelled ECOR, are stored as absolute
          values (i.e. ECOR = ABS(ECOR)).
       This program cannot perform calibration on any file that has already
          been processed with GEXCAL.  If the GEXCAL comment is found in the
          FITS header, the calibrated data will be extracted and returned to
          the user (if the user included the optional vector parameters).

  	Note:  Data processed with MGEX contain multiple spectra, each stored
          in a separate row of the output FITS file.  GEXCAL will calibrate
          all the spectra unless specific rows are entered via the ROW 
          keyword.  Users should realize that the flux, quality flag, and
          error arrays returned by GEXCAL (via the calling sequence) will be
          two dimensional arrays in such cases.
       
*PROCEDURE:

       The FITS header is read with IUEFHRD.  The value of NAXIS2 is checked
       to see how many rows of data exist in the file.  Then all rows (or
       only those specified via the ROW keyword) are read with IFITSRD.  Then,
       check for a comment in the header to the effect that GEXCAL has already
       been run on this data.  If so, simply return the vectors to the user.
       
       If GEXCAL has not yet been run, proceed.  Extract the CENTER value(s)
       from the header.  Then determine the aperture.  Use the FILENAME 
       keyword in the header to distinguish between NEWSIPS- and IUESIPS-
       generated original data (i.e., FILENAME will be a SILO file if NEWSIPS).
       If IUESIPS, construct a "scale factor record" for use with CALIB etc.
       Next, get the exposure time(s) if not entered via the EXPS keyword.
       For single spectra, INTIME is used and the user may enter the time in
       minutes, seconds, and milliseconds.  Otherwise, the times must be 
       entered in seconds.   Then, get the observation date, and THDA at time
       of read.  For IUESIPS data the user may choose not to correct for the
       THDA variations, or to enter a THDA value other than that at read, if
       the THDA is not found in the header or THDA keyword.  Also for IUESIPS
       SDC is called to see whether the user wants to correct for sensitivity
       degradation.   Set up plotting parameters and determine output file
       name if needed.

       For each row,  calibrate and correct both the fluxes and the errors
       with NEWCALIB (NEWSIPS) or CALIB and TEMPCOR (IUESIPS), and then plot
       the results with NSPLOT.  If there are more than one spectrum, pause
       until the user hits return so that the plot will not immediately 
       be overwritten.  Then, if the user wanted the data written to a FITS
       file, use IFITSWRT to do so.  After all rows are processed, reset the
       plotting parameters and return.
  
*I_HELP nn:
  
*MODIFICATION HISTORY:

      Written by R. THOMPSON (based on IUELO by Sally Heap)
      8-12-87 RWT add 0 parameter case and change compiles of 
        implemented procedures
      10-2-87 RWT fix error in label file name and display label
         when exposure times are not contained in header
       9-3-88 RWT set H(2)=1 (# of orders) so CALIB applies LWR
         sens. degradation correction. Reset value after CALIB is
         executed.
      dec-08-1989 jtb@gsfc modifications for unix/sun idl
       7-20-90 RWT calibrate Gaussian unvertainty as suggested by CMU,
         overplot uncertainties, do not create SAV file (leave as
         option for user), and check for existence of label file
         before calling LABEL.
       8 July 1991  LLT clean up, update prolog, tested on VAX
	16 Jul 1991  PJL tested on SUN and VAX; updated prolog
       02 Dec 1991  GRA removed references to old environment
                        variables from prolog.
	 8 Nov 1993  PJL  update prolog references to files in IUER_DAT
       21 Dec 1993  RWT modify to handle NEWSIPS data or IUESIPS data
                        in FITS format, and apply all corrections unless
                        information is missing from header.
       31 Jan 1994  LLT Further modifications to deal with IUESIPS data
                        (H vector with necessary entries inc. ITF flag,
                        find keywords with KEYGEN-given names which differ
                        from the usuals from NEWSIPS---THDA-SPE and DATE-OBS),
                        I/O mods (deal with GEX2 file properly, write out
                        results if requested via FILE keyword, show user
                        selected portions of VICAR label instead of entire
                        FITS header.
        3 Feb 1994  LLT Fix call to NSPLOT.  Output FITS header.
        8 Feb 1994  LLT Add NOPLOTS keyword to suppress plotting.
        5 Mar 1994  LLT Include aperture in IUESIPS plot annotation.
       12 Mar 1994  LLT Add Q to parameter list, check to see if GEXCAL
                        has already been run (and return data if so), edit 
                        prolog, fix "noplots" keyword.
       29 Apr 1994  LLT THDAFLAG & LWRFLAG keywords used to set H([68,69])
                        for IUESIPS data, test for !noplot, preserve VICAR
                        label in FITS header.
       06 May 1994  RWT convert camera name to number (as changed in keygen)
       10 May 1994  LLT fix plotting problem, write net flux to last field
                        of output FITS file.
       18 May 1994  LLT update prolog
       16 Dec 1994  LLT Loop through rows (to accomodate MGEX).  Remove LTI
                        and IUEPLOT. Add ROW, EXPS, CENTER, and THDA keywords.

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


GFILTER

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

    GFILTER   

*CLASS:

    numerical function

*CATEGORY:

*PURPOSE:  

    To convolve a 1- or 2-dimensional gaussian point spread function
    with the specified input array.
 
*CALLING SEQUENCE: 

    GFILTER,Y,NPT,SIG,NEWY
 
*PARAMETERS:

    Y     (REQ) (I) (12) (BILFD)
          Required input vector or array  (e.g., flux vector or image)

    NPT   (REQ) (I) (0)   (F D)
          Required scalar giving the number of data points to be included
          in the Gaussian filter. Even values are converted to the next
          lowest odd number.

    SIG   (REQ) (I) (01) (F D)
          Width of Gaussian (i.e., standard deviation) in units of X
          For a 2-dimensional Gaussian with a non-symmetrical profile, 
          specify both an x & y value as a 2-element vector.

    NEWY  (REQ) (O) (12) (F D)
          Filtered Y vector or array.
 
*EXAMPLES:

    Apply a 9-point Gaussian filter with a sigma of 2.0 to Y:
          gfilter,y,9,2.0,newy

    Apply a 7x7 Gaussian with a x-sigma of 3.0 and a y-sigma of 2.5
    to array IMAGE:
          gfilter,image,7,[3.0,2.5],nimage


*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

     PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

    - The first and last (npt-1)/2 data points are not changed.
    - Even values for NPT are converted to odd numbers by
      subtracting 1.

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

*MODIFICATION HISTORY:

    Based on GAUSSFILTER by WSPOCK
    Oct 19 1994  RWT GSFC  modify to use variables as input
    Nov 30 1994  RWT GSFC  add support for 2-D arrays and use
                           gausspsf to derive gaussian profile

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


GOCOPY

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

    GOCOPY     (General IDL Library 01) 22-FEB-81

*CLASS:

    i/o

*CATEGORY:
     
*PURPOSE:  

    To copy one file from an input tape to an IUE GO-format disk file.
 
*CALLING SEQUENCE:    

    GOCOPY,IN,IMAGET,FNAME,NBYTES,NLINES
 
*PARAMETERS: 

    IN        (REQ) (I) (0) (S)
              Input device file name

    IMAGET    (REQ) (I) (0) (S)
              File name to be copied.

    FNAME     (OPT) (O) (0) (S)
              Name of generated disk file.

    NBYTES    (OPT) (I)
	       Maximum number of bytes per data record.  
              Required on VMS systems.

    NLINES    (OPT) (I)
	       Number of data lines (records) to be read in IUE file.  
              Required on VMS systems.

*EXAMPLES:

    GOCOPY,'nrmt0','lwp15357l'
             'nrmt0' = input unit
             'lwp15357l' = file name

*SYSTEM VARIABLES USED:

    !err

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    PARCHECK
    PLATFORM
 
*FILES USED:

    The file corresponding to unit IN is copied to disk with the
    extension .go. The file is copied into the user's current
    default directory.

*SIDE EFFECTS:

*RESTRICTIONS:

    Device Dependent - tape drive(s) must be available. 

*NOTES:

    The input tape should be at the beginning of the file to be copied, 
    and will be left after the EOF defining the file.

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

    On UNIX systems, GOCOPY copies the input file to disk using the 
    UNIX command dd.
 
*MODIFICATION HISTORY:

    Dec 13, 1989 RWT based on filecopy.pro
       4-10-91 KBC modify spawn to copy file to disk based on 
                   operating system type
	5- 7-91 PJL modified to allow go tape file to be copied onto
		disk as a go file on VMS systems - involved adding NBYTES
		and NLINES to calling sequence;  tested
       8 14 91 GRA cleaned up; used new IUER_USERDATA syntax; tested on
                   SUN, VAX
       8 22 91 GRA tested on SUN (SCSI 9-track), VAX (Q-bus 9-track)
       9 11 91 GRA added section to determine input tape type from
                   the mt status command on unix systems. This
                   information is used to control program branching
                   for the unix dd command. tested on VAX and SUN
                   systems; updated prolog.
       10/4/91 GRA defined sys = !version.os for system dependent branches.
     22 Nov 91 GRA removed IUER_USERDATA logical; updated prolog; tested.
     20 Jan 92 PJL block's size must be at least 360
     10 Jun 94  PJL  replaced !version with PLATFORM
     20 Oct 94  PJL  added code for tapectrl.device equal 'NA'

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


GOTORDAF

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

	GOTORDAF
 
*CLASS:

*CATEGORY:

	IUESIPS

*PURPOSE:  

	To convert IUE GO-format (IUESIPS) disk files to RDAF-format disk
	files which have truncated data records (i.e. 2000 byte rather than
	2048 byte records).
 
*CALLING SEQUENCE:

	GOTORDAF,IMAGET
 
*PARAMETERS: 

	IMAGET  (I) (REQ) (S) (0)
		Input file in GO-format. Wildcards are allowed, otherwise
		full file name must be specified.

*EXAMPLES:

	(1) Convert all MELO files 

		IDL>gotordaf,'*.melo*'
  
	(2) Convert all SWP files (assumes all SWP* files in current directory
	    are in GO-format).

		IDL>gotordaf,'swp*.*'

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK
	IDFILE  
	DATAREC   
	VICAR     
	PLATFORM

*FILES USED: 

	Two disk files (.LAB & .DAT) are written for each file input.
	(see [IUERDAF.MANUALS]IUECOPY.TXT for description of output files).
 
*SIDE EFFECTS:

*RESTRICTIONS:

	Only for use with IUESIPS files.

*NOTES:    

	Users should be careful using wildcards since files may be selected
	which are not in the expected GO-format.

	Program assumes VMS GO files include variable-length record
	information when it determines whether truncated records may be
	present (see DATAREC).

*PROCEDURE: 

	Users account is searched for the desired image(s) using FINDFILE.  
	Each image in string array is then converted to RDAF .DAT and .LAB 
	files.
 
*MODIFICATION HISTORY:

        8-16-91 rwt (based on SIPSCOPY)
        8-27-91 rwt remove unnecessary input parameters
        4-29-92 rwt modify for version 2 & truncated records
        5-01-92 rwt replace itfflag, reniue, labgen, and datgen
                subroutines with vicar and datarec
        6-09-92 rwt correct error in offset for non-vms systems.
        9-29-92 rwt make vicar and datarec separate routines
	22 Nov 93  PJL  updated documentation; lowercase
        7 Jun 94  PJL  replaced !version.os with PLATFORM
       11 Oct 94  PJL  added code for quota = 'NA'

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


GRIDTERP

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

    GRIDTERP     (General IDL Library 01) 13 March, 1983   

*CLASS:

    interpolation

*CATEGORY:

*PURPOSE:

    This is a linear interpolation procedure to operate properly on IUE
    data.  The flux, gross, and back vectors are interpolated, but the eps 
    vector is set to the minimum of the two relevant values.
    This routine will work fast !  You can interpolate to a 3000 point
    grid in about 13 seconds when all 5 output vectors are desired, faster
    if you only care about flux and eps.
 
*CALLING SEQUENCE:

    GRIDTERP,WGRID,WAVE,FLUX,EPS,GROSS,BACK
 
*PARAMETERS:

    WGRID  (REQ) (I) (1) (F D)
           Required input vector containing the wavelength grid the 
           spectral data are to be interpolated to.
           This vector must be strictly increasing.

    WAVE   (REQ) (I/O) (1) (F D)
           Required input vector containing the wavelength data of the
           spectrum which is to be interpolated. This vector must be
           strictly increasing.

    FLUX   (REQ) (I/O) (1) (F D)
           Required input vector containing the flux data of the spectrum
           which is to be interpolated.
           
    EPS    (REQ) (I/O) (1) (I L F D)
           Required input/output vector containing the data quality flags

    GROSS  (REQ) (I/O) (1) (I L F D)
           Required input/output vector containing the gross spectrum

    BACK   (REQ) (I/O) (1) (I L F D)
           Required input/output vector containing the spectral background.

*EXAMPLES:

    To interpolate an IUE spectrum onto a new grid,
    IUEHI,imaget,order,H,WAVE,FLUX,EPS
    GRIDTERP,WGRID,WAVE,FLUX,EPS,G,B  (G AND B ARE DUMMY PARAMS)
   
*SYSTEM VARIABLES USED:

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    PARCHECK
 
*FILES USED:

*SIDE EFFECTS:

    The original (uninterpolated) vectors are destroyed.

*RESTRICTIONS:

*NOTES:

            If you don't have or desire to interpolate one of the input
            parameters, simply enter an undefined dummy parameter in its
            place and the procedure will ingnore that parameter.  For
            example say you don't have the gross or background.  In that
            case just type GRIDTERP,WGRID,WAVE,FLUX,EPS,DUMMY,DUMMY and
            only the flux and eps will be done.

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

*PROCEDURE:

            WAVE,FLUX,GROSS, and BACK are linearly interpolated onto the
            new WGRID.
 
            The EPS vector is not linearly interpolated, rather each
            the value assigned to each grid point is the minimum of the
            eps values on either side of that point.


*MODIFICATION HISTORY:

     1982          G. Seab   CU      initial program
     Mar. 13, 1983  Derryl Eckt       implemented at CURDAF
     Oct. 23, 1985  JKF  GSFC  DIDL compatible..replaced REORDER
           with vector subscripting
     Aug  11, 1986  RWT  GSFC  use NELEMENTS, and change GE to GT
           in line 39 (SMR #123)
     Feb. 18, 1987  RWT  GSFC  VAX Mods: N_ELEMENTS for NELEMENTS, account
           references, total 1st 2 elements of SIZE rather than full array
     Apr. 13, 1987  RWT  GSFC  VAX Mods: add PARCHECK and remove INSERTS
     Mar. 21, 1988  CAG  GSFC  VAX RDAF-style prolog
     Jan. 03, 1990  RWT  GSFC  UNIX mods: use lower-case, use vector
           subscripts to correct error in zeroing out-of-range values,
           and modify where commands
     Jun. 21, 1991  PJL  GSFC  cleaned up; tested on SUN and VAX; 
				updated prolog

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


GWREAD

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

	GWREAD     (General IDL Library 01) OCTOBER 27, 1986
 
*PURPOSE:  

	To set file protection for input file back to the default setting.
	This allows owner all privileges, group members execute (VMS only)
	and read privileges, and others/world read privilege only.
 
*CALLING SEQUENCE: 

	GWREAD,FILEN
 
*PARAMETERS: 

	FILEN   (REQ) (I) (0) (S)
		Required input string scalar giving the file which is to have
		its protection modified. Wild cards can be used.

*EXAMPLES:

	To set myfile.pro to default protection setting:
		gwread,'myfile.pro'

	To change all versions of myfile.pro (VMS):
		gwread,'myfile.pro;*'

	To change all SWP files (VMS):
		gwread,'swp*.*;*'

	To change all SWP files (non-VMS):
		gwread,'swp*'

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	DECOMPOSE
	PARCHECK
	PLATFORM

*FILES USED:

	All files matching FILEN have protection modified.

*SIDE EFFECTS:

*RESTRICTIONS:

	Only files in the user's own disk area can be specified.

*NOTES:

	1) Only files on the users disk can be specified.
	2) See NOREAD.PRO for removing file access to group and other members.

*PROCEDURE: 

	Unix and Ultrix operating systems:

		GWREAD uses DECOMPOSE to restrict input files to those existing
		in the users account.  'chmod' is used to add read and write
		privileges for group members, and read privileges for others.
		The final protection settings are displayed using 'ls -la'.

	VMS operating systems:

		'set protection=(S:RWED,O:RWED,G:RE,W:R)' is used to set file 
		privileges to default values.  'directory/security' is then 
		called to display the new settings.

*MODIFICATION HISTORY:

	Oct 27, 1986  RWT  GSFC initial program
	Mar 10, 1988  CAG  GSFC add VAX RDAF-style prolog, printing 
				calling sequence if parameter omitted, and 
				check for correct number of parameters.
	Mar  4, 1991  PJL  GSFC modified for unix/sun
	Apr 03, 1991  GRA  CASA added section to modify protections for the
				VMS operating system.
	Jun 21, 1991  PJL  GSFC cleaned up; tested on SUN and VAX; updated
				prolog
	Aug  7, 1991  PJL  added version number; tested on SUN and VAX; 
			   updated prolog
	Oct 11, 1991  PJL  removed group write permission and world/other
			   execute permission
	22 Oct 93  PJL  updated prolog
	 7 Jun 94  PJL  replaced !version.os with PLATFORM
       11 Oct 94  PJL  added code for security.unset and dirlis.cmd equal 'NA'

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


HDUGEN

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

  	HDUGEN            2/11/92
  
*CLASS:

	File Conversion 
  
*CATEGORY:
  
*PURPOSE:

       Creates a FITS header and data unit (hdu) containing the
       specified input HEADER and FIMAGE array, and stores it in a
       FITS file called HDU.FIT. An optional keyword can be used to
       change the output file name.
  
*CALLING SEQUENCE:

  	HDUGEN,HEADER,FIMAGE,fname=nam
  
*PARAMETERS:

       HEADER  (REQ) (I) (1) (S)
               FITS header input as a string array.

       FIMAGE  (REQ) (I) (2) (I)
               array to be included in image extension. 

       fname=nam (OPT) (KEY) (0) (S)
               keyword for changing output file name. Extension
               should be included.

*SYSTEM VARIABLES USED:
  
       none

*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:

    	PARCHECK
	PCHECK
       IUEFHMOD
	PLATFORM
  
*FILES USED:
  
        HDU.FIT or FNAME - output fits file 
  
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*PROCEDURE:

       Opens fname and adds header then data.
  
*I_HELP nn:
  
*EXAMPLES:
  
*NOTES:
        
	tested with IDL Version 2.1.2 (sunos sparc)    
	tested with IDL Version 2.1.2 (vax vms)        28 Dec 92 (rwt)
       tested with IDL Version 2.1.2 (ultrix mipsel)  
       tested with IDL Version 2.2.0 (ultrix vax)     

*MODIFICATION HISTORY:

      	Written by R. Thompson 3/4/92 (based on IMXGEN)
       06-23-92 rwt allow any data type
	24 Feb 93  PJL  added version.os branch to handle Version 3 UNIX/Ultrix
			problem with the /none keyword
       17 Feb 94  RWT  correct error when header string array 
                       has (36*n + 1) elements.
       24 Feb 94 RWT   correct error when header string array
                       has 36*n elements.
        8 Jun 94  PJL  replaced !version with PLATFORM

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


HEXTODEC

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

       HEXTODEC

*CLASS:

*CATEGORY:

*PURPOSE:

       Converts hexadecimal string to an integer (decimal) vector.

*CALLING SEQUENCE:

       HEXTODEC,INSTR,OUTVEC,DIGITS

*PARAMETERS:

       INSTR   (REQ) (I) (0) S)
               A string containing the hexadecimal number(s).

       OUTVEC  (REQ) (O) (1) (L)
               The vector of decimal values.

       DIGITS  (REQ) (I) (0) (I)
               The number of digits in each hexadecimal value.

*EXAMPLES:

      instr = '20304FB7'
      hextodec,instr,outvec,2
      print,outvec
                32          48          79         183

*SYSTEM VARIABLES USED:

       none

*INTERACTIVE INPUT:

       none

*SUBROUTINES CALLED:

       PARCHECK

*FILES USED:

       none

*SIDE EFFECTS:

       none

*RESTRICTIONS:

       Each hexadecimal number must have the same number of digits.

*NOTES:

*PROCEDURE:

       The length of the string is divided by the digits per hexadecimal
       number to determine the number of elements for the outvec parameter.
       If the string length in not evenly divisible by the number of digits,
       the procedure returns.

       Each character in the input string is placed into a element of the
       working array (workarr).  The 'A', 'B', 'C', 'D', 'E', and 'F' values
       are replaced in the working array by the decimal value (10 through 15).

       The decimal value on each hexadecimal number is calculated.

*I_HELP  nn:

*MODIFICATION HISTORY:

       16 Feb 94  PJL  wrote
	18 Feb 94  PJL  added ' ' or '' part

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


HFIX

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

       HFIX     AUGUST 29,1986
  
*CLASS:

       Utility, Data correction, reprocessing, and calibration.
  
*CATEGORY:

	IUESIPS
  
*PURPOSE:

       Allows user to add the ITF flag, exposure time, THDA sensitivity 
       correction flag, and LWR sensitivity degradation correction flag to
       header record of IUE data files.
  
*CALLING SEQUENCE:

       HFIX,IMAGET,err
  
*PARAMETERS:

       IMAGET  (REQ) (I) (0,1) (S)
               This can either be an argument for FINDFILE or an array of
               filenames.  Images must be in RDAF format, and they must have
               the standard .DAT and .LAB extensions.  Both the .DAT and the
               .LAB files must exist (and have the same filenames!), but only
               one per image need be selected by FINDFILE.
  
          err  (opt) (o) (0) (i)
               Error flag---non-zero if there was a problem opening IMAGET.

*EXAMPLES:

       hfix,'swp1234h'    ; prompts user for setting exposure times and
    	                   ; correction flags for SWP 1234.
  
*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:

       User is prompted for:
          1) modifying exposure time 
          2) changing or adding flag for applying correction for THDA
	      sensitivity variation
          3) adding flag for applying LWR sensitivity degradation correction
             (if input image is a low dispersion LWR image)
          4) If LWR degradation correction is requested, and the extracted
             observation date does not look reasonable, then the user is
             prompted for a new observation date.
  	
*SUBROUTINES CALLED:

       PARCHECK - check input parameters
       LTI - sets THDA sensitivity flag (H(68))
       SDC - sets flag for LWR sensitivity degradation correction (H(69))
       INTIME - adds exposure time to header (H[39:41])
       LABEL - displays .LAB file
       YESNO - evaluates user input to prompts
  	IUE_PARSE - determine filename extension
	CHKFITS - check file format

*FILES USED:

       IMAGET - Header record of .DAT file is updated using input from user.
		 Part of .LAB file is displayed.

*SIDE EFFECTS:
  
       None.

*RESTRICTIONS:

       Only for use with IUESIPS data.
  
*NOTES:

       HFIX was designed to be used with the new versions of CALIB, and
	IUESPEC which apply various corrections based on the entries found
	in record 0 of the image file.  If the header entries are modified
	using HFIX, the other procedures can be run without user interaction.
       Both the .DAT and .LAB files of IMAGET must exist.
  
*PROCEDURE:

       If IMAGET is a scalar, it is used as an argument for FINDFILE.  HFIX
       will process multiple files.  First, the label is read and searched
       for the ITF info (below the "PCFC" line).  When found, the flag is
       set (note that the label is never converted to ASCII) and inserted in
       H(580). LABEL is then called to list out the first 10 lines of the 
       IUE image label (note that the .LAB file must exist).   IUE_PARSE is
       used to extract the extension from the imaget (if present), so that
       the .DAT file can be specified regardless of what was given. The header 
       record is then opened and the exposure time entries (H(39) to H(41)) 
       are listed. The user is prompted for any modifications. The user is 
       then prompted for whether the THDA sensitivity variation correction 
       is desired unless the flag has already been set in which case it is
       displayed and the user prompted for modifications. If specified,
       LABT is called to display the temperature information stored in the
       .LAB file. Finally, the user is asked if the LWR sensitivity
       degradation correction is desired. If yes, then H(69) is set to -1
       (indicating the correction is desired), and the observation date is
       determined. If the date is < 1978 or > 1999, then the user is prompted
       for a new year and GMT day which is written into entries H(6) and H(7).
  
*I_HELP nn:
  
*MODIFICATION HISTORY:

       8-28-86 CREATED FROM EXPTIME.PRO BY R. THOMPSON
       5-14-87 RWT modularized to use existing routines instead of 
               subroutines
       8-12-87 RWT VAX mods: remove EXTRAC's, use STREBCASC and GET_LUN
       1-21-88 RWT add ITFFLAG & correct for image numbers > 32767
      10-10-88 GS  to print appropriate aperture
       1-02-89 RWT add procedure call listing
       2-14-89 RWT add comment about OBC/rise time correction
       11-7-89 RWT Unix mods: remove !ERR references and modify
            print formats
       8 July 1991 LLT update prolog, clean up, add parcheck, tested on VAX
      25 July 1991 PJL tested on SUN; updated prolog
      22 Nov  1991 GRA removed references to IUER_USERDATA, IUELO, and 
                       IUEHI from prolog.
      26 Jan  1993 LLT add iue_parse - so that ".DAT" is not added to a
                       filename that already includes an extension.
       5 Feb  1993 LLT Add code to figure the ITF flag (faster than ITFFLAG),
                       allow multiple files to be processed.
      27 Aug 1993  RWT correct error when no extension is included in imaget
	23 Nov 93  PJL  updated documentation;  added CHKFITS
	 5 Jan 94  PJL  correct file name print when file not found
       21 Jan 94  LLT  Fix assoc command to find ITF flag so that UNIX will
                       understand
       12 Mar 94  LLT  Add code to exit gracefully in the event of an error.
       18 Apr 94  LLT  Allow senscor flag to be set for LWR LBL files.

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


HISSORT1

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

	HISSORT1.PRO
  
*CLASS:

	Menu Procedure
  
*CATEGORY:
  
*PURPOSE:

 	Procedure to print out relevant configuration items using specified 
	selection criteria and HISTGRAPH.TAB
  
*CALLING SEQUENCE:

	HISSORT1,TYPE,CONFIG,SNAME,APNAME,DATE,ENTRY
  
*PARAMETERS:

	TYPE	(REQ) (I) (1) (I)
		Type of spectrum (output of itype.pro).

       CONFIG	(REQ) (I) (1) (I L F D)
		Vector of configurations satisfying bargraph selection.

       SNAME	(REQ) (I) (0) (S)
		Scheme name extracted from label (output of ipdata.pro) .

       APNAME	(REQ) (I) (0) (S)
		Aperture type as found in label (output of ipdata.pro).

       DATE	(REQ) (I) (1) (I)
		Processing date (output of ipdata.pro).

       ENTRY	(REQ) (I) (1) (I)
		Beginning entry numbers in hist. file for each year.

  
*EXAMPLES:
  
*SYSTEM VARIABLES USED:

       !iuer.dat
  
*INTERACTIVE INPUT:
  
*SUBROUTINES CALLED:

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

	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:

 	Procedure to print out relevant configuration items using specified 
	selection criteria and HISTGRAPH.TAB  

*I_HELP nn:
  
*MODIFICATION HISTORY:
       1-2-90 RWT UNIX mods: convert to lower case, remove lookup command
       4-10-91 KBC modify filename structure based on operating system type
                   for compatibility on SUN/DEC/VAX
	5-29-91 PJL corrected mistake from UNIX conversion (uppercase 
		characters must be used for tests); run cnum and config
		though equations to make sure computer "sees" equal values as
		equal values; added PARCHECK
	7-16-91 PJL changed logical; cleaned up; tested on SUN and VAX; 
		    updated prolog
      2 Sep 94 LLT IUER_DAT ---> !iuer.dat

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


HIST

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

    HIST    (General IDL Library 01)  

*CLASS:

    statistics, histogram

*CATEGORY:

*PURPOSE:  

    To generate a histogram plot of the distribution of values in the
    input array. 

*CALLING SEQUENCE: 

    HIST,A,N,XHIST,YHIST

*PARAMETERS: 

    A     (REQ) (I) (1 2)  (B I L F)
          Required input vector or array for which the histogram is
          desired.

    N     (REQ) (I) (0) (B I L F)
          Required input scalar parameter giving the width of each
          bin for the histogram. Units are the same as for the A array.

    XHIST (REQ) (O) (1) (B I L F)
          Required output vector of the bins whose values correspond
          to the range of values covered by A.

    YHIST (REQ) (O) (1) (B I L F)
          Required output vector of the frequency of occurrence of 
          values corresponding to the bins XHIST in A.

*EXAMPLES:

    To compute the histogram for a portion of an IUE extended line by
    line image, as read into memory using READFILE, and with bin
    interval of 1000 FN:

    HIST,FIMAGE,1000.,XHIST,YHIST

*SYSTEM VARIABLES USED:

    !NOPLOT
  
*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

    PARCHECK

*FILES USED:

*SIDE EFFECTS:

    Care should be taken to ensure that the number of bins to be plotted
    does not exceed 16,383, since the IDL plot procedure will not function
    correctly with a larger number of points.

*RESTRICTIONS:
    Does not support double precision data type.

*NOTES:

    Note that XHIST and YHIST contain repeated elements
    and zero elements, respectively so that the instruction
    PLOT, XHIST, YHIST produces a bar graph.

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

*PROCEDURE: 

    The number of points in A are counted for each 
    interval of width N.  A histogram is plotted using
    these values.

*MODIFICATION HISTORY:

    Apr  8 1980  D. Lindler and I Dean Ahmad, initial program.
    Jun  5 1987  RWT GSFC  use vector assignment statements
    Nov 24 1987  RWT GSFC  use !NOPLOT for plotting,
                           add procedure call listing,
                           convert I*2 parameters to I*4,
                           and separate vector and array
                           calculations.
    Mar 14 1988  CAG GSFC  add VAX RDAF-style prolog.
    Mar 11 1991  PJL GSFC  modified for unix/sun
    Jun 21 1991  PJL GSFC  cleaned up; tested on SUN and VAX; 
			    updated prolog
    Apr  7 1994  RWT GSFC  make xmin, xmax, & n floating point to avoid
                           potential overflow problems with integers,
                           truncate rather than round-off K value, 
                           and update prolog.

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


HITFIX

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

	HITFIX     (General IDL Library 01) January 1990

*CLASS: 

	data editing, image editing

*CATEGORY:

*PURPOSE:

	This procedure replaces an interactively defined "blemish" region
	with the average value from an interactively defined "background"
	region in the input image.

*CALLING SEQUENCE: 

	HITFIX,IMAGE,BLEM,BACK,header

*PARAMETERS:

	IMAGE	(REQ) (I/O) (2) (B)
		The required input vector containing the image to be edited.
		As output, this vector contains the modified image.

	BLEM	(REQ) (O) (1) (I)
		Required output vector containing the pixel coordinates (upper
		left corner and lower right corner) of the rectangular blemish
		region.

	BACK	(REQ) (O) (1) (I)
		Required output vector containing the pixel coordinates (upper
		left corner and lower right corner) of the rectangular
		background region.

	HEADER	(OPT) (I/O) (1) (S)
		Fits header.  If included then the pixel coordinates (upper
		left corner and lower right corner) of the rectangular blemish
		and background regions will be added in HISTORY keywords.

*EXAMPLES:

	For IUESIPS data, the following example reads an lbl file, converts
	the flux image to byte type, and executes HITFIX.

		readfile,'lwp9879s',lab,head,wave,flux,eps
		image = bytscl(flux)
		hitfix,image,blem,back

	For NEWSIPS data, the following example reads a silo file, converts
	the flux image to byte type, and executes HITFIX.

		readsi,'swp21654.silo',main,wave,image,flags
		bimage = byte(image)
		hitfix,bimage,blem,back

	For NEWSIPS data, the fits haeder may be updated:

		hitfix,bimage,blem,back,main

*SYSTEM VARIABLES USED:

	!d.name
	!err
	!stime

*INTERACTIVE INPUT:

	This procedure allows the user to interactively define a rectangular
	blemish and background region.  The user is prompted to choose the
	opposite (diagonal) corners of each region using the graphics
	crosshairs.  After the regions are defined, the user can elect to
	continue the procedure or re-define the background and blemish
	regions.  If the "continue" option is selected, the modified image
	will be output and the procedure will return to the calling procedure
	(or IDL).

*SUBROUTINES CALLED:

	PARCHECK
	PCHECK
	ADDPAR

*FILES USED:

	none

*SIDE EFFECTS:

	IDL graphics window 2 is created.

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

	Requires an image display device.

*NOTES:
 
	This procedure is currently called as a subroutine of LBLFIX.

*PROCEDURE: 

	A window is created to match the size of the input image and plot is
	called to establish the pixel coordinate scaling.  Cursor,/data is
	used to determine the subsequently selected cursor positions in pixel
	coordinates.  The selected blemish region is overplotted with a solid
	line and the background region is overplotted with a dashed line.
	The pixel values in the blemish region are then replaced with the
	average pixel value in the background region.  The coordinates of the
	upper left and lower right corners of both regions, along with the
	modified image are then returned to the calling routine.
        
*MODIFICATION HISTORY:

	written for unix/sun idl by jerry bonnell csc @gsfc january 1990
		based on a program by george sonneborn nasa @gsfc aug. 1989
	25 Jun 91  PJL  cleaned up; added PARCHECK and TEK device check; 
			tested on SUN; updated prolog
	20 Aug 93  PJL  add NEWSIPS example; added PCHECK and ADDPAR; added
			HEADER parameter

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


IBFIND

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

*CLASS:

*CATEGORY:
 
*PURPOSE:  
	
    	Searched the IUE Reference Databases for all entries which satisfy 
	the search parameters.

*CALLING SEQUENCE:
	
      	IBFIND,QS,ARTLIST,OBJLIST,artnum,objnum
 
*PARAMETERS:
	
     	QS  	(REQ) (I)
         	6 element string array of selection criteria for search.

     	ARTLIST	(REQ) (O)
           	List of IUE article numbers in two of the three IUE Reference
		Databases (IUEREF and IUECOAU) which satisfy the search
		criteria.  If there are no values that satisfy the search
		parameters, then artlist(0) = 0.

     	OBJLIST	(REQ) (O)
           	List of IUE object numbers in two of the three IUE Reference
		Databases (IUEREF and ALIAS) which satisfy the search criteria.
		If there are no values that satisfy the search parameters, then
		objlist(0) = 0.

	ARTNUM	(OPT) (O)
		The number of IUE article numbers found in the IUE Reference
		Databases (IUEREF, ALIAS, and IUECOAU) databases.

	OBJFES	(OPT) (O)
		The number of IUE object numbers found in the IUE Reference
               Databases (IUEREF, ALIAS, and IUECOAU) databases.

*EXAMPLES:

       The following sequence of operations can be used to search
       for the information on ALP CAM:

       Clear previous search parameters and set the Epoch to 1950:
               qs = strarr(6)
       Set new search parameter:
               qs(1) = 'alias = ALP CAM'
       Perform search:
		ibfind,qs,artlist,objistl,artnum,objnum
       Print information in terminal format on the terminal:
		ibprint,qs,artlist,objlist,1,1,artnum,objnum
         
*SYSTEM VARIABLES USED:

	none
	
*INTERACTIVE INPUT:

	none
	
*SUBROUTINES CALLED:
	
       PARCHECK
	IDBOPEN
	IDBFIND
	IDBCLOSE
	IDBGET
	IBORDER
	
*FILES USED:
	
       The database files are opened by IDBOPEN and used for input:
		IUEJRNL's files:
			!iuer.database iuejrnl.dbd
			!iuer.database iuejrnl.dbf
			!iuer.database iuejrnl.dbh
			!iuer.database iuejrnl.dbx
		ALIAS's files:
			!iuer.database alias.dbd
			!iuer.database alias.dbf
			!iuer.database alias.dbh
			!iuer.database alias.dbx
		IUECOAU's files:
			!iuer.database iuecoau.dbd
			!iuer.database iuecoau.dbf
			!iuer.database iuecoau.dbh
			!iuer.database iuecoau.dbx
	
*SIDE EFFECTS:

*RESTRICTIONS:

	Only certain fields in the IUEREF, ALIAS, and IUECOAU databases
	can be searched.
 
*NOTES:

	The QS array is an one dimensional string array of 6 elements.
       The elements of this array are  assigned the following meanings:
 Element   Parameter         Name         Search  Kind       Encoding
    0   Coauthor's last name coau_name       I   string
    1   Object name          alias           I   string
    2   Camera Number        cam_num         S    flag       LWP = 1, LWR = 2,
                                                             SWP = 3, SWR = 4
    3   Image Number         image_num       S   range or flag
    4   Author's last name   auth_name       I   string
    5   Year of journal      jrnl_year       S   range or flag

       Searches are S for sorted and I for indexed.
  	Different types of searches have different notation:
		flag - only a small set of possible values
			cam_num = 1
		flag or range - can be a specific value or within a range
			image_num = 3000
			3000 < image_num < 3050
               string - for any occurrence of the string within a field
			alias = 'CAM'
			will return ALP CAM and Z CAM among others
                     
       The search time can take anywhere from a couple seconds to several
       hours depending on the selection criteria and the computer system.
       The slowest searches are those requiring only sequential searches.
       This form of searching is done on all criteria not marked as sorted
       in the menu.  A message is printed if the search is being preformed
       on more than two hundred non-sorted entries.  If an non-sorted field
       is to searched on, then it is advisable to limit the number of entries
       to be searched by also searching on sorted fields.  Searches that
       involve sorted and non-sorted fields are performed first on the sorted
       fields first and then that subset is used for the non-sorted search.

       The faster search times are achieved by searching the sorted elements
       which are marked on the menu.  Search times are usually less than 30
       seconds for searches involving sorted elements only.

       Searches on strings will be satisfied by a match of the substring 
       anywhere in the string.  For example, a search on alias = 'CAM'
	will return object names ALP CAM and Z CAM among others.

	Called in IUEREF software suite - IUEREF.
 
*PROCEDURE:

	The databases to be searched and order for them to search in is
	determined based on the enties in qs.  Only IUEJRNL is searched when no
	object name [qs(1)] or coauthor's name [qs(0)] is given, and at least
	one of the remaining criteria is given [qs(2:5)]; this is option 1.  
	IUEJRNL and IUECOAU are searched when an object name [qs(1)] is not
	given and a coauthor's name [qs(0)] is given; this is option 2.  When
	an object name and coauthor's name are both given, then ALIAS, IUEJRNL,
	and IUECOAU are searched; this is option 3.  When a coauthor's name is
	not given [qs(0)], an object name is given [qs(1)], and at least one
	other criteria is given [qs(2:5)], then the object number obtained
	from searching ALIAS is combined with the other criteria when searching
	IUEJRNL; this is option 4.  When only an object name is given, then
	ALIAS is searched for the object number, and the object number is used
	to search IUEJRNL for the article number(s); this is option 5.

	The article and object number(s) are extracted from the database(s),
	duplicates are removed, and the vectors are returned.

*I_HELP nn: 
	
*MODIFICATION HISTORY:
 
	 2 Feb 93  PJL  created based on isfind
	12 Feb 93  PJL  documentation
	25 Feb 93  PJL  shorten field names
	25 Jun 93  PJL  updated documentation to reflect field name changes
	 1 Dec 93  PJL  added two missing idbclose statements
        2 Nov 94  PJL  changed prolog reference from IUER_MLOG to
                       !iuer.database
	

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


IBMENU

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

   	IBMENU
  
*CLASS:

*CATEGORY:
  
*PURPOSE:

   	Menu routine for selecting search characteristics for the IUE
	Reference database.
  
*CALLING SEQUENCE:

    	IBMENU,CMD,QSEARCH
  
*PARAMETERS:

    	CMD  	(REQ) (O) (0) (I)
            	Command option requested.

    	QSEARCH (REQ) (O)
            	(Array) Search Criteria.
  
*EXAMPLES:

	To enter the camera name:
		qs = strarr(6)
		ibmenu,2,qs
  
*SYSTEM VARIABLES USED:

	!iuer.inf
  
*INTERACTIVE INPUT:

      	"Press RETURN to continue"
  
*SUBROUTINES CALLED:

	PARCHECK
	IDBOPEN
	IDBCLOSE
     	IBMENU1
	IBMENU2
	IBVIEW
	IDBHELP
	PLATFORM
       SHOWTXT
  
*FILES USED:

	!iuer.inf iueref.txt
	!iuer.inf iuejrnl.txt
	!iuer.inf iuecoau.txt
	!iuer.inf iuealias.txt
	!iuer.inf dbexpert.txt

	!iuer.database iuejrnl.dbd
	!iuer.database iuecoau.dbd
	!iuer.database alias.dbd

*SIDE EFFECTS:
  
*RESTRICTIONS:

*NOTES:

  	Called in IUEREF software suite - IUEREF.

*PROCEDURE:

      	IBMENU calls IBMENU1 which presents the user with a series of menus
	for searching the IUE Reference database.  Based on the option the
	user selects from these menus, IBMENU will print the help/documentation
	files to the terminal, call a procedure (IBMENU2 or IBVIEW), print
	an error message (cmd le -1), or return to the calling procedure
	(cmd ge 21).

*I_HELP nn:
  
*MODIFICATION HISTORY:

	 2 Feb 93  PJL  wrote based in ismenu
	12 Feb 93  PJL  documentation
	23 Jul 93  PJL  added field listings
	 7 Jun 94  PJL  replaced !version.os with PLATFORM
       18 Oct 94  PJL  added code for page command equal 'NA'
       21 Oct 94  PJL  IUER_ logicals ---> !iuer structure
        2 Nov 94  PJL  changed prolog reference from !iuer.mlog to
                       !iuer.database
        8 Mar 95  RWT  use SHOWTXT to display text when spawning is not
                       possible (e.g., MACs).

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


IBMENU1

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

   	IBMENU1
  
*CLASS:

*CATEGORY:
  
*PURPOSE:

    	Main menu for IUE Reference Database search procedure.
  
*CALLING SEQUENCE:

   	IBMENU1,CMD
  
*PARAMETERS:

 	CMD 	(REQ) (I) (0) (I)
		Command option requested.
  
*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:
  
	The procedure will ask the user to choose from a printed list of 
	options which contain search parameters.
  
*SUBROUTINES CALLED:

	PARCHECK
  
*FILES USED:

	none
  
*SIDE EFFECTS:
  
*RESTRICTIONS:

*NOTES:

	Called in IUEREF software suite - IBMENU.

     	When first called, cmd = -1, which prints the menu.  Then the user
     	is asked for a new value of cmd.

*PROCEDURE:
  
	This procedure prints a option list which contain search parameters.
	The procedure will then ask the user to pick a search parameter and 
	store the result before returning.

*I_HELP nn:
  
*MODIFICATION HISTORY:

	 2 Feb 93  PJL  wrote based on ismenu1

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


IBMENU2

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

   	IBMENU2
  
*CLASS:
  
*CATEGORY:
  
*PURPOSE:

    	Enter items for menu selection options 1-5.
  
*CALLING SEQUENCE:

   	IBMENU2,CMD,QS
  
*PARAMETERS:

    	CMD 	(REQ) (I) (0) (I) 
    	   	Menu selection command number

    	QS  	(REQ) (O)
    	   	String array of selection criteria
  
*EXAMPLES:
  
	To enter camera name:
		qs = strarr(6)
		ibmenu2,2,qs

*SYSTEM VARIABLES USED:

	none
  
*INTERACTIVE INPUT:
  
       Values for search to be performed - object name, camera name/number,
	image number, author's last name, coauthor's last name, and year of
	journal.

	"Press RETURN to continue."
  
*SUBROUTINES CALLED:
  
  	PARCHECK
  
*FILES USED:

	none
  
*SIDE EFFECTS:
  
*RESTRICTIONS:

*NOTES:

       Called in IUEREF software suite - IBMENU.

*PROCEDURE:
  
    	This procedure is used to retrieve pieces of data. The data asked 
	of the user depends on and option chosen in IBMENU1. The procedure
	handles one of five options including the following:

			1) Object Name     		qs(1)
			2) Camera Name/Number		qs(2)
			3) Image Number			qs(3)
			4) Author's Last Name		qs(4)
			   Coauthor's Last Name		qs(0)
			5) Year of Journal		qs(5)

*I_HELP nn:
  
*MODIFICATION HISTORY:

	 2 Feb 93  PJL  wrote based on ismenu2
	12 Feb 93  PJL  changed journal year to a range
	16 Feb 93  PJL  removed FES camera option
	25 Feb 93  PJL  shorten field names
	25 Jun 93  PJL  changed cam_no to cam_num and image to image_num

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


IBORDER

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

	IBORDER

*CLASS:

*CATEGORY:

*PURPOSE:

	Uses the IUEJRNL database's entry numbers to obtain the IUE article
	numbers and the IUE object numbers.

*CALLING SEQUENCE:

	IBORDER,LIST,COUNT,ARTLIST,OBJLIST,ARTNUM,OBJNUM

*PARAMETERS:

	LIST	(REQ) (I)
		The vector of entry numbers from the IUEJRNL database.  If
		list(0) = 0, then there are no entries.

	COUNT	(REQ) (I)
		The number of entry numbers from the IUEJRNL database.

	ARTLIST	(REQ) (O)
		The vector of IUE article numbers.  If artlist(0) = 0, then
		ere are no entries.

	OBJLIST	(REQ) (O)
		The vector of IUE object numbers.  If objlist(0) = 0, then
		there are no entries.

	ARTNUM	(REQ) (O)
		The number of IUE article numbers.

	OBJNUM	(REQ) (O)
		The number of IUE object numbers.

*EXAMPLES:

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK
	IDBOPEN
	IDBEXT
	IDB_OR
	IDBCLOSE

*FILES USED:

	IUEJRNL database
	   !iuer.database  iuejrnl.dbd
	   !iuer.database  iuejrnl.dbh
	   !iuer.database  iuejrnl.dbf
	   !iuer.database  iuejrnl.dbx

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	Called in IUEREF software suite - IBFIND.

*PROCEDURE:

	The IUEJRNL database is used with the the list to obtain the
	article numbers and object numbers.

*I_HELP  nn:

*MODIFICATION HISTORY:

	 3 Feb 93  PJL  wrote
	16 Feb 93  PJL  documentation
	25 Feb 93  PJL  shorten field names
        2 Nov 94  PJL  changed prolog reference from IUER_MLOG to
                       !iuer.database

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


IBPRINT

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

    	IBPRINT

*CLASS:

*CATEGORY:
 
*PURPOSE:  
	
    	To provide printed information on the entries in the IUE Reference
	databases specified in the list specified. 
 
*CALLING SEQUENCE:

	IBPRINT,QS,ARTLIST,OBJLIST,TYPE,OUT,ARTNUM,OBJNUM
 
*PARAMETERS:

	QS	(REQ) (I)
		The string array of search criteria.

    	ARTLIST	(REQ) (I)
    	      	(Vector) The list of articles numbers for IUEJRNL and IUECOAU.

    	OBJLIST	(REQ) (I)
    	      	(Vector) The list of object numbers for IUEJRNL and ALIAS.

    	TYPE 	(REQ) (I)
    	      	(Scalar) The print format.
    	      	    0 = Select format (and output device) with menu.
		    1 = Terminal format:  Bibliographies of articles.  (default)
		    2 = Line printer format:  Bibliographies of articles.
		    3 = Full listing:  Not in table form.
		    4 = Terminal format:  Articles, IUE camera and image number.
		    5 = Terminal format:  Aliases.

      	OUT 	(REQ) (I)
               (Integer) Denotes output device as follows:
                      	0 = nowhere
                      	1 = to your terminal
                      	2 = to your default printer (beware if it 
			    is a laser printer)
                      	3 = to a print file  ibprint.prt

	ARTNUM	(REQ) (I)
		The number of valid article numbers.

	OBJNUM	(REQ) (I)
		The number of valid object numbers.

*EXAMPLES: 
	
       To print the entries in IUE Reference database in a line printer
	format to a file 
 
                ibprint,qs,artlist,objlist,2,3,artnum,objnum

*SYSTEM VARIABLES USED:

	!iuetextunit
	
*INTERACTIVE INPUT:

	If not given in the calling statement, the type ond output device
	options have to be entered.

	If the table fills more than one page:
		space bar	next full page
		RETURN		next line
		'q', 'Q'	quit paging
		'h', 'H', '?'	help information
	can be entered at the prompt.

*SUBROUTINES CALLED:

	PARCHECK
	YESNO
	IDBOPEN
	IDBPRINT
	IDBGET
	IDBSORT
	IDBCLOSE
	IBPRT12
	IBPRT3
	IBPRT5
	PLATFORM
 
*FILES USED:

	ibprint.prt for a disk file.
	ibprint.tmp for a file to print.

      	A valid device for the terminal.
	
*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

      	Format number 2 requires a 132 column spooled output device.
      	If OUT is  0, no output will be generated.
       If OUT is '' or 1, output will go to the users terminal.
       IF OUT is 2, then LIST is output to default printer.
      	If the first entry of LIST is 0, no output will be generated.
      	When the interactive mode is used, the values of both TYPE and OUT
      	are updated by the user.

	Called in the IUEREF software suite - IUEREF.
 	
*PROCEDURE:

	Determines output format to use and output device.  If there are
	no entries, return to the calling procedure.  If output device is
	a file, determine if it already exist.  If yes, check with user
	about continuing.  Print entries in requested format.  Send
	ibprint.tmp to the printer is that was the request (on the VAX,
	the file is then deleted).
	
*I_HELP nn:
 
*MODIFICATION HISTORY:

	 3 Feb 93  PJL  wrote based on isprint
	16 Feb 93  PJL  documentation
	17 Feb 93  PJL  added printing searched on object name with the object
			number
	25 Feb 93  PJL  shorten field names
	25 Jun 93  PJL  changed field name from image to image_num
	 7 Jun 94  PJL  replaced !version.os with PLATFORM
       11 Oct 94  PJL  added code for pdelete = 'NA'

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


IBPRT12

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

    	IBPRT12

*CLASS:

*CATEGORY:
 
*PURPOSE:  
	
    	To provide printed information on the entries in the IUE Reference
	databases specified in the list specified. 
 
*CALLING SEQUENCE:

	IBPRT12,ARTLIST,OUT,WIDTH
 
*PARAMETERS:

	ARTLIST	(REQ) (I)
		(Vector)  The list of article numbers for IUEJRNL and IUECOAU.

	OUT	(REQ) (I)
		Filename or device for output to be printed to.

	WIDTH	(REQ) (I)
		Length of output line on device.
 
*EXAMPLES: 
	
       To print the entries in artlist in bibliographic format (width of 80
	columns) to the file ibprint.prt:
 
                isprt12,artlist,'ibprint.prt',80
  
*SYSTEM VARIABLES USED:

	none
	
*INTERACTIVE INPUT:

       If the table fills more than one page:
               space bar       next full page
               RETURN          next line
               'q', 'Q'        quit paging
               'h', 'H', '?'   help information
       can be entered at the prompt.

*SUBROUTINES CALLED:

	PARCHECK
	IDBOPEN
	IDBEXT
	IDBMATCH
	IDBGET
	IDBSORT
	IDBCLOSE
 
*FILES USED:


	ibprint.prt for a disk file
	ibprint.tmp for a file to be sent to the printer
      	If OUT is a valid device, the output will be written to that device. 

	IUEJRNL database
	   !iuer.database  iuejrnl.dbd
	   !iuer.database  iuejrnl.dbh
	   !iuer.database  iuejrnl.dbf
	   !iuer.database  iuejrnl.dbx

	IUECOAU database
	   !iuer.database  iuecoau.dbd
	   !iuer.database  iuecoau.dbh
	   !iuer.database  iuecoau.dbf
	   !iuer.database  iuecoau.dbx
	
*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	Called in IUEREF software suite - IBPRINT.
 	
*PROCEDURE:

	If there are any entries in artlist, each is printed.
	
*I_HELP nn:
 
*MODIFICATION HISTORY:

	 4 Feb 93  PJL  wrote based on isprt3
	 9 Feb 93  PJL  attempt to increase speed
	23 Feb 93  PJL  attempt to increase speed; added "please wait" message
	25 Feb 93  PJL  shorten field names
        2 Nov 94  PJL  changed prolog reference from IUER_MLOG to
                       !iuer.database

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


IBPRT3

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

    	IBPRT3

*CLASS:

*CATEGORY:
 
*PURPOSE:  
	
    	To provide printed information on the entries in the IUE Reference
	databases specified in the list specified. 
 
*CALLING SEQUENCE:

	IBPRT3,ARTLIST,OBJLIST,OUT
 
*PARAMETERS:

	ARTLIST	(REQ) (I)
		(Vector)  The list of articles numbers for IUEJRNL and IUECOAU.

	OBJLIST	(REQ) (I)
		(Vector)  The list of object numbers for IUEJRNL and ALIAS.

	OUT	(REQ) (I)
		Filename or device for output to be printed to.
 
*EXAMPLES: 
	
       To print the entries in artlist and objlist to the file ibprint.prt:
 
                ibprt3,artlist,objlist,'ibprint.prt'
  
*SYSTEM VARIABLES USED:

	none
	
*INTERACTIVE INPUT:

       If the table fills more than one page:
               space bar       next full page
               RETURN          next line
               'q', 'Q'        quit paging
               'h', 'H', '?'   help information
       can be entered at the prompt.

*SUBROUTINES CALLED:

	PARCHECK
	IDBOPEN
	IDBEXT
	IDBMATCH
	IDBFIND
	IDBSORT
	IDB_OR
	IDBCLOSE
	IBPRT5
 
*FILES USED:

	ibprint.prt for a disk file
	ibprint.tmp for a file to be sent to the printer
      	If OUT is a valid device, the output will be written to that device. 

	IUEJRNL database
	   !iuer.database  iuejrnl.dbd
	   !iuer.database  iuejrnl.dbh
	   !iuer.database  iuejrnl.dbf
	   !iuer.database  iuejrnl.dbx

	IUECOAU database
	   !iuer.database  iuecoau.dbd
	   !iuer.database  iuecoau.dbh
	   !iuer.database  iuecoau.dbf
	   !iuer.database  iuecoau.dbx
	
*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	Called in IUEREF software suite - IBPRINT.
 	
*PROCEDURE:

	If there are any entries in artlist, each is printed.  Likewise for
	objlist.
	
*I_HELP nn:
 
*MODIFICATION HISTORY:

	 3 Feb 93  PJL  wrote based on isprt3
	16 Feb 93  PJL  documentation
	24 Feb 93  PJL  shorten field names
	 8 Mar 93  PJL  changed volume to a character field
	25 Jun 93  PJL  changed field name from image to image_num
	 2 Dec 93  PJL  correct typo
        2 Nov 94  PJL  changed prolog reference from IUER_MLOG to
                       !iuer.database

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


IBPRT5

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

	IBPRT5

*CLASS:

*CATEGORY:

*PURPOSE:

	To provide printed information on the entries in the IUE Reference
	databases specified in the list specified.

*CALLING SEQUENCE:

	IBPRT5,OBJLIST,OBJNUM,FILEOUT

*PARAMETERS:

	OBJLIST	(REQ) (I)
		(Vector)  The list of object numbers for IUEJRNL and ALIAS.

	OBJNUM	(REQ) (I)
		The number of object numbers.

	FILEOUT	(REQ) (I)
		Filename or device for output to be printed to (called from
		IBPRINT) or the open unit number (called from IBPRT3).

*EXAMPLES:

	To print the entries in artlist and objlist to the file ibprint.prt:

		ibprt3,objlist,objnum,'ibprint.prt'

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

       If the table fills more than one page:
               space bar       next full page
               RETURN          next line
               'q', 'Q'        quit paging
               'h', 'H', '?'   help information
       can be entered at the prompt.

*SUBROUTINES CALLED:

	PARCHECK
	IDBOPEN
	IDBGET
	IDBEXT
	IDBCLOSE

*FILES USED:

	ibprint.prt for a disk file
       ibprint.tmp for a file to be sent to the printer
       If OUT is a valid device, the output will be written to that device.

	ALIAS database
	   !iuer.database  alias.dbd
	   !iuer.database  alias.dbh
	   !iuer.database  alias.dbf
	   !iuer.database  alias.dbx

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

	Called in IUEREF software suite - IBPRINT and IBPRT3.

*PROCEDURE:

	If a filename or device name is given - not an open unit number - that
	file is opened.  The ALIAS database is opened.  For each object number
	in objlist, the alias(es) are found, the object number, number of
	aliases, and the aliases are printed.  When finished the database is
	closed, and if a file was opened in ibprt5, then it is closed.

*I_HELP  nn:

*MODIFICATION HISTORY:

	10 Feb 93  PJL  wrote based on isprt3
	16 Feb 93  PJL  documentation
	25 Feb 93  PJL  shorten field names
        2 Nov 94  PJL  changed prolog reference from IUER_MLOG to
                       !iuer.database

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


IBSORT

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

	IBSORT

*CLASS:

*CATEGORY:

	database

*PURPOSE:

	Procedure to sort data into ascending order, like a simple bubble sort.
	original subscript order is maintained when values are equal (FIFO).
	(This differs from the IDL SORT routine alone, which may rearrange 
       order for equal values)

*CALLING SEQUENCE:

	IBSORT,ARRAY,RESULT,asort,info=info,reverse=rev

*PARAMETERS:

	ARRAY	(REQ) (I)
		array to be sorted

	RESULT	(REQ) (O)
		sort subscripts are returned as function value

	ASORT	(OPT) (I)
		sorted array

       /REVERSE  (OPT) (I) (keyword)
		  if this keyword is set, and non-zero, then data is sorted
                 in descending order instead of ascending order.

	/INFO	(OPT) (I) (keyword)
		optional keyword to cause brief message about # equal values.

*EXAMPLES:

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

	written by F. Varosi Oct.90:
	uses WHERE to find equal clumps, instead of looping with IF ( EQ ).
       compatible with string arrays, test for degenerate array 
	20-MAY-1991	JKF/ACC via T AKE- return indexes if the array to 
					be sorted has all equal values.
       Aug - 91  Added  REVERSE keyword   W. Landsman      
	25 Mar 92  PJL  added prolog
	 1 Apr 92  PJL  renamed BSORT to IBSORT; added PARCHECK and npar
			eq 0 print
	 3 Aug 92  PJL  changed function to procedure; clean up; corrected npar

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


IBVIEW

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

	Menu Procdure
  
*CATEGORY:
  
*PURPOSE:
	
    	Procedure to list the search criteria for IUEREF.
  
*CALLING SEQUENCE:
	
    	IBVIEW,PFLAG,QS
  
*PARAMETERS:
	
      PFLAG  	(REQ) (I) (0) (I)
        	Print flag =1 direct printout to the terminal.
                         OTHERWISE DIRECT PRINTOUT AS SPECIFIED IN ACMD

      QS     	(REQ) (I)
        	(Array) selection criteria.
  
*EXAMPLES:  
	
*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none
	
*SUBROUTINES CALLED:
	
	PARCHECK
	PLATFORM
  
*FILES USED:

       Creates IBVIEW.PRT if ACMD ge 2, if ACMD eq 2, the file will be
	printed and deleted.
	
*SIDE EFFECTS:
  
*RESTRICTIONS:
  
*NOTES:

	Called in IUEREF software suit - IBMENU and IUEREF.
  
*PROCEDURE:

       QS is passed in as selection criteria.  Through a series of tests,
       IBVIEW writes out the selections to your terminal and/or to
       a disk file which may be printed & deleted, or saved, depending
       on the value of pflag.
  
*I_HELP nn:  
  
*MODIFICATION HISTORY:
	
	 2 Feb 93  PJL  wrote based on isview
	12 Feb 93  PJL  allow journal year to be a range
	16 Feb 93  PJL  removed FES option
	19 Mar 93  PJL  fixed camera/image bug
	25 Jun 93  PJL  updated documentation to reflect cam_no to cam_num
			field name change
	 7 Jun 94  PJL  replaced !version.os with PLATFORM
       11 Oct 94  PJL  added code for pdelete = 'NA'

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


IDBCIRCLE

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

   	IDBCIRCLE

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	Find sources in a database within a specified radius of a specified
   	center.  Database should include RA and DEC items and should previously
   	be opened with IDBOPEN

*CALLING SEQUENCE:

    	IDBCIRCLE,QDB,QITEMS,QDBREC,RA_CEN,DEC_CEN,LIST,radius,dis,sublist,
	   SILENT=silent,EPOCH=epoch

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

	QDBREC	(REQ) (I)
               QDBREC(i) contains the entry number in the second data base
               corresponding to entry i in the first data base.

    	RA_CEN	(REQ) (I)
		Right ascension of the search center in decimal DEGREES, scalar

    	DEC_CEN	(REQ) (I)
		Declination of the search center in decimal DEGREES, scalar
             	RA_CEN and DEC_CEN should be in the same equinox as the 
             	currently opened catalog.

     	LIST	(REQ) (O)
		Vector giving entry numbers in the currently opened catalog
            	which have positions within the specified search circle
            	LIST is set to -1 if no sources fall within the search circle
            	COUNT is set to the number sources found.

    	RADIUS	(OPT) (I)
		Radius of the search field in arc minutes, scalar.
             	IDBCIRCLE prompts for RADIUS if not supplied.

    	SUBLIST	(OPT) (I)
		Vector giving entry numbers in currently opened database
             	to be searched.  Default is to search all entries

     	DIS	(OPT) (O)
		The distance in arcminutes of each entry specified by LIST
            	to the search center (given by RA_CEN and DEC_CEN)

     	SILENT	(OPT) (I) (keyword)
		If this keyword is set, then IDBCIRCLE will not print the 
            	number of entries found.

	EPOCH	(OPT) (I) (keyword)
		Sets the Epoch for the search coordinates to 2000.
		The default is 1950.

*EXAMPLES:

     	Find all SAO stars within 40' of the nucleus of M33
     	(at 1h 31m 1.67s 30d 24' 15'')

        IDL> idbopen,qdb,qitems,qdbrec,'sao'
        IDL> iueten,res1,1,31,1.67
        IDL> iueten,res2,30,24,15
        IDL> idbcircle,qdb,qitems,qdbrec,res1*15.,res2,list,40

*SYSTEM VARIABLES USED:

	!radeg

*INTERACTIVE INPUT:

  	IDBCIRCLE prompts for RADIUS if not supplied.

*SUBROUTINES CALLED:

	IDB_INFO
	IDBEXT
	IGCIRC
	IDBFIND

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

     	A IDBFIND search is first performed on a square area of given radius.
     	The list is the restricted to a circular area by using IGCIRC to 
     	compute the distance of each object to the field center.

*I_HELP  nn:

*MODIFICATION HISTORY:

      	Written W. Landsman     STX           January 1990
      	Fixed search when crossing 0h         July 1990
      	Spiffed up code a bit     October, 1991
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL	renamed DBCIRCLE to IDBCIRCLE; added PARCHECK
			and npar eq 0 print
	 3 Aug 92  PJL  changed from a function to a procedure; added IUEDB
			to calling sequence; cleaned up
	13 Aug 92  PJL  replaced IUEDB structure with qdb, qitems, and qdbrec
			parameters; added EPOCH keyword; updated prolog
	17 Aug 92  PJL  replaced !err with COUNT; changed calling sequence
			for IDBFIND
	31 Aug 92  PJL  changed R.A. hours to R.A. decimal degrees

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


IDBCLOSE

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

    	IDBCLOSE

*CLASS:

*CATEGORY:

	database

*PURPOSE:

    	Procedure to close a data base file


*CALLING SEQUENCE:

   	IDBCLOSE,QDB,QITEMS,QDBREC

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

	QDBREC	(REQ) (I)
               QDBREC(i) contains the entry number in the second data base
               corresponding to entry i in the first data base.

*EXAMPLES:

	idbclose,qdb,qitems,qdbrec

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	IDB_INFO

*FILES USED:

	Closes all .dbx files that are open.
	Closes all .dbf files that are open.

*SIDE EFFECTS:

	the data base files currently opened are closed

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

	version 2  D. Lindler  Oct. 1987
       For IDL version 2      August 1990
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL	renamed DBCLOSE to ISBCLOSE; added dummy parameter,
			PARCHECK, and npar eq 0 print
	31 Jul 92  PJL  changed IUEDB common block to a structure parameter
			that is passed between procedures; cleaned up
	 7 Aug 92  PJL  add checking if IUEDB exists
	13 Aug 92  PJL  replaced IUEDB structure with QDB, QITEMS, and QDBREC
			parameters; updated prolog

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


IDBCREATE

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

    	IDBCREATE

*CLASS:

*CATEGORY:

	database

*PURPOSE:

    	Create new data base file or modify description.  A database 
	definition file (.DBD) file must already exist.  The default
	directory must be a !iuer.database directory.

*CALLING SEQUENCE:

	IDBCREATE,NAME,newindex,newdb,maxitems

*PARAMETERS:

	NAME	(REQ) (I)
		name of the data base (with no qualifier), scalar string. 
             	The description will be read from the file "NAME".DBD. 

	NEWINDEX  (OPT) (I)
		  if non-zero then a new index file is created, otherwise
		  it is assumed that changes do not affect the index file.
		  (default=0)

	NEWDB	(OPT) (I)
		if non-zero then a new data base file (.dbf) will
		be created. Otherwise changes are assumed not to affect
		the file's present format.

	MAXITEMS   (OPT) (I)
		   maximum number of items in data base.  If not supplied
		   then the number of items is limited to 200.

	No outputs.

*EXAMPLES:

*SYSTEM VARIABLES USED:

       !iuer.database
	!iuepriv
	!msg_prefix
	!err_string
	!syserr_string

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	IUEZPARCH
	IUEGETTOK
	PLATFORM
       MULDIRFF

*FILES USED:

	name.dbd   input - contents and structure information
	name.dbh   output - list description  of columns
	name.dbf   output - for the data entries
	name.dbx   output - for the indexed and sorted values

*SIDE EFFECTS:

	data base description file !iuer.database name.dbh is created
	and optionally !iuer.database name.dbf (data file) and
	!iuer.database name.dbx (index file) if it is a new data base.
       
*RESTRICTIONS:

	If newdb = 0 is not specified, the changes to the .dbd file can
	not alter the length of the records in the data base file.
	and may not alter positions of current fields in the file.
	permissible changes are:
		1) utilization of spares to create a item or field
		2) change in field name(s)
		3) respecification of index items
		4) changes in default print formats
		5) change in data base title
		6) changes in pointer specification to other data
			data bases

	!iuepriv must be 2 or greater to execute this routine.

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

	version 2  D. Lindler  OCT, 1987
	Modified to work under IDL version 2.  M. Greason, STX, June 1990.
	Modified to work under Unix  D. Neill, ACC, Feb 1991.
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL  renamed DBCREATE to IDBCREATE; added PARCHECK and
			npar eq 0 print; changed !priv to !iuepriv; changed
			ZDBASE to IZDBASE
	 5 Aug 92  PJL  replace IZPARCHECK with IUEZPARCH, IGETLOG with GETENV,
			and IGETTOK with IUEGETTOK; cleaned up
	 2 Sep 92  PJL	replaced IZDBASE with IUER_MLOG
	24 Feb 93  PJL  added version.os branch to handle Version 3 UNIX/Ultrix
			problem with the /none keyword
	 8 Jun 94  PJL  replaced !version with PLATFORM
        2 Sep 94  LLT  IUER_MLOG ---> !iuer.mlog
        2 Nov 94  PJL  added MULDIRFF;  changed !iuer.mlog to !iuer.database

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


IDBDATE

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

	IDBDATE

*CLASS:

*CATEGORY:

*PURPOSE:

	Convert a date format of 25-mar-1980 21:40:00 to a Julian date,
       observation year (80), and observation day (85).

*CALLING SEQUENCE:

	IDBDATE,OBSDAT,JULIAN,OBSYR,OBSDAY

*PARAMETERS:

	OBSDAT	(REQ) (I) (0) (S)
		The observation date in the format, '25-mar-1980 21:40:00'.

	JULIAN	(REQ) (O) (0) (D)
		The Julian date.

	OBSYR	(REQ) (O) (0) (I)
		The last to digits of the observation year.

	OBSDAY	(REQ) (O) (0) (I)
		The observation day number.

*EXAMPLES:

	obsdat = '28-aug-1990 01:30:40'
	idbdate,obsdat,julian,obsyr,obsday
	julian = 2448131.5625
	obsyr = 90
	obsday = 240

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

	none

*SUBROUTINES CALLED:

	PARCHECK
	JULDATE

*FILES USED:

	none

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

	18 May 92  PJL  wrote
	19 May 92  PJL  added Julian date
       07 Dec 92  RWT  compile expv2:juldate
	27 Apr 93  PJL  make sure hour and minute are not blank
	13 Sep 93  PJL  changed Julian date to Modified Julian date;  updated
			prolog
       26 Aug 94  PJL  changed Modified Julian date to Julian date - with all
                       the digits
       18 Nov 94  PJL  add use of seconds to call to JULDATE
	12 Apr 95  PJL  make month lowercase

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


IDBEXT

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

   	IDBEXT

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	Procedure to extract values of up to 12 items from data base file,
	and place into IDL variables

*CALLING SEQUENCE:

   	IDBEXT,QDB,QITEMS,QDBREC,LIST,ITEMS,V1,v2,v3,v4,v5,v6,v7,v8,v9,
	   v10,v11,v12

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

	QDBREC	(REQ) (I)
               QDBREC(i) contains the entry number in the second data base
               corresponding to entry i in the first data base.

   	LIST	(REQ) (I)
		list of entry numbers to be printed, vector or scalar
          	If list = -1, then all entries will be extracted.
          	list may be converted to a vector by IDBEXT 

   	ITEMS	(REQ) (I)
		standard item list specification.  See DBPRINT for 
          	the 6 different ways that items may be specified. 

   	V1	(REQ) (O)
		the vectors of values for up to 12 items.

	V2...V12   (OPT) (O)
		   the vectors of values for up to 12 items.

*EXAMPLES:

   	Extract all RA and DEC values from the currently opened database, and
   	place into the IDL vectors, IDLRA and IDLDEC.
          idbext,qdb,qitems,qdbrec,-1,'RA,DEC',idlra,idldec

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	IUEZPARCH
	IDB_ITEM
	IDB_INFO
	IDBITINF
	IDBEXT_DBF
	IDBEXT_IND

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

	version 2  D. Lindler  NOV. 1987
       check for INDEXED items   W. Landsman   Feb. 1989
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL  renamed DBEXT to IDBEXT; added PARCHECK and npar
			eq 0 print
	30 Jul 92  PJL  added IUEDB to calling sequence; replaced IZPARCHECK
			with IUEZPARCH; clean up
	 3 Aug 92  PJL  corrected npar
	13 Aug 92  PJL  replaced IUEDB structure with QDB, QITEMS, and QDBREC
			parameters; updated prolog
	25 Aug 92  PJL  removed use of !err
       20 Jun 94  PJL  renamed IDB_ITEM_INFO to IDBITINF

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


IDBEXT_DBF

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

   	IDBEXT_DBF

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	Procedure to extract values of up to 12 items from a data base file. 
   	This is a subroutine of IDBEXT, which is the routine a user should 
   	normally use.

*CALLING SEQUENCE:

   	IDBEXT_DBF,QDB,QITEMS,QDBREC,LIST,DBNO,SBYTE,NBYTES,IDLTYPE,
	   NVAL,V1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

	QDBREC	(REQ) (I)
               QDBREC(i) contains the entry number in the second data base
               corresponding to entry i in the first data base.

    	LIST	(REQ) (I)
		list of entry numbers to extract desired items.   It is the 
           	entry numbers in the primary data base unless dbno is greater 
           	than or equal to -1.  In that case it is the entry number in 
           	the specified data base.

    	DBNO	(REQ) (I)
		number of the opened db file if set to -1 then all databases
		are included

    	SBYTE	(REQ) (I)
		starting byte in the entry.  If single data base then it must 
            	be the starting byte for that data base only and not the 
            	concatenation of db records 

    	NBYTES	(REQ) (I)
		number of bytes in the entry

    	IDLTYPE	(REQ) (I)
		idl data type of each item to be extracted

    	NVAL	(REQ) (I)
		number of values per entry of each item to be extracted

    	V1	(REQ) (O)
		the vectors of values for up to 12 items

	V2...V12   (OPT) (O)
		   the vectors of values for up to 12 items

*EXAMPLES:

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	IDB_INFO
	IDBRD

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

	version 1  D. Lindler  Nov. 1987
       Extract multiple valued entries    W. Landsman   May 1989
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL  renamed DBEXT_DBF to IDBEXT_DBF; added PARCHECK
			and npar eq 0
	30 Jul 92  PJL  replaced common block with IUEDB structure to be
			passed between procedures; cleaned up
	13 Aug 92  PJL  replaced IUEDB structure with QDB, QITEMS, and QDBREC
			parameters; updated prolog

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


IDBEXT_IND

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

   	IDBEXT_IND

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	Routine to read a indexed item values from index file

*CALLING SEQUENCE:

   	IDBEXT_IND,QDB,QITEMS,LIST,ITEM,DBNO,VALUES

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

   	LIST	(REQ) (I)
		list of entry numbers to extract values for
	   	(if it is a scalar, values for all entries are extracted)

   	ITEM	(REQ) (I)
		item to extract

   	DBNO	(REQ) (I)
		number of the opened data base

   	VALUES	(REQ) (O)
		vector of values returned as function value

*EXAMPLES:

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	IDB_INFO
	IDB_ITEM
	IDBITINF

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

	version 1  D. Lindler  Feb 88
	26 Mar 92  PJL 	added prolog
	 1 Apr 92  PJL  renamed DBEXT_IND to IDBEXT_IND; added PARCHECK and
			npar eq 0 print
	30 Jul 92  PJL  added IUEDB to call; cleaned up
	13 Aug 92  PJL  replaced iuedb structure with qdb and qitems parameters;
			updated prolog
	25 Aug 92  PJL  removed use of !err
       20 Jun 94  PJL  renamed IDB_ITEM_INFO to IDBITINF

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


IDBFIND

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

   	IDBFIND 

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	Procedure to search data base for entries with specified
   	search characteristics.

*CALLING SEQUENCE:

   	IDBFIND,QDB,QITEMS,QDBREC,SPAR,RESULT,COUNT,listin,silent=silent

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

	QDBREC	(REQ) (I)
               QDBREC(i) contains the entry number in the second data base
               corresponding to entry i in the first data base.

	SPAR	(REQ) (I)
		search_parameters (string)...each search parameter 
                is of the form:

	        option 1) min_val < item_name < max_val
		option 2) item_name = value
               option 3) item_name = [value_1, value_10]
                         Note: option 3 is also the slowest.
		option 4) item_name > value
		option 5) item_name < value
		option 6) item_name = value(tolerance) ;eg. temp=25.0(5.2)
		option 7) item_name			;must be non-zero

	      Multiple search parameters are separated by a comma.
		eg.     'cam_no=2,14 is interpreted as greater than or equal.
	
	      RA and DEC keyfields are stored as floating point numbers 
               in the data base may be entered as HH:MM:SEC and
		DEG:MIN:SEC. Where:

			HH:MM:SEC   equals  HH + MM/60.0  + SEC/3600.
			DEG:MIN:SEC equals DEG + MIN/60.0 + SEC/3600.
			
		For example:
		  40:34:10.5 < dec < 43:25:19 , 8:22:1.0 < ra < 8:23:23.0

	      Specially encoded date/time in the data base may
		be entered by  YY/DAY:hr:min:sec which is
		interpreted as  
                       YY*1000+DAY+hr/24.0+min/24.0/60.+sec/24.0/3600.

		For example
			85/201:10:35:30

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


IDBFINDE

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

   	IDBFINDE  (formerly IDBFIND_ENTRY)

*CLASS:

*CATEGORY:

	database

*PURPOSE:

  	This is a subroutine of idbfind and is not a standalone procedure
  	It performs a entry number search.

*CALLING SEQUENCE:

	IDBFINDE,TYPE,SVALS,NENTRIES,VALUES,COUNT

*PARAMETERS:

   	TYPE	(REQ) (I)
		type of search (output from dbfparse)

   	SVALS	(REQ) (I)
		search values (output from dbfparse)

   	VALUES	(REQ) (I)
		array of values to search

  	GOOD	(REQ) (O)
		indices of good values

	COUNT	(REQ) (O)
		The number of good values.

*EXAMPLES:

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

   	D. Lindler  July,1987
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL  renamed DBFIND_ENTRY and IDBFIND_ENTRY; added
			PARCHECK and npar eq 0
	31 Jul 92  PJL  cleaned up
	25 Aug 92  PJL  removed the use of !err; added COUNT to the calling
			sequence
       20 Jun 93  renamed from IDBFIND_ENTRY to IDBFINDE

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


IDBFINDS

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

   	IDBFINDS  (formerly IDBFIND_SORT)

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	This is a subroutine of IDBFIND and is not a standalone procedure

*CALLING SEQUENCE:

	IDBFINDS,QDB,QITEMS,IT,TYPE,SVALS,LIST,NUMBER

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

	IT	(REQ) (I)
		item number, scalar

	TYPE	(REQ) (I)
		type of search (output from dbfparse)

	SVALS	(REQ) (I)
		search values (output from dbfparse)

	LIST	(REQ) (I/O)
		found entries

	NUMBER	(REQ) (O)
		Number of valid entries.

*EXAMPLES:

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	IDB_INFO
	IDBITINF
	IDBSEARCH
	IMATCH

*FILES USED:

*SIDE EFFECTS:

       number = -2 for an invalid search

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

    	D. Lindler  July,1987
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL	renamed DBFIND_SORT to IDBFIND_SORT; added PARCHECK
			and npar eq 0 print
	31 Jul 92  PJL  added IUEDB parameter to procedure call; cleaned up
	13 Aug 92  PJL  replaced iuedb structure with qdb and qitems parameters;
			updated prolog
	17 Aug 92  PJL  replaced !err with number; added number to calling
			sequence
       20 Jun 94  PJL  renamed IDB_ITEM_INFO to IDBITINF; renamed from
                       IDBFIND_SORT to IDBFINDS

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


IDBFPARSE

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

   	IDBFPARSE

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	Subroutine of IDBFIND

*CALLING SEQUENCE:

   	IDBFPARSE,SPAR,ITEMS,STYPE,VALUES

*PARAMETERS:

   	SPAR	(REQ) (I)
		search parameter specification

   	ITEMS	(REQ) (O)
		list of items to search on

   	STYPE	(REQ) (O)
		search type

   	VALUES	(REQ) (O)
		search values

*EXAMPLES:

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	IUEGETTOK

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

   	D. Lindler NOV, 1987
	26 Mar 92  PJL	addedprolog
	 1 Apr 92  PJL  rename DBFPARSE to IDBFPARSE; added PARCHECK and
			npar eq 0 print
	 3 Aug 92  PJL  cleaned up

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


IDBGET

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

   	IDBGET

*CLASS:

*CATEGORY:

	database

*PURPOSE:

   	Find entry number of fields which contain specified values in
   	a specified item.  IDBGET is an altnerative to IDBFIND when the
   	desired search values are not easily expressed as a string.  

*CALLING SEQUENCE:

   	IDBGET,QDB,QITEMS,QDBREC,ITEM,VALUES,LIST,listin,silent=silent)

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

	QDBREC	(REQ) (I)
               QDBREC(i) contains the entry number in the second data base
               corresponding to entry i in the first data base.

   	ITEM	(REQ) (I)
		Item name or number

   	VALUES	(REQ) (I)
		 scalar or vector containing item values to search for.

   	LIST	(REQ) (O)
		vector giving the entry number of entries containing desired
          	item values.  The number of elements in  LIST may be different 
          	from that of VALUE, since a value might be located zero, once, 
          	or many times in the database.  Use the function DBMATCH if a 
          	one to one correspondence is desired between VALUES and LIST. 

   	LISTIN	(OPT) (I)
		list of entries to be searched.  If not supplied, or
            	set to -1, then all entries are searched

    	SILENT	(OPT) (I) (keyword)
		If this keyword is supplied, then IDBGET will not display
          	the number of entries found

*EXAMPLES:

   	Get info on selected HD stars in Bright Star catalogue

   	IDL> idbopen,qdb,qitems,qdbrec,'yale_bs'
   	IDL> hd_no = [1141,2363,3574,4128,6192,6314,6668]  ; Desired HD numbers
       Get corresponding entry numbers
   	IDL> idbget,qdb,qitems,qdbrec,'hd_no',hd_no,list

*SYSTEM VARIABLES USED:

	none

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	IDB_ITEM
	IDBITINF
	IDBEXT
	IDBSEARCH
	IDBFINDS
	IDB_INFO

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

*I_HELP  nn:

*MODIFICATION HISTORY:

   	Written,    W. Landsman      STX     February, 1989
	26 Mar 92  PJL	added prolog
	 1 Apr 92  PJL	renamed DBGET to IDBGET; added PARCHECK and
			npar eq 0 print
	 3 Aug 92  PJL  changed from a function to a procedure; add IUEDB
			to the calling sequence
	13 Aug 92  PJL  replaced IUEDB structure with QDB, QITEMS, and QDBREC
			parameters; updated prolog
	17 Aug 92  PJL  removed !err
	25 Aug 92  PJL  change in IDBFIND_SORT calling sequence
       20 Jun 94  PJL  renamed IDB_ITEM_INFO to IDBITINF and IDBFIND_SORT to
                       IDBFINDS

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


IDBHELP

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

   	IDBHELP

*CLASS:

*CATEGORY:

*PURPOSE:

   	Procedure to either list available databases (if no database is 
   	currently open) or the items in the currently open database.

*CALLING SEQUENCE:

   	IDBHELP,QDB,QITEMS,flag,textout=textout

*PARAMETERS:

	QDB	(REQ) (I)
               QDB(*,i) contains the following for each data base opened bytes
                 0-18   data base name character*19
                 19-79  data base title character*61
                 80-81  number of items (integer*2)
                 82-83  record length of DBF file (integer*2)
                 84-87  number of entries in file (integer*4)
                 88-89  position of first item for this file in QITEMS (I*2)
                 90-91  position of last item for this file (I*2)
                 92-95  Last Sequence number used (item=SEQNUM) (I*4)
                 96     Unit number of .DBF file
                 97     Unit number of .IND file (0 if none exists)
                 98-99  Index number of item pointing to this file
                          (0 for first db)
                 100-103 Number of entries with space allocated
                 104    Update flag (0 open for read only, 1 open for update)

	QITEMS	(REQ) (I)
               QITEMS(*,i) contains decription of item number i with following
               byte assignments:
                 0-19    item name (character*20)
                 20-21   IDL data type (integet*2)
                 22-23   Number of values for item (1 for scalar) (integer*2)
                 24-25   Starting byte position in original DBF record
                           (integer*2)
                 26-27   Number of bytes per data value (integer*2)
                 28      Index type
                 29-97   Item description
                 98-99   Print format field length
                 100     Flag set to one if pointer item
                 101-119 Data base this item points to
                 120-125 Print format
                 126-170 Print headers
                 171-172 Starting byte in record returned by DBRD
                 173-174 Data base number in QDB
                 175-176 Data base number this item points to
                 177-178 item number within file

    	FLAG	(OPT) (I)
		if set to nonzero then item or database descriptions are
		also printed.  default=0
	     	If flag is a string, then it is interpreted as the
	     	name of a data base (if no data base is opened) or a name 
            	of an item in the opened data base.   In this case, help
            	is displayed only for the particular item or database

    	TEXTOUT (OPT) (I) (keyword)
		Used to determine output device.  If not present, the
            	value of !TEXTOUT system variable is used (see TEXTOPEN )
		 textout=1	Terminal with /MORE
		 textout=2	Terminal without /MORE
		 textout=3	.PRT
		 textout=4	LASER PRINTER
		 textout=5      USER MUST OPEN FILE;            

	No outputs.

*EXAMPLES:

*SYSTEM VARIABLES USED:

       !iuer.database
	!iuetextout
	!iuetextunit

*INTERACTIVE INPUT:

*SUBROUTINES CALLED:

	PARCHECK
	ITEXTOPEN
	IDB_INFO
	IDB_ITEM
	IDBITINF
	DECOMPOSE
	ITEXTCLOSE
       MULDIRFF

*FILES USED:

*SIDE EFFECTS:

*RESTRICTIONS:

*NOTES:

*PROCEDURE:

    	If no data base is opened then a list of data bases are
    	printed, otherwise the items in the open data base are printed.

    	If a string is supplied for flag and a data base is opened
    	flag is assumed to be an item name.  The information for that
    	item is printed along with contents in