FITS


List of Routines


Routine Descriptions

CHECK_FITS

[Next Routine] [List of Routines]
 NAME:
	CHECK_FITS
 PURPOSE:
	Given a FITS array IM, and a associated FITS or STSDAS header HDR, this
	procedure will check that
		(1) HDR is a string array, and IM is defined and numeric   
		(2) The NAXISi values in HDR are appropiate to the dimensions 
                   of IM
		(3) The BITPIX value in HDR is appropiate to the datatype of IM
	If HDR contains a DATATYPE keyword (as in STSDAS files), then this is 
	also checked against the datatype of of IM
	If the UPDATE keyword is present, then FITS header will be modified, if
	necessary, to force agreement with the image array

 CALLING SEQUENCE:
	check_FITS, im, hdr, [ dimen, idltype, /UPDATE, /NOTYPE, /SDAS ]

 INPUTS:
	IM -  FITS or  STSDAS array, (e.g. as read by SXREAD or READFITS )
	HDR - FITS or  STSDAS header (string array) associated with IM

 OPTIONAL OUTPUTS:
	dimen - vector containing actual array dimensions
	idltype- data type of the FITS array as specified in the IDL SIZE
		function (1 for BYTE, 2 for INTEGER*2, 3 for INTEGER*4, etc.)

 OPTIONAL KEYWORD INPUTS:
	/NOTYPE - If this keyword is set, then only agreement of the array
		dimensions with the FITS header are checked, and not the 
		data type.
	/UPDATE - If this keyword is set then the BITPIX, NAXIS and DATATYPE
		FITS keywords will be updated to agree with the array
	/SDAS - If this keyword is set then the header is assumed to be from
		an SDAS (.hhh) file.    CHECK_FITS will then ensure that (1)
		a DATATYPE keyword is included in the header and (2) BITPIX
		is always written with positive values.
	/FITS -  If this keyword is present then CHECK_FITS assumes that it is
		dealing with a FITS header and not an SDAS header, see notes
		below.

 SYSTEM VARIBLE:
	If there is a fatal problem with the FITS array or header then !ERR is
	set to -1.   ( If the UPDATE keyword was supplied, and the header could
	be fixed then !ERR = 0.)

 PROCEDURE:
	Program checks the NAXIS1 and NAXIS2 parameters in the header to
	see if they match the image array dimensions.

 NOTES:
	An important distinction between an STSDAS header and a FITS header
	is that the BITPIX value in an STSDAS is always positive, e.g. BITPIX=32
	for REAL*4 data.    Users should use either the /SDAS or the /FITS 
	keyword if it is important whether the STSDAS or FITS convention for 
	REAL*4 data is used.     Otherwise, CHECK_FITS assumes that if a 
	DATATYPE keyword is present then it is dealing with an STSDAS header.

 MODIFICATION HISTORY:
	Written, December 1991  W. Landsman Hughes/STX to replace CHKIMHD
	No error returned if NAXIS=0 and IM is a scalar   W. Landsman  Feb 93
	Fixed bug for REAL*8 STSDAS data W. Landsman July 93
	Make sure NAXIS agrees with NAXISi  W. Landsman  October 93

(See /usr/local/idl/lib/zastron/fits/check_fits.pro)


