LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel Class Reference
Inheritance diagram for lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel:

Public Member Functions

 __init__ (self, camera=None, level=None, **kwargs)
 
 updateMetadata (self, setDate=False, **kwargs)
 
 initFromCamera (self, camera, detectorId=None)
 
 getLengths (self)
 
 fromDict (cls, dictionary)
 
 toDict (self)
 
 fromTable (cls, tableList)
 
 toTable (self)
 
 repackCorrelations (self, amp, correlationShape)
 
 makeDetectorKernelFromAmpwiseKernels (self, detectorName, ampsToExclude=[])
 
 replaceDetectorKernelWithAmpKernel (self, ampName, detectorName)
 

Public Attributes

 level
 
 expIdMask
 
 rawMeans
 
 rawVariances
 
 rawXcorrs
 
 badAmps
 
 shape
 
 gain
 
 noise
 
 meanXcorrs
 
 valid
 
 ampKernels
 
 detKernels
 

Protected Attributes

 _instrument
 
 _detectorId
 
 _detectorName
 
 _detectorSerial
 

Static Protected Attributes

str _OBSTYPE = 'bfk'
 
str _SCHEMA = 'Brighter-fatter kernel'
 
float _VERSION = 1.1
 

Detailed Description

Calibration of brighter-fatter kernels for an instrument.

ampKernels are the kernels for each amplifier in a detector, as
generated by having ``level == 'AMP'``.

detectorKernel is the kernel generated for a detector as a
whole, as generated by having ``level == 'DETECTOR'``.

makeDetectorKernelFromAmpwiseKernels is a method to generate the
kernel for a detector, constructed by averaging together the
ampwise kernels in the detector.  The existing application code is
only defined for kernels with ``level == 'DETECTOR'``, so this method
is used if the supplied kernel was built with ``level == 'AMP'``.

Parameters
----------
camera : `lsst.afw.cameraGeom.Camera`
    Camera describing detector geometry.
level : `str`
    Level the kernels will be generated for.
log : `logging.Logger`, optional
    Log to write messages to.
**kwargs :
    Parameters to pass to parent constructor.

Notes
-----
Version 1.1 adds the `expIdMask` property, and substitutes
`means` and `variances` for `rawMeans` and `rawVariances`
from the PTC dataset.

expIdMask : `dict`, [`str`,`numpy.ndarray`]
    Dictionary keyed by amp names containing the mask produced after
    outlier rejection.
rawMeans : `dict`, [`str`, `numpy.ndarray`]
    Dictionary keyed by amp names containing the unmasked average of the
    means of the exposures in each flat pair.
rawVariances : `dict`, [`str`, `numpy.ndarray`]
    Dictionary keyed by amp names containing the variance of the
    difference image of the exposures in each flat pair.
    Corresponds to rawVars of PTC.
rawXcorrs : `dict`, [`str`, `numpy.ndarray`]
    Dictionary keyed by amp names containing an array of measured
    covariances per mean flux.
    Corresponds to covariances of PTC.
badAmps : `list`
    List of bad amplifiers names.
shape : `tuple`
    Tuple of the shape of the BFK kernels.
gain : `dict`, [`str`,`float`]
    Dictionary keyed by amp names containing the fitted gains.
noise : `dict`, [`str`,`float`]
    Dictionary keyed by amp names containing the fitted noise.
meanXcorrs : `dict`, [`str`,`numpy.ndarray`]
    Dictionary keyed by amp names containing the averaged
    cross-correlations.
valid : `dict`, [`str`,`bool`]
    Dictionary keyed by amp names containing validity of data.
ampKernels : `dict`, [`str`, `numpy.ndarray`]
    Dictionary keyed by amp names containing the BF kernels.
detKernels : `dict`
    Dictionary keyed by detector names containing the BF kernels.

Definition at line 34 of file brighterFatterKernel.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.__init__ ( self,
camera = None,
level = None,
** kwargs )

Definition at line 102 of file brighterFatterKernel.py.

