LSST Applications g0265f82a02+c6dfa2ddaf,g1162b98a3f+b2075782a9,g2079a07aa2+1b2e822518,g2bbee38e9b+c6dfa2ddaf,g337abbeb29+c6dfa2ddaf,g3ddfee87b4+a60788ef87,g50ff169b8f+2eb0e556e8,g52b1c1532d+90ebb246c7,g555ede804d+a60788ef87,g591dd9f2cf+ba8caea58f,g5ec818987f+864ee9cddb,g858d7b2824+9ee1ab4172,g876c692160+a40945ebb7,g8a8a8dda67+90ebb246c7,g8cdfe0ae6a+4fd9e222a8,g99cad8db69+5e309b7bc6,g9ddcbc5298+a1346535a5,ga1e77700b3+df8f93165b,ga8c6da7877+aa12a14d27,gae46bcf261+c6dfa2ddaf,gb0e22166c9+8634eb87fb,gb3f2274832+d0da15e3be,gba4ed39666+1ac82b564f,gbb8dafda3b+5dfd9c994b,gbeb006f7da+97157f9740,gc28159a63d+c6dfa2ddaf,gc86a011abf+9ee1ab4172,gcf0d15dbbd+a60788ef87,gdaeeff99f8+1cafcb7cd4,gdc0c513512+9ee1ab4172,ge79ae78c31+c6dfa2ddaf,geb67518f79+ba1859f325,geb961e4c1e+f9439d1e6f,gee10cc3b42+90ebb246c7,gf1cff7945b+9ee1ab4172,w.2024.12
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Protected Attributes | List of all members
lsst.ip.isr.deferredCharge.DeferredChargeCalib Class Reference
Inheritance diagram for lsst.ip.isr.deferredCharge.DeferredChargeCalib:
lsst.ip.isr.calibType.IsrCalib

Public Member Functions

 __init__ (self, useGains=True, **kwargs)
 
 fromDetector (self, detector)
 
 fromDict (cls, dictionary)
 
 toDict (self)
 
 fromTable (cls, tableList)
 
 toTable (self)
 

Public Attributes

 driftScale
 
 decayTime
 
 globalCti
 
 serialTraps
 

Static Protected Attributes

str _OBSTYPE = 'CTI'
 
str _SCHEMA = 'Deferred Charge'
 
float _VERSION = 1.0
 

Detailed Description

Calibration containing deferred charge/CTI parameters.

Parameters
----------
**kwargs :
    Additional parameters to pass to parent constructor.

Notes
-----
The charge transfer inefficiency attributes stored are:

driftScale : `dict` [`str`, `float`]
    A dictionary, keyed by amplifier name, of the local electronic
    offset drift scale parameter, A_L in Snyder+2021.
decayTime : `dict` [`str`, `float`]
    A dictionary, keyed by amplifier name, of the local electronic
    offset decay time, \tau_L in Snyder+2021.
globalCti : `dict` [`str`, `float`]
    A dictionary, keyed by amplifier name, of the mean global CTI
    paramter, b in Snyder+2021.
serialTraps : `dict` [`str`, `lsst.ip.isr.SerialTrap`]
    A dictionary, keyed by amplifier name, containing a single
    serial trap for each amplifier.

Definition at line 213 of file deferredCharge.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.ip.isr.deferredCharge.DeferredChargeCalib.__init__ ( self,
useGains = True,
** kwargs )

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 242 of file deferredCharge.py.

242 def __init__(self, useGains=True, **kwargs):
243 self.driftScale = {}
244 self.decayTime = {}
245 self.globalCti = {}
246 self.serialTraps = {}
247
248 super().__init__(**kwargs)
249
250 units = 'electrons' if useGains else 'ADU'
251 self.updateMetadata(USEGAINS=useGains, UNITS=units)
252
253 self.requiredAttributes.update(['driftScale', 'decayTime', 'globalCti', 'serialTraps'])
254

