LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Static Protected Attributes | List of all members
lsst.ip.isr.isrMockLSST.IsrMockLSST Class Reference
Inheritance diagram for lsst.ip.isr.isrMockLSST.IsrMockLSST:
lsst.ip.isr.isrMock.IsrMock lsst.ip.isr.isrMockLSST.BfKernelMockLSST lsst.ip.isr.isrMockLSST.CrosstalkCoeffMockLSST lsst.ip.isr.isrMockLSST.DefectMockLSST lsst.ip.isr.isrMockLSST.RawMockLSST lsst.ip.isr.isrMockLSST.ReferenceMockLSST lsst.ip.isr.isrMockLSST.TransmissionMockLSST lsst.ip.isr.isrMockLSST.CalibratedRawMockLSST lsst.ip.isr.isrMockLSST.TrimmedRawMockLSST lsst.ip.isr.isrMockLSST.BiasMockLSST lsst.ip.isr.isrMockLSST.DarkMockLSST lsst.ip.isr.isrMockLSST.FlatMockLSST lsst.ip.isr.isrMockLSST.FringeMockLSST

Public Member Functions

 __init__ (self, **kwargs)
 
 run (self)
 
 makeImage (self)
 
 applyGain (self, ampData, gain)
 
 amplifierAddXGradient (self, ampData, start, end)
 

Static Public Attributes

 ConfigClass = IsrMockLSSTConfig
 

Static Protected Attributes

str _DefaultName = "isrMockLSST"
 

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 72 of file isrMockLSST.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.ip.isr.isrMockLSST.IsrMockLSST.__init__ ( self,
** kwargs )

Member Function Documentation

◆ amplifierAddXGradient()

lsst.ip.isr.isrMockLSST.IsrMockLSST.amplifierAddXGradient ( self,
ampData,
start,
end )
Add a x-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 290 of file isrMockLSST.py.

290 def amplifierAddXGradient(self, ampData, start, end):
291 """Add a x-axis linear gradient to an amplifier's image data.
292
293 This method operates in the amplifier coordinate frame.
294
295 Parameters
296 ----------
297 ampData : `lsst.afw.image.ImageF`
298 Amplifier image to operate on.
299 start : `float`
300 Start value of the gradient (at y=0).
301 end : `float`
302 End value of the gradient (at y=ymax).
303 """
304 nPixX = ampData.getDimensions().getX()
305 ampArr = ampData.array
306 ampArr[:] = ampArr[:] + (np.interp(range(nPixX), (0, nPixX - 1), (start, end)).reshape(1, nPixX)
307 + np.zeros(ampData.getDimensions()).transpose())
308
309

◆ applyGain()

lsst.ip.isr.isrMockLSST.IsrMockLSST.applyGain ( self,
ampData,
gain )
Apply gain to the amplifier's data.
This method divides the data by the gain
because the mocks need to convert the data in electron to ADU,
so it does the inverse operation to applyGains in isrFunctions.

Parameters
----------
ampData : `lsst.afw.image.ImageF`
    Amplifier image to operate on.
gain : `float`
    Gain value in e^-/DN.

Definition at line 274 of file isrMockLSST.py.

274 def applyGain(self, ampData, gain):
275 """Apply gain to the amplifier's data.
276 This method divides the data by the gain
277 because the mocks need to convert the data in electron to ADU,
278 so it does the inverse operation to applyGains in isrFunctions.
279
280 Parameters
281 ----------
282 ampData : `lsst.afw.image.ImageF`
283 Amplifier image to operate on.
284 gain : `float`
285 Gain value in e^-/DN.
286 """
287 ampArr = ampData.array
288 ampArr[:] = ampArr[:] / gain
289

◆ makeImage()

lsst.ip.isr.isrMockLSST.IsrMockLSST.makeImage ( self)
Generate a simulated ISR LSST image.

Returns
-------
exposure : `lsst.afw.image.Exposure` or `dict`
    Simulated ISR image data.

Notes
-----
This method constructs a "raw" data image.

Reimplemented from lsst.ip.isr.isrMock.IsrMock.

Definition at line 114 of file isrMockLSST.py.