102 def __init__(self, camera=None, level=None, **kwargs):
103 self.level = level
104
105 # Things inherited from the PTC
106 self.expIdMask = dict()
107 self.rawMeans = dict()
108 self.rawVariances = dict()
109 self.rawXcorrs = dict()
110 self.badAmps = list()
111 self.shape = (17, 17)
112 self.gain = dict()
113 self.noise = dict()
114
115 # Things calculated from the PTC
116 self.meanXcorrs = dict()
117 self.valid = dict()
118
119 # Things that are used downstream
120 self.ampKernels = dict()
121 self.detKernels = dict()
122
123 super().__init__(**kwargs)
124
125 if camera:
126 self.initFromCamera(camera, detectorId=kwargs.get('detectorId', None))
127
128 self.requiredAttributes.update(['level', 'expIdMask', 'rawMeans', 'rawVariances', 'rawXcorrs',
129 'badAmps', 'gain', 'noise', 'meanXcorrs', 'valid',
130 'ampKernels', 'detKernels'])
131

Member Function Documentation

◆ fromDict()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.fromDict ( cls,
dictionary )
Construct a calibration from a dictionary of properties.

Parameters
----------
dictionary : `dict`
    Dictionary of properties.

Returns
-------
calib : `lsst.ip.isr.BrighterFatterKernel`
    Constructed calibration.

Raises
------
RuntimeError
    Raised if the supplied dictionary is for a different
    calibration.
    Raised if the version of the supplied dictionary is 1.0.

Definition at line 233 of file brighterFatterKernel.py.

233 def fromDict(cls, dictionary):
234 """Construct a calibration from a dictionary of properties.
235
236 Parameters
237 ----------
238 dictionary : `dict`
239 Dictionary of properties.
240
241 Returns
242 -------
243 calib : `lsst.ip.isr.BrighterFatterKernel`
244 Constructed calibration.
245
246 Raises
247 ------
248 RuntimeError
249 Raised if the supplied dictionary is for a different
250 calibration.
251 Raised if the version of the supplied dictionary is 1.0.
252 """
253 calib = cls()
254
255 if calib._OBSTYPE != (found := dictionary['metadata']['OBSTYPE']):
256 raise RuntimeError(f"Incorrect brighter-fatter kernel supplied. Expected {calib._OBSTYPE}, "
257 f"found {found}")
258 calib.setMetadata(dictionary['metadata'])
259 calib.calibInfoFromDict(dictionary)
260
261 calib.level = dictionary['metadata'].get('LEVEL', 'AMP')
262 calib.shape = (dictionary['metadata'].get('KERNEL_DX', 0),
263 dictionary['metadata'].get('KERNEL_DY', 0))
264
265 calibVersion = dictionary['metadata']['bfk_VERSION']
266 if calibVersion == 1.0:
267 calib.log.debug("Old Version of brighter-fatter kernel found. Current version: "
268 f"{calib._VERSION}. The new attribute 'expIdMask' will be "
269 "populated with 'True' values, and the new attributes 'rawMeans' "
270 "and 'rawVariances' will be populated with the masked 'means' "
271 "and 'variances' values."
272 )
273 # use 'means', because 'expIdMask' does not exist.
274 calib.expIdMask = {amp: np.repeat(True, len(dictionary['means'][amp])) for amp in
275 dictionary['means']}
276 calib.rawMeans = {amp: np.array(dictionary['means'][amp]) for amp in dictionary['means']}
277 calib.rawVariances = {amp: np.array(dictionary['variances'][amp]) for amp in
278 dictionary['variances']}
279 elif calibVersion == 1.1:
280 calib.expIdMask = {amp: np.array(dictionary['expIdMask'][amp]) for amp in dictionary['expIdMask']}
281 calib.rawMeans = {amp: np.array(dictionary['rawMeans'][amp]) for amp in dictionary['rawMeans']}
282 calib.rawVariances = {amp: np.array(dictionary['rawVariances'][amp]) for amp in
283 dictionary['rawVariances']}
284 else:
285 raise RuntimeError(f"Unknown version for brighter-fatter kernel: {calibVersion}")
286
287 # Lengths for reshape:
288 _, smallLength, nObs = calib.getLengths()
289 smallShapeSide = int(np.sqrt(smallLength))
290
291 calib.rawXcorrs = {amp: np.array(dictionary['rawXcorrs'][amp]).reshape((nObs,
292 smallShapeSide,
293 smallShapeSide))
294 for amp in dictionary['rawXcorrs']}
295
296 calib.gain = dictionary['gain']
297 calib.noise = dictionary['noise']
298
299 calib.meanXcorrs = {amp: np.array(dictionary['meanXcorrs'][amp]).reshape(calib.shape)
300 for amp in dictionary['rawXcorrs']}
301 calib.ampKernels = {amp: np.array(dictionary['ampKernels'][amp]).reshape(calib.shape)
302 for amp in dictionary['ampKernels']}
303 calib.valid = {amp: bool(value) for amp, value in dictionary['valid'].items()}
304 calib.badAmps = [amp for amp, valid in dictionary['valid'].items() if valid is False]
305
306 calib.detKernels = {det: np.array(dictionary['detKernels'][det]).reshape(calib.shape)
307 for det in dictionary['detKernels']}
308
309 calib.updateMetadata()
310 return calib
311
std::vector< SchemaItem< Flag > > * items

