Continuum subtraction

Brackett gamma line emission (2166 nm) in the planetary nebula NGC 7027

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


Contents:

Overview

This section is appropriate only for narrow-band data, not for broadband data. If you have narrow-band data, you probably have three impacks at this point: the lower continuum wavelenth, the line wavelength, and the upper continuum wavelength. What we need to do now is to use the two continuum emission images to interpolate the spatial distribution and intensity of the continuum emission at the line wavelength. The "line" emission image is actually line+continuum emission, so we need to subtract from that the continuum emission. The result will be just line emission.


remag

A couple of complications to the continuum subtraction are that, in general, the registration and magnification of the three wavelengths don't match. You'll need to know the platescale of the three wavelengths. Platescale is measured at the telescope by taking images of a starpair at many different wavelengths. The actual separation in arcseconds between the stars won't change, but the separation in pixels will vary with wavelength. The platescale v. wavelength curve is fairly steep for wavelengths less than two microns, but it levels out after two microns. Here's an example from the oct99wiro observing run:

[Plot of platescale
v. wavelength]
Because of this behavior of the platescale curve, we tend to measure platescale at line and continuum wavelengths shortward of two microns, but we usually only take platescale measurements at line wavelengths longward of two microns. (The astute reader will notice that the anomolous data points in the above plot coincide with the broadband wavelengths 1.25, 1.65, 2.23, and 3.26 microns--the optical properties of a broadband filter differ enough from that of the narrowband filters to drive these points off the smoother curve established by the narrowband filter platescale measurements.)

If the platescales of your three images vary significantly with wavelength, you will need to remagnify the images to the same platescale. I suggest that you remagnify the continuum emission images, and leave the line+continuum emission image at its original platescale. If you don't know the platescales of your images (eg., if the boneheads at the telescope only measured platescale at the line wavelength, even though it's in the steep portion of the platescale v. wavelength curve), and if you have at least two point sources in each image, you can determine the relative platescales, which is good enough for determining the magnification factors you'll need to remagnify the images. For example, let's say you want to continuum-subtract data taken at 1644 nm, and your continuum emission images were taken at wavelengths of 1550 and 1780 nm. Let's also pretend that you only know the platescale at 1644 nm, and that your data images look something like the following:

[Image of a star
formagion region]
(This is the star formation region AFGL 437; data reduction by UR graduate Peter Allen). We could use cuts to find the coordinates of the star marked A and of one of the stars near the B. We could do this for each image (ie., each wavelength), and, using the Pythagorean theorem, find the separation in pixels between the two stars at each wavelength. The magnification factor M to needed change from the original platescale ps_orig to the target platescale ps_new is
M   =   (   ps_orig   /   ps_new   )   =   (   sep_new   /   sep_orig   )
where sep_orig and sep_new are the separations in pixels between the two stars in the image to be remagnified and in the image with the target platescale, respectively.

The remag procedure is used to actually perform the remagnification:
IDLprompt> remag, inthing, outthing, magfac
where magfac is the magnification factor discussed above. inthing may be an image or an impack, and outthing will have the same format (ie.,image or impack) as inthing. If outthing is an impack, the header will indicate a change in the magnification. Another feature of remag is that you may optionally use different magnification factors for the x- and y-directions:
IDLprompt> remag, inthing, outthing, xmagfac, ymagfac
This is not usually necessary, but the option is available. An instance where this might be necessary would be if the detector array were not normal to the optical path. In this case, it might well be necessary to use different magnification factors for the two directions (see the chapter on platescale analysis for more about this).

An important thing to know about remag is that it conserves flux. As the algorithm makes a new image from the original, it rescales the pixel values in such a way as to not affect the calibration. Regretably, the remag procedure runs rather slowly, because, like nsigma and dist_astro, it must remap the image one pixel at a time. This is an unfortunate side effect of the algorithm's flux-conserving nature.

After using remag, the image will have a new magnification. As a result, the new image will have dimensions different from that of the original image. Also, remagnified images characteristically have a faint gridwork structure to them--this is annoying, but not unusual. It's a natural consequence of this kind of algorithm, which blurs pixels when shifting them. Some pixels are moved by nearly integer amounts, and are less blurred---this is what creates the gridwork pattern.


resize

After remagnifying, the images in your impacks are probably of different sizes. This is going to be trouble. Before we do the continuum subtraction, we need all three images to be the same size. We can use the resize procedure to do this:
IDLprompt> resize, imapackname, newxdim, newydim
This works pretty much as you'd expect, the image in impackname is resized to have the dimensions newxdimxnewydim. You can also give resize an image, rather than an impack---it'll convert the first positional parameter without altering its format.

A word of caution: resize alters the image you give it. If the new dimensions are larger than the original dimensions (ie., an enlargement), resize just makes the image bigger, and the pixels in the extra space all have values of zero---no big deal. However, if you specify either new dimension to be smaller than the corresponding original dimension, everything past the original dimension is cropped out and discarded. For this reason, it's a good idea to see which of the three images (lower continuum, line+continuum, and upper continuum) is largest, and then use resize to enlarge the other two.


contsub

Now that the images have the same platescales and sizes, we need to see to the registration---we need to align the three images just as we aligned our original data images before tessellating. Do it the same way, but you should probably use the line+continuum emission image as the anchor image. Once you've figured out the shift parameters for the continuum emission images, you're almost ready to do the continuum subtraction. You need to make a three-element vector which has the wavelengths of the three images (referring to the example mentioned above, these three wavelengths would be 1550, 1644, and 1780 nm):
IDLprompt> lambda_arr = [1550., 1644., 1780.]
(I chose to express these in nanometers, but it doesn't matter: you could use microns, or even furlongs, as long as you are consistent). Make sure that the three wavelengths are in increasing order. Now we can continuum-subtract:
IDLprompt> linecsimpack = contsub( shiftxy( lcimpack , lcdx , lcdy ) , $ IDLprompt> lineimpack , shiftxy( ucimpack , ucdx , ucdy ) , lambda_arr )
(Remember that trick about splitting up long commands onto multiple command lines?) The function contsub takes as its four positional parameters, in order, a 2-D array corresponding to the properly-registered lower continuum emission image, an impack with the line+continuum emission image (and its associated header), a 2-D array corresponding to the properly-registered upper continuum emission image, and the three-element vector giving the wavelengths of the images. The result, linecsimpack, is an impack whose image is the continuum-subtracted, line emission image, and whose header is the header from the line+continuum emission impack (lineimpack), altered to indicate the continuum subtraction. The continuum-subtracted version of the above image of AFGL 437 looks like the following:

[Another image of a
star formagion region]
(The arrow indicates the position of a molecular jet seen at radio wavelengths.) Clearly, most of the continuum sources, such as field stars, have been removed by the continuum subtraction. A few sources remain near the region of active star formation, which may indicate line emission.

Another feature of contsub is that it can be used to perform the calibration, if that hasn't already happened. If the images aren't already calibrated, then you MUST calibrate during or before the continuum subtraction. If you know the calibration factors (see the chapter on flux calibration), and if the images aren't already calibrated (ie., if the pixels still have units of ADUs, rather than Janskys), then make a three-element array which has the three calibration factors (in order of increasing wavelength). Then include this array as the value of the keyword calib in the call to contsub:
IDLprompt> linecsimpack = contsub( shiftxy( lcimpack , lcdx , lcdy ) , $ IDLprompt> lineimpack , shiftxy( ucimpack , ucdx , ucdy ) , lambda_arr , $ IDLprompt> calib = calib_arr )

Incidentally, the second positional parameter of contsub can also be an image (rather than an impack). In this case the result is also an image.


Carl Welch