114 def makeImage(self):
115 """Generate a simulated ISR LSST image.
116
117 Returns
118 -------
119 exposure : `lsst.afw.image.Exposure` or `dict`
120 Simulated ISR image data.
121
122 Notes
123 -----
124 This method constructs a "raw" data image.
125 """
126 exposure = self.getExposure()
127
128 # We introduce effects as they happen from a source to the signal,
129 # so the effects go from electrons to ADU.
130 # The ISR steps will then correct these effects in the reverse order.
131 for idx, amp in enumerate(exposure.getDetector()):
132
133 # Get image bbox and data
134 bbox = None
135 if self.config.isTrimmed:
136 bbox = amp.getBBox()
137 else:
138 bbox = amp.getRawDataBBox().shiftedBy(amp.getRawXYOffset())
139
140 ampData = exposure.image[bbox]
141
142 # Sky effects in e-
143 if self.config.doAddSky:
144 self.amplifierAddNoise(ampData, self.config.skyLevel, np.sqrt(self.config.skyLevel))
145
146 if self.config.doAddSource:
147 for sourceAmp, sourceFlux, sourceX, sourceY in zip(self.config.sourceAmp,
148 self.config.sourceFlux,
149 self.config.sourceX,
150 self.config.sourceY):
151 if idx == sourceAmp:
152 self.amplifierAddSource(ampData, sourceFlux, sourceX, sourceY)
153
154 # Other effects in e-
155 if self.config.doAddFringe:
156 self.amplifierAddFringe(amp, ampData, np.array(self.config.fringeScale),
157 x0=np.array(self.config.fringeX0),
158 y0=np.array(self.config.fringeY0))
159
160 if self.config.doAddFlat:
161 if ampData.getArray().sum() == 0.0:
162 self.amplifierAddNoise(ampData, 1.0, 0.0)
163 u0 = exposure.getDimensions().getX()
164 v0 = exposure.getDimensions().getY()
165 self.amplifierMultiplyFlat(amp, ampData, self.config.flatDrop, u0=u0, v0=v0)
166
167 # ISR effects
168 # 1. Add dark in e- (different from isrMock which does it in ADU)
169 if self.config.doAddDark:
170 self.amplifierAddNoise(ampData,
171 self.config.darkRate * self.config.darkTime,
172 np.sqrt(self.config.darkRate * self.config.darkTime))
173
174 # 2. Gain normalize (from e- to ADU)
175 # TODO: DM-43601 gain from PTC per amplifier
176 # TODO: DM-36639 gain with temperature dependence
177 if self.config.doApplyGain:
178 self.applyGain(ampData, self.config.gain)
179
180 # 3. Add read noise with or without a bias level
181 # to the image region in ADU.
182 self.amplifierAddNoise(ampData, self.config.biasLevel if self.config.doAddBias else 0.0,
183 self.config.readNoise / self.config.gain)
184
185 # 4. Apply cross-talk in ADU
186 if self.config.doAddCrosstalk:
187 ctCalib = CrosstalkCalib()
188 for idxS, ampS in enumerate(exposure.getDetector()):
189 for idxT, ampT in enumerate(exposure.getDetector()):
190 ampDataT = exposure.image[ampT.getBBox() if self.config.isTrimmed
191 else ampT.getRawDataBBox().shiftedBy(ampT.getRawXYOffset())]
192 outAmp = ctCalib.extractAmp(exposure.getImage(), ampS, ampT,
193 isTrimmed=self.config.isTrimmed)
194 self.amplifierAddCT(outAmp, ampDataT, self.crosstalkCoeffs[idxS][idxT])
195
196 # We now apply parallel and serial overscans
197 for amp in exposure.getDetector():
198 # Get image bbox and data
199 bbox = None
200 if self.config.isTrimmed:
201 bbox = amp.getBBox()
202 else:
203 bbox = amp.getRawDataBBox().shiftedBy(amp.getRawXYOffset())
204 ampData = exposure.image[bbox]
205
206 # Get overscan bbox and data
207 if not self.config.isTrimmed:
208 parallelOscanBBox = amp.getRawParallelOverscanBBox().shiftedBy(amp.getRawXYOffset())
209 parallelOscanData = exposure.image[parallelOscanBBox]
210
211 serialOscanBBox = amp.getRawSerialOverscanBBox().shiftedBy(amp.getRawXYOffset())
212
213 # 5. Apply parallel overscan in ADU
214 if self.config.doAddParallelOverscan:
215 if not self.config.isTrimmed:
216 # Add read noise with or without a bias level
217 # to the parallel overscan region.
218 self.amplifierAddNoise(parallelOscanData, self.config.biasLevel
219 if self.config.doAddBias else 0.0,
220 self.config.readNoise / self.config.gain)
221 # Apply gradient along the Y axis
222 # to the parallel overscan region.
223 self.amplifierAddYGradient(parallelOscanData, -1.0 * self.config.overscanScale,
224 1.0 * self.config.overscanScale)
225
226 # Apply gradient along the Y axis to the image region
227 self.amplifierAddYGradient(ampData, -1.0 * self.config.overscanScale,
228 1.0 * self.config.overscanScale)
229
230 # 6. Add Parallel overscan xtalk.
231 # TODO: DM-43286
232
233 if self.config.doAddSerialOverscan:
234 if not self.config.isTrimmed:
235 # We grow the image to the parallel overscan region
236 # (we do this instead of using the whole raw region
237 # in case there are prescan regions)
238 grownImageBBox = bbox.expandedTo(parallelOscanBBox)
239 # Now we grow the serial overscan region
240 # to include the corners
241 serialOscanBBox = geom.Box2I(
242 geom.Point2I(serialOscanBBox.getMinX(),
243 grownImageBBox.getMinY()),
244 geom.Extent2I(serialOscanBBox.getWidth(),
245 grownImageBBox.getHeight()),
246 )
247 serialOscanData = exposure.image[serialOscanBBox]
248
249 # Add read noise with or without a bias level
250 # to the serial overscan region.
251 self.amplifierAddNoise(serialOscanData, self.config.biasLevel
252 if self.config.doAddBias else 0.0,
253 self.config.readNoise / self.config.gain)
254
255 # 7. Apply serial overscan in ADU
256 # Apply gradient along the X axis to both overscan regions.
257 self.amplifierAddXGradient(serialOscanData, -1.0 * self.config.overscanScale,
258 1.0 * self.config.overscanScale)
259 self.amplifierAddXGradient(parallelOscanData, -1.0 * self.config.overscanScale,
260 1.0 * self.config.overscanScale)
261
262 # Apply gradient along the X axis to the image region.
263 self.amplifierAddXGradient(ampData, -1.0 * self.config.overscanScale,
264 1.0 * self.config.overscanScale)
265
266 if self.config.doGenerateAmpDict:
267 expDict = dict()
268 for amp in exposure.getDetector():
269 expDict[amp.getName()] = exposure
270 return expDict
271 else:
272 return exposure
273
An integer coordinate rectangle.
Definition Box.h:55

