Data reduction II

J-band continuum emission (1250 nm) in the planetary nebula M1-92.

program names, file names
variable names
prompts, commands, program code


Contents:

Bad pixels

Invariably, some of the images will have pixels which have nonsensical values. This can be caused by a cosmic ray hitting the detector (especially for longer integrations), by an anomoly in the performance of a pixel in the detector, etc. In most cases this is no big deal, but if a bad pixel (ie., a pixel with a ridiculously large or small value) is near the object being observed, then it's probably worth throwing out that pixel.

Pick out troublesome pixels using the rec keyword of v:
IDLprompt> v, impackname, /rec
Clicking on bad pixels with the first mouse button records their positions (and values) to the file ~/idlpro/disp.rec. A helpful trick is to also reverse the color map (with the second mouse button)---this will highlight any pixels with large negative values. After clicking on all the bad pixels, terminate v (with the third mouse button). Then run the following command:
IDLprompt> bpmap, impackname
The bpmap procedure will read in all the coordinates in ~/idlpro/disp.rec and set those pixels in the weight plane of impackname to zero.

If you are dealing with a series of impacks in a single array, rather than with individiual impacks, use the following form:
IDLprompt> bpmap, impackarrname, arr=IND
where IND is the array index of the image package you wish to alter.


N-sigma filter

A more automated way of dealing with bad pixels is to run an N-sigma filter. The procedure nsigma is such a filter:
IDLprompt> nsigma, impackname, sig=N
where N is some numerical value (eg., 5, for a 5-sigma filter). For every pixel in the image plane of impackname, nsigma computes the mean and deviation of the 24 nearest neighbors of the reference pixel. If the reference pixel differs by more than N deviations from the mean, the corresponding pixel in impackname's weight plane is set to zero (if impackname starts out with no weight plane, nsigma gives it an initial weight plane of 1's).

If you are dealing with a series of impacks in a single array, rather than with individiual impacks, use the following form:
IDLprompt> nsigma, impackarrname, sig=N, arr=IND
where IND is the array index of the image package you wish to alter.

This kind of program has its limitations, particularly in the case of two hot pixels which are adjacent (or nearly so): when nsigma comes to the first hot pixel, it will find a large mean and a large deviation in the neighbors, and so the reference pixel may not fail the filter. Also, this program runs slowly, as it must calculate statistics of a 24-member sample for each and every pixel in the image plane.

Because of its limitations, I'm not convinced that this is a worthwhile step in the process of data reduction, but the code is available if you want to use it.


Background normalization

Ideally, a background subtraction should result in giving near-zero values to most pixels on the array---at least, this should happen to pixels that appear to correspond to blank sky. Sometimes this doesn't happen if, for whatever reason, some overall bias was present in either the foreground or background image. You might find that the average value in the background is, for example, around 25 ADUs (the ADU is the unit a pixel value has before flux calibration), rather than around zero ADUs.

This problem can be corrected with the bkgnorm procedure:
IDLprompt> bkgnorm, impackname
(bkgnorm accepts most of the same parameters of v, with the notable exception of the magnification, which expects it as a keyword---see the documentation of bkgnorm for details). This will allow you to draw a box on the image in impackname, via the box feature of v. Draw the box in a blank part of the image. bkgnorm will then display the box (magnified, and with appropriate display parameters) so that you can see if it contains any bad pixels that you may have overlooked. As usual, just click the third mouse button to terminate the viewing program.

At this point bkgnorm will compute the mean of the box and, after asking you to confirm the alteration, that mean value will be subtracted from every pixel in the image plane of impackname. This alteration will then be annotated in impackname's header.

If you are dealing with a series of impacks in a single array, rather than with individiual impacks, use the following form:
IDLprompt> bkgnorm, impackarrname, arr=IND
where IND is the array index of the image package you wish to alter.

A final point to make is that bkgnorm reports (by printing to the command window) the RMS of the pixel values found in the box. It would be a good idea to keep a running tally of these values as you reduce the data. If the RMS values are very consistent (more to the point, if RMS2 is fairly consistent), then it doesn't matter. If RMS2 experiences significant variations between images, however, it may be necessary to make use of this information when tessellating the images.


Carl Welch