Parameters for "gsub"
Start by opening a DS9 window before
running this task and by editing the parameters for the task "gsub".
The task parameters will look like this:

This task will use a template image of the supernova host galaxy and
a prior SN+galaxy image, to subtract the galaxy from the SN+galaxy image.
This procedure involves: 1) image registration, 2) psf match, and 3) flux match.
Start by specifying the name of the SN+galaxy image in the "image" parameter,
and the galaxy template image in the "template" parameter.
The "opt_ir" parameter specifies whether you are working with CCD or infrared images.
The detector parameters "scale", "datamin", "datamax", and "epadu" correspond to
that of the SN+galaxy image, and are self explanatory.
The "fwhmpsf" is a parameter that specifies the FWHM of the PSF in arcsec
and is a parameter that is used to automatically find field stars for the
image registration. The parameter "threshold" is in units of the FWHM of
the sky brightness distribution, and defines the threshold to begin star
detection in the image, and "nstar" sets the minimum number of stars to find
in the SN+galaxy image.
The "cbox" parameter specifies the centering box in arcsec.
You can restrict the region for star search using the "ssec" parameter.
You don't need to worry about the remaining parameters because they are
not used by the task.
Running the task "gsub"
Before running "gsub" you need to:
1) create a subdirectory named "sub" and move yourself to that spot (above
this directory are located the SN+galaxy images);
2) copy the template image (B.final in this example) to the current directory;
3) use the "findstars" task to make a list of the brightest stars in the
template image ("gsub" assumes that this file is present in the current
directory with the "coo" extension added to the template image name, i.e.,
B.final.coo in this example).
Image registration:
The task "gsub" will start by displaying the template image with the field stars
surrounded by purple circles, and will proceed to call the "findstars" task to
find stars in the field of the SN+galaxy image. Using these two sets of stars
it will try to match the stars of both images, after which it will compute
the geometric transformation. You will get on the screen some information
regarding the transformation such as the scale factors (xmag and ymag),
the rotation angle in degrees (xrotation and yrotation) and the rms of the
fit (xrms and yrms). The latter two should be less than 0.2 pixels. Finally,
you will get the registered template image displayed on DS9. You can use the
blink option to check that the registration worked fine. Hit any key to
continue.
PSF match:
You will be presented with the SN+galaxy image and the good PSF
star candidates shown with double circles. You will be prompted
to mark at least one of such stars. Next, you will be presented
with a contour plot that shows the kernel function derived from
the PSF stars. Here all you have to do is to restrict (or enlarge)
the box size to include only the outermost well-defined contour.
Finally, you will get the convolved template displayed on DS9.
You can use the blink option to check that the convolution
worked fine. Hit any key to continue.
A small adjustment to the image registration will be performed and the
resulting image will be displayed.
Flux match:
At this point you are prompted to mark the lower left and upper right corners
of the box where you want to perform the galaxy subtraction. It must contain
the supernova and sufficient pixels around it for the measurement of the
sky. Try to avoid including nearby local standards.
You will get a plot that shows the flux transformation between the two
images. Each point represents a star. If the plot has too much scatter
you can decrease the size of the boxes used for the statistics. Once
you are happy with the fit you can quit with "q".
The task will produce a galaxy subtracted image with the "_sub"
extension added to the original image.