◆ run()

lsst.ip.isr.isrMockLSST.IsrMockLSST.run ( self)
Generate a mock ISR product following LSSTCam ISR, 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 from lsst.ip.isr.isrMock.IsrMock.

Definition at line 88 of file isrMockLSST.py.

88 def run(self):
89 """Generate a mock ISR product following LSSTCam ISR, and return it.
90
91 Returns
92 -------
93 image : `lsst.afw.image.Exposure`
94 Simulated ISR image with signals added.
95 dataProduct :
96 Simulated ISR data products.
97 None :
98 Returned if no valid configuration was found.
99
100 Raises
101 ------
102 RuntimeError
103 Raised if both doGenerateImage and doGenerateData are specified.
104 """
105 if self.config.doGenerateImage and self.config.doGenerateData:
106 raise RuntimeError("Only one of doGenerateImage and doGenerateData may be specified.")
107 elif self.config.doGenerateImage:
108 return self.makeImage()
109 elif self.config.doGenerateData:
110 return self.makeData()
111 else:
112 return None
113

Member Data Documentation

◆ _DefaultName

str lsst.ip.isr.isrMockLSST.IsrMockLSST._DefaultName = "isrMockLSST"
staticprotected

Definition at line 82 of file isrMockLSST.py.

◆ ConfigClass

lsst.ip.isr.isrMockLSST.IsrMockLSST.ConfigClass = IsrMockLSSTConfig
static

Definition at line 81 of file isrMockLSST.py.


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