IsrMock#
- class lsst.ip.isr.IsrMock(**kwargs)#
Bases:
TaskClass to generate consistent mock images for ISR testing.
ISR testing currently relies on one-off fake images that do not accurately mimic the full set of detector effects. This class uses the test camera/detector/amplifier structure defined in
lsst.afw.cameraGeom.testUtilsto avoid making the test data dependent on any of the actual obs package formats.Methods Summary
amplifierAddFringe(amp, ampData, scale[, x0, y0])Add a fringe-like ripple pattern to an amplifier's image data.
amplifierAddNoise(ampData, mean, sigma[, rng])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.
getCamera([isForAssembly])Construct a test camera object.
getExposure([isTrimmed])Construct a test exposure.
getWcs()Construct a dummy WCS object.
localCoordToExpCoord(ampData, x, y)Convert between a local amplifier coordinate and the full exposure coordinate.
Generate a simple Gaussian brighter-fatter kernel.
Generate the simulated crosstalk coefficients.
makeData()Generate simulated ISR data.
Generate a simple single-entry defect list.
Generate a CTI calibration.
Generate a simple Gaussian brighter-fatter kernel.
Generate a simulated ISR image.
Generate a linearity dataset.
Generate a simulated flat transmission curve.
run()Generate a mock ISR product, and return it.
Methods Documentation
- 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.arrayorfloat Peak intensity scaling for the ripple.
- x0
numpy.arrayorfloat, optional Fringe center
- y0
numpy.arrayorfloat, 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.
- amp
- amplifierAddNoise(ampData, mean, sigma, rng=None)#
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.
- rng
np.random.RandomState, optional Random state to use instead of self.rng.
- ampData
- 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.
- ampData
- 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).
- ampData
- 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.
- amp
- getCamera(isForAssembly=False)#
Construct a test camera object.
Parameters#
- isForAssembly
bool If True, construct a camera with “super raw” orientation (all amplifiers have LL readout corner but still contains the necessary flip and offset info needed for assembly. This is needed if isLsstLike is True. If False, return a camera with bboxes flipped and offset to the correct orientation given the readout corner.
Returns#
- camera
lsst.afw.cameraGeom.camera Test camera.
- isForAssembly
- getExposure(isTrimmed=None)#
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.
Parameters#
- isTrimmed
boolorNone, optional Override the configuration isTrimmed?
Returns#
- exposure
lsst.afw.exposure.Exposure Construct exposure containing masked image of the appropriate size.
- isTrimmed
- 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.
- wcs
- 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.
- ampData
- makeBfKernel()#
Generate a simple Gaussian brighter-fatter kernel.
Returns#
- kernel
numpy.ndarray Simulated brighter-fatter kernel.
- kernel
- makeCrosstalkCoeff()#
Generate the simulated crosstalk coefficients.
Returns#
- coeffs
numpy.ndarray Simulated crosstalk coefficients.
- coeffs
- 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
- defectList
- makeDeferredChargeCalib()#
Generate a CTI calibration.
- makeElectrostaticBf()#
Generate a simple Gaussian brighter-fatter kernel.
Returns#
- kernel
numpy.ndarray Simulated brighter-fatter kernel.
- kernel
- makeImage()#
Generate a simulated ISR image.
Returns#
- exposure
lsst.afw.image.Exposureordict 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.
- exposure
- makeLinearity()#
Generate a linearity dataset.
Returns#
linearizer :
lsst.ip.isr.Linearizer
- makeTransmissionCurve()#
Generate a simulated flat transmission curve.
Returns#
- transmission
lsst.afw.image.TransmissionCurve Simulated transmission curve.
- transmission
- 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.
- image