FUNCTION c2_cal, img, header ;+ ; NAME: ; C2_CAL ; ; PURPOSE: ; This function calibrates a C2 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 = C2_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: ; C2_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 C2_CALFAC procedure. ; Routines not in NRL_LIB: ; C2_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 c2_calibrate.pro ; Centering added. Call to revised c2_calfactor ; (called c2_calfac) ; 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 c2_cal_img, vig_full, vig_fn, msk_fn COMMON dbms, ludb, lulog version = 'C2_CAL: Version 1, September 18, 1998' szlog = SIZE (lulog) hdr = header vhdr = header IF (DATATYPE (hdr) NE 'STC') THEN hdr = LASCO_FITSHDR2STRUCT (hdr) IF (hdr.detector NE 'C2') THEN BEGIN PRINT, 'ERROR: c2_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 + 'C2_cl*vig*.dat', yymmdd) IF (vig_fn NE '') THEN BEGIN ;--- Note that file is FITS. vig = READFITS (vig_fn, hvig) vhdr = LASCO_FITSHDR2STRUCT (hvig) mask = vig ;--- Centers for that vignetting file. ;--- Here, I put the centers into the vig file header ;--- for use in center_img. xvigcen = 512. yvigcen = 506. FXADDPAR, hvig, 'CRPIX1', xvigcen FXADDPAR, hvig, 'CRPIX2', yvigcen lhvig = LASCO_FITSHDR2STRUCT (hvig) ;--- Center the vignetting function vig = center_img (vig, lhvig) IF (szlog (0) NE 0) THEN printf, lulog, 'Used ' + vig_fn ENDIF $ ELSE BEGIN print, 'ERROR: c2_cal - No ' + sd + 'C2_cl*vig*.dat file' IF (szlog (0) NE 0) THEN $ printf, lulog, 'ERROR: c2_cal - No ' + sd + 'C2_cl*vig*.dat file' RETURN, 0 ENDELSE msk_fn= GET_CAL_NAME (sd + 'C2_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: c2_cal - No '+sd+'C2_cl*msk*.dat file' IF (szlog (0) NE 0) THEN $ printf, lulog, 'ERROR: c2_cal - No '+sd+'C2_cl*msk*.dat file - using flat mask' ;--- Use a flat mask file if none exists. mask = vig mask (*, *) = 1.0 ENDELSE vig_full = vig * mask ENDIF ;} ;--- c2_calfac returns a factor in units of MSB/(DN/pixel-sec) ;--- c2_calfac 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 = C2_CALFAC (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 img = center_img (img, hdr) RETURN, (img - bias) * vig END