OverscanCorrectionTask¶
-
class
lsst.ip.isr.
OverscanCorrectionTask
(statControl=None, **kwargs)¶ Bases:
lsst.pipe.base.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: - statControl :
lsst.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: - overscanValue :
numpy.ndarray
, (Nrows, ) or scalar Overscan fit to broadcast.
- imageArray :
numpy.ndarray
, (Nrows, Ncols) Image array that we want to match.
- transpose :
bool
, optional Switch order to broadcast along the other axis.
Returns: - overscanModel :
numpy.ndarray
, (Nrows, Ncols) or scalar Expanded overscan fit.
Raises: - RuntimeError
Raised if no axis has the appropriate dimension.
- overscanValue :
-
static
collapseArray
(maskedArray)¶ Collapse overscan array (and mask) to a 1-D vector of values.
Parameters: - maskedArray :
numpy.ma.masked_array
Masked array of input overscan data.
Returns: - collapsed :
numpy.ma.masked_array
Single dimensional overscan data, combined with the mean.
- maskedArray :
-
collapseArrayMedian
(maskedArray)¶ Collapse overscan array (and mask) to a 1-D vector of using the correct integer median of row-values.
Parameters: - maskedArray :
numpy.ma.masked_array
Masked array of input overscan data.
Returns: - collapsed :
numpy.ma.masked_array
Single dimensional overscan data, combined with the afwMath median.
- maskedArray :
-
correctOverscan
(exposure, amp, imageBBox, overscanBBox, isTransposed=True)¶
-
debugView
(image, model, amp=None)¶ Debug display for the final overscan solution.
Parameters: - image :
lsst.afw.image.Image
Input image the overscan solution was determined from.
- model :
numpy.ndarray
orfloat
Overscan model determined for the image.
- amp :
lsst.afw.cameraGeom.Amplifier
, optional Amplifier to extract diagnostic information.
- image :
-
emptyMetadata
() → None¶ Empty (clear) the metadata for this Task and all sub-Tasks.
-
fitOverscan
(overscanImage, isTransposed=False)¶
-
getFullMetadata
() → lsst.pipe.base._task_metadata.TaskMetadata¶ Get metadata for all tasks.
Returns: - metadata :
TaskMetadata
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.- metadata :
-
getFullName
() → str¶ Get the task name as a hierarchical name including parent task names.
Returns: - fullName :
str
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”.
- fullName :
-
getImageArray
(image)¶ Extract the numpy array from the input image.
Parameters: - image :
lsst.afw.image.Image
orlsst.afw.image.MaskedImage
Image data to pull array from.
- calcImage :
numpy.ndarray
Image data array for numpy operating.
- image :
-
getTaskDict
() → Dict[str, weakref.ReferenceType[lsst.pipe.base.task.Task]]¶ Get a dictionary of all tasks as a shallow copy.
Returns: - taskDict :
dict
Dictionary containing full task name: task object for the top-level task and all subtasks, sub-subtasks, etc.
- taskDict :
-
static
integerConvert
(image)¶ Return an integer version of the input image.
Parameters: - image :
numpy.ndarray
,lsst.afw.image.Image
orMaskedImage
Image to convert to integers.
Returns: - outI :
numpy.ndarray
,lsst.afw.image.Image
orMaskedImage
The integer converted image.
Raises: - RuntimeError
Raised if the input image could not be converted.
- image :
-
classmethod
makeField
(doc: str) → lsst.pex.config.configurableField.ConfigurableField¶ Make a
lsst.pex.config.ConfigurableField
for this task.Parameters: - doc :
str
Help text for the field.
Returns: - configurableField :
lsst.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")
- doc :
-
makeSubtask
(name: str, **keyArgs) → None¶ Create a subtask as a new instance as the
name
attribute of this task.Parameters: - name :
str
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 ofConfigurableField
orRegistryField
.- name :
-
static
maskExtrapolated
(collapsed)¶ Create mask if edges are extrapolated.
Parameters: - collapsed :
numpy.ma.masked_array
Masked array to check the edges of.
Returns: - maskArray :
numpy.ndarray
Boolean numpy array of pixels to mask.
- collapsed :
-
maskOutliers
(imageArray)¶ Mask outliers in a row of overscan data from a robust sigma clipping procedure.
Parameters: - imageArray :
numpy.ndarray
Image to filter along numpy axis=1.
Returns: - maskedArray :
numpy.ma.masked_array
Masked image marking outliers.
- imageArray :
-
measureConstantOverscan
(image)¶ Measure a constant overscan value.
Parameters: - image :
lsst.afw.image.Image
orlsst.afw.image.MaskedImage
Image data to measure the overscan from.
Returns: - results :
lsst.pipe.base.Struct
Overscan result with entries: -
overscanValue
: Overscan value to subtract (float
) -isTransposed
: Orientation of the overscan (bool
)
- image :
-
measureVectorOverscan
(image, isTransposed=False)¶ Calculate the 1-d vector overscan from the input overscan image.
Parameters: - image :
lsst.afw.image.MaskedImage
Image containing the overscan data.
- isTransposed :
bool
If true, the image has been transposed.
Returns: - results :
lsst.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
)
- image :
-
run
(exposure, amp, isTransposed=False)¶ Measure and remove an overscan from an amplifier image.
Parameters: - exposure :
lsst.afw.image.Exposure
Image data that will have the overscan corrections applied.
- amp :
lsst.afw.cameraGeom.Amplifier
Amplifier to use for debugging purposes.
- isTransposed :
bool
, optional Is the image transposed, such that serial and parallel overscan regions are reversed? Default is False.
Returns: - overscanResults :
lsst.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.
- exposure :
-
static
splineEval
(indices, interp)¶ Wrapper function to match spline evaluation API to polynomial fit API.
Parameters: - indices :
numpy.ndarray
Locations to evaluate the spline.
- interp :
lsst.afw.math.interpolate
Interpolation object to use.
Returns: - values :
numpy.ndarray
Evaluated spline values at each index.
- indices :
-
splineFit
(indices, collapsed, numBins)¶ Wrapper function to match spline fit API to polynomial fit API.
Parameters: - indices :
numpy.ndarray
Locations to evaluate the spline.
- collapsed :
numpy.ndarray
Collapsed overscan values corresponding to the spline evaluation points.
- numBins :
int
Number of bins to use in constructing the spline.
Returns: - interp :
lsst.afw.math.Interpolate
Interpolation object for later evaluation.
- indices :
-
timer
(name: str, logLevel: int = 10) → Iterator[None]¶ Context manager to log performance data for an arbitrary block of code.
Parameters: 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: - exposure :
lsst.afw.image.Exposure
Exposure containing data.
- amp :
lsst.afw.cameraGeom.Amplifier
Amplifier containing geometry information.
- bbox :
lsst.geom.Box2I
Bounding box of the overscan region.
- skipLeading :
int
Number of leading (towards data region) rows/columns to skip.
- skipTrailing :
int
Number of trailing (away from data region) rows/columns to skip.
- transpose :
bool
, optional Operate on the transposed array.
Returns: - overscanArray :
numpy.array
, (N, M) Data array to fit.
- overscanMask :
numpy.array
, (N, M) Data mask.
- exposure :
- statControl :