idlastro / Disk I/O (e.g. IRAF files): IRAFWRT

[Source code]

NAME
IRAFWRT
PURPOSE
Write IDL data in IRAF (OIF) format (.imh and .pix files).
EXPLANATION
Does the reverse of IRAFRD.    IRAFWRT writes the "old" IRAF format
used prior to v2.11.   However, this "old" format is still readable by
the current version of IRAF.
CALLING SEQUENCE
IRAFWRT, image, hdr, filename, [ PIXDIR = ]
INPUTS
image - array containing data
hdr   - The  corresponding FITS header.   Use MKHDR to create a minimal
        FITS header if one does not already exist.
filename - Scalar string giving the name of the file to be written 
        Should not include the extension name, which will be supplied 
        by IRAFWRT.
OUTPUTS
None
OPTIONAL KEYWORD INPUT
PIXDIR - scalar string specifying the directory into which to write
        the IRAF pixel (.pix) file.   The default is to write the pixel
        file to the same directory as the header (.imh) file
SIDE EFFECTS
Image array and  FITS header are written to IRAF pixel file 
         'filename'.pix and header file 'filename'.imh
EXAMPLE
Write an empty 50 x 50 array of all zeros to an IRAF file named 'EMPTY'
IDL> im = intarr( 50, 50)         ;Create empty array
IDL> mkhdr, hdr, im               ;Create a minimal FITS header
IDL> irafwrt, im, hdr, 'empty'    ;Write to a IRAF file named 'empty'
PROCEDURE
IRAFWRT gets information about the data - image dimensions, size, 
datatype, maximum and minimum pixel values - and writes it into
the binary part of the header. The ASCII part of the header
is directly copied after deleting records with certain keywords 
A pixel file is created, with a header in the first 1024 bytes
RESTRICTIONS
(1) The files are not created by IRAFWRT are not identical to those 
        created by the IRAF routine rfits.    However, the files 
        created by IRAFWRT appear to be compatible with all the IRAF 
        routines tested so far.
(2)  IRAFWRT has been tested on a limited number of data types
(3)  IRAFWRT has only been tested on Unix and VMS systems.
PROCEDURES CALLED
FDECOMP, IS_IEEE_BIG(), ISARRAY(), REPCHR(), STRN(), SXDELPAR, SXPAR()
MODIFICATION HISTORY
Written K. Venkatakrishna, STX February 1992
VMS compatibility    W. Landsman      April 1992
Work with headers without DATE-OBS or ORIGIN           August 1992
Preserve HISTORY records with other FITS records       March 1995    
Fix case where a minimal FITS header supplied          August 1995
Work under Alpha/OSF and Linux                         Dec.   1995
Make sureheader has 80 char lines, use IS_IEEE_BIG()   May    1997
Don't apply strlowcase to .pix name   W. Landsman      April 1999
Work with double precision            W. Landsman      May 1999
Minimize use of obsolete !ERR         W. Landsman      Feb. 2000
Assume since V5.5, remove VMS support W. Landsman       Sep. 2006
Get the dimensions, vector of dimensions and the data type
find the minimum and maximum pixel values
Get history records
opy header to new variable and leave original variable unmodified
ake sure it is 80 bytes
Create header array
write header length, data type
and number of dimensions into
header
find current time in seconds wrt Jan-01-80 000000
write maximum
and minimum pixel
values
write the ascii part of the header
write pixel file location
into header
Get the history records
write the history comment strings (as many as possible) in binary form
into the available 1160 bytes
write time of image creation
time of last modification
and time minimum and maximum
pixel values were computed
Write the data into the .pix file