Personal tools
You are here: Home / COSMOS2 / subsky

subsky

Back to Programs

subsky

subsky uses the Kelson (PASP 115,688) procedure to do an optimally sampled sky subtraction. The program relies on a good CCD-science coordinate system mapping to construct a cosmic ray-cleaned median sky spectrum for each slit, which is then subtracted from the slit image. Output is a new set of CCD images with sky subtracted (unless the data is nod&shuffle;), and with errors attached.


USAGEsubsky -f framename -m mapfile [-z badpixfile] [-d] [-o object_id] [-r] [-p parameter_file]
INPUT
framename is a set of image files on which sky subtraction is done
mapfile.map is the map file which applies
badpixfile.badpix is a non-standard bad pixel map
-d set the diagnostic flag
-o object_id allows you to run subsky on a single slit, given by the object_id as defined in the SMF file (new in version 2.20)
-r reload previous subsky output (new in version 2.20)
-p parameter_file use parameter_file.par instead of the standard subsky.par file (new in version 2.20)
OUTPUTframename_s_cn.fits
PARAMETERS
minlambda minimum wavelength for sky subtraction
maxlambda maximum wavelength for sky subtraction
siglimit CR rejection threshold, in units of sigma(sky)
noise typical CCD read noise
gain typical CCD gain, in e-/adu
medbox size of running median box for CR rejection (in pixels)
deltaknot knot spacing, in pixels
splineorder order of spline fit
2d_spline do 2 dimensional spline fit?
exclude half-width of excluded strip near object spectrum
edge excluded region at ends of slit, in pixels
diag_0 lower limit of diagnostic interval
diag_1 upper limit of diagnostic interval
sub_sky subtract sky?
OPTIONAL PARAMETERS
edge2excluded region at other end of slit
objshiftnumber of pixels to shift object position


Details:

subsky uses 1-d or 2-d B-Splines to fit the sky spectrum of flux vs wavelength. If 2-d spline fits are selected, the fit along the slit is first order, with a knot at each end of the fitted region. When the object spectra are strong, sky fits can be improved by excluding a strip around the object spectrum in the analysis. Excluding a small region near the ends of the slit, via the parameter edge, can also improve the fit. If a bad pixel file is specified, it is used to determine regions to be masked before the spline fit is calculated. If none is specified, the standard dewar-specific file is used. Depending on the characteristics of the data, the spline parameters may need some tuning to optimally fit sky. An non-optimal knot spacing or fit order can produce ringing in the fit, or a poor fit to strong night sky lines. Values near deltaknot = 1.0 pixel, and splineorder = 3 often work best (spline order must be 3 or 5). If the diagnostic flag is set, no output files are written, but subsky plots the region between wavelengths diag_0 and diag_1, showing data points and spline fit, to allow tuning of the parameters. Some more details on adjusting parameters can be found in the COSMOS Cookbook.


If minlambda and maxlambda are both set to 0, subsky uses the values from the map file.


The output data is a 3-d fits file. The first plane of the file is the sky subtracted image, the second plane contains the 1-sigma pixel-by-pixel error estimates. Bad pixels have errors set to a negative number.


Nod&shuffle; data: In the case of nod&shuffle; data, no sky subtraction is done. However, subsky must still be used as part of the normal reduction pipeline in order to obtain error values for the data, which are used in the cosmic ray rejection step in sumspec.


A few optional parameters were added in COSMOS 2.20 to allow the user to further customize the sky-subtraction process.

  1. The edge2 parameter is useful for cases where you want to exclude more rows on one side of the slit than on the other side in the sky-fitting process. To determine which side of the slit corresponds to edge and edge2, you have to display the full IMACS 8-chip mosaic or the stitched LDSS3 frame.
    • For data in Normal orientation (i.e. dispersion runs in the vertical direction), edge corresponds to rows excluded on the left-hand side of the slit and edge2 corresponds to rows excluded on the right-hand side.
    • For data in N&S; orientation (i.e. dispersion runs in the horizontal direction), edge corresponds to rows excluded on the bottom of the slit and edge2 corresponds to rows excluded on the top.
  2. By setting the objshift parameter, you can shift the defined object position from the map file if the object is not exactly in the center of the slit, or wherever you expected it to be as defined in the SMF file. If the object position is off from its expected position by the number of pixels you set the exclude parameter to, the object will likely be included in the sky-fitting, so having this option can be useful in such cases.
    • For data in Normal orientation, a negative value will shift the object position to the left, and a positive value will shift it to the right.
    • For data in N&S; orientation, a negative value will shift the object position downwards, and a positive value will shift it upwards.

NOTE: Since both edge2 and objshift are optional parameters, older parameter files will still work fine, as edge2 defaults to whatever edge is set to and objshift defaults to zero.

There are also new optional flags introduced in COSMOS 2.20, which enable the user to use different parameters for different slits. Here are a few examples that illustrate how these can be used:

  1. Say you want to preserve your original subsky.par file, but want to try a different set of parameters for a particular exposure. You can copy subsky.par to subsky_exp1.par, for example, then change the parameters in the latter and use that file:
    subsky -m ccd0434 -f ccd0431_f -p subsky_exp1
  2. Say you want to rerun subsky on one of your slits, but with slightly different parameters. If the slit is called "obj001" in the SMF file, for example, you can copy subsky.par to subsky-obj001.par and change the parameters in the latter. Then in the command, you can tell it to reload the previous subsky output with the -r flag, and have it run again only on this one slit with the -o flag:
    subsky -m ccd0434 -f ccd0431_f -p subsky-obj001 -r -o obj001

Back to Programs