Drizzle

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

Bases: object

Combine images using the drizzle algorithm

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='', xmin=0, xmax=0, ymin=0, ymax=0, unitkey='', expkey='', wt_scl=1.0)

Combine a fits file with the output drizzled image.

infilestr

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

inweightstr, 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.

xminfloat, 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.

xmaxfloat, 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.

yminfloat, 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.

ymaxfloat, 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.

unitkeystring, 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.

expkeystring, 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_sclfloat, 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='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.

insciarray

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

inwcswcs

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

inwhtarray, 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.

xminfloat, 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.

xmaxfloat, 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.

yminfloat, 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.

ymaxfloat, 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.

expinfloat, 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_unitsstr, 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_sclfloat, 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='poly5', sinscl=1.0)

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

infilestr

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.

interpstr, 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).

sincsclfloat, optional

The scaling factor for sinc interpolation.

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

Resample the output image using an input world coordinate system.

blotwcswcs

The world coordinate system to resample on.

interpstr, 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).

sincsclfloat, 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='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.

outfilestr

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

out_unitsstr, 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.

outheaderheader, optional

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