◆ fromTable()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.fromTable ( cls,
tableList )
Construct calibration from a list of tables.

This method uses the `fromDict` method to create the
calibration, after constructing an appropriate dictionary from
the input tables.

Parameters
----------
tableList : `list` [`astropy.table.Table`]
    List of tables to use to construct the brighter-fatter
    calibration.

Returns
-------
calib : `lsst.ip.isr.BrighterFatterKernel`
    The calibration defined in the tables.

Definition at line 366 of file brighterFatterKernel.py.

366 def fromTable(cls, tableList):
367 """Construct calibration from a list of tables.
368
369 This method uses the `fromDict` method to create the
370 calibration, after constructing an appropriate dictionary from
371 the input tables.
372
373 Parameters
374 ----------
375 tableList : `list` [`astropy.table.Table`]
376 List of tables to use to construct the brighter-fatter
377 calibration.
378
379 Returns
380 -------
381 calib : `lsst.ip.isr.BrighterFatterKernel`
382 The calibration defined in the tables.
383 """
384 ampTable = tableList[0]
385
386 metadata = ampTable.meta
387 inDict = dict()
388 inDict['metadata'] = metadata
389
390 amps = ampTable['AMPLIFIER']
391
392 # Determine version for expected values. The ``fromDict``
393 # method can unpack either, but the appropriate fields need to
394 # be supplied.
395 calibVersion = metadata['bfk_VERSION']
396
397 if calibVersion == 1.0:
398 # We expect to find ``means`` and ``variances`` for this
399 # case, and will construct an ``expIdMask`` from these
400 # parameters in the ``fromDict`` method.
401 rawMeanList = ampTable['MEANS']
402 rawVarianceList = ampTable['VARIANCES']
403
404 inDict['means'] = {amp: mean for amp, mean in zip(amps, rawMeanList)}
405 inDict['variances'] = {amp: var for amp, var in zip(amps, rawVarianceList)}
406 elif calibVersion == 1.1:
407 # This will have ``rawMeans`` and ``rawVariances``, which
408 # are filtered via the ``expIdMask`` fields.
409 expIdMaskList = ampTable['EXP_ID_MASK']
410 rawMeanList = ampTable['RAW_MEANS']
411 rawVarianceList = ampTable['RAW_VARIANCES']
412
413 inDict['expIdMask'] = {amp: mask for amp, mask in zip(amps, expIdMaskList)}
414 inDict['rawMeans'] = {amp: mean for amp, mean in zip(amps, rawMeanList)}
415 inDict['rawVariances'] = {amp: var for amp, var in zip(amps, rawVarianceList)}
416 else:
417 raise RuntimeError(f"Unknown version for brighter-fatter kernel: {calibVersion}")
418
419 rawXcorrs = ampTable['RAW_XCORRS']
420 gainList = ampTable['GAIN']
421 noiseList = ampTable['NOISE']
422
423 meanXcorrs = ampTable['MEAN_XCORRS']
424 ampKernels = ampTable['KERNEL']
425 validList = ampTable['VALID']
426
427 inDict['rawXcorrs'] = {amp: kernel for amp, kernel in zip(amps, rawXcorrs)}
428 inDict['gain'] = {amp: gain for amp, gain in zip(amps, gainList)}
429 inDict['noise'] = {amp: noise for amp, noise in zip(amps, noiseList)}
430 inDict['meanXcorrs'] = {amp: kernel for amp, kernel in zip(amps, meanXcorrs)}
431 inDict['ampKernels'] = {amp: kernel for amp, kernel in zip(amps, ampKernels)}
432 inDict['valid'] = {amp: bool(valid) for amp, valid in zip(amps, validList)}
433
434 inDict['badAmps'] = [amp for amp, valid in inDict['valid'].items() if valid is False]
435
436 if len(tableList) > 1:
437 detTable = tableList[1]
438 inDict['detKernels'] = {det: kernel for det, kernel
439 in zip(detTable['DETECTOR'], detTable['KERNEL'])}
440 else:
441 inDict['detKernels'] = {}
442
443 return cls.fromDict(inDict)
444