DFITSRD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DFITSRD
 PURPOSE:
	Convert true disk FITS formatted file(s) into STSDAS formatted file(s).
	Disk FITS refers to files (that can be created by IRAF or AIPS) that
	keep the exact format (e.g. 2880 byte record length) of a FITS tape.  
	STSDAS files have a detached header and 512 byte record length. 

 CALLING SEQUNCE: 
	DFITSRD, infile, outname, [ /NOPROMPT ]

 INPUTS:
	INFILE = input FITS file name (default extension .DAT), scalar string
	OUTNAME = output file name (ALWAYS has extensions .hhh for header and 
		.hhd for data; user supplied extensions are ignored.   Scalar
		string

 INTERACTIVE INPUT:
	User will be prompted if INFILE or OUTNAME are undefined or integers.

 NOTES:
	Output files are always created with the extensions .hhh (header) and 
	.hhd (data).     DFITSRD is a shell for the procedure DFITSREAD which
	does the actual processing of the FITS file.

 INPUT KEYWORD PARAMETERS:
	NOPROMPT - If this keyword is set then DFITSRD will not prompt for 
		another file name to be processed.  This keyword is useful 
		when DFITSRD is called from a driver procedure.

 SIDE EFFECTS:
	For each FITS disk file STSDAS disk files will be created
	with names:
		name.hhh and name.hhd
	Fits extension files will have names:
		name_x.HHH and name_x.HHD
	where x runs from 1 to the number of extensions.

 EXAMPLES:
	(1) Prompt for input and output file names
		IDL> dfitsrd,1
  
	(2) Write FITS image, ngc598.fits to an STSDAS files m33.hhh/d 
		IDL> dfitsrd,'ngc598.fits','m33'

 PROCEDURES USED:
	dfitsread, fdecomp, datatype

 MODIFICATION HISTORY:
	B. Pfarr - adapted from FITSRD, modified to read from disk 8/88
	W. Lansdman - display calling sequence if no params suplied Sep. 92

(See /usr/local/idl/lib/zastron/fits/dfitsrd.pro)


DFITSRD_LARGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   DFITSRD_LARGE
 PURPOSE:
   Convert true disk FITS formatted file(s) into STSDAS formatted file(s).
   Disk FITS refers to files (that can be created by IRAF or AIPS) that
   keep the exact format (e.g. 2880 byte record length) of a FITS tape.  
   STSDAS files have a detached header and 512 byte record length. 
 CALLING SEQUNCE: 
   DFITSRD_LARGE,infile,outname
 OPTIONAL INPUTS:
   INFILE = string, input file name (default extension .DAT)
   OUTNAME = string, output file name (ALWAYS has extensions 
      	       .hhh for header and .hhd for data; user supplied extensions
              are ignored.
 INTERACTIVE INPUT:
   If user does not pass infile and/or outname in as parameters,
   user will be prompted for input file names (default extension .DAT),
   and output file names.   Output files are always created with the
   extensions .hhh (header) and .hhd (data).
 INPUT KEYWORD PARAMETERS:
   NOPROMPT - If this keyword is set then DFITSRD_LARGE will not prompt for
              another file name to be processed.  This keyword is useful when
              DFITSRD_LARGE is called from a driver procedure.
 SIDE NOTES:
    Use DFITSRD instead of DFITSRD_LARGE for small to moderately sized
    files.  It is much faster.  Use DFITSRD_LARGE if you do not have a
    large enough dynamic memory allocation to read the file with DFITSRD.
 SIDE EFFECTS:
	For each FITS disk file STSDAS disk files will be created
	with names:
		name.hhh and name.hhd
	Fits extension files will have names:
		name_x.HHH and name_x.HHD
	where x runs from 1 to the number of extensions.
 MODIFICATION HISTORY:
       B. Pfarr - adapted from FITSRD, modified to read from disk 8/88
	W. Thompson - changed call to DFITSREAD to DFITSREAD_LARGE, 4/91

(See /usr/local/idl/lib/zastron/fits/dfitsrd_large.pro)


DFITSREAD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DFITSREAD
 PURPOSE:
	Procedure will read a disk FITS file and write to a STSDAS disk file.
	The header is placed in .HHH and the data is placed in the file 
	.HHD.  This procedure is called by DFITSRD which is the procedure
	that an interactive user would normally use.

 CALLING SEQUENCE: 
	dfitsread, unit, name, [ EXTEN= , NBTYES = ]

 INPUTs:
	unit - unit number of opened input file
	name - file name (without an extension)

 OPTIONAL OUTPUT KEYWORDS:
	EXTEN = This keyword is set to 1 if the FITS header contains the 
		keyword EXTEND = T,  otherwise, exten = 0
		NOTE: exten = 1 does NOT gaurantee extensions are present
	NBYTES - Contains the number of bytes written to disk, integer scalar

 OUTPUT:
	name - name of file if input keyword parameter is supplied
 SIDE EFFECTS:
	files name.hhh and name.hhd are created
 HISTORY:                               
	B. Pfarr - adapted from FITSREAD to handle disk files
	Converted to Version 2 IDL,  K. Bhagat,  August 1990
	Added call to IEEE_TO_HOST, single I/O calls, W. Landsman   Jan, 1992
	Force SIMPLE = 'F' in STSDAS file    W. Landsman Aug 1993

(See /usr/local/idl/lib/zastron/fits/dfitsread.pro)


DFITSREAD_LARGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   DFITSREAD_LARGE
 PURPOSE:
   Procedure will read a disk FITS file 
   The header is placed in .HHH and the data is
   placed in the file .HHD.  Called by DFITSRD_LARGE
 CALLING SEQUENCE: 
   dfitsread_large,unit,name,exten=exten
 INPUTs:
   unit - unit number of opened input file
   name - file name (without an extension)
 KEYWORD:
   exten = exten - 
	    If header keyword EXTEND = T, exten = 1, otherwise, exten = 0
      	    exten = 1 does NOT gaurantee extensions are present
 OUTPUT:
	name - name of file if input keyword parameter is supplied
 SIDE NOTES:
    Use DFITSREAD instead of DFITSREAD_LARGE for small to moderately sized
    files.  It is much faster.  Use DFITSREAD_LARGE if you do not have a
    large enough dynamic memory allocation to read the file with DFITSREAD.
 SIDE EFFECTS:
	files name.hhh and name.hhd are created
 HISTORY:                               
    B. Pfarr - adapted from FITSREAD to handle disk files
    Converted to Version 2 IDL,  K. Bhagat,  August 1990
    W. T. Thompson  May, 1990, changed to write data to
		disk in pieces rather than all at once at the end
		of a group.

(See /usr/local/idl/lib/zastron/fits/dfitsread_large.pro)


DFITSWRITE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:   
	DFITSWRITE
 PURPOSE:
	Procedure will write an internal SDAS file to a FITS file on disk.
	Note: Called by DFITSWRT

 CALLING SEQUENCE:
	DFITSWRITE, unit, file [, KEYWORD]

 INPUTS:
	unit - IDL logical unit number
	file - internal FITS file name without extension (extension
		is assumed to be .HHH and .HHD)

 OPTIONAL INPUT:
	keyword - FITS keyword to place file name into.  if not supplied
		or equals '' then the file name is not put into the
		header before writing it to disk FITS file.

 SIDE EFFECT:
	A FITS file is written to disk.

 PROCEDURE CALLS:
	remchar, sxhread, sxpar, fdecomp, sxaddpar, host_to_ieee

 HISTORY:
	version 3  D. Lindler   Nov. 1986                
	version 5  B. Pfarr  modified from FITSWRITE
	Added HOST_TO_IEEE call W. Landsman            January, 1992
	Remove dummy SDAS group parameters             February, 1992

(See /usr/local/idl/lib/zastron/fits/dfitswrite.pro)


DFITSWRT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:	
	DFITSWRT
 PURPOSE: 
	Convert ST/SDAS formatted files to true disk FITS formatted file(s).
	D(isk) fits: refers to files (that can be created by IRAF or AIPS) that
	keep the exact format (e.g. 2880 byte record length) of a FITS tape.  
	ST/SDAS files: has detached header and 512 byte record length. 

 CALLING SEQUENCE:
	DFITSWRT , iname, oname, [ EXTEND =  ]

 INPUT:
	iname  - name of existing ST/SDAS formatted file to be converted.
		if iname is set to 1, then user will be prompted for file names.
	oname - output file name for to disk FITS file [default DFITS]
		note: user may also specify extension for filename...default
		is .FITS (i.e. DFITS.FITS).

 KEYWORD:
	EXTEND  - Set this keyword nonzero if you want DFITSWRT to include 
		any SDAS table extensions files into the disk FITS output.
		The table extensions must be of the form iname_extnumber 
		(see example).  
 EXAMPLES:
	(1)   Run DFITSWRT interactively

	IDL> dfitswrt,1

	(2)    You have files SDAS.HHH and SDAS.HHD plus additional SDAS tables 
		or other groups:

		DFITSWRT,'SDAS','SDAS',/EXTEND

		Note: as the disk FITS file is created, it will look for
		the SDAS group (or tables) named:
			sdas_1.hhh  and sdas_1.hhd
			sdas_2.hhh  and sdas_2.hhd
                             .
                             :
           Note: the number of group(or table) files depends on the
               number of existing SDAS group(or table) input files.
           The output file will be named SDAS.FITS

 NOTES:
	DFITSWRT does not do any validity checking on the FITS header
	In particular, be sure that the FITS header has EXTEND = 'T'
	if extensions are included.     

 MODIFICATION HISTORY:
	version 3  D. Lindler  Nov 86
       Fixed use of /EXTEND keyword, cleaned up documentation 
                                      W. Landsman  ST Systems  October 91

(See /usr/local/idl/lib/zastron/fits/dfitswrt.pro)


FITSDIR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      FITSDIR 
 PURPOSE:
      Provide a brief description of the FITS  files on a disk.   The values
      of the FITS keywords NAXISi, OBS-DATE, TELESCOPE, OBJECT, EXPTIME are
      displayed.    All of these are commonly used FITS keywords and all
      except EXPTIME are officially reserved FITS keywords.

 CALLING SEQUENCE:
      FITSDIR , [ directory, TEXTOUT =, NoTelescope = ] 

 OPTIONAL INPUT PARAMETERS:
      DIRECTORY - Scalar string giving file name, disk or directory to be 
          searched.   Wildcard file names are allowed.    Examples of 
          valid VMS or Unix names include '*.fit' or 'tape*'.    An example
          of a valid VMS name is  'UIT$USER2:[JONES]*.FIT' while a valid 
          Unix string is 'iraf/*.fits'.

          If not given, FITSDIR searches *.fits files in the default 
          directory.

 OPTIONAL KEYWORD INPUT PARAMETER
      NOTELESCOPE - If this keyword is set and non-zero then the value of 
           the (usually less important) TELESCOPE keyword is not displayed, 
            and more space is available to display the other keyword values
                                                                    
     TEXTOUT - Controls output device as described in TEXTOUT procedure
	       textout=1      TERMINAL using /more option
	       textout=2      TERMINAL without /more option
	       textout=3      .prt
	       textout=4      laser.tmp
	       textout=5      user must open file
              textout = filename (default extension of .prt)

 OUTPUT PARAMETERS:
     None.

 RESTRICTIONS:
     (1)   Field values may be truncated if their length exceeds the default
           format.

           File name    NAXISi    OBS-DATE    TELESCOPE    OBJECT    EXPTIME
            A18           A11       A10          A10        A20        F7.1
            A20           A12       A10                     A29        F7.1

     (2)   Only reads the primary FITS headers.    FITS files containing
           only extensions (binary or ASCII tables) may have little
           information in their primary header.    

     (3)   Users may wish to modify the program to display other FITS 
           keywords of particular interest to them
 EXAMPLES:  
      IDL> fitsdir          ;Print info on all '*.fits' files in current 
                             directory.     
     IDL> fitsdir ,'*.fit'   ;Lists all '*.fit' files in current directory 
     IDL> fitsdir ,'tape*'   ;Print info on all tape* files in current 
                             ;directory.    Files meeting the wildcard name
                             ;that are not FITS files are ignored

     Write info on all *.fits files in the Unix directory /usr2/smith, to a 
     file 'smith.txt' and don't display the value of the TELESCOPE keyword

     IDL> fitsdir ,'/usr2/smith/*.fits',t='smith.txt', /NoTel 

 PROCEDURE:
     FINDFILE is used to find the specified FITS files.   The header of
     each file is read, and rejected if the file is not FITS.    Each header 
     searched for the parameters NAXISi, TELESCOP, OBJECT, DATE-OBS and 
     EXPTIME.  

 SYSTEM VARIABLES:
     If textout keyword is not used to select an output device, then the 
     non-standard system variable !TEXTOUT  will be the default.

 PROCEDURES USED:
     ZPARCHECK, FDECOMP,  SPEC_DIR, TEXTOPEN, TEXTCLOSE
 MODIFICATION HISTORY:
     Written, W. Landsman,  HSTX    February, 1993

(See /usr/local/idl/lib/zastron/fits/fitsdir.pro)


FITS_INFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FITS_INFO
 PURPOSE:
	Provide information about the contents of a FITS file, (primary header
	and data if any + extensions).    Information is printed at the terminal
	and/or stored in a common block

 CALLING SEQUENCE:
	FITS_INFO, filename, [ SILENT = , TEXTOUT = , N_ext = ]

 INPUT:
	FILENAME = Scalar or vector string giving the name of the FITS file(s)
		Can include wildcards such as '*.fits'

 OPTIONAL INPUT KEYWORDS:
	SILENT - This key word will suppress display of the file description
		on the terminal
	TEXTOUT - specifies output device.
		textout=1        TERMINAL using /more option
		textout=2        TERMINAL without /more option
		textout=3        .prt
		textout=4        laser.tmp
		textout=5        user must open file, see TEXTOPEN
		textout = filename (default extension of .prt)

 OPTIONAL OUTPUT KEYWORD:
	N_ext - Returns an integer scalar giving the number of extensions in
		the FITS file

 COMMON BLOCKS
	DESCRIPTOR =  File descriptor string of the form N_hdrrec Naxis IDL_type
		Naxis1 Naxis2 ... Naxisn [N_hdrrec table_type Naxis
		IDL_type Naxis1 ... Naxisn] (repeated for each extension) 
		See the procedure RDFITS_STRUCT for an example of the
		use of this common block

 EXAMPLE:
 	Display info about all FITS files of the form '*.fit' in the current
		directory

		IDL> fits_info, '*.fit'

	Any time a *.fit file is found which is *not* in FITS format, an error 
	message is displayed at the terminal and the program continues

 PROCEDURES USED:
	GETTOK, STRN, SXPAR, TEXTOPEN, TEXTCLOSE 

 SYSTEM VARIABLES:
	Uses the non-standard system variable !TEXTOUT to select an output
	device if the TEXTOUT keyword is not supplied

 MODIFICATION HISTORY:
	Written, K. Venkatakrishna, Hughes STX, May 1992
	Added N_ext keyword, and table_name info, G. Reichert
	Some cleaning up of the code W. Landsman   October 1992
	Work on *very* large FITS files   October 92

(See /usr/local/idl/lib/zastron/fits/fits_info.pro)


HEADFITS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	HEADFITS
 CALLING SEQUENCE:
	Result = headfits( filename ,[ EXTEN = ])

 PURPOSE:
	Read a FITS file header record      

 INPUTS:
	FILENAME = String containing the name of the FITS file to be read.

 OPTIONAL INPUT KEYWORD:
	EXTEN  = integer scalar, specifying which FITS extension to read.
		For example, to read the header of the first extension set
		EXTEN = 1.   Default is to read the primary FITS header 
		(EXTEN = 0).

 OUTPUTS:
	Result of function = FITS header, string array

 EXAMPLE:
	Read the FITS header of a file 'test.fits' into a string variable, h

	IDL>  h = headfits( 'test.fits')

 MODIFICATION HISTORY:
	adapted by Frank Varosi from READFITS by Jim Wofford, January, 24 1989
	Keyword EXTEN added, K.Venkatakrishna, May 1992
	Make sure first 8 characters are 'SIMPLE'  W. Landsman October 1993

(See /usr/local/idl/lib/zastron/fits/headfits.pro)


MKHDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	MKHDR
 PURPOSE:
	Make a minimal primary FITS image header or a minimal FITS IMAGE
	extension header.   If an array is supplied  then the 
	created FITS header will be appropiate to the supplied array.  
 	Otherwise, the user can specify the dimensions and datatype.

 CALLING SEQUENCE:
	MKHDR, header			;Prompt for image size and type
		or
	MKHDR, header, im, [ /IMAGE, /EXTEND ]
		or
	MKHDR, header, type, naxisx, [/IMAGE, /EXTEND ]    	

 OPTIONAL INPUTS:
	IM - If IM is a vector or array then the header will be made
		appropiate to the size and type of IM.  IM does not have
		to be the actual data; it can be a dummy array of the same
		type and size as the data.    Set IM = '' to create a dummy
		header with NAXIS = 0. 
	TYPE - If more than 2 parameters are supplied, then the second parameter
		is intepreted as an integer giving the IDL datatype e.g. 
		1 - LOGICAL*1, 2 - INTEGER*2, 4 - REAL*4, 3 - INTEGER*4
	NAXISX - Vector giving the size of each dimension (NAXIS1, NAXIS2, 
		etc.).  

 OUTPUT:
	HDR - image header, (string array) with required keywords
		BITPIX, NAXIS, NAXIS1, ... Further keywords can be added
		to the header with SXADDPAR. 

 OPTIONAL INPUT KEYWORDS:
	IMAGE   = If set, then a minimal header for a FITS IMAGE extension
		is created.    An IMAGE extension header is identical to
		a primary FITS header except the first keyword is 
		'XTENSION' = 'IMAGE' instead of 'SIMPLE  ' = 'T'
	EXTEND	= If set, then the keyword EXTEND is inserted into the file,
		with the value of "T" (true).

 RESTRICTIONS:
	(1)  MKHDR should not be used to make an STSDAS header or a FITS
		ASCII or Binary Table header.   Instead use

		SXHMAKE - to create a minimal STSDAS header
		FXHMAKE - to create a minimal FITS binary table header
		FTCREATE - to create a minimal FITS ASCII table header

	(2)  Any data already in the header before calling MKHDR
		will be destroyed.
 EXAMPLE:
	Create a minimal FITS header, HDR, for a 30 x 40 x 50 INTEGER*2 array

	      IDL> MKHDR, HDR, 2, [30,40,50]

	Alternatively, if the array already exists as an IDL variable, ARRAY,

	       IDL> MKHDR, HDR, ARRAY

 PROCEDURES CALLED:
	SXADDPAR, GET_DATE

 REVISION HISTORY:
    Written November, 1988               W. Landsman
    May, 1990, Adapted for IDL Version 2.0, J. Isensee

(See /usr/local/idl/lib/zastron/fits/mkhdr.pro)


RDFITS_STRUCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RDFITS_STRUCT
 PURPOSE:
	Read an entire FITS file into an IDL structure.   Each header, image
	or table array is placed in a separate structure tag.

 CALLING SEQUENCE:
	RDFITS_STRUCT, filename, struct, [ /NODELETE, /SILENT ]

 INPUT:
	FILENAME = Scalar string giving the name of the FITS file

 OPTIONAL KEYWORD: 
	NODELETE -  RDFITS_STRUCT creates a temporary file with the name 
		temp_'fitsname'.pro which contains the IDL structure definition
		Normally, this temporary file is deleted -- set the /NODELETE
		keyword to keep it. 
	SILENT - Set this keyword to suppress informational displays at the
		terminal.

 OUTPUT:
    struct = structure into which FITS data is read.   The primary header
             and image are placed into tag names HDR0 and IM0.   Any
             extensions are placed into the tag names HDRi, TABi

 PROCEDURES USED:
	FITS_INFO, HEADFITS, GETTOK, READFITS, STRN, FDECOMP

 METHOD:
	The procedure FITS_INFO is used to determine whether a primary image
	exists and the number of extensions.     The number and type of
	structure tags required is written to a temporary file and assigned
	to an appropiate HEADFITS or READFITS call.     The temporary file
	is executed using CALL_PROCEDURE.   

 EXAMPLE:
	Read the FITS file 'm33.fits' into an IDL structure, st

	IDL> rdfits_struct, 'm33.fits', st
	IDL> help, /str, st                   ;Display info about the structure

 RESTRICTIONS:
	The current algorithm is not particularly efficient. The user must delete the
  temporary file under MacOS.

 MODIFICATION HISTORY:
	Written K. Venkatakrishna, STX April 1992
	Code cleaned up a bit  W. Landsman  STX  October 92
	Modified for MacOS     I.  Freedman  HSTX April 1994

(See /usr/local/idl/lib/zastron/fits/rdfits_struct.pro)


READFITS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	READFITS
 PURPOSE:
	Read a FITS file into IDL data and header variables.

 CALLING SEQUENCE:
	Result = READFITS( Filename,[ Header, /NOSCALE, EXTEN_NO = ,
			/SILENT , NaNVALUE = , STARTROW = , NUMROW = ] )

 INPUTS:
	FILENAME = Scalar string containing the name of the FITS file  
		(including extension) to be read.

 OUTPUTS:
	Result = FITS data array constructed from designated record.

 OPTIONAL OUTPUT:
	Header = String array containing the header from the FITS file.

 OPTIONAL INPUT KEYWORDS:
	NOSCALE - If present and non-zero, then the ouput data will not be
		scaled using the optional BSCALE and BZERO keywords in the 
		FITS header.   Default is to scale.

	SILENT - Normally, READFITS will display the size the array at the
		terminal.  The SILENT keyword will suppress this

	NaNVALUE - This scalar is only needed on Vax architectures.   It 
		specifies the value to translate any IEEE "not a number"
		values in the FITS data array.   It is needed because
		the Vax does not recognize the "not a number" convention.

	EXTEN_NO - scalar integer specify the FITS extension to read.  For
		example, specify EXTEN = 1 or /EXTEN to read the first 
		FITS extension.    Extensions are read using recursive
		calls to READFITS.

	POINT_LUN  -  Position (in bytes) in the FITS file at which to start
		reading.   Useful if READFITS is called by another procedure
		which needs to directly read a FITS extension.    Should 
		always be a multiple of 2880.

	STARTROW - This keyword only applies when reading a FITS extension
		It specifies the row (scalar integer) of the extension table at
		which to begin reading. Useful when one does not want to read 
		the entire table.

	NUMROW -  This keyword only applies when reading a FITS extension. 
		If specifies the number of rows (scalar integer) of the 
		extension table to read.   Useful when one does not want to
		read the entire table.

 EXAMPLE:
	Read a FITS file TEST.FITS into an IDL image array, IM and FITS 
	header array, H.   Do not scale the data with BSCALE and BZERO.

		IDL> im = READFITS( 'TEST.FITS', h, /NOSCALE)

	If the file contain a FITS extension, it could be read with

		IDL> tab = READFITS( 'TEST.FITS', htab, /EXTEN )

	To read only rows 100-149 of the FITS extension,

		IDL> tab = READFITS( 'TEST.FITS', htab, /EXTEN, 
					STARTR=100, NUMR = 50 )

 RESTRICTIONS:
		Cannot handle random group FITS

 NOTES:
	The procedure FXREAD can be used as an alternative to READFITS.
	FXREAD has the option of reading a subsection of the primary FITS data.

 PROCEDURES USED:
	Functions:   SXPAR, WHERENAN
	Procedures:  IEEE_TO_HOST, SXADDPAR

 MODIFICATION HISTORY:
	MODIFIED, Wayne Landsman  October, 1991
	Added call to TEMPORARY function to speed processing     Feb-92
	Added STARTROW and NUMROW keywords for FITS tables       Jul-92
	Close logical unit if EOF encountered
	Make SILENT keyword work for tables                      Oct-92
	Work under "windows"   R. Isaacman                       Jan-93
	Check for SIMPLE keyword in first 8 characters           Feb-93
	Removed EOF function for DECNET access                   Aug-93
	Work under "alpha"                                       Sep-93

(See /usr/local/idl/lib/zastron/fits/readfits.pro)


WRITEFITS

[Previous Routine] [List of Routines]
 NAME:
	WRITEFITS
 PURPOSE:
	Write an an IDL array into a disk FITS file.    Works with all types
	of FITS files except random groups

 CALLING SEQUENCE:
	writefits, filename, data [, header, NaNvalue = , /APPEND] 

 INPUTS:
	FILENAME = String containing the name of the file to be written.

	DATA = Image array to be written to FITS file.    If DATA is 
              undefined or a scalar, then only the FITS header (which
              must have NAXIS = 0) will be written to disk

 OPTIONAL INPUT:
	HEADER = String array containing the header for the FITS file.
		 If variable HEADER is not given, the program will generate
		 a minimal FITS header.

 OPTIONAL INPUT KEYWORD:
       NaNvalue - Value in the data array to be set to the IEEE NaN
                 condition.   This is the FITS representation of undefined
                 values 
       APPEND - If this keyword is set then the supplied header and data
                array are assumed to be an extension and are appended onto
                the end of an existing FITS file.    Note that the primary
                header in the existing file must already have an EXTEND
                keyword to indicate the presence of an FITS extension.

 OUTPUTS:
	None

 RESTRICTIONS:
       (1) It recommended that BSCALE and BZERO not be used (or set equal
           to 1. and 0) with REAL*4 or REAL*8 data.
       (2) WRITEFITS will remove any group parameters from the FITS header

 EXAMPLE:
       Write a randomn 50 x 50 array as a FITS file creating a minimal header.

       IDL> im = randomn(seed, 50, 50)        ;Create array
       IDL> writefits, 'test', im             ;Write to a FITS file "test"

 PROCEDURES USED:
       CHECK_FITS, HOST_TO_IEEE, SXDELPAR, SXADDPAR, SXPAR

 MODIFICATION HISTORY:
	WRITTEN, Jim Wofford, January, 29 1989
       MODIFIED, Wayne Landsman, added BITPIX = -32,-64 support for UNIX
       Use new BYTEODER keywords 22-Feb-92
       Modify OPENW for V3.0.0   W. Landsman       Dec 92
       Work for "windows"   R. Isaacman            Jan 93
	More checks for null data                   Mar 94

(See /usr/local/idl/lib/zastron/fits/writefits.pro)