; data_reduction.pro, v1.0. ; R Painter, BSc Project Student '10/'11, 30.03.11. ; Calling sequence: result=data_reduction(data,exposure,mbias,mdark,mflat,mask) ; Fully reduces raw astronomical data in one routine, utilizing the "fixbadpixel.pro" routine as a subroutine. ; Typically completes within 2 minutes, however if a large & complex mask is used (e.g. if masking hot, warm and cool pixels simultaneously), the procedure can take up to 10 minutes per image. ; Input exposure must be in seconds. ; NB: The exposure time in seconds of a SBIG ST-7E FITS file is able to be read in from its header using the following code: exposure=fxpar(header,'date-obs') ; Steps: Raw -> -master bias -> -scalable master dark -> /normalized master flat -> pixel fix w/ input mask. FUNCTION data_reduction,data,exposure,mbias,mdark,mflat,mask data_red=data exposure_min=exposure/60 mbias=mbias mdark=mdark mflat=mflat mask=mask ; subtract mbias & scalable mdark, ensuring non-zero during subraction phase data_red=data_red+100000 data_red=data_red-mbias data_red=data_red-[mdark/(30/exposure_min)] data_red=data_red-100000 ; zero array, if negative values remain min=min(data_red) if min lt 0 then begin &$ data_red=data_red-min &$ endif ; divide by normalized mflat data_red=data_red/mflat ; fix bad pixels, using input mask data_red=fixbadpixel(data_red,mask) ; restore negative values, if array previously zeroed if min lt 0 then begin &$ data_red=data_red+min &$ endif return,data_red end