DefectMock

class lsst.ip.isr.DefectMock(**kwargs)

Bases: lsst.ip.isr.IsrMock

Simulated defect list.

Methods Summary

amplifierAddCT(ampDataSource, ampDataTarget, …) Add a scaled copy of an amplifier to another, simulating crosstalk.
amplifierAddFringe(amp, ampData, scale[, x0, y0]) Add a fringe-like ripple pattern to an amplifier’s image data.
amplifierAddNoise(ampData, mean, sigma) Add Gaussian noise to an amplifier’s image data.
amplifierAddSource(ampData, scale, x0, y0) Add a single Gaussian source to an amplifier.
amplifierAddYGradient(ampData, start, end) Add a y-axis linear gradient to an amplifier’s image data.
amplifierMultiplyFlat(amp, ampData, fracDrop) Multiply an amplifier’s image data by a flat-like pattern.
emptyMetadata() Empty (clear) the metadata for this Task and all sub-Tasks.
getCamera() Construct a test camera object.
getExposure() Construct a test exposure.
getFullMetadata() Get metadata for all tasks.
getFullName() Get the task name as a hierarchical name including parent task names.
getName() Get the name of the task.
getTaskDict() Get a dictionary of all tasks as a shallow copy.
getWcs() Construct a dummy WCS object.
localCoordToExpCoord(ampData, x, y) Convert between a local amplifier coordinate and the full exposure coordinate.
makeBfKernel() Generate a simple Gaussian brighter-fatter kernel.
makeCrosstalkCoeff() Generate the simulated crosstalk coefficients.
makeData() Generate simulated ISR data.
makeDefectList() Generate a simple single-entry defect list.
makeField(doc) Make a lsst.pex.config.ConfigurableField for this task.
makeImage() Generate a simulated ISR image.
makeSubtask(name, **keyArgs) Create a subtask as a new instance as the name attribute of this task.
makeTransmissionCurve() Generate a simulated flat transmission curve.
run() Generate a mock ISR product, and return it.
timer(name, logLevel) Context manager to log performance data for an arbitrary block of code.

Methods Documentation

amplifierAddCT(ampDataSource, ampDataTarget, scale)

Add a scaled copy of an amplifier to another, simulating crosstalk.

This method operates in the amplifier coordinate frame.
Parameters:
ampDataSource : lsst.afw.image.ImageF

Amplifier image to add scaled copy from.

ampDataTarget : lsst.afw.image.ImageF

Amplifier image to add scaled copy to.

scale : float

Flux scale of the copy to add to the target.

Notes

This simulates simple crosstalk between amplifiers.

amplifierAddFringe(amp, ampData, scale, x0=100, y0=0)

Add a fringe-like ripple pattern to an amplifier’s image data.

Parameters:
amp : AmpInfoRecord

Amplifier to operate on. Needed for amp<->exp coordinate transforms.

ampData : lsst.afw.image.ImageF

Amplifier image to operate on.

scale : numpy.array or float

Peak intensity scaling for the ripple.

x0 : numpy.array or float, optional

Fringe center

y0 : numpy.array or float, optional

Fringe center

Notes

This uses an offset sinc function to generate a ripple pattern. True fringes have much finer structure, but this pattern should be visually identifiable. The (x, y) coordinates are in the frame of the amplifier, and (u, v) in the frame of the full trimmed image.

amplifierAddNoise(ampData, mean, sigma)

Add Gaussian noise to an amplifier’s image data.

This method operates in the amplifier coordinate frame.
Parameters:
ampData : lsst.afw.image.ImageF

Amplifier image to operate on.

mean : float

Mean value of the Gaussian noise.

sigma : float

Sigma of the Gaussian noise.

amplifierAddSource(ampData, scale, x0, y0)

Add a single Gaussian source to an amplifier.

This method operates in the amplifier coordinate frame.
Parameters:
ampData : lsst.afw.image.ImageF

Amplifier image to operate on.

scale : float

Peak flux of the source to add.

x0 : float

X-coordinate of the source peak.

y0 : float

Y-coordinate of the source peak.

amplifierAddYGradient(ampData, start, end)

Add a y-axis linear gradient to an amplifier’s image data.

This method operates in the amplifier coordinate frame.
Parameters:
ampData : lsst.afw.image.ImageF

Amplifier image to operate on.

start : float

Start value of the gradient (at y=0).

end : float

End value of the gradient (at y=ymax).