Member Function Documentation

◆ fromDetector()

lsst.ip.isr.deferredCharge.DeferredChargeCalib.fromDetector ( self,
detector )
Read metadata parameters from a detector.

Parameters
----------
detector : `lsst.afw.cameraGeom.detector`
    Input detector with parameters to use.

Returns
-------
calib : `lsst.ip.isr.Linearizer`
    The calibration constructed from the detector.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 255 of file deferredCharge.py.

255 def fromDetector(self, detector):
256 """Read metadata parameters from a detector.
257
258 Parameters
259 ----------
260 detector : `lsst.afw.cameraGeom.detector`
261 Input detector with parameters to use.
262
263 Returns
264 -------
265 calib : `lsst.ip.isr.Linearizer`
266 The calibration constructed from the detector.
267 """
268
269 pass
270

◆ fromDict()

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

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

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

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

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 272 of file deferredCharge.py.

272 def fromDict(cls, dictionary):
273 """Construct a calibration from a dictionary of properties.
274
275 Parameters
276 ----------
277 dictionary : `dict`
278 Dictionary of properties.
279
280 Returns
281 -------
282 calib : `lsst.ip.isr.CalibType`
283 Constructed calibration.
284
285 Raises
286 ------
287 RuntimeError
288 Raised if the supplied dictionary is for a different
289 calibration.
290 """
291 calib = cls()
292
293 if calib._OBSTYPE != dictionary['metadata']['OBSTYPE']:
294 raise RuntimeError(f"Incorrect CTI supplied. Expected {calib._OBSTYPE}, "
295 f"found {dictionary['metadata']['OBSTYPE']}")
296
297 calib.setMetadata(dictionary['metadata'])
298
299 calib.driftScale = dictionary['driftScale']
300 calib.decayTime = dictionary['decayTime']
301 calib.globalCti = dictionary['globalCti']
302
303 for ampName in dictionary['serialTraps']:
304 ampTraps = dictionary['serialTraps'][ampName]
305 calib.serialTraps[ampName] = SerialTrap(ampTraps['size'], ampTraps['emissionTime'],
306 ampTraps['pixel'], ampTraps['trap_type'],
307 ampTraps['coeffs'])
308 calib.updateMetadata()
309 return calib
310

◆ fromTable()

