Viewing contents of file '../idllib/ghrs/pro/abscal.pro'
function abscal,value,header
;+
; NAME:
; ABSCAL
; PURPOSE:
; Provide an absolute calibration using the BZERO and BSCALE keywords
; in an FITS header
; CALLING SEQUENCE:
; RESULT = ABSCAL(VALUE,HEADER)
; INPUTS:
; VALUE - Any scalar, vector, or array (usually an integer type giving a
; relative intensity).
; HEADER - A FITS header array containing the absolute calibration
; keyword BSCALE, and optionally BZERO and BUNIT.
; OUTPUT:
; RESULT = BSCALE*VALUE + BZERO, where the BSCALE and BZERO scalars
; are taken from the FITS header.
; If the absolute calibration keywords do not exist, then
; RESULT = VALUE, and !ERR = -1.
; SYSTEM VARIALBES:
; If the system variable !DEBUG is set, then ABSCAL will print the
; calibration units given by the BUNIT keyword.
; REVISION HISTORY:
; Written W. Landsman, STX Corporation January 1987
;-
if n_elements(value) eq 0 then message, $
'Array (first parameter) to be calibrated is not defined'
zparcheck,'ABSCAL',header,2,7,1,'FITS Image header'
bscale = sxpar(header,'BSCALE')
if !ERR eq -1 then begin ;Did BSCALE keyword exist?
print,'ABSCAL - No calibration keywords in FITS header'
return,value
endif
bzero = sxpar(header,'BZERO') ;Get BZERO keyword, 0 if not found
if !DEBUG then begin ;Print calibration units
bunits = sxpar(header,'BUNIT') ;Are calibration units supplied?
if !ERR ne -1 then print,'ABSCAL - Calibration Units ',bunits else $
print,'ABSCAL - Calibration Units not given'
endif
return,value*bscale + bzero
end