amplifierMultiplyFlat(amp, ampData, fracDrop, u0=100.0, v0=100.0)

Multiply an amplifier’s image data by a flat-like pattern.

Parameters:
amp : lsst.afw.ampInfo.AmpInfoRecord

Amplifier to operate on. Needed for amp<->exp coordinate transforms.

ampData : lsst.afw.image.ImageF

Amplifier image to operate on.

fracDrop : float

Fractional drop from center to edge of detector along x-axis.

u0 : float

Peak location in detector coordinates.

v0 : float

Peak location in detector coordinates.

Notes

This uses a 2-d Gaussian to simulate an illumination pattern that falls off towards the edge of the detector. The (x, y) coordinates are in the frame of the amplifier, and (u, v) in the frame of the full trimmed image.

emptyMetadata() → None

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

getCamera()

Construct a test camera object.

Returns:
camera : lsst.afw.cameraGeom.camera

Test camera.

getExposure()

Construct a test exposure.

The test exposure has a simple WCS set, as well as a list of unlikely header keywords that can be removed during ISR processing to exercise that code.

Returns:
exposure : lsst.afw.exposure.Exposure

Construct exposure containing masked image of the appropriate size.

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.

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”.
getName() → str

Get the name of the task.

Returns:
taskName : str

Name of the task.

See also

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

getWcs()

Construct a dummy WCS object.

Taken from the deprecated ip_isr/examples/exampleUtils.py.

This is not guaranteed, given the distortion and pixel scale listed in the afwTestUtils camera definition.

Returns:
wcs : lsst.afw.geom.SkyWcs

Test WCS transform.

localCoordToExpCoord(ampData, x, y)

Convert between a local amplifier coordinate and the full exposure coordinate.

Parameters:
ampData : lsst.afw.image.ImageF

Amplifier image to use for conversions.

x : int

X-coordinate of the point to transform.

y : int

Y-coordinate of the point to transform.

Returns:
u : int

Transformed x-coordinate.

v : int

Transformed y-coordinate.

Notes

The output is transposed intentionally here, to match the internal transpose between numpy and afw.image coordinates.

makeBfKernel()

Generate a simple Gaussian brighter-fatter kernel.

Returns:
kernel : numpy.ndarray

Simulated brighter-fatter kernel.

makeCrosstalkCoeff()

Generate the simulated crosstalk coefficients.

Returns:
coeffs : numpy.ndarray

Simulated crosstalk coefficients.

makeData()

Generate simulated ISR data.

Currently, only the class defined crosstalk coefficient matrix, brighter-fatter kernel, a constant unity transmission curve, or a simple single-entry defect list can be generated.

Returns:
dataProduct :

Simulated ISR data product.

makeDefectList()

Generate a simple single-entry defect list.

Returns:
defectList : lsst.meas.algorithms.Defects

Simulated defect list

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")
makeImage()

Generate a simulated ISR image.

Returns:
exposure : lsst.afw.image.Exposure or dict

Simulated ISR image data.

Notes

This method currently constructs a “raw” data image by:

  • Generating a simulated sky with noise
  • Adding a single Gaussian “star”
  • Adding the fringe signal
  • Multiplying the frame by the simulated flat
  • Adding dark current (and noise)
  • Adding a bias offset (and noise)
  • Adding an overscan gradient parallel to the pixel y-axis
  • Simulating crosstalk by adding a scaled version of each amplifier to each other amplifier.

The exposure with image data constructed this way is in one of three formats.

  • A single image, with overscan and prescan regions retained
  • A single image, with overscan and prescan regions trimmed
  • A dict, containing the amplifer data indexed by the amplifier name.

The nonlinearity, CTE, and brighter fatter are currently not implemented.

Note that this method generates an image in the reverse direction as the ISR processing, as the output image here has had a series of instrument effects added to an idealized exposure.

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 of ConfigurableField or RegistryField.

makeTransmissionCurve()

Generate a simulated flat transmission curve.

Returns:
transmission : lsst.afw.image.TransmissionCurve

Simulated transmission curve.

run()

Generate a mock ISR product, and return it.

Returns:
image : lsst.afw.image.Exposure

Simulated ISR image with signals added.

dataProduct :

Simulated ISR data products.

None :

Returned if no valid configuration was found.

Raises:
RuntimeError

Raised if both doGenerateImage and doGenerateData are specified.

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

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

Parameters:
name : str

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