crrej -- Generate an image free of cosmic rays from multiple exposures of the same field.
crrej input output masks sigmas
One way to reduce the cosmic rays (CR) registered in images is to take multiple exposures of the same field and combine the images by rejecting very high counts in each pixel stack. This task is a sophisticated implementation of this simple idea. It allows the user to combine images of different exposure length even in the presence of a varying background or "sky".
CRREJ has the following features and characteristics:
(1) DIFFERENT EXPOSURE TIMESThe input images may have different exposure times. The header keyword containing the exposure time should be specified by the parameter EXPNAME. The final combined image has an effective exposure time equal to the sum of exposure times of all input images. For pixels free from cosmic rays, the final pixel value is simply the sum of all input pixel values. For pixels having one or more CR in their input stacks, the final pixel value is the sum of the good pixels, normalized to the total exposure time of all input images. If all pixels are bad, the output pixel value is filled by the value specified in FILLVAL.
(2) CHOICE OF INITIAL GUESSComputing the average value of each pixel from the input images it uses only those pixels within N*(sigma) of some "initial guess" image. Pixels too far above AND BELOW the initial estimate are rejected and not used in the average. Pixels which are too low are rejected so as to avoid a negative bias on the result. This initial guess is produced by taking either the median or the minimum of the input images (the latter is particularly useful when only 2 or 3 images are available).
(3) NOISE MODELThe "sigma" includes a constant noise term (READNOISE), noise proportional to the square root of counts (statistical noise), and noise proportional to the counts (SCALENOISE). The latter is useful when the pointing of the telescope has changed by a small fraction of a pixel between images. Under such circumstances, the undersampling of the image by the CCD will cause stars to be rejected as cosmic rays if a scale noise is not included.
(4) PROPAGATE REJECTIONSIt is possible to perform a more stringent test for cosmic rays in pixels adjacent to rejected pixels. The radius over which pixels will be subjected to special scrutiny is controllable in units of pixels (RADIUS). Pixels inside of RADIUS which differ from the expected value by PFACTOR*SIGMAS will be rejected. The default setting of RADIUS=1.5 and PFACTOR=0.5 tests all pixels adjacent to rejected pixels with SIGMAS one-half that used in the primary rejection. Setting PFACTOR=0 causes all pixels within RADIUS to be rejected.
(5) ITERATIVE REJECTIONThe rejection process can be iterative. After computing a summed image, it is fed back in as the "initial guess" and the calculation is repeated. Both the number of iterations and the value of N (the number of sigmas used in rejecting pixels) are specifiable separately for each iteration (SIGMAS). For example, SIGMAS="4,3" performs two iterations, with 4-sigma rejection on the first iteration, and 3-sigma rejection on the second iteration.
The purpose of the iterations is two fold: (a) to allow the solution to slowly achieve an equilibrium, and (b) to allow for propagation of information about rejected pixels into adjacent pixels.
(6) DATA QUALITY FILESAn option allows the user to create or modify image masks, one for each input image, showing the location of pixels estimated to have cosmic ray hits. The masks are in I2 format (the format of HST data quality files). At cosmic ray locations, the value specified in CRDQVAL is logically OR'ed with the corresponding data quality pixel.
(7) SKY SUBTRACTIONSetting SKY=MODE will cause a sky to be estimated and removed from each image. SKY=NONE turns off sky subtaction. The sum of the skies will be placed in the header keyword set by the parameter skyname.
(8) MULTIPLE GROUPSThis task works on multi-group images as well as single group images.
This parameter is optional, i.e. this output file will not be created if this parameter is NULL. If these files already exist, the information in these files are used to exclude data during the CR rejection calculation. The cosmic ray DQ flags generated by this task will be logically OR'ed with pixel values in these files.
You can specify up to 3 keyword names here. In the output image, each of the specified keywords equals to the sum of the same keyword from all input images. Only the first keyword is used for scaling. For example: you can specify "exptime,darktime" for WFPC2 images.
1. Get a cosmic-ray-free combined image from all .c0h images in the local directory.
w_> crrej *.c0h crfree.hhh "" "4,4,3,2"
2. Two WFPC images are not precisely aligned due to a fractional pixel shift in pointing between images. Dividing one image by another shows that near the cores of stellar PSF's the ratio in counts from one image to the next can be as high as 1.5 in the PC and perhaps 1.05 in the WF. Therefore set scaleno = 10,1 while setting sigmas=8,6,5.
John Biretta, May 18, 1993 memo.
This program, under IRAF v2.14, encounters a invalid floating point operation when input images with pixel type of SHORT are provided. Input images with pixel type of REAL work as expected.
imcombine, combine, gcombine