◆ getLengths()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.getLengths ( self)
Return the set of lengths needed for reshaping components.

Returns
-------
kernelLength : `int`
    Product of the elements of self.shape.
smallLength : `int`
    Size of an untiled covariance.
nObs : `int`
    Number of observation pairs used in the kernel.

Definition at line 208 of file brighterFatterKernel.py.

208 def getLengths(self):
209 """Return the set of lengths needed for reshaping components.
210
211 Returns
212 -------
213 kernelLength : `int`
214 Product of the elements of self.shape.
215 smallLength : `int`
216 Size of an untiled covariance.
217 nObs : `int`
218 Number of observation pairs used in the kernel.
219 """
220 kernelLength = self.shape[0] * self.shape[1]
221 smallLength = int((self.shape[0] - 1)*(self.shape[1] - 1)/4)
222 if self.level == 'AMP':
223 nObservations = set([len(self.rawMeans[amp]) for amp in self.rawMeans])
224 if len(nObservations) != 1:
225 raise RuntimeError("Inconsistent number of observations found.")
226 nObs = nObservations.pop()
227 else:
228 nObs = 0
229
230 return (kernelLength, smallLength, nObs)
231
daf::base::PropertySet * set
Definition fits.cc:931

◆ initFromCamera()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.initFromCamera ( self,
camera,
detectorId = None )
Initialize kernel structure from camera.

Parameters
----------
camera : `lsst.afw.cameraGeom.Camera`
    Camera to use to define geometry.
detectorId : `int`, optional
    Index of the detector to generate.

Returns
-------
calib : `lsst.ip.isr.BrighterFatterKernel`
    The initialized calibration.

Raises
------
RuntimeError
    Raised if no detectorId is supplied for a calibration with
    ``level='AMP'``.

Definition at line 152 of file brighterFatterKernel.py.

152 def initFromCamera(self, camera, detectorId=None):
153 """Initialize kernel structure from camera.
154
155 Parameters
156 ----------
157 camera : `lsst.afw.cameraGeom.Camera`
158 Camera to use to define geometry.
159 detectorId : `int`, optional
160 Index of the detector to generate.
161
162 Returns
163 -------
164 calib : `lsst.ip.isr.BrighterFatterKernel`
165 The initialized calibration.
166
167 Raises
168 ------
169 RuntimeError
170 Raised if no detectorId is supplied for a calibration with
171 ``level='AMP'``.
172 """
173 self._instrument = camera.getName()
174
175 if detectorId is not None:
176 detector = camera[detectorId]
177 self._detectorId = detectorId
178 self._detectorName = detector.getName()
179 self._detectorSerial = detector.getSerial()
180
181 if self.level == 'AMP':
182 if detectorId is None:
183 raise RuntimeError("A detectorId must be supplied if level='AMP'.")
184
185 self.badAmps = []
186
187 for amp in detector:
188 ampName = amp.getName()
189 self.expIdMask[ampName] = []
190 self.rawMeans[ampName] = []
191 self.rawVariances[ampName] = []
192 self.rawXcorrs[ampName] = []
193 self.gain[ampName] = amp.getGain()
194 self.noise[ampName] = amp.getReadNoise()
195 self.meanXcorrs[ampName] = []
196 self.ampKernels[ampName] = []
197 self.valid[ampName] = []
198 elif self.level == 'DETECTOR':
199 if detectorId is None:
200 for det in camera:
201 detName = det.getName()
202 self.detKernels[detName] = []
203 else:
204 self.detKernels[self._detectorName] = []
205
206 return self
207