lsst.ip.isr.deferredCharge.DeferredChargeCalib.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` [`lsst.afw.table.Table`]
    List of tables to use to construct the crosstalk
    calibration.  Two tables are expected in this list, the
    first containing the per-amplifier CTI parameters, and the
    second containing the parameters for serial traps.

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

Raises
------
ValueError
    Raised if the trap type or trap coefficients are not
    defined properly.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 341 of file deferredCharge.py.

341 def fromTable(cls, tableList):
342 """Construct calibration from a list of tables.
343
344 This method uses the ``fromDict`` method to create the
345 calibration, after constructing an appropriate dictionary from
346 the input tables.
347
348 Parameters
349 ----------
350 tableList : `list` [`lsst.afw.table.Table`]
351 List of tables to use to construct the crosstalk
352 calibration. Two tables are expected in this list, the
353 first containing the per-amplifier CTI parameters, and the
354 second containing the parameters for serial traps.
355
356 Returns
357 -------
358 calib : `lsst.ip.isr.DeferredChargeCalib`
359 The calibration defined in the tables.
360
361 Raises
362 ------
363 ValueError
364 Raised if the trap type or trap coefficients are not
365 defined properly.
366 """
367 ampTable = tableList[0]
368
369 inDict = {}
370 inDict['metadata'] = ampTable.meta
371
372 amps = ampTable['AMPLIFIER']
373 driftScale = ampTable['DRIFT_SCALE']
374 decayTime = ampTable['DECAY_TIME']
375 globalCti = ampTable['GLOBAL_CTI']
376
377 inDict['driftScale'] = {amp: value for amp, value in zip(amps, driftScale)}
378 inDict['decayTime'] = {amp: value for amp, value in zip(amps, decayTime)}
379 inDict['globalCti'] = {amp: value for amp, value in zip(amps, globalCti)}
380
381 inDict['serialTraps'] = {}
382 trapTable = tableList[1]
383
384 amps = trapTable['AMPLIFIER']
385 sizes = trapTable['SIZE']
386 emissionTimes = trapTable['EMISSION_TIME']
387 pixels = trapTable['PIXEL']
388 trap_type = trapTable['TYPE']
389 coeffs = trapTable['COEFFS']
390
391 for index, amp in enumerate(amps):
392 ampTrap = {}
393 ampTrap['size'] = sizes[index]
394 ampTrap['emissionTime'] = emissionTimes[index]
395 ampTrap['pixel'] = pixels[index]
396 ampTrap['trap_type'] = trap_type[index]
397
398 # Unpad any trailing NaN values: find the continuous array
399 # of NaNs at the end of the coefficients, and remove them.
400 inCoeffs = coeffs[index]
401 breakIndex = 1
402 nanValues = np.where(np.isnan(inCoeffs))[0]
403 if nanValues is not None:
404 coeffLength = len(inCoeffs)
405 while breakIndex < coeffLength:
406 if coeffLength - breakIndex in nanValues:
407 breakIndex += 1
408 else:
409 break
410 breakIndex -= 1 # Remove the fixed offset.
411 if breakIndex != 0:
412 outCoeffs = inCoeffs[0: coeffLength - breakIndex]
413 else:
414 outCoeffs = inCoeffs
415 ampTrap['coeffs'] = outCoeffs.tolist()
416
417 if ampTrap['trap_type'] == 'linear':
418 if len(ampTrap['coeffs']) < 1:
419 raise ValueError("CTI Amplifier %s coefficients for trap has illegal length %d.",
420 amp, len(ampTrap['coeffs']))
421 elif ampTrap['trap_type'] == 'logistic':
422 if len(ampTrap['coeffs']) < 2:
423 raise ValueError("CTI Amplifier %s coefficients for trap has illegal length %d.",
424 amp, len(ampTrap['coeffs']))
425 elif ampTrap['trap_type'] == 'spline':
426 if len(ampTrap['coeffs']) % 2 != 0:
427 raise ValueError("CTI Amplifier %s coefficients for trap has illegal length %d.",
428 amp, len(ampTrap['coeffs']))
429 else:
430 raise ValueError('Unknown trap type: %s', ampTrap['trap_type'])
431
432 inDict['serialTraps'][amp] = ampTrap
433
434 return cls.fromDict(inDict)
435

◆ toDict()

lsst.ip.isr.deferredCharge.DeferredChargeCalib.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.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 311 of file deferredCharge.py.

311 def toDict(self):
312 """Return a dictionary containing the calibration properties.
313 The dictionary should be able to be round-tripped through
314 ``fromDict``.
315
316 Returns
317 -------
318 dictionary : `dict`
319 Dictionary of properties.
320 """
321 self.updateMetadata()
322 outDict = {}
323 outDict['metadata'] = self.getMetadata()
324
325 outDict['driftScale'] = self.driftScale
326 outDict['decayTime'] = self.decayTime
327 outDict['globalCti'] = self.globalCti
328
329 outDict['serialTraps'] = {}
330 for ampName in self.serialTraps:
331 ampTrap = {'size': self.serialTraps[ampName].size,
332 'emissionTime': self.serialTraps[ampName].emission_time,
333 'pixel': self.serialTraps[ampName].pixel,
334 'trap_type': self.serialTraps[ampName].trap_type,
335 'coeffs': self.serialTraps[ampName].coeffs}
336 outDict['serialTraps'][ampName] = ampTrap
337
338 return outDict
339

◆ toTable()

lsst.ip.isr.deferredCharge.DeferredChargeCalib.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.  Two tables are generated for this list, the
    first containing the per-amplifier CTI parameters, and the
    second containing the parameters for serial traps.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 436 of file deferredCharge.py.

436 def toTable(self):
437 """Construct a list of tables containing the information in this
438 calibration.
439
440 The list of tables should create an identical calibration
441 after being passed to this class's fromTable method.
442
443 Returns
444 -------
445 tableList : `list` [`lsst.afw.table.Table`]
446 List of tables containing the crosstalk calibration
447 information. Two tables are generated for this list, the
448 first containing the per-amplifier CTI parameters, and the
449 second containing the parameters for serial traps.
450 """
451 tableList = []
452 self.updateMetadata()
453
454 ampList = []
455 driftScale = []
456 decayTime = []
457 globalCti = []
458
459 for amp in self.driftScale.keys():
460 ampList.append(amp)
461 driftScale.append(self.driftScale[amp])
462 decayTime.append(self.decayTime[amp])
463 globalCti.append(self.globalCti[amp])
464
465 ampTable = Table({'AMPLIFIER': ampList,
466 'DRIFT_SCALE': driftScale,
467 'DECAY_TIME': decayTime,
468 'GLOBAL_CTI': globalCti,
469 })
470
471 ampTable.meta = self.getMetadata().toDict()
472 tableList.append(ampTable)
473
474 ampList = []
475 sizeList = []
476 timeList = []
477 pixelList = []
478 typeList = []
479 coeffList = []
480
481 # Get maximum coeff length
482 maxCoeffLength = 0
483 for trap in self.serialTraps.values():
484 maxCoeffLength = np.maximum(maxCoeffLength, len(trap.coeffs))
485
486 # Pack and pad the end of the coefficients with NaN values.
487 for amp, trap in self.serialTraps.items():
488 ampList.append(amp)
489 sizeList.append(trap.size)
490 timeList.append(trap.emission_time)
491 pixelList.append(trap.pixel)
492 typeList.append(trap.trap_type)
493
494 coeffs = trap.coeffs
495 if len(coeffs) != maxCoeffLength:
496 coeffs = np.pad(coeffs, (0, maxCoeffLength - len(coeffs)),
497 constant_values=np.nan).tolist()
498 coeffList.append(coeffs)
499
500 trapTable = Table({'AMPLIFIER': ampList,
501 'SIZE': sizeList,
502 'EMISSION_TIME': timeList,
503 'PIXEL': pixelList,
504 'TYPE': typeList,
505 'COEFFS': coeffList})
506
507 tableList.append(trapTable)
508
509 return tableList
510
511
std::vector< SchemaItem< Flag > > * items

Member Data Documentation

◆ _OBSTYPE

str lsst.ip.isr.deferredCharge.DeferredChargeCalib._OBSTYPE = 'CTI'
staticprotected

Definition at line 238 of file deferredCharge.py.

◆ _SCHEMA

str lsst.ip.isr.deferredCharge.DeferredChargeCalib._SCHEMA = 'Deferred Charge'
staticprotected

Definition at line 239 of file deferredCharge.py.

◆ _VERSION

float lsst.ip.isr.deferredCharge.DeferredChargeCalib._VERSION = 1.0
staticprotected

Definition at line 240 of file deferredCharge.py.

◆ decayTime

lsst.ip.isr.deferredCharge.DeferredChargeCalib.decayTime

Definition at line 244 of file deferredCharge.py.

◆ driftScale

lsst.ip.isr.deferredCharge.DeferredChargeCalib.driftScale

Definition at line 243 of file deferredCharge.py.

◆ globalCti

lsst.ip.isr.deferredCharge.DeferredChargeCalib.globalCti

Definition at line 245 of file deferredCharge.py.

◆ serialTraps

lsst.ip.isr.deferredCharge.DeferredChargeCalib.serialTraps

Definition at line 246 of file deferredCharge.py.


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