idlastro / FITS I/O: CHECK_FITS

[Source code]

NAME
CHECK_FITS
PURPOSE
Check that keywords in a FITS header array match the associated data  
EXPLANATION
Given a FITS array IM, and a associated FITS 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 appropriate to the dimensions 
            of IM
        (3) The BITPIX value in HDR is appropriate to the datatype of IM
If the /UPDATE keyword is present, then the FITS header will be 
modified, if necessary, to force agreement with the image array
CALLING SEQUENCE
check_FITS, im, hdr, [ dimen, idltype, /UPDATE, /NOTYPE, /SILENT
                       ERRMSG = ]'
INPUT PARAMETERS
IM -  FITS array, e.g. as read by READFITS
HDR - FITS 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 16 bit integer, 3 for 32 bit integer 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 NAXISi
        FITS keywords will be updated to agree with the array
/FITS, /SDAS -  these are obsolete keywords that now do nothing 
/SILENT - If keyword is set and nonzero, the informational messages 
        will not be printed
/ALLOW_DEGEN - Don't check for degenerate axes.
OPTIONAL KEYWORD OUTPUT
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.  
PROCEDURE
Program checks the NAXIS and NAXISi keywords in the header to
see if they match the image array dimensions, and checks whether
the BITPIX keyword agrees with the array type.
PROCEDURE CALLS
FXADDPAR, FXPAR(), SXDELPAR
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
 Converted to IDL V5.0   W. Landsman   September 1997
Allow unsigned data types   W. Landsman December 1999
Allow BZERO = 0 for unsigned data types   W. Landsman January 2000
Added ERRMSG keyword, W. Landsman February 2000
Use FXADDPAR to put NAXISi in proper order   W. Landsman August 2000
Improper FXADDPAR call for DATATYPE keyword  W. Landsman December 2000
Remove explicit setting of obsolete !err W. Landsman February 2004
Remove SDAS support   W. Landsman       November 2006
Fix dimension errors introduced Nov 2006
Work again for null arrays W. Landsman/E. Hivon May 2007
Use V6.0 notation  W.L.  Feb. 2011
Add /ALLOW_DEGEN, William Thompson, 26-Jun-2019
s hdr of string type?
ull primary array
oes NAXIS agree with # of NAXISi?
emove degenerate dimensions