◆ makeDetectorKernelFromAmpwiseKernels()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.makeDetectorKernelFromAmpwiseKernels ( self,
detectorName,
ampsToExclude = [] )
Average the amplifier level kernels to create a detector level
kernel.  There is no change in index ordering/orientation from
this averaging.

Parameters
----------
detectorName : `str`
    Detector for which the averaged kernel will be used.
ampsToExclude : `list` [`str`], optional
    Amps that should not be included in the average.

Definition at line 553 of file brighterFatterKernel.py.

553 def makeDetectorKernelFromAmpwiseKernels(self, detectorName, ampsToExclude=[]):
554 """Average the amplifier level kernels to create a detector level
555 kernel. There is no change in index ordering/orientation from
556 this averaging.
557
558 Parameters
559 ----------
560 detectorName : `str`
561 Detector for which the averaged kernel will be used.
562 ampsToExclude : `list` [`str`], optional
563 Amps that should not be included in the average.
564 """
565 inKernels = np.array([self.ampKernels[amp] for amp in
566 self.ampKernels if amp not in ampsToExclude])
567 avgKernel = np.zeros_like(inKernels[0])
569 sctrl.setNumSigmaClip(5.0)
570 for i in range(np.shape(avgKernel)[0]):
571 for j in range(np.shape(avgKernel)[1]):
572 avgKernel[i, j] = afwMath.makeStatistics(inKernels[:, i, j],
573 afwMath.MEANCLIP, sctrl).getValue()
574
575 self.detKernels[detectorName] = avgKernel
576
Pass parameters to a Statistics object.
Definition Statistics.h:83
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition Statistics.h:361

◆ repackCorrelations()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.repackCorrelations ( self,
amp,
correlationShape )
If the correlations were masked, they need to be repacked into the
correct shape.

Parameters
----------
amp : `str`
    Amplifier needing repacked.
correlationShape : `tuple` [`int`], (3, )
    Shape the correlations are expected to take.

Definition at line 531 of file brighterFatterKernel.py.

531 def repackCorrelations(self, amp, correlationShape):
532 """If the correlations were masked, they need to be repacked into the
533 correct shape.
534
535 Parameters
536 ----------
537 amp : `str`
538 Amplifier needing repacked.
539 correlationShape : `tuple` [`int`], (3, )
540 Shape the correlations are expected to take.
541 """
542 repackedCorrelations = []
543 idx = 0
544 for maskValue in self.expIdMask[amp]:
545 if maskValue:
546 repackedCorrelations.append(self.rawXcorrs[amp][idx])
547 idx += 1
548 else:
549 repackedCorrelations.append(np.full((correlationShape[1], correlationShape[2]), np.nan))
550 self.rawXcorrs[amp] = repackedCorrelations
551

◆ replaceDetectorKernelWithAmpKernel()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.replaceDetectorKernelWithAmpKernel ( self,
ampName,
detectorName )

Definition at line 577 of file brighterFatterKernel.py.

577 def replaceDetectorKernelWithAmpKernel(self, ampName, detectorName):
578 self.detKernel[detectorName] = self.ampKernel[ampName]

◆ toDict()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.toDict ( self)
Return a dictionary containing the calibration properties.

The dictionary should be able to be round-tripped through
`fromDict`.

Returns
-------
dictionary : `dict`
    Dictionary of properties.

Definition at line 312 of file brighterFatterKernel.py.

