astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- drizzle v1.11 »
- The Drizzle Library »
- API Documentation »
- Drizzle

# Drizzle

class `drizzle.drizzle.``Drizzle`(infile=u'', outwcs=None, wt_scl=u'exptime', pixfrac=1.0, kernel=u'square', fillval=u'INDEF')

  Bases: `object`

  Combine images using the drizzle algorithm

  Create a new Drizzle output object and set the drizzle parameters.

  All parameters are optional, but either infile or outwcs must be supplied. If infile initializes the object from a file written after a previous run of drizzle. Results from the previous run will be combined with new results. The value passed in outwcs will be ignored. If infile is not set, outwcs will be used to initilize a new run of drizzle.

  Parameters:

  infile : str, optional

  > A fits file containing results from a previous run. The three extensions SCI, WHT, and CTX contain the combined image, total counts and image id bitmap, repectively. The WCS of the combined image is also read from the SCI extension.

  outwcs : wcs, optional

  > The world coordinate system (WCS) of the combined image. This parameter must be present if no input file is given and is ignored if one is.

  wt_scl : str, optional

  > How each input image should be scaled. The choices are `exptime` which scales each image by its exposure time, `expsq` which scales each image by the exposure time squared, or an empty string, which allows each input image to be scaled individually.

  pixfrac : float, optional

  > The fraction of a pixel that the pixel flux is confined to. The default value of 1 has the pixel flux evenly spread across the image. A value of 0.5 confines it to half a pixel in the linear dimension, so the flux is confined to a quarter of the pixel area when the square kernel is used.

  kernel : str, optional

  > The name of the kernel used to combine the inputs. The choice of kernel controls the distribution of flux over the kernel. The kernel names are: “square”, “gaussian”, “point”, “tophat”, “turbo”, “lanczos2”, and “lanczos3”. The square kernel is the default.

  fillval : str, otional

  > The value a pixel is set to in the output if the input image does not overlap it. The default value of INDEF does not set a value.

  Methods Summary

  `add_fits_file`(infile[, inweight, xmin, ...]) | Combine a fits file with the output drizzled image.
  `add_image`(insci, inwcs[, inwht, xmin, xmax, ...]) | Combine an input image with the output drizzled image.
  `blot_fits_file`(infile[, interp, sinscl]) | Resample the output using another image’s world coordinate system.
  `blot_image`(blotwcs[, interp, sinscl]) | Resample the output image using an input world coordinate system.
  `increment_id`() | Increment the id count and add a plane to the context image if needed
  `write`(outfile[, out_units, outheader]) | Write the output from a set of drizzled images to a file.

  Methods Documentation

  `add_fits_file`(infile, inweight=u'', xmin=0, xmax=0, ymin=0, ymax=0, unitkey=u'', expkey=u'', wt_scl=1.0)

    Combine a fits file with the output drizzled image.

    Parameters:

    infile : str

    > The name of the fits file, possibly including an extension.

    inweight : str, otional

    > The name of a file containing a pixel by pixel weighting of the input data. If it is not set, an array will be generated where all values are set to one.

    xmin : float, otional

    > This and the following three parameters set a bounding rectangle on the output image. Only pixels on the output image inside this rectangle will have their flux updated. Xmin sets the minimum value of the x dimension. The x dimension is the dimension that varies quickest on the image. If the value is zero or less, no minimum will be set in the x dimension. All four parameters are zero based, counting starts at zero.

    xmax : float, otional

    > Sets the maximum value of the x dimension on the bounding box of the ouput image. If the value is zero or less, no maximum will be set in the x dimension.

    ymin : float, optional

    > Sets the minimum value in the y dimension on the bounding box. The y dimension varies less rapidly than the x and represents the line index on the output image. If the value is zero or less, no minimum will be set in the y dimension.

    ymax : float, optional

    > Sets the maximum value in the y dimension. If the value is zero or less, no maximum will be set in the y dimension.

    unitkey : string, optional

    > The name of the header keyword containing the image units. The units can either be “counts” or “cps” (counts per second.) If it is left blank, the value is assumed to be “cps.” If the value is counts, before using the input image it is scaled by dividing it by the exposure time.

    expkey : string, optional

    > The name of the header keyword containing the exposure time. The exposure time is used to scale the image if the units are counts and to scale the image weighting if the drizzle was initialized with wt_scl equal to “exptime” or “expsq.” If the value of this parameter is blank, the exposure time is set to one, implying no scaling.

    wt_scl : float, optional

    > If drizzle was initialized with wt_scl left blank, this value will set a scaling factor for the pixel weighting. If drizzle was initialized with wt_scl set to “exptime” or “expsq”, the exposure time will be used to set the weight scaling and the value of this parameter will be ignored.

  `add_image`(insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0, expin=1.0, in_units=u'cps', wt_scl=1.0)

    Combine an input image with the output drizzled image.

    Instead of reading the parameters from a fits file, you can set them by calling this lower level method. `Add_fits_file` calls this method after doing its setup.

    Parameters:

    insci : array

    > A 2d numpy array containing the input image to be drizzled. it is an error to not supply an image.

    inwcs : wcs

    > The world coordinate system of the input image. This is used to convert the pixels to the output coordinate system.

    inwht : array, optional

    > A 2d numpy array containing the pixel by pixel weighting. Must have the same dimenstions as insci. If none is supplied, the weghting is set to one.

    xmin : float, optional

    > This and the following three parameters set a bounding rectangle on the output image. Only pixels on the output image inside this rectangle will have their flux updated. Xmin sets the minimum value of the x dimension. The x dimension is the dimension that varies quickest on the image. If the value is zero or less, no minimum will be set in the x dimension. All four parameters are zero based, counting starts at zero.

    xmax : float, optional

    > Sets the maximum value of the x dimension on the bounding box of the ouput image. If the value is zero or less, no maximum will be set in the x dimension.

    ymin : float, optional

    > Sets the minimum value in the y dimension on the bounding box. The y dimension varies less rapidly than the x and represents the line index on the output image. If the value is zero or less, no minimum will be set in the y dimension.

    ymax : float, optional

    > Sets the maximum value in the y dimension. If the value is zero or less, no maximum will be set in the y dimension.

    expin : float, optional

    > The exposure time of the input image, a positive number. The exposure time is used to scale the image if the units are counts and to scale the image weighting if the drizzle was initialized with wt_scl equal to “exptime” or “expsq.”

    in_units : str, optional

    > The units of the input image. The units can either be “counts” or “cps” (counts per second.) If the value is counts, before using the input image it is scaled by dividing it by the exposure time.

    wt_scl : float, optional

    > If drizzle was initialized with wt_scl left blank, this value will set a scaling factor for the pixel weighting. If drizzle was initialized with wt_scl set to “exptime” or “expsq”, the exposure time will be used to set the weight scaling and the value of this parameter will be ignored.

  `blot_fits_file`(infile, interp=u'poly5', sinscl=1.0)

    Resample the output using another image’s world coordinate system.

    Parameters:

    infile : str

    > The name of the fits file containing the world coordinate system that the output file will be resampled to. The name may possibly include an extension.

    interp : str, optional

    > The type of interpolation used in the resampling. The possible values are “nearest” (nearest neighbor interpolation), “linear” (bilinear interpolation), “poly3” (cubic polynomial interpolation), “poly5” (quintic polynomial interpolation), “sinc” (sinc interpolation), “lan3” (3rd order Lanczos interpolation), and “lan5” (5th order Lanczos interpolation).

    sincscl : float, optional

    > The scaling factor for sinc interpolation.

  `blot_image`(blotwcs, interp=u'poly5', sinscl=1.0)

    Resample the output image using an input world coordinate system.

    Parameters:

    blotwcs : wcs

    > The world coordinate system to resample on.

    interp : str, optional

    > The type of interpolation used in the resampling. The possible values are “nearest” (nearest neighbor interpolation), “linear” (bilinear interpolation), “poly3” (cubic polynomial interpolation), “poly5” (quintic polynomial interpolation), “sinc” (sinc interpolation), “lan3” (3rd order Lanczos interpolation), and “lan5” (5th order Lanczos interpolation).

    sincscl : float, optional

    > The scaling factor for sinc interpolation.

  `increment_id`()

    Increment the id count and add a plane to the context image if needed

    Drizzle tracks which input images contribute to the output image by setting a bit in the corresponding pixel in the context image. The uniqid indicates which bit. So it must be incremented each time a new image is added. Each plane in the context image can hold 32 bits, so after each 32 images, a new plane is added to the context.

  `write`(outfile, out_units=u'cps', outheader=None)

    Write the output from a set of drizzled images to a file.

    The output file will contain three extensions. The “SCI” extension contains the resulting image. The “WHT” extension contains the combined weights. The “CTX” extension is a bit map. The nth bit is set to one if the nth input image contributed non-zero flux to the output image. The “CTX” image is three dimensionsional to account for the possibility that there are more than 32 input images.

    Parameters:

    outfile : str

    > The name of the output file. If the file already exists, the old file is deleted after writing the new file.

    out_units : str, optional

    > The units of the output image, either `counts` or `cps` (counts per second.) If the units are counts, the resulting image will be multiplied by the computed exposure time.

    outheader : header, optional

    > A fits header containing cards to be added to the primary header of the output image.