FUNCTION c3_cal, img, header ;+ ; NAME: ; C3_CAL ; ; PURPOSE: ; This function calibrates a C3 image to mean solar brightness units ; It centers the image before applying the vignetting and mask functions ; The vignetting function is centered as well. ; It works for polarizer as well as clear images. ; ; CATEGORY: ; REDUCE ; ; CALLING SEQUENCE: ; Result = C3_CAL(Img, Header) ; ; INPUTS: ; Img: A 2-D image array in units of DN ; Header: An image header (FITS or LASCO header structure) ; ; OUTPUTS: ; The calibrated image is returned. The units are mean solar ; brightness. ; ; COMMON BLOCKS: ; C3_CAL_IMG, DBMS ; ; RESTRICTIONS: ; Centers are taken from the FITS header. The precise orbital ; information needs to be applied to get the 'correct' center ; before applying the vignetting function. ; ; Header entries need to be adjusted for centering performed ; here. I do not know whether to change the crpix value ; add a new header value, or put it into history. ; ; PROCEDURE: ; The routine reads in the vignetting and a mask array from the ; NRL_LIB/lasco/data/calib directory. To obtain the calibration ; factors, it calls Elmore's C3_CALFAC procedure. ; Routines not in NRL_LIB: ; C3_CAL, and center_img ; ; MODIFICATION HISTORY: ; Written by: RA Howard, 6/12/98, copy from c3_calibrate.pro ; Revised by: DF Elmore, 9/18/98, from Russ's c3_calibrate.pro ; Centering added. ; and use of default flat mask if no file exists. ; SUMMING routine replaced by rebin and explicit scaling ; ; SCCS variables for IDL use ; ; %W% %H% :LASCO IDL LIBRARY ; ; ;- COMMON c3_cal_img, vig_full, vig_fn, msk_fn COMMON dbms, ludb, lulog version = 'C3_CAL: Version 1, September 18, 1998' szlog = SIZE (lulog) hdr = header IF (DATATYPE (hdr) NE 'STC') THEN hdr = LASCO_FITSHDR2STRUCT (hdr) IF (hdr.detector NE 'C3') THEN BEGIN PRINT, 'ERROR: c3_cal - Wrong telescope ' + hdr.detector RETURN, 0 END ;--- Check to see if vignetting function already read in. ;--- If it hasn't, then read it and the mask in. sz = SIZE (vig_full) IF (sz (0) EQ 0) THEN BEGIN ;{ sd = getenv ('NRL_LIB') + '/lasco/data/calib/' dte = STR2UTC (hdr.date_obs) yymmdd = UTC2YYMMDD (dte) vig_fn = get_cal_name (sd + 'C3_cl*vig*.dat', yymmdd) IF (vig_fn NE '') THEN BEGIN vig = fltarr (1024, 1024) mask = vig OPENR, lucal, vig_fn, /GET_LUN READU, lucal, vig IF (szlog (0) NE 0) THEN printf, lulog, 'Used '+vig_fn CLOSE, lucal FREE_LUN, lucal ENDIF $ ELSE BEGIN print, 'ERROR: c3_calibrate - No '+sd+'C3_cl*vig*.dat file' IF (szlog (0) NE 0) THEN $ printf, lulog, 'ERROR: c3_calibrate - No '+sd+'C3_cl*vig*.dat file' RETURN, 0 ENDELSE msk_fn = get_cal_name (sd + 'C3_cl*msk*.dat', yymmdd) ; If the mask function is not centered, add code similar to that for vignetting IF (msk_fn ne '') THEN BEGIN OPENR, lucal, msk_fn, /GET_LUN READU, lucal, mask IF (szlog (0) NE 0) THEN printf, lulog, 'Used ' + msk_fn CLOSE, lucal FREE_LUN, lucal ENDIF ELSE BEGIN print, 'ERROR: c3_cal - No ' + sd + 'C3_cl*msk*.dat file' IF (szlog (0) NE 0) THEN $ printf, lulog, 'ERROR: c3_cal - No ' + sd + $ 'C3_cl*msk*.dat file - using flat mask' ;--- Use a flat mask file if none exists mask = vig mask (*, *) = 1. endelse vig_full = vig*mask ENDIF ;} ;--- c3_calfactor returns a factor in units of MSB/(DN/pixel-sec). ;--- c3_calfactor adjusts factor for binning, exposure time, ;--- filter and polarizer. valid = get_exp_factor (hdr, expfac, bias) hdr.EXPTIME = hdr.EXPTIME * expfac hdr.offset = bias calfac = c3_calfactor (header) factor = calfac / hdr.EXPTIME IF (hdr.r1col EQ 20) AND (hdr.r1row EQ 1) AND $ (hdr.r2col EQ 1043) AND (hdr.r2row EQ 1024) $ THEN vig = vig_full * factor ELSE $ BEGIN x1 = hdr.r1col - 20 x2 = hdr.r2col - 20 y1 = hdr.r1row - 1 y2 = hdr.r2row - 1 vig = vig_full (x1:x2, y1:y2) * factor ENDELSE ; This section does not use SUMMING function [DFE]. summing = (hdr.lebxsum) * (hdr.lebysum) vig = rebin (vig, hdr.naxis1, hdr.naxis2) vig = vig / summing summing = (hdr.sumcol>1) * (hdr.sumrow>1) vig = vig / summing ;;;;---> Here is where to show change in image centers. IF (DATATYPE(header) NE 'STC') THEN BEGIN FXADDPAR, header, 'HISTORY', version FXADDPAR, header, 'HISTORY', vig_fn FXADDPAR, header, 'HISTORY', msk_fn IF (valid EQ -1) THEN $ FXADDPAR, header, 'WARNING', 'Invalid exposure factor. Used 1.' FXADDPAR, header, 'CALFAC', calfac, 'Conversion from DN to MSB' FXADDPAR, header, 'EXPFAC', expfac, 'Exposure time correction factor' FXADDPAR, header, 'EXPTIME', hdr.EXPTIME, 'Corrected exposure time' FXADDPAR, header, 'OFFSET', bias, 'Corrected CCD offset bias' ENDIF ; ;;;---> Vignette or center first??? img = (img - bias) * vig img = center_img (img, hdr) RETURN, img ;img = center_img (img, hdr) ;return, (img - bias) * vig END