312 def toDict(self):
313 """Return a dictionary containing the calibration properties.
314
315 The dictionary should be able to be round-tripped through
316 `fromDict`.
317
318 Returns
319 -------
320 dictionary : `dict`
321 Dictionary of properties.
322 """
323 self.updateMetadata()
324
325 outDict = {}
326 metadata = self.getMetadata()
327 outDict['metadata'] = metadata
328
329 # Lengths for ravel:
330 kernelLength, smallLength, nObs = self.getLengths()
331
332 outDict['expIdMask'] = {amp: np.array(self.expIdMask[amp]).tolist() for amp in self.expIdMask}
333 outDict['rawMeans'] = {amp: np.array(self.rawMeans[amp]).tolist() for amp in self.rawMeans}
334 outDict['rawVariances'] = {amp: np.array(self.rawVariances[amp]).tolist() for amp in
335 self.rawVariances}
336
337 for amp in self.rawXcorrs.keys():
338 # Check to see if we need to repack the data.
339 correlationShape = np.array(self.rawXcorrs[amp]).shape
340 if nObs != correlationShape[0]:
341 if correlationShape[0] == np.sum(self.expIdMask[amp]):
342 # Repack data.
343 self.repackCorrelations(amp, correlationShape)
344 else:
345 raise ValueError("Could not coerce rawXcorrs into appropriate shape "
346 "(have %d correlations, but expect to see %d.",
347 correlationShape[0], np.sum(self.expIdMask[amp]))
348
349 outDict['rawXcorrs'] = {amp: np.array(self.rawXcorrs[amp]).reshape(nObs*smallLength).tolist()
350 for amp in self.rawXcorrs}
351 outDict['badAmps'] = self.badAmps
352 outDict['gain'] = self.gain
353 outDict['noise'] = self.noise
354
355 outDict['meanXcorrs'] = {amp: self.meanXcorrs[amp].reshape(kernelLength).tolist()
356 for amp in self.meanXcorrs}
357 outDict['ampKernels'] = {amp: self.ampKernels[amp].reshape(kernelLength).tolist()
358 for amp in self.ampKernels}
359 outDict['valid'] = self.valid
360
361 outDict['detKernels'] = {det: self.detKernels[det].reshape(kernelLength).tolist()
362 for det in self.detKernels}
363 return outDict
364

◆ toTable()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.toTable ( self)
Construct a list of tables containing the information in this
calibration.

The list of tables should create an identical calibration
after being passed to this class's fromTable method.

Returns
-------
tableList : `list` [`lsst.afw.table.Table`]
    List of tables containing the crosstalk calibration
    information.

Definition at line 445 of file brighterFatterKernel.py.

445 def toTable(self):
446 """Construct a list of tables containing the information in this
447 calibration.
448
449 The list of tables should create an identical calibration
450 after being passed to this class's fromTable method.
451
452 Returns
453 -------
454 tableList : `list` [`lsst.afw.table.Table`]
455 List of tables containing the crosstalk calibration
456 information.
457
458 """
459 tableList = []
460 self.updateMetadata()
461
462 # Lengths
463 kernelLength, smallLength, nObs = self.getLengths()
464
465 ampList = []
466 expIdMaskList = []
467 rawMeanList = []
468 rawVarianceList = []
469 rawXcorrs = []
470 gainList = []
471 noiseList = []
472
473 meanXcorrsList = []
474 kernelList = []
475 validList = []
476
477 if self.level == 'AMP':
478 for amp in self.rawMeans.keys():
479 ampList.append(amp)
480 expIdMaskList.append(self.expIdMask[amp])
481 rawMeanList.append(self.rawMeans[amp])
482 rawVarianceList.append(self.rawVariances[amp])
483
484 correlationShape = np.array(self.rawXcorrs[amp]).shape
485 if nObs != correlationShape[0]:
486 if correlationShape[0] == np.sum(self.expIdMask[amp]):
487 # Repack data.
488 self.repackCorrelations(amp, correlationShape)
489 else:
490 raise ValueError("Could not coerce rawXcorrs into appropriate shape "
491 "(have %d correlations, but expect to see %d.",
492 correlationShape[0], np.sum(self.expIdMask[amp]))
493
494 rawXcorrs.append(np.array(self.rawXcorrs[amp]).reshape(nObs*smallLength).tolist())
495 gainList.append(self.gain[amp])
496 noiseList.append(self.noise[amp])
497
498 meanXcorrsList.append(self.meanXcorrs[amp].reshape(kernelLength).tolist())
499 kernelList.append(self.ampKernels[amp].reshape(kernelLength).tolist())
500 validList.append(int(self.valid[amp] and not (amp in self.badAmps)))
501
502 ampTable = Table({'AMPLIFIER': ampList,
503 'EXP_ID_MASK': expIdMaskList,
504 'RAW_MEANS': rawMeanList,
505 'RAW_VARIANCES': rawVarianceList,
506 'RAW_XCORRS': rawXcorrs,
507 'GAIN': gainList,
508 'NOISE': noiseList,
509 'MEAN_XCORRS': meanXcorrsList,
510 'KERNEL': kernelList,
511 'VALID': validList,
512 })
513
514 ampTable.meta = self.getMetadata().toDict()
515 tableList.append(ampTable)
516
517 if len(self.detKernels):
518 detList = []
519 kernelList = []
520 for det in self.detKernels.keys():
521 detList.append(det)
522 kernelList.append(self.detKernels[det].reshape(kernelLength).tolist())
523
524 detTable = Table({'DETECTOR': detList,
525 'KERNEL': kernelList})
526 detTable.meta = self.getMetadata().toDict()
527 tableList.append(detTable)
528
529 return tableList
530

