LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
lsst.ip.isr.isrMock.IsrMock Class Reference
Inheritance diagram for lsst.ip.isr.isrMock.IsrMock:
lsst.ip.isr.isrMock.BfKernelMock lsst.ip.isr.isrMock.CrosstalkCoeffMock lsst.ip.isr.isrMock.DefectMock lsst.ip.isr.isrMock.MasterMock lsst.ip.isr.isrMock.RawMock lsst.ip.isr.isrMock.TransmissionMock lsst.ip.isr.isrMockLSST.IsrMockLSST lsst.ip.isr.isrMock.BiasMock lsst.ip.isr.isrMock.DarkMock lsst.ip.isr.isrMock.FlatMock lsst.ip.isr.isrMock.FringeMock lsst.ip.isr.isrMock.CalibratedRawMock lsst.ip.isr.isrMock.RawDictMock lsst.ip.isr.isrMock.TrimmedRawMock lsst.ip.isr.isrMockLSST.BfKernelMockLSST lsst.ip.isr.isrMockLSST.CrosstalkCoeffMockLSST lsst.ip.isr.isrMockLSST.DefectMockLSST lsst.ip.isr.isrMockLSST.LinearizerMockLSST lsst.ip.isr.isrMockLSST.RawMockLSST lsst.ip.isr.isrMockLSST.ReferenceMockLSST lsst.ip.isr.isrMockLSST.TransmissionMockLSST

Public Member Functions

 __init__ (self, **kwargs)
 
 run (self)
 
 makeData (self)
 
 makeBfKernel (self)
 
 makeDefectList (self)
 
 makeCrosstalkCoeff (self)
 
 makeTransmissionCurve (self)
 
 makeLinearity (self)
 
 makeImage (self)
 
 getCamera (self)
 
 getExposure (self, isTrimmed=None)
 
 getWcs (self)
 
 localCoordToExpCoord (self, ampData, x, y)
 
 amplifierAddNoise (self, ampData, mean, sigma, rng=None)
 
 amplifierAddYGradient (self, ampData, start, end)
 
 amplifierAddSource (self, ampData, scale, x0, y0)
 
 amplifierAddCT (self, ampDataSource, ampDataTarget, scale)
 
 amplifierAddFringe (self, amp, ampData, scale, x0=100, y0=0)
 
 amplifierMultiplyFlat (self, amp, ampData, fracDrop, u0=100.0, v0=100.0)
 

Public Attributes

 rng
 
 crosstalkCoeffs
 
 bfKernel
 

Static Public Attributes

 ConfigClass = IsrMockConfig
 

Protected Attributes

 _display
 

Static Protected Attributes

str _DefaultName = "isrMock"
 

Detailed Description

