OverscanCorrectionTask

class lsst.ip.isr.OverscanCorrectionTask(statControl=None, **kwargs)

Bases: Task

Correction task for overscan.

This class contains a number of utilities that are easier to understand and use when they are not embedded in nested if/else loops.

Parameters:
statControllsst.afw.math.StatisticsControl, optional

Statistics control object.

Methods Summary

broadcastFitToImage(overscanValue, imageArray)

Broadcast 0 or 1 dimension fit to appropriate shape.

collapseArray(maskedArray)

Collapse overscan array (and mask) to a 1-D vector of values.

collapseArrayMedian(maskedArray)

Collapse overscan array (and mask) to a 1-D vector of using the correct integer median of row-values.

correctOverscan(exposure, amp, imageBBox, ...)

debugView(image, model[, amp])

Debug display for the final overscan solution.

emptyMetadata()

Empty (clear) the metadata for this Task and all sub-Tasks.

fitOverscan(overscanImage[, isTransposed])

getFullMetadata()

Get metadata for all tasks.

getFullName()

Get the task name as a hierarchical name including parent task names.

getImageArray(image)

Extract the numpy array from the input image.

getName()

Get the name of the task.

getTaskDict()

Get a dictionary of all tasks as a shallow copy.

integerConvert(image)

Return an integer version of the input image.

makeField(doc)

Make a lsst.pex.config.ConfigurableField for this task.

makeSubtask(name, **keyArgs)

Create a subtask as a new instance as the name attribute of this task.

maskExtrapolated(collapsed)

Create mask if edges are extrapolated.

maskOutliers(imageArray)

Mask outliers in a row of overscan data from a robust sigma clipping procedure.

measureConstantOverscan(image)

Measure a constant overscan value.

measureVectorOverscan(image[, isTransposed])

Calculate the 1-d vector overscan from the input overscan image.

run(exposure, amp[, isTransposed])

Measure and remove an overscan from an amplifier image.

splineEval(indices, interp)

Wrapper function to match spline evaluation API to polynomial fit API.

splineFit(indices, collapsed, numBins)

Wrapper function to match spline fit API to polynomial fit API.

timer(name[, logLevel])

Context manager to log performance data for an arbitrary block of code.

trimOverscan(exposure, amp, bbox, ...[, ...])

Trim overscan region to remove edges.

Methods Documentation

broadcastFitToImage(overscanValue, imageArray, transpose=False)

Broadcast 0 or 1 dimension fit to appropriate shape.

Parameters:
overscanValuenumpy.ndarray, (Nrows, ) or scalar

Overscan fit to broadcast.

imageArraynumpy.ndarray, (Nrows, Ncols)

Image array that we want to match.

transposebool, optional

Switch order to broadcast along the other axis.

Returns:
overscanModelnumpy.ndarray, (Nrows, Ncols) or scalar

Expanded overscan fit.

Raises:
RuntimeError

Raised if no axis has the appropriate dimension.

static collapseArray(maskedArray)

Collapse overscan array (and mask) to a 1-D vector of values.

Parameters:
maskedArraynumpy.ma.masked_array

Masked array of input overscan data.

Returns:
collapsednumpy.ma.masked_array

Single dimensional overscan data, combined with the mean.

collapseArrayMedian(maskedArray)

Collapse overscan array (and mask) to a 1-D vector of using the correct integer median of row-values.

Parameters:
maskedArraynumpy.ma.masked_array

Masked array of input overscan data.

Returns:
collapsednumpy.ma.masked_array

Single dimensional overscan data, combined with the afwMath median.

correctOverscan(exposure, amp, imageBBox, overscanBBox, isTransposed=True)
debugView(image, model, amp=None)

Debug display for the final overscan solution.

Parameters:
imagelsst.afw.image.Image

Input image the overscan solution was determined from.

modelnumpy.ndarray or float

Overscan model determined for the image.

amplsst.afw.cameraGeom.Amplifier, optional

Amplifier to extract diagnostic information.

emptyMetadata() None

Empty (clear) the metadata for this Task and all sub-Tasks.

fitOverscan(overscanImage, isTransposed=False)
getFullMetadata() TaskMetadata

Get metadata for all tasks.

Returns:
metadataTaskMetadata

The keys are the full task name. Values are metadata for the top-level task and all subtasks, sub-subtasks, etc.

Notes

The returned metadata includes timing information (if @timer.timeMethod is used) and any metadata set by the task. The name of each item consists of the full task name with . replaced by :, followed by . and the name of the item, e.g.:

topLevelTaskName:subtaskName:subsubtaskName.itemName

using : in the full task name disambiguates the rare situation that a task has a subtask and a metadata item with the same name.

getFullName() str

Get the task name as a hierarchical name including parent task names.

Returns:
fullNamestr

The full name consists of the name of the parent task and each subtask separated by periods. For example:

  • The full name of top-level task “top” is simply “top”.

  • The full name of subtask “sub” of top-level task “top” is “top.sub”.

  • The full name of subtask “sub2” of subtask “sub” of top-level task “top” is “top.sub.sub2”.

getImageArray(image)

Extract the numpy array from the input image.

Parameters:
imagelsst.afw.image.Image or lsst.afw.image.MaskedImage

Image data to pull array from.

calcImagenumpy.ndarray

Image data array for numpy operating.

getName() str

Get the name of the task.

Returns:
taskNamestr

Name of the task.

See also

getFullName
getTaskDict() Dict[str, ReferenceType[Task]]

Get a dictionary of all tasks as a shallow copy.

Returns:
taskDictdict

Dictionary containing full task name: task object for the top-level task and all subtasks, sub-subtasks, etc.

