AmpOffsetTask

class lsst.ip.isr.AmpOffsetTask(*args, **kwargs)

Bases: Task

Calculate and apply amp offset corrections to an exposure.

Methods Summary

emptyMetadata()

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

getAmpAssociations(amps)

Determine amp geometry and amp associations from a list of amplifiers.

getAmpEdges(im, amps, ampSides)

Calculate the amp edges for all amplifiers.

getAmpOffsets(im, amps, associations, sides)

Calculate the amp offsets for all amplifiers.

getFullMetadata()

Get metadata for all tasks.

getFullName()

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

getInterfaceOffset(ampNameA, ampNameB, ...)

Calculate the amp offset for a given interface between two amplifiers.

getName()

Get the name of the task.

getNeighbors(ampIds, ampId)

Get the neighbor amplifiers and their sides for a given amplifier.

getTaskDict()

Get a dictionary of all tasks as a shallow copy.

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.

run(exposure)

Calculate amp offset values, determine corrective pedestals for each amp, and update the input exposure in-place.

timer(name[, logLevel])

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

Methods Documentation

emptyMetadata() None

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

getAmpAssociations(amps)

Determine amp geometry and amp associations from a list of amplifiers.

Parse an input list of amplifiers to determine the layout of amps within a detector, and identify all amp sides (i.e., the horizontal and vertical junctions between amps).

Returns a matrix with a shape corresponding to the geometry of the amps in the detector.

Parameters:
ampslist [lsst.afw.cameraGeom.Amplifier]

List of amplifier objects used to deduce associations.

Returns:
ampAssociationsnumpy.ndarray

An N x N matrix (N = number of amplifiers) that illustrates the connections between amplifiers within the detector layout. Each row and column index corresponds to the ampIds of a specific pair of amplifiers, and the matrix elements indicate their associations as follows:

  • 0: No association

  • -1: Association exists (direction specified in the ampSides matrix)

  • n >= 1: Diagonal elements indicate the number of neighboring amplifiers for the corresponding ampId==row==column number.

ampSidesnumpy.ndarray

An N x N matrix (N = the number of amplifiers) representing the amp side information corresponding to the ampAssociations matrix. The elements are integers defined as below:

  • -1: No side due to no association or the same amp (diagonals)

  • 0: Side on the bottom

  • 1: Side on the right

  • 2: Side on the top

  • 3: Side on the left

getAmpEdges(im, amps, ampSides)

Calculate the amp edges for all amplifiers.

Parameters:
imlsst.afw.image._image.ImageF

Amplifier image to extract data from.

ampslist [lsst.afw.cameraGeom.Amplifier]

List of amplifier objects.

ampSidesnumpy.ndarray

An N x N matrix containing amp side information, where N is the number of amplifiers.

Returns:
ampEdgesdict [int, dict [int, numpy.ndarray]]

A dictionary containing amp edge(s) for each amplifier, corresponding to one or more potential sides, where each edge is associated with a side. The outer dictionary has integer keys representing amplifier IDs, and the inner dictionary has integer keys representing side IDs for each amplifier and values that are 1D arrays of floats representing the 1D medianified strips from the amp image, referred to as “amp edge”: {ampID: {sideID: numpy.ndarray}, …}

getAmpOffsets(im, amps, associations, sides)

Calculate the amp offsets for all amplifiers.

Parameters:
imlsst.afw.image._image.ImageF

Amplifier image to extract data from.

ampslist [lsst.afw.cameraGeom.Amplifier]

List of amplifier objects.

associationsnumpy.ndarray

An N x N matrix containing amp association information, where N is the number of amplifiers.

sidesnumpy.ndarray

An N x N matrix containing amp side information, where N is the number of amplifiers.

Returns:
ampsOffsetsnumpy.ndarray

1D float array containing the calculated amp offsets for all amplifiers.

interfaceOffsetDictdict [str, float]

Dictionary mapping interface IDs to their corresponding raw (uncapped) offset values.

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”.

getInterfaceOffset(ampNameA, ampNameB, edgeA, edgeB)

Calculate the amp offset for a given interface between two amplifiers.

Parameters:
ampNameAstr

Name of the first amplifier.

ampNameBstr

Name of the second amplifier.

edgeAnumpy.ndarray

Amp edge for the first amplifier.

edgeBnumpy.ndarray

Amp edge for the second amplifier.

Returns:
interfaceOffsetfloat

The calculated amp offset value for the given interface between amps A and B.

interfaceOffsetOriginalfloat

The original calculated amp offset value for the given interface between amps A and B.

ampEdgeGoodFracfloat

Fraction of viable pixel rows along the amp edge.

minFracFailbool

True if the fraction of unmasked pixel rows is below the ampEdgeMinFrac threshold.

maxOffsetFailbool

True if the absolute offset value exceeds the ampEdgeMaxOffset threshold.

getName() str

Get the name of the task.

Returns:
taskNamestr

Name of the task.

See also

getFullName

Get the full name of the task.

getNeighbors(ampIds, ampId)

Get the neighbor amplifiers and their sides for a given amplifier.

Parameters:
ampIdsnumpy.ndarray

Matrix with amp side association information.

ampIdint

The amplifier ID for which neighbor amplifiers and side IDs are to be found.

Returns:
neighborslist [int]

List of neighbor amplifier IDs.

sideslist [int]

List of side IDs, with each ID corresponding to its respective neighbor amplifier.

getTaskDict() dict[str, weakref.ReferenceType[lsst.pipe.base.task.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.

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.

run(exposure)

Calculate amp offset values, determine corrective pedestals for each amp, and update the input exposure in-place.

Parameters:
exposure: `lsst.afw.image.Exposure`

Exposure to be corrected for amp offsets.

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.

logLevelint

A logging level constant.

See also

lsst.utils.timer.logInfo

Implementation function.

Examples

Creating a timer context:

with self.timer("someCodeToTime"):
    pass  # code to time