◆ updateMetadata()

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.updateMetadata ( self,
setDate = False,
** kwargs )
Update calibration metadata.

This calls the base class's method after ensuring the required
calibration keywords will be saved.

Parameters
----------
setDate : `bool`, optional
    Update the CALIBDATE fields in the metadata to the current
    time. Defaults to False.
kwargs :
    Other keyword parameters to set in the metadata.

Definition at line 132 of file brighterFatterKernel.py.

132 def updateMetadata(self, setDate=False, **kwargs):
133 """Update calibration metadata.
134
135 This calls the base class's method after ensuring the required
136 calibration keywords will be saved.
137
138 Parameters
139 ----------
140 setDate : `bool`, optional
141 Update the CALIBDATE fields in the metadata to the current
142 time. Defaults to False.
143 kwargs :
144 Other keyword parameters to set in the metadata.
145 """
146 kwargs['LEVEL'] = self.level
147 kwargs['KERNEL_DX'] = self.shape[0]
148 kwargs['KERNEL_DY'] = self.shape[1]
149
150 super().updateMetadata(setDate=setDate, **kwargs)
151

Member Data Documentation

◆ _detectorId

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel._detectorId
protected

Definition at line 177 of file brighterFatterKernel.py.

◆ _detectorName

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel._detectorName
protected

Definition at line 178 of file brighterFatterKernel.py.

◆ _detectorSerial

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel._detectorSerial
protected

Definition at line 179 of file brighterFatterKernel.py.

◆ _instrument

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel._instrument
protected

Definition at line 173 of file brighterFatterKernel.py.

◆ _OBSTYPE

str lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel._OBSTYPE = 'bfk'
staticprotected

Definition at line 98 of file brighterFatterKernel.py.

◆ _SCHEMA

str lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel._SCHEMA = 'Brighter-fatter kernel'
staticprotected

Definition at line 99 of file brighterFatterKernel.py.

◆ _VERSION

float lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel._VERSION = 1.1
staticprotected

Definition at line 100 of file brighterFatterKernel.py.

◆ ampKernels

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.ampKernels

Definition at line 120 of file brighterFatterKernel.py.

◆ badAmps

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.badAmps

Definition at line 110 of file brighterFatterKernel.py.

◆ detKernels

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.detKernels

Definition at line 121 of file brighterFatterKernel.py.

◆ expIdMask

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.expIdMask

Definition at line 106 of file brighterFatterKernel.py.

◆ gain

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.gain

Definition at line 112 of file brighterFatterKernel.py.

◆ level

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.level

Definition at line 103 of file brighterFatterKernel.py.

◆ meanXcorrs

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.meanXcorrs

Definition at line 116 of file brighterFatterKernel.py.

◆ noise

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.noise

Definition at line 113 of file brighterFatterKernel.py.

◆ rawMeans

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.rawMeans

Definition at line 107 of file brighterFatterKernel.py.

◆ rawVariances

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.rawVariances

Definition at line 108 of file brighterFatterKernel.py.

◆ rawXcorrs

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.rawXcorrs

Definition at line 109 of file brighterFatterKernel.py.

◆ shape

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.shape

Definition at line 111 of file brighterFatterKernel.py.

◆ valid

lsst.ip.isr.brighterFatterKernel.BrighterFatterKernel.valid

Definition at line 117 of file brighterFatterKernel.py.


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