This step measures, subtracts and/or equalizes the sky from each input image while recording the subtracted value in the image header.
Authors: | |
---|---|
Christopher Hanley, Megan Sosey, Mihai Cara | |
License: | |
http://www.stsci.edu/resources/software_hardware/pyraf/LICENSE |
Function for computing and subtracting (or equalizing/matching) the backgroud in input images. The algorithm for sky subtraction can be selected through the skymethod parameter. This function will update the MDRIZSKY keyword in the headers of the input files.
Sky subtraction is generally recommended for optimal flagging and removal of CR’s when the sky background is more than a few electrons. However, some science applications may require the sky to not be removed, allowing for the final drizzle step to be performed with no sky subtraction. If you turn off sky subtraction, you should also set drizzle.pixfrac to 1, otherwise variations in sky between images will add noise to your data.
In addition to the “pure” sky computation, this task can be used for sky “equalization”, that is, it can match sky values in the images that are part of a mosaic.
For cameras with multiple detectors (such as ACS/WFC, WFPC2, or WFC3), the sky values in each exposure are first measured separately for the different detectors. These different values are then compared, and the lowest measured sky value is used as the estimate for all of the detectors for that exposure. This is based on the premise that for large extended or bright targets, the pixel intensity distribution in one or more of the detectors may be significantly skewed toward the bright end by the target itself, thereby overestimating the sky on that detector. If the other detector is less affected by such a target, then its sky value will be lower, and can therefore also be substituted as the sky value for the detector with the bright source.
For more information on the science applications of the sky task, see the DrizzlePac Handbook:.
Parameters: | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
input : str or list of str (Default = None)
outExt : str (Default = None)
configObj : configObject (Default = None)
group : int (Default = None)
editpars : bool (Default = False)
inputDict : dict, optional
|
|||||||||||||||||||||||||||||||||||
Returns: | |||||||||||||||||||||||||||||||||||
None : The input file’s primary headers is updated with the computed sky value. |
|||||||||||||||||||||||||||||||||||
Other Parameters: | |||||||||||||||||||||||||||||||||||
skysub : bool (Default = Yes)
skymethod : {‘localmin’, ‘globalmin+match’, ‘globalmin’, ‘match’}, optional (Default = ‘localmin’)
skywidth : float, optional (Default Value = 0.1)
skystat : {‘median’, ‘mode’, ‘mean’}, optional (Default Value = ‘median’)
skylower : float, optional (Default Value = INDEF)
skyupper : float, optional (Default Value = INDEF)
skyclip : int, optional (Default Value = 5)
skylsigma : float, optional (Default Value = 4.0)
skyusigma : float, optional (Default Value = 4.0)
skymask_cat : str, optional (Default Value = ‘’)
use_static : bool, optional (Default Value = True)
sky_bits : int, None, optional (Default = 0)
skyfile : str, optional (Default Value = ‘’)
skyuser : str (Default = ‘’)
in_memory : bool, optional (Default Value = False)
|
Notes
sky provides new algorithms for sky value computations and enhances previously available algorithms used by, e.g., Astrodrizzle.
First, the standard sky computation algorithm (see skymethod = 'localmin') was upgraded to be able to use DQ flags and user supplied masks to remove “bad” pixels from being used for sky statistics computations.
Second, two new methods have been introduced: 'globalmin' and 'match', as well as a combination of the two – 'globalmin+match'.
The 'globalmin' method computes the minimum sky value across all chips in all input images. That sky value is then considered to be the background in all input images.
The 'match' algorithm is somewhat similar to the traditional sky subtraction method (skymethod='localmin') in the sense that it measures the sky indipendently in input images (or detector chips). The major differences are that, unlike the traditional method,
- 'match' algorithm computes relative sky values with regard to the sky in a reference image chosen from the input list of images; and
- Sky statistics is computed only in the part of the image that intersects other images.
This makes 'match' sky computation algorithm particularly useful for “equalizing” sky values in large mosaics in which one may have only (at least) pair-wise intersection of images without having a common intersection region (on the sky) in all images.
The ‘match’ method works in the following way: for each pair of intersecting images, an equation is written that requires that average surface brightness in the overlapping part of the sky be equal in both images. The final system of equations is then solved for unknown background levels.
Warning
Current algorithm is not capable of detecting cases when some groups of intersecting images (from the input list of images) do not intersect at all other groups of intersecting images (except for the simple case when single images do not intersect any other images). In these cases the algorithm will find equalizing sky values for each group. However since these groups of images do not intersect each other, sky will be matched only within each group and the “inter-group” sky mismatch could be significant.
Users are responsible for detecting such cases and adjusting processing accordingly.
Warning
Because this method computes relative sky values compared to a reference image (which will have its sky value set to 0), the sky values computed with this method usually are smaller than the “absolute” sky values computed, e.g., with the 'localmin' algorithm. Since astrodrizzle expects “true” (as opposite to relative) sky values in order to correctly compute the median image or to perform cosmic-ray detection, this algorithm in not recommended to be used alone for sky computations to be used with astrodrizzle.
For the same reason, IVM weighting in astrodrizzle should not be used with 'match' method: sky values reported in MDRIZSKY header keyword will be relative sky values (sky offsets) and derived weights will be incorrect.
The 'globalmin+match' algorithm combines 'match' and 'globalmin' methods in order to overcome the limitation of the 'match' method described in the note above: it uses 'globalmin' algorithm to find a baseline sky value common to all input images and the 'match' algorithm to “equalize” sky values in the mosaic. Thus, the sky value of the “reference” image will be equal to the baseline sky value (instead of 0 in 'match' algorithm alone) making this method acceptable for use in conjunction with astrodrizzle.
Exposure – a subset of FITS image extensions in an input image that correspond to different chips in the detector used to acquire the image. The subset of image extensions that form an exposure is defined by specifying extensions to be used with input images (see parameter input).
See help for skypac.parseat.parse_at_line for details on how to specify image extensions.
Footprint – the outline (edge) of the projection of a chip or of an exposure on the celestial sphere.
Note
sky works directly on geometrically distorted flat-fielded images thus avoiding the need to perform an additional drizzle step to perform distortion correction of input images.
Initially, the footprint of a chip in an image is aproximated by a 2D planar rectangle representing the borders of chip’s distorted image. After applying distortion model to this rectangle and progecting it onto the celestial sphere, it is approximated by spherical polygons. Footprints of exposures and mosaics are computed as unions of such spherical polygons while overlaps of image pairs are found by intersecting these spherical polygons.
Primary reason for introducing “sky match” algorithm was to try to equalize the sky in large mosaics in which computation of the “absolute” sky is difficult due to the presence of large diffuse sources in the image. As discussed above, sky accomplishes this by comparing “sky values” in a pair of images in the overlap region (that is common to both images). Quite obviously the quality of sky “matching” will depend on how well these “sky values” can be estimated. We use quotation marks around sky values because for some image “true” background may not be present at all and the measured sky may be the surface brightness of large galaxy, nebula, etc.
Here is a brief list of possible limitations/factors that can affect the outcome of the matching (sky subtraction in general) algorithm:
Something to keep in mind is that the full AstroDrizzle interface will make backup copies of your original files and place them in the OrIg/ directory of your current working directory. If you are working with the stand alone interfaces, it is assumed that the user has already taken care of backing up their original datafiles as the input file with be directly altered.
Examples
Basic example of how to call sky yourself from a python command line, this example will use the default parameter settings and subtract a sky value from each *flt.fits image in the current directory, saving the output file with the extension of “mysky”:
>>> from drizzlepac import sky
>>> sky.sky('*flt.fits',outExt='mysky')
Print out syntax help for running astrodrizzle
Parameters: | |
---|---|
file : str (Default = None)
|