idlastro / FITS I/O: MRD_HREAD

[Source code]

NAME
MRD_HREAD
PURPOSE
Reads a FITS header from an opened disk file or Unix pipe
EXPLANATION
Like FXHREAD but also works with compressed Unix files
CALLING SEQUENCE
MRD_HREAD, UNIT, HEADER  [, STATUS, /SILENT, ERRMSG =, /FIRSTBLOCK ]
INPUTS
UNIT    = Logical unit number of an open FITS file
OUTPUTS
HEADER  = String array containing the FITS header.
OPT. OUTPUTS
STATUS  = Condition code giving the status of the read.  Normally, this
            is zero, but is set to -1 if an error occurs, or if the
            first byte of the header is zero (ASCII null).
OPTIONAL KEYWORD INPUT
/FIRSTBLOCK - If set, then only the first block (36 lines or less) of 
          the FITS header are read into the output variable.   If only
          size information (e.g. BITPIX, NAXIS) is needed from the
          header, then the use of this keyword can save time.  The 
          file pointer is still positioned at the end of the header,
          even if the /FIRSTBLOCK keyword is supplied.
/SILENT - If set, then warning messages about any invalid characters in
          the header are suppressed.
/SKIPDATA - If set, then the file point is positioned at the end of the
          HDU after the header is read, i.e. the following data block
          is skipped.   Useful, when one wants to the read the headers
          of multiple extensions.
/NO_BADHEADER - if set, returns if FITS header has illegal characters
          By default, MRD_HREAD replaces bad characters with blanks,
          issues a warning, and continues.
OPTIONAL OUTPUT PARAMETER
ERRMSG  = If this keyword is present, then any error messages will be
          returned to the user in this parameter rather than
          depending on the MESSAGE routine in IDL.  If no errors are
          encountered, then a null string is returned.
RESTRICTIONS
The file must already be positioned at the start of the header.  It
must be a proper FITS file.
SIDE EFFECTS
The file ends by being positioned at the end of the FITS header, unless
an error occurs.
REVISION HISTORY
Written,  Thomas McGlynn                     August 1995
Modified, Thomas McGlynn               January 1996
   Changed MRD_HREAD to handle Headers which have null characters
    A warning message is printed out but the program continues.
    Previously MRD_HREAD would fail if the null characters were
    not in the last 2880 byte block of the header.  Note that
    such characters are illegal in the header but frequently
    are produced by poor FITS writers.
Added /SILENT keyword   W. Landsman   December 2000
Added /FIRSTBLOCK keyword  W. Landsman   February 2003
Added ERRMSG, SKIPDATA keyword W. Landsman          April 2009
Close file unit even after error message   W.L.  October 2010
Added /NO_BADHEADER  Zarro (ADNET), January 2012