;+ ; NAME: ; get_spe_cal ; ; PURPOSE: (one line) ; return calibrated SPE file ; ; DESCRIPTION: ; return calibrated SPE file ; ; CATEGORY: ; IMAGES ; ; CALLING SEQUENCE: ; cal = get_spe_cal(cfilename, cerr, cbad, head=head, $ ; silent=silent, $ ; gain_arr=gain_arr, znoise_arr=znoise_arr, $ ; ferr_arr=ferr_arr, bad_arr=bad_arr, bad_list=bad_list) ; INPUTS: ; cfilename : filename of calibrated SPE file ; ; OPTIONAL INPUT PARAMETERS: ; -------- behavior of the routine ------------ ; silent : 1 if the routine is to perform silently. Default = 0, ; print out statements ; ; OUTPUTS: ; cal - the calibrated image cube ; ; OPTIONAL OUTPUTS: ; cerr - the error in the calibrated image cube ; cbad - bad pixel image for the calibrated image cube ; ; OUTPUT KEYWORDS: ; head - the header of the PDU ; ; SIDE EFFECTS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY: ; Written 14 Jun 2007 Leslie Ann Young SwRI ; Modified 13 Sep 2007 LAY ;- function get_spe_cal, cfilename, cerr, cbad, head=head, $ silent=silent, $ gain_arr=gain_arr, znoise_arr=znoise_arr, $ ferr_arr=ferr_arr, bad_arr=bad_arr, $ bad_list=bad_list, justhead=justhead func = 'get_spe_cal' if not keyword_set(silent) then silent = 0b cfn = cfilename[0] ; in case cfilename is array[1] if not isfile(cfn) then begin if isfile(cfn + '.gz') then begin cfn = cfn + '.gz' endif else begin print, func, ' : ', cfn, ' not found' return, -1 endelse endif if not silent then begin print, func, ' : reading ', cfn endif if not isfile(cfn) then begin print, func, ' : ', cfn, ' does not exist' return, -1 endif if keyword_set(justhead) then begin head = headfits(cfn) return, -1 endif cal = readfits(cfn, fhead, /silent) gain_arr = readfits(cfn, ex=1, /silent) znoise_arr = readfits(cfn, ex=2, /silent) ferr_arr = readfits(cfn, ex=3, /silent) bad_arr = readfits(cfn, ex=4, /silent) bad_list = readfits(cfn, ex=5, /silent) head = spe_head(fhead, valid, spehead, exptime=exptime) if n_params() gt 1 then begin cerr = spe_err(cal, gain_arr, znoise_arr, ferr_arr) end if n_params() gt 2 then begin nxnyn, cal, nx, ny, nimages cbad = bytarr(nx,ny,nimages) for i = 0, nimages-1 do begin cbad[*,*,i] = (bad_arr ne 0) or (bad_list[i] ne 0) endfor end return, cal end