static integerConvert(image)

Return an integer version of the input image.

Parameters:
imagenumpy.ndarray, lsst.afw.image.Image or MaskedImage

Image to convert to integers.

Returns:
outInumpy.ndarray, lsst.afw.image.Image or MaskedImage

The integer converted image.

Raises:
RuntimeError

Raised if the input image could not be converted.

classmethod makeField(doc: str) ConfigurableField

Make a lsst.pex.config.ConfigurableField for this task.

Parameters:
docstr

Help text for the field.

Returns:
configurableFieldlsst.pex.config.ConfigurableField

A ConfigurableField for this task.

Examples

Provides a convenient way to specify this task is a subtask of another task.

Here is an example of use:

class OtherTaskConfig(lsst.pex.config.Config):
    aSubtask = ATaskClass.makeField("brief description of task")
makeSubtask(name: str, **keyArgs: Any) None

Create a subtask as a new instance as the name attribute of this task.

Parameters:
namestr

Brief name of the subtask.

keyArgs

Extra keyword arguments used to construct the task. The following arguments are automatically provided and cannot be overridden:

  • “config”.

  • “parentTask”.

Notes

The subtask must be defined by Task.config.name, an instance of ConfigurableField or RegistryField.

static maskExtrapolated(collapsed)

Create mask if edges are extrapolated.

Parameters:
collapsednumpy.ma.masked_array

Masked array to check the edges of.

Returns:
maskArraynumpy.ndarray

Boolean numpy array of pixels to mask.

maskOutliers(imageArray)

Mask outliers in a row of overscan data from a robust sigma clipping procedure.

Parameters:
imageArraynumpy.ndarray

Image to filter along numpy axis=1.

Returns:
maskedArraynumpy.ma.masked_array

Masked image marking outliers.

measureConstantOverscan(image)

Measure a constant overscan value.

Parameters:
imagelsst.afw.image.Image or lsst.afw.image.MaskedImage

Image data to measure the overscan from.

Returns:
resultslsst.pipe.base.Struct

Overscan result with entries: - overscanValue: Overscan value to subtract (float) - isTransposed: Orientation of the overscan (bool)

measureVectorOverscan(image, isTransposed=False)

Calculate the 1-d vector overscan from the input overscan image.

Parameters:
imagelsst.afw.image.MaskedImage

Image containing the overscan data.

isTransposedbool

If true, the image has been transposed.

Returns:
resultslsst.pipe.base.Struct

Overscan result with entries:

overscanValue

Overscan value to subtract (float)

maskArray

List of rows that should be masked as SUSPECT when the overscan solution is applied. (list [ bool ])

isTransposed

Indicates if the overscan data was transposed during calcuation, noting along which axis the overscan should be subtracted. (bool)

run(exposure, amp, isTransposed=False)

Measure and remove an overscan from an amplifier image.

Parameters:
exposurelsst.afw.image.Exposure

Image data that will have the overscan corrections applied.

amplsst.afw.cameraGeom.Amplifier

Amplifier to use for debugging purposes.

isTransposedbool, optional

Is the image transposed, such that serial and parallel overscan regions are reversed? Default is False.

Returns:
overscanResultslsst.pipe.base.Struct

Result struct with components:

imageFit

Value or fit subtracted from the amplifier image data (scalar or lsst.afw.image.Image).

overscanFit

Value or fit subtracted from the serial overscan image data (scalar or lsst.afw.image.Image).

overscanImage

Image of the serial overscan region with the serial overscan correction applied (lsst.afw.image.Image). This quantity is used to estimate the amplifier read noise empirically.

parallelOverscanFit

Value or fit subtracted from the parallel overscan image data (scalar, lsst.afw.image.Image, or None).

parallelOverscanImage

Image of the parallel overscan region with the parallel overscan correction applied (lsst.afw.image.Image or None).

Raises:
RuntimeError

Raised if an invalid overscan type is set.

static splineEval(indices, interp)

Wrapper function to match spline evaluation API to polynomial fit API.

Parameters:
indicesnumpy.ndarray

Locations to evaluate the spline.

interplsst.afw.math.interpolate

Interpolation object to use.

Returns:
valuesnumpy.ndarray

Evaluated spline values at each index.

splineFit(indices, collapsed, numBins)

Wrapper function to match spline fit API to polynomial fit API.

Parameters:
indicesnumpy.ndarray

Locations to evaluate the spline.

collapsednumpy.ndarray

Collapsed overscan values corresponding to the spline evaluation points.

numBinsint

Number of bins to use in constructing the spline.

Returns:
interplsst.afw.math.Interpolate

Interpolation object for later evaluation.

timer(name: str, logLevel: int = 10) Iterator[None]

Context manager to log performance data for an arbitrary block of code.

Parameters:
namestr

Name of code being timed; data will be logged using item name: Start and End.

logLevel

A logging level constant.

See also

timer.logInfo

Examples

Creating a timer context:

with self.timer("someCodeToTime"):
    pass  # code to time
trimOverscan(exposure, amp, bbox, skipLeading, skipTrailing, transpose=False)

Trim overscan region to remove edges.

Parameters:
exposurelsst.afw.image.Exposure

Exposure containing data.

amplsst.afw.cameraGeom.Amplifier

Amplifier containing geometry information.

bboxlsst.geom.Box2I

Bounding box of the overscan region.

skipLeadingint

Number of leading (towards data region) rows/columns to skip.

skipTrailingint

Number of trailing (away from data region) rows/columns to skip.

transposebool, optional

Operate on the transposed array.

Returns:
overscanArraynumpy.array, (N, M)

Data array to fit.

overscanMasknumpy.array, (N, M)

Data mask.