We find that for our scientific goals it is necessary to improve the flat-field correction provided by our dome flats by generating a dark-sky or super-sky-flat. We generate this "delta" correction flat (which is really just accounting for color differences between the night-sky and our dome lamps, and for our case of trying to study objects at or below the sky level is appropriate to apply) by combining multiple object frames, effectively rejecting all of the real objects in the frame and leaving us with a high SNR image of "blank" sky. Unfortunately, any pupil-ghost image or fringing (present in at least I-band, z'-band, and most red narrow-band filters) that might be present in your input images are still in this combined frame. Before you can apply a sky-flat to your images, and assuming you want to remove the additive pupil-ghost and fringing components from all of your images, you must first create template pupil-ghost and fringe-correction frames and subtract scaled versions of these frames from all of your object frames. If you can live with the errors introduced by just dividing these components out, you can just used what I call version one of the skyflat. For the NDWFS KPNO 4m data we potentiall have to correct for both a pupil-ghost (depending on the band) and fringing (also wave-length dependent). For the CTIO data only fringing is a possible correction. For some bands, e.g. R-band, neither of these corrections is generally necessary. Below we take the most complicated/general case as an example: generating an I-band super-sky-flat. In order the steps that will be described are:
1.) Using 25 to 30 "object" frames along with sflatcombine and mscpupil to generate a Pupil template image that can be subtracted from each of the original object frames.
2.) How to subtract the pupil-ghost using rmpupil from each of your object frames.
3.) How to generate your fringe correction frame using 25-30 object frames from which the pupil-ghost has already been removed. You will use the tasks sflatcombine, mscsplit, fmedian, imarith, and mscjoin.
4.) How to remove the fringing from each of your object frames using the task rmfringe.
5.) How to generate your final super- or dark-sky-flat using sflatcombine.
The first step in removing the pupil-ghost is to generate a pupil template to subtract from each of the images. You will generate your pupil template using mscpupil and an input image. You used this same task when you corrected any dome-flat that had a pupil-ghost present. However, when you use the task to generate a pupil-template you need to save the measured "pupil-ghost". This requires setting type=data in the parameter file for mscpupil. Here is an example of suitable parameters for this step.
PACKAGE = mscred TASK = mscpupil input = Sflat990327V1I List of input images output = Pupil_I List of output images (masks = BPM) List of masks (type = data) Output type (lmedian= no) Subtract line-by-line median? (xc = 27.) Pattern center offset (pixels) (yc = 9.) Pattern center offset (pixels) (rin = 300.) Radius of inner background ring (pixels) (drin = 20.) Width of inner background ring (pixels) (rout = 1500.) Radius of outer background ring (pixels) (drout = 20.) Width of outer background ring (pixels) (funcin = chebyshev) Inner azimuthal background fitting function (orderin= 2) Inner azimuthal background fitting order (funcout= spline3) Outer azimuthal background fitting function (orderou= 2) Outer azimuthal background fitting order (rfuncti= spline3) Radial profile fitting function (rorder = 40) Radial profile fitting order (abin = 0.) Azimuthal bin (deg) (astep = 0.) Azimuthal step (deg) (niterat= 3) Number of rejection iterations (lreject= 3.) Low rejection rms factor (hreject= 3.) High rejection rms factor (datamin= INDEF) Minimum good data value (datamax= INDEF) Maximum good data value (verbose= yes) Print information? (fd = ) (mode = ql)
Note that the input image for mscpupil needs to have a high SNR image of the pupil-ghost and not have objects or other light in the frame (if the frames have fringing it will not be possible to avoid that contribution). For the NDWFS, we generate this image, named Sflat990327V1I in the example above (indicating the first version, V1, of a sky-flat for I-band data taken on March 27, 1999 UT), by combining 25 to 35 individual object frames that have been processed through the application of the dome-flat. This produces an image with high SNR in the sky, pupil-ghost, and fringing. The output file, Pupil_I in the example above, will be an image containing the pupil-ghost, some fringing single in the region of the pupil-ghost, plus some defects due to bad columns in the region of the pupil-ghost. This image will be scaled and subtracted from the individual object frames using rmpupil. Here is an example of the parameters for sflatcombine to generate the input image for mscpupil. The asci file input list of images to sflatcombine contains one image per line. We usually use 25 to 30 images. We have successfully used imags from two similar nights if on a single night we did not have enough images. Note that sflatcombine will append the filter name to the end of the root name you specify, so the output of the task below would be Sflat990327V1I.fits.
PACKAGE = mscred TASK = sflatcombine input = @objects_I.list List of images to combine (output = Sflat990327V1 Output sky flat field root name (combine= average) Type of combine operation (reject = ccdclip) Type of rejection (ccdtype= object) CCD image type to combine (subsets= yes) Combine images by subset parameter? (scale = mode) Image scaling (statsec= ) Image section for computing statistics (nkeep = 1) Minimum to keep (pos) or maximum to reject (neg) (nlow = 1) minmax: Number of low pixels to reject (nhigh = 1) minmax: Number of high pixels to reject (mclip = yes) Use median in sigma clipping algorithms? (lsigma = 6.) Lower sigma clipping factor (hsigma = 3.) Upper sigma clipping factor (rdnoise= rdnoise) ccdclip: CCD readout noise (electrons) (gain = gain) ccdclip: CCD gain (electrons/DN) (snoise = 0.) ccdclip: Sensitivity noise (fraction) (pclip = -0.5) pclip: Percentile clipping parameter (blank = 1.) Value if there are no pixels (grow = 3.) Radius (pixels) for neighbor rejection (fd = ) (mode = ql)
Now rmpupil can be used to remove the pupil-ghost from the individual object frames. This routine scales the pupil template generated above, (Pupil_I.fits), and subtracts it out of the input image. This can be done in a non-interactive mode, but in general we find it necessary to adjust the scaling interactively. To assist in this process, when the task is run interactively both the image you are trying to correct and draft corrected image (the result of subtracting the template) will be block averaged and displayed in two frame buffers of your ximtool-alt window, the uncorrected image in frame 1 and the corrected image in frame 2. The task rmpupil will estimate an initial scaling factor that is generally close, but not close enough, on the first pass. The scaling must either be increased (for too little subtraction on the first pass) or decreased (for too much subtraction) at the prompt provided in the xgterm window. After the pupil-ghost is satisfactorially removed, a new pupil-free out put image is created. Below is a sample parameter listing for rmpupil. Note that we have chosen to correct a new output image and to indicate that it has been corrected for the pupil-ghost by adding a "p" to its name. The name of the file used as the template as well as the adopted scaling are written to the image header.
PACKAGE = mscred TASK = rmpupil input = obj039.fits List of input mosaic exposures output = obj039p.fits List of output mosaic exposures template= Pupil_I Template mosaic exposure (type = difference) Type of removal (extname= im[2367]) Extensions for fit (blkavg = 8) Block average factor (fudge = 1.1) Fudge factor (scale = INDEF) Scale (INDEF for automatic estimate) (interac= yes) Interactive? (mscexam= no) Examine corrections with MSCEXAM? (verbose= yes) Verbose output? newscale= 0. Scale (0=done, -1=abort, -2=new blkavg) newblk = 4 New block average factor (fd1 = ) (fd2 = ) (fd3 = ) (mode = ql)
Just as we had to remove the pupil-ghost, we might have to remove the contribution of fringing from our frames. In a manner similar to that followed to correct for the pupil-ghost we combine multiple object frames (this time those that have had the pupil-ghost removed) to produce a new image from which we will construct a fringe template. This is also a good time to check the accuracy of our subtraction of the pupil-ghost, since if all the images have been handled properly there will be no pupil in this new combined sky-flat. Note that the removal of the pupil-ghost will have partially (in some cases completely) corrected the fringing in the region of the pupil-ghost. Here is a parameter file for using sflatcombine to generate the second-pass version (no pupil-ghost, fringing still present) of the sky-flat. The output image in this example will be named Sflat990327V2I.fits.
PACKAGE = mscred TASK = sflatcombine input = @object_p_I.inlist List of images to combine (output = Sflat990327V2) Output sky flat field root name (combine= average) Type of combine operation (reject = ccdclip) Type of rejection (ccdtype= object) CCD image type to combine (subsets= yes) Combine images by subset parameter? (scale = mode) Image scaling (statsec= ) Image section for computing statistics (nkeep = 1) Minimum to keep (pos) or maximum to reject (neg) (nlow = 1) minmax: Number of low pixels to reject (nhigh = 1) minmax: Number of high pixels to reject (mclip = yes) Use median in sigma clipping algorithms? (lsigma = 6.) Lower sigma clipping factor (hsigma = 3.) Upper sigma clipping factor (rdnoise= rdnoise) ccdclip: CCD readout noise (electrons) (gain = gain) ccdclip: CCD gain (electrons/DN) (snoise = 0.) ccdclip: Sensitivity noise (fraction) (pclip = -0.5) pclip: Percentile clipping parameter (blank = 1.) Value if there are no pixels (grow = 3.) Radius (pixels) for neighbor rejection (fd = ) (mode = ql)
There are several remaining steps required to finally generate the fringe correction frame. Currently, some of the necessary steps require using IRAF tasks that do not work on MEF files (we are working to update them), so we must first split the output image from above step into separate files, one fits file per CCD. This is done with the task mscsplit. This is an example parameter file. Note I have chosen to delete the original MEF file after the copies have been made.
PACKAGE = mscred TASK = mscsplit input = Sflat990327V2I List of input MEF files (output = Sflat990327V2I) List of output root names (mefext = .fits) MEF filename extension (delete = yes) Delete MEF file after splitting? (verbose= yes) Verbose? (fd1 = ) (fd2 = ) (mode = ql)
The output names of the files produced by this task would be the following:
Sflat990327V2I_0.fits
Sflat990327V2I_1.fits
Sflat990327V2I_2.fits
Sflat990327V2I_3.fits
Sflat990327V2I_4.fits
Sflat990327V2I_5.fits
Sflat990327V2I_6.fits
Sflat990327V2I_7.fits
Sflat990327V2I_8.fits
We want our fringe template to only have the signal from the fringing, not the residual flat-field structure we want to correct with our sky-flat. For this reason, we run fmedian on the individual frames, 1-8 (0 is just a header frame) and generate new copies without the larger scale fluctuations we want to end up in the super-sky-flat. Here is an example parameter file. The input and output were just asci files, titled "infmedian" and "outfmedian", and were just lists of the individual *_*.fits files above for the "infmedian", and *fm_*.fits for the "outfmedian" file names.
PACKAGE = imfilter TASK = fmedian input = @infmedian Input images to be filtered output = @outfmedian Output images xwindow = 129 X window size of median filter ywindow = 129 Y window size of median filter (hmin = -20000) Minimum histogram bin (hmax = 30000) Maximum histogram bin (zmin = -20000.) Pixel value corresponding to hmin (zmax = 30000.) Pixel value corresponding to hmax (zloreje= -20000.) Lowside pixel value cutoff (zhireje= 30000.) High side pixel value cutoff (unmap = yes) Unmap the digitized values ? (boundar= nearest) Boundary (constant,nearest,reflect,wrap) (constan= 0.) Constant for boundary extension (verbose= yes) Print messages about actions taken by the task (mode = ql)
Next step is to subtract the files in @outfmedian from the files in @infmedian using imarith. Here is an example: msc> imarith Sflat990327IV2_1.fits - Sflat990327IV2fm_1.fits FringeI990327_1.fits
Next copy the 0 extension from the original skyflat over to the 0 extension for the new fringe frame (copy Sflat990327IV2_0.fits FringeI990327_0.fits). This is necessary for mscjoin to be able to combine the FringeI990327_*.fits files into a single MEF file. An example of the parameter file for mscjoin is the following:
PACKAGE = mscred TASK = mscjoin input = FringeI990327 List of input root names (output = FringeI990327) List of output MEF names (delete = yes) Delete input images after joining? (verbose= yes) Verbose? (fd1 = ) (fd2 = ) (mode = ql)
The task rmfringe can now be run on each object frame. This task works in a similar manner to rmpupil, but works on all 8 CCDs rather than just the central four. One difference, it accepts the input initial scale as its first guess, i.e. it does not try to estimate the proper scaling. You should run this task interactively. Here is an example parameter file.
PACKAGE = mscred TASK = rmfringe input = obj168p List of input mosaic exposures output = obj168pf List of output mosaic exposures template= FringeI990327.fits Template mosaic exposure (extname= ) Extensions for fit (blkavg = 4) Block average factor (scale = 0.8) Scale (interac= yes) Interactive? (mscexam= no) Examine corrections with MSCEXAM? (verbose= yes) Verbose output? newscale= 0. Scale (0=done, -1=abort, -2=new blkavg) newblk = 4 New block average factor (fd1 = ) (fd2 = ) (fd3 = ) (mode = ql)
Note that the output file is a new image.
PACKAGE = mscred TASK = sflatcombine input = @object_pf_I.list List of images to combine (output = Sflat990327V3) Output sky flat field root name (combine= average) Type of combine operation (reject = ccdclip) Type of rejection (ccdtype= object) CCD image type to combine (subsets= yes) Combine images by subset parameter? (scale = mode) Image scaling (statsec= ) Image section for computing statistics (nkeep = 1) Minimum to keep (pos) or maximum to reject (neg) (nlow = 1) minmax: Number of low pixels to reject (nhigh = 1) minmax: Number of high pixels to reject (mclip = yes) Use median in sigma clipping algorithms? (lsigma = 6.) Lower sigma clipping factor (hsigma = 3.) Upper sigma clipping factor (rdnoise= rdnoise) ccdclip: CCD readout noise (electrons) (gain = gain) ccdclip: CCD gain (electrons/DN) (snoise = 0.) ccdclip: Sensitivity noise (fraction) (pclip = -0.5) pclip: Percentile clipping parameter (blank = 1.) Value if there are no pixels (grow = 3.) Radius (pixels) for neighbor rejection (fd = ) (mode = ql)Now it is finally time to apply the sky flat (Sflat990327V3I.fits in this example) to the objects frames that have had the pupil-ghost and fringe components subtracted (our obj*pf.fits files).