Class 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.testUtils` to avoid making the test data
dependent on any of the actual obs package formats.

Definition at line 264 of file isrMock.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.ip.isr.isrMock.IsrMock.__init__ ( self,
** kwargs )

Reimplemented in lsst.ip.isr.isrMock.RawMock, lsst.ip.isr.isrMock.TrimmedRawMock, lsst.ip.isr.isrMock.CalibratedRawMock, lsst.ip.isr.isrMock.RawDictMock, lsst.ip.isr.isrMock.MasterMock, lsst.ip.isr.isrMock.BiasMock, lsst.ip.isr.isrMock.DarkMock, lsst.ip.isr.isrMock.FlatMock, lsst.ip.isr.isrMock.FringeMock, lsst.ip.isr.isrMock.UntrimmedFringeMock, lsst.ip.isr.isrMock.BfKernelMock, lsst.ip.isr.isrMock.DefectMock, lsst.ip.isr.isrMock.CrosstalkCoeffMock, lsst.ip.isr.isrMock.TransmissionMock, lsst.ip.isr.isrMockLSST.IsrMockLSST, lsst.ip.isr.isrMockLSST.RawMockLSST, lsst.ip.isr.isrMockLSST.TrimmedRawMockLSST, lsst.ip.isr.isrMockLSST.CalibratedRawMockLSST, lsst.ip.isr.isrMockLSST.ReferenceMockLSST, lsst.ip.isr.isrMockLSST.DarkMockLSST, lsst.ip.isr.isrMockLSST.BiasMockLSST, lsst.ip.isr.isrMockLSST.FlatMockLSST, lsst.ip.isr.isrMockLSST.FringeMockLSST, lsst.ip.isr.isrMockLSST.BfKernelMockLSST, lsst.ip.isr.isrMockLSST.DefectMockLSST, lsst.ip.isr.isrMockLSST.CrosstalkCoeffMockLSST, lsst.ip.isr.isrMockLSST.LinearizerMockLSST, and lsst.ip.isr.isrMockLSST.TransmissionMockLSST.

Definition at line 276 of file isrMock.py.

276 def __init__(self, **kwargs):
277 super().__init__(**kwargs)
278 self.rng = np.random.RandomState(self.config.rngSeed)
279 # The coefficients have units adu for IsrTask and have
280 # units electron for IsrTaskLSST.
281 self.crosstalkCoeffs = np.array([[0.0, 0.0, 0.0, 0.0, 0.0, -1e-3, 0.0, 0.0],
282 [1e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
283 [1e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
284 [1e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
285 [1e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
286 [1e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
287 [1e-2, 0.0, 0.0, 2.2e-2, 0.0, 0.0, 0.0, 0.0],
288 [1e-2, 5e-3, 5e-4, 3e-3, 4e-2, 5e-3, 5e-3, 0.0]])
289 if getDebugFrame(self._display, "mockCrosstalkCoeffs"):
290 self.crosstalkCoeffs = np.array([[0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
291 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
292 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
293 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
294 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
295 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
296 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
297 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])
298 # Generic gaussian BF kernel
299 self.bfKernel = np.array([[1., 4., 7., 4., 1.],
300 [4., 16., 26., 16., 4.],
301 [7., 26., 41., 26., 7.],
302 [4., 16., 26., 16., 4.],
303 [1., 4., 7., 4., 1.]]) / 273.0
304

Member Function Documentation

◆ amplifierAddCT()

lsst.ip.isr.isrMock.IsrMock.amplifierAddCT ( self,
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.

Definition at line 794 of file isrMock.py.

794 def amplifierAddCT(self, ampDataSource, ampDataTarget, scale):
795 """Add a scaled copy of an amplifier to another, simulating crosstalk.
796
797 This method operates in the amplifier coordinate frame.
798
799 Parameters
800 ----------
801 ampDataSource : `lsst.afw.image.ImageF`
802 Amplifier image to add scaled copy from.
803 ampDataTarget : `lsst.afw.image.ImageF`
804 Amplifier image to add scaled copy to.
805 scale : `float`
806 Flux scale of the copy to add to the target.
807
808 Notes
809 -----
810 This simulates simple crosstalk between amplifiers.
811 """
812 ampDataTarget.array[:] = (ampDataTarget.array[:]
813 + scale * ampDataSource.array[:])
814

◆ amplifierAddFringe()

lsst.ip.isr.isrMock.IsrMock.amplifierAddFringe ( self,
amp,
ampData,
scale,
x0 = 100,
y0 = 0 )
Add a fringe-like ripple pattern to an amplifier's image data.

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

Definition at line 816 of file isrMock.py.

816 def amplifierAddFringe(self, amp, ampData, scale, x0=100, y0=0):
817 """Add a fringe-like ripple pattern to an amplifier's image data.
818
819 Parameters
820 ----------
821 amp : `~lsst.afw.ampInfo.AmpInfoRecord`
822 Amplifier to operate on. Needed for amp<->exp coordinate
823 transforms.
824 ampData : `lsst.afw.image.ImageF`
825 Amplifier image to operate on.
826 scale : `numpy.array` or `float`
827 Peak intensity scaling for the ripple.
828 x0 : `numpy.array` or `float`, optional
829 Fringe center
830 y0 : `numpy.array` or `float`, optional
831 Fringe center
832
833 Notes
834 -----
835 This uses an offset sinc function to generate a ripple
836 pattern. True fringes have much finer structure, but this
837 pattern should be visually identifiable. The (x, y)
838 coordinates are in the frame of the amplifier, and (u, v) in
839 the frame of the full trimmed image.
840 """
841 for x in range(0, ampData.getDimensions().getX()):
842 for y in range(0, ampData.getDimensions().getY()):
843 (u, v) = self.localCoordToExpCoord(amp, x, y)
844 ampData.getArray()[y][x] = np.sum((ampData.getArray()[y][x]
845 + scale * np.sinc(((u - x0) / 50)**2
846 + ((v - y0) / 50)**2)))
847

◆ amplifierAddNoise()

lsst.ip.isr.isrMock.IsrMock.amplifierAddNoise ( self,
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.

Definition at line 729 of file isrMock.py.

729 def amplifierAddNoise(self, ampData, mean, sigma, rng=None):
730 """Add Gaussian noise to an amplifier's image data.
731
732 This method operates in the amplifier coordinate frame.
733
734 Parameters
735 ----------
736 ampData : `lsst.afw.image.ImageF`
737 Amplifier image to operate on.
738 mean : `float`
739 Mean value of the Gaussian noise.
740 sigma : `float`
741 Sigma of the Gaussian noise.
742 rng : `np.random.RandomState`, optional
743 Random state to use instead of self.rng.
744 """
745 if rng is not None:
746 _rng = rng
747 else:
748 _rng = self.rng
749
750 ampArr = ampData.array
751 ampArr[:] = ampArr[:] + _rng.normal(mean, sigma,
752 size=ampData.getDimensions()).transpose()
753

◆ amplifierAddSource()

lsst.ip.isr.isrMock.IsrMock.amplifierAddSource ( self,
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.

Definition at line 773 of file isrMock.py.

773 def amplifierAddSource(self, ampData, scale, x0, y0):
774 """Add a single Gaussian source to an amplifier.
775
776 This method operates in the amplifier coordinate frame.
777
778 Parameters
779 ----------
780 ampData : `lsst.afw.image.ImageF`
781 Amplifier image to operate on.
782 scale : `float`
783 Peak flux of the source to add.
784 x0 : `float`
785 X-coordinate of the source peak.
786 y0 : `float`
787 Y-coordinate of the source peak.
788 """
789 for x in range(0, ampData.getDimensions().getX()):
790 for y in range(0, ampData.getDimensions().getY()):
791 ampData.array[y][x] = (ampData.array[y][x]
792 + scale * np.exp(-0.5 * ((x - x0)**2 + (y - y0)**2) / 3.0**2))
793

◆ amplifierAddYGradient()

lsst.ip.isr.isrMock.IsrMock.amplifierAddYGradient ( self,
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).

Definition at line 754 of file isrMock.py.

754 def amplifierAddYGradient(self, ampData, start, end):
755 """Add a y-axis linear gradient to an amplifier's image data.
756
757 This method operates in the amplifier coordinate frame.
758
759 Parameters
760 ----------
761 ampData : `lsst.afw.image.ImageF`
762 Amplifier image to operate on.
763 start : `float`
764 Start value of the gradient (at y=0).
765 end : `float`
766 End value of the gradient (at y=ymax).
767 """
768 nPixY = ampData.getDimensions().getY()
769 ampArr = ampData.array
770 ampArr[:] = ampArr[:] + (np.interp(range(nPixY), (0, nPixY - 1), (start, end)).reshape(nPixY, 1)
771 + np.zeros(ampData.getDimensions()).transpose())
772

◆ amplifierMultiplyFlat()

lsst.ip.isr.isrMock.IsrMock.amplifierMultiplyFlat ( self,
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.

Reimplemented in lsst.ip.isr.isrMockLSST.IsrMockLSST.

Definition at line 848 of file isrMock.py.

848 def amplifierMultiplyFlat(self, amp, ampData, fracDrop, u0=100.0, v0=100.0):
849 """Multiply an amplifier's image data by a flat-like pattern.
850
851 Parameters
852 ----------
853 amp : `lsst.afw.ampInfo.AmpInfoRecord`
854 Amplifier to operate on. Needed for amp<->exp coordinate
855 transforms.
856 ampData : `lsst.afw.image.ImageF`
857 Amplifier image to operate on.
858 fracDrop : `float`
859 Fractional drop from center to edge of detector along x-axis.
860 u0 : `float`
861 Peak location in detector coordinates.
862 v0 : `float`
863 Peak location in detector coordinates.
864
865 Notes
866 -----
867 This uses a 2-d Gaussian to simulate an illumination pattern
868 that falls off towards the edge of the detector. The (x, y)
869 coordinates are in the frame of the amplifier, and (u, v) in
870 the frame of the full trimmed image.
871 """
872 if fracDrop >= 1.0:
873 raise RuntimeError("Flat fractional drop cannot be greater than 1.0")
874
875 sigma = u0 / np.sqrt(-2.0 * np.log(fracDrop))
876
877 for x in range(0, ampData.getDimensions().getX()):
878 for y in range(0, ampData.getDimensions().getY()):
879 (u, v) = self.localCoordToExpCoord(amp, x, y)
880 f = np.exp(-0.5 * ((u - u0)**2 + (v - v0)**2) / sigma**2)
881 ampData.array[y][x] = (ampData.array[y][x] * f)
882
883

◆ getCamera()

lsst.ip.isr.isrMock.IsrMock.getCamera ( self)
Construct a test camera object.

Returns
-------
camera : `lsst.afw.cameraGeom.camera`
    Test camera.

Definition at line 535 of file isrMock.py.

535 def getCamera(self):
536 """Construct a test camera object.
537
538 Returns
539 -------
540 camera : `lsst.afw.cameraGeom.camera`
541 Test camera.
542 """
543 cameraWrapper = afwTestUtils.CameraWrapper(
544 plateScale=self.config.plateScale,
545 radialDistortion=self.config.radialDistortion,
546 isLsstLike=self.config.isLsstLike,
547 )
548 camera = cameraWrapper.camera
549 return camera
550

◆ getExposure()

lsst.ip.isr.isrMock.IsrMock.getExposure ( self,
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 : `bool` or `None`, optional
    Override the configuration isTrimmed?

Returns
-------
exposure : `lsst.afw.exposure.Exposure`
    Construct exposure containing masked image of the
    appropriate size.

Definition at line 551 of file isrMock.py.

551 def getExposure(self, isTrimmed=None):
552 """Construct a test exposure.
553
554 The test exposure has a simple WCS set, as well as a list of
555 unlikely header keywords that can be removed during ISR
556 processing to exercise that code.
557
558 Parameters
559 ----------
560 isTrimmed : `bool` or `None`, optional
561 Override the configuration isTrimmed?
562
563 Returns
564 -------
565 exposure : `lsst.afw.exposure.Exposure`
566 Construct exposure containing masked image of the
567 appropriate size.
568 """
569 if isTrimmed is None:
570 _isTrimmed = self.config.isTrimmed
571 else:
572 _isTrimmed = isTrimmed
573
574 camera = self.getCamera()
575 detector = camera[self.config.detectorIndex]
576 image = afwUtils.makeImageFromCcd(detector,
577 isTrimmed=_isTrimmed,
578 showAmpGain=False,
579 rcMarkSize=0,
580 binSize=1,
581 imageFactory=afwImage.ImageF)
582
583 var = afwImage.ImageF(image.getDimensions())
584 mask = afwImage.Mask(image.getDimensions())
585 image.assign(0.0)
586
587 maskedImage = afwImage.makeMaskedImage(image, mask, var)
588 exposure = afwImage.makeExposure(maskedImage)
589 exposure.setDetector(detector)
590 exposure.setWcs(self.getWcs())
591
592 visitInfo = afwImage.VisitInfo(exposureTime=self.config.expTime, darkTime=self.config.darkTime)
593 exposure.getInfo().setVisitInfo(visitInfo)
594 # Set a dummy ID.
595 exposure.getInfo().setId(12345)
596
597 metadata = exposure.getMetadata()
598 metadata.add("SHEEP", 7.3, "number of sheep on farm")
599 metadata.add("MONKEYS", 155, "monkeys per tree")
600 metadata.add("VAMPIRES", 4, "How scary are vampires.")
601
602 ccd = exposure.getDetector()
603 newCcd = ccd.rebuild()
604 newCcd.clear()
605 readoutMap = {
606 'LL': ReadoutCorner.LL,
607 'LR': ReadoutCorner.LR,
608 'UR': ReadoutCorner.UR,
609 'UL': ReadoutCorner.UL,
610 }
611 for amp in ccd:
612 newAmp = amp.rebuild()
613 newAmp.setLinearityCoeffs((0., 1., 0., 0.))
614 newAmp.setLinearityType("Polynomial")
615 newAmp.setGain(self.config.gain)
616 newAmp.setSuspectLevel(25000.0)
617 newAmp.setSaturation(32000.0)
618 readoutCorner = 'LL'
619
620 # Apply flips to bbox where needed
621 imageBBox = amp.getRawDataBBox()
622 rawBbox = amp.getRawBBox()
623 parallelOscanBBox = amp.getRawParallelOverscanBBox()
624 serialOscanBBox = amp.getRawSerialOverscanBBox()
625 prescanBBox = amp.getRawPrescanBBox()
626
627 if self.config.isLsstLike:
628 # This follows cameraGeom.testUtils
629 xoffset, yoffset = amp.getRawXYOffset()
630 offext = lsst.geom.Extent2I(xoffset, yoffset)
631 flipx = bool(amp.getRawFlipX())
632 flipy = bool(amp.getRawFlipY())
633 if flipx:
634 xExt = rawBbox.getDimensions().getX()
635 rawBbox.flipLR(xExt)
636 imageBBox.flipLR(xExt)
637 parallelOscanBBox.flipLR(xExt)
638 serialOscanBBox.flipLR(xExt)
639 prescanBBox.flipLR(xExt)
640 if flipy:
641 yExt = rawBbox.getDimensions().getY()
642 rawBbox.flipTB(yExt)
643 imageBBox.flipTB(yExt)
644 parallelOscanBBox.flipTB(yExt)
645 serialOscanBBox.flipTB(yExt)
646 prescanBBox.flipTB(yExt)
647 if not flipx and not flipy:
648 readoutCorner = 'LL'
649 elif flipx and not flipy:
650 readoutCorner = 'LR'
651 elif flipx and flipy:
652 readoutCorner = 'UR'
653 elif not flipx and flipy:
654 readoutCorner = 'UL'
655 rawBbox.shift(offext)
656 imageBBox.shift(offext)
657 parallelOscanBBox.shift(offext)
658 serialOscanBBox.shift(offext)
659 prescanBBox.shift(offext)
660 newAmp.setReadoutCorner(readoutMap[readoutCorner])
661 newAmp.setRawBBox(rawBbox)
662 newAmp.setRawDataBBox(imageBBox)
663 newAmp.setRawParallelOverscanBBox(parallelOscanBBox)
664 newAmp.setRawSerialOverscanBBox(serialOscanBBox)
665 newAmp.setRawPrescanBBox(prescanBBox)
666 newAmp.setRawFlipX(False)
667 newAmp.setRawFlipY(False)
668 no_offset = lsst.geom.Extent2I(0, 0)
669 newAmp.setRawXYOffset(no_offset)
670
671 newCcd.append(newAmp)
672
673 exposure.setDetector(newCcd.finish())
674
675 exposure.image.array[:] = np.zeros(exposure.getImage().getDimensions()).transpose()
676 exposure.mask.array[:] = np.zeros(exposure.getMask().getDimensions()).transpose()
677 exposure.variance.array[:] = np.zeros(exposure.getVariance().getDimensions()).transpose()
678
679 return exposure
680
Represent a 2-dimensional array of bitmask pixels.
Definition Mask.h:77
Information about a single exposure of an imaging camera.
Definition VisitInfo.h:68
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT > > image, typename std::shared_ptr< Mask< MaskPixelT > > mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT > > variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
A function to return an Exposure of the correct type (cf.
Definition Exposure.h:484

◆ getWcs()

lsst.ip.isr.isrMock.IsrMock.getWcs ( self)
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.

Definition at line 681 of file isrMock.py.

681 def getWcs(self):
682 """Construct a dummy WCS object.
683
684 Taken from the deprecated ip_isr/examples/exampleUtils.py.
685
686 This is not guaranteed, given the distortion and pixel scale
687 listed in the afwTestUtils camera definition.
688
689 Returns
690 -------
691 wcs : `lsst.afw.geom.SkyWcs`
692 Test WCS transform.
693 """
694 return afwGeom.makeSkyWcs(crpix=lsst.geom.Point2D(0.0, 100.0),
695 crval=lsst.geom.SpherePoint(45.0, 25.0, lsst.geom.degrees),
696 cdMatrix=afwGeom.makeCdMatrix(scale=1.0*lsst.geom.degrees))
697
Point in an unspecified spherical coordinate system.
Definition SpherePoint.h:57
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition SkyWcs.cc:521
Eigen::Matrix2d makeCdMatrix(lsst::geom::Angle const &scale, lsst::geom::Angle const &orientation=0 *lsst::geom::degrees, bool flipX=false)
Make a WCS CD matrix.
Definition SkyWcs.cc:133

◆ localCoordToExpCoord()

lsst.ip.isr.isrMock.IsrMock.localCoordToExpCoord ( self,
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.

Definition at line 698 of file isrMock.py.

698 def localCoordToExpCoord(self, ampData, x, y):
699 """Convert between a local amplifier coordinate and the full
700 exposure coordinate.
701
702 Parameters
703 ----------
704 ampData : `lsst.afw.image.ImageF`
705 Amplifier image to use for conversions.
706 x : `int`
707 X-coordinate of the point to transform.
708 y : `int`
709 Y-coordinate of the point to transform.
710
711 Returns
712 -------
713 u : `int`
714 Transformed x-coordinate.
715 v : `int`
716 Transformed y-coordinate.
717
718 Notes
719 -----
720 The output is transposed intentionally here, to match the
721 internal transpose between numpy and afw.image coordinates.
722 """
723 u = x + ampData.getBBox().getBeginX()
724 v = y + ampData.getBBox().getBeginY()
725
726 return (v, u)
727

◆ makeBfKernel()

lsst.ip.isr.isrMock.IsrMock.makeBfKernel ( self)
Generate a simple Gaussian brighter-fatter kernel.

Returns
-------
kernel : `numpy.ndarray`
    Simulated brighter-fatter kernel.

Reimplemented in lsst.ip.isr.isrMockLSST.IsrMockLSST.

Definition at line 362 of file isrMock.py.

362 def makeBfKernel(self):
363 """Generate a simple Gaussian brighter-fatter kernel.
364
365 Returns
366 -------
367 kernel : `numpy.ndarray`
368 Simulated brighter-fatter kernel.
369 """
370 return self.bfKernel
371

◆ makeCrosstalkCoeff()

lsst.ip.isr.isrMock.IsrMock.makeCrosstalkCoeff ( self)
Generate the simulated crosstalk coefficients.

Returns
-------
coeffs : `numpy.ndarray`
    Simulated crosstalk coefficients.

Definition at line 383 of file isrMock.py.

383 def makeCrosstalkCoeff(self):
384 """Generate the simulated crosstalk coefficients.
385
386 Returns
387 -------
388 coeffs : `numpy.ndarray`
389 Simulated crosstalk coefficients.
390 """
391
392 return self.crosstalkCoeffs
393

◆ makeData()

lsst.ip.isr.isrMock.IsrMock.makeData ( self)
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.

Definition at line 331 of file isrMock.py.

331 def makeData(self):
332 """Generate simulated ISR data.
333
334 Currently, only the class defined crosstalk coefficient
335 matrix, brighter-fatter kernel, a constant unity transmission
336 curve, or a simple single-entry defect list can be generated.
337
338 Returns
339 -------
340 dataProduct :
341 Simulated ISR data product.
342 """
343 if sum(map(bool, [self.config.doBrighterFatter,
344 self.config.doDefects,
345 self.config.doTransmissionCurve,
346 self.config.doCrosstalkCoeffs,
347 self.config.doLinearizer])) != 1:
348 raise RuntimeError("Only one data product can be generated at a time.")
349 elif self.config.doBrighterFatter:
350 return self.makeBfKernel()
351 elif self.config.doDefects:
352 return self.makeDefectList()
353 elif self.config.doTransmissionCurve:
354 return self.makeTransmissionCurve()
355 elif self.config.doCrosstalkCoeffs:
356 return self.crosstalkCoeffs
357 elif self.config.doLinearizer:
358 return self.makeLinearizer()
359 else:
360 return None
361

◆ makeDefectList()

lsst.ip.isr.isrMock.IsrMock.makeDefectList ( self)
Generate a simple single-entry defect list.

Returns
-------
defectList : `lsst.meas.algorithms.Defects`
    Simulated defect list

Reimplemented in lsst.ip.isr.isrMockLSST.IsrMockLSST.

Definition at line 372 of file isrMock.py.

372 def makeDefectList(self):
373 """Generate a simple single-entry defect list.
374
375 Returns
376 -------
377 defectList : `lsst.meas.algorithms.Defects`
378 Simulated defect list
379 """
380 return Defects([lsst.geom.Box2I(lsst.geom.Point2I(0, 0),
381 lsst.geom.Extent2I(40, 50))])
382
An integer coordinate rectangle.
Definition Box.h:55

◆ makeImage()

lsst.ip.isr.isrMock.IsrMock.makeImage ( self)
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.

Reimplemented in lsst.ip.isr.isrMockLSST.IsrMockLSST.

Definition at line 414 of file isrMock.py.

414 def makeImage(self):
415 """Generate a simulated ISR image.
416
417 Returns
418 -------
419 exposure : `lsst.afw.image.Exposure` or `dict`
420 Simulated ISR image data.
421
422 Notes
423 -----
424 This method currently constructs a "raw" data image by:
425
426 * Generating a simulated sky with noise
427 * Adding a single Gaussian "star"
428 * Adding the fringe signal
429 * Multiplying the frame by the simulated flat
430 * Adding dark current (and noise)
431 * Adding a bias offset (and noise)
432 * Adding an overscan gradient parallel to the pixel y-axis
433 * Simulating crosstalk by adding a scaled version of each
434 amplifier to each other amplifier.
435
436 The exposure with image data constructed this way is in one of
437 three formats.
438
439 * A single image, with overscan and prescan regions retained
440 * A single image, with overscan and prescan regions trimmed
441 * A `dict`, containing the amplifer data indexed by the
442 amplifier name.
443
444 The nonlinearity, CTE, and brighter fatter are currently not
445 implemented.
446
447 Note that this method generates an image in the reverse
448 direction as the ISR processing, as the output image here has
449 had a series of instrument effects added to an idealized
450 exposure.
451 """
452 exposure = self.getExposure()
453
454 for idx, amp in enumerate(exposure.getDetector()):
455 bbox = None
456 if self.config.isTrimmed is True:
457 bbox = amp.getBBox()
458 else:
459 bbox = amp.getRawDataBBox()
460
461 ampData = exposure.image[bbox]
462
463 if self.config.doAddSky is True:
464 self.amplifierAddNoise(ampData, self.config.skyLevel, np.sqrt(self.config.skyLevel))
465
466 if self.config.doAddSource is True:
467 for sourceAmp, sourceFlux, sourceX, sourceY in zip(self.config.sourceAmp,
468 self.config.sourceFlux,
469 self.config.sourceX,
470 self.config.sourceY):
471 if idx == sourceAmp:
472 self.amplifierAddSource(ampData, sourceFlux, sourceX, sourceY)
473
474 if self.config.doAddFringe is True:
475 self.amplifierAddFringe(amp, ampData, np.array(self.config.fringeScale),
476 x0=np.array(self.config.fringeX0),
477 y0=np.array(self.config.fringeY0))
478
479 if self.config.doAddFlat is True:
480 if ampData.getArray().sum() == 0.0:
481 self.amplifierAddNoise(ampData, 1.0, 0.0)
482 u0 = exposure.getDimensions().getX()
483 v0 = exposure.getDimensions().getY()
484 self.amplifierMultiplyFlat(amp, ampData, self.config.flatDrop, u0=u0, v0=v0)
485
486 if self.config.doAddDark is True:
487 self.amplifierAddNoise(ampData,
488 self.config.darkRate * self.config.darkTime / self.config.gain,
489 np.sqrt(self.config.darkRate
490 * self.config.darkTime / self.config.gain))
491
492 if self.config.doAddCrosstalk is True:
493 ctCalib = CrosstalkCalib()
494 for idxS, ampS in enumerate(exposure.getDetector()):
495 for idxT, ampT in enumerate(exposure.getDetector()):
496 ampDataT = exposure.image[ampT.getBBox()
497 if self.config.isTrimmed else ampT.getRawDataBBox()]
498 outAmp = ctCalib.extractAmp(exposure.getImage(), ampS, ampT,
499 isTrimmed=self.config.isTrimmed)
500 self.amplifierAddCT(outAmp, ampDataT, self.crosstalkCoeffs[idxS][idxT])
501
502 for amp in exposure.getDetector():
503 bbox = None
504 if self.config.isTrimmed is True:
505 bbox = amp.getBBox()
506 else:
507 bbox = amp.getRawDataBBox()
508
509 ampData = exposure.image[bbox]
510
511 if self.config.doAddBias is True:
512 self.amplifierAddNoise(ampData, self.config.biasLevel,
513 self.config.readNoise / self.config.gain)
514
515 if self.config.doAddOverscan is True:
516 oscanBBox = amp.getRawHorizontalOverscanBBox()
517 oscanData = exposure.image[oscanBBox]
518 self.amplifierAddNoise(oscanData, self.config.biasLevel,
519 self.config.readNoise / self.config.gain)
520
521 self.amplifierAddYGradient(ampData, -1.0 * self.config.overscanScale,
522 1.0 * self.config.overscanScale)
523 self.amplifierAddYGradient(oscanData, -1.0 * self.config.overscanScale,
524 1.0 * self.config.overscanScale)
525
526 if self.config.doGenerateAmpDict is True:
527 expDict = dict()
528 for amp in exposure.getDetector():
529 expDict[amp.getName()] = exposure
530 return expDict
531 else:
532 return exposure
533

◆ makeLinearity()

lsst.ip.isr.isrMock.IsrMock.makeLinearity ( self)
Generate a linearity dataset.

Returns
-------
linearizer : `lsst.ip.isr.Linearizer`

Definition at line 405 of file isrMock.py.

405 def makeLinearity(self):
406 """Generate a linearity dataset.
407
408 Returns
409 -------
410 linearizer : `lsst.ip.isr.Linearizer`
411 """
412 raise NotImplementedError("Linearizer not implemented for isrMock.")
413

◆ makeTransmissionCurve()

lsst.ip.isr.isrMock.IsrMock.makeTransmissionCurve ( self)
Generate a simulated flat transmission curve.

Returns
-------
transmission : `lsst.afw.image.TransmissionCurve`
    Simulated transmission curve.

Definition at line 394 of file isrMock.py.

394 def makeTransmissionCurve(self):
395 """Generate a simulated flat transmission curve.
396
397 Returns
398 -------
399 transmission : `lsst.afw.image.TransmissionCurve`
400 Simulated transmission curve.
401 """
402
403 return afwImage.TransmissionCurve.makeIdentity()
404

◆ run()

lsst.ip.isr.isrMock.IsrMock.run ( self)
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.

Reimplemented in lsst.ip.isr.isrMockLSST.IsrMockLSST.

Definition at line 305 of file isrMock.py.

305 def run(self):
306 """Generate a mock ISR product, and return it.
307
308 Returns
309 -------
310 image : `lsst.afw.image.Exposure`
311 Simulated ISR image with signals added.
312 dataProduct :
313 Simulated ISR data products.
314 None :
315 Returned if no valid configuration was found.
316
317 Raises
318 ------
319 RuntimeError
320 Raised if both doGenerateImage and doGenerateData are specified.
321 """
322 if self.config.doGenerateImage and self.config.doGenerateData:
323 raise RuntimeError("Only one of doGenerateImage and doGenerateData may be specified.")
324 elif self.config.doGenerateImage:
325 return self.makeImage()
326 elif self.config.doGenerateData:
327 return self.makeData()
328 else:
329 return None
330

Member Data Documentation

◆ _DefaultName

str lsst.ip.isr.isrMock.IsrMock._DefaultName = "isrMock"
staticprotected

Definition at line 274 of file isrMock.py.

◆ _display

lsst.ip.isr.isrMock.IsrMock._display
protected

Definition at line 289 of file isrMock.py.

◆ bfKernel

lsst.ip.isr.isrMock.IsrMock.bfKernel

Definition at line 299 of file isrMock.py.

◆ ConfigClass

lsst.ip.isr.isrMock.IsrMock.ConfigClass = IsrMockConfig
static

Definition at line 273 of file isrMock.py.

◆ crosstalkCoeffs

lsst.ip.isr.isrMock.IsrMock.crosstalkCoeffs

Definition at line 281 of file isrMock.py.

◆ rng

lsst.ip.isr.isrMock.IsrMock.rng

Definition at line 278 of file isrMock.py.


The documentation for this class was generated from the following file: