LSST Applications g034a557a3c+dd8dd8f11d,g0afe43252f+b86e4b8053,g11f7dcd041+017865fdd3,g1cd03abf6b+8446defddb,g1ce3e0751c+f991eae79d,g28da252d5a+ca8a1a9fb3,g2bbee38e9b+b6588ad223,g2bc492864f+b6588ad223,g2cdde0e794+8523d0dbb4,g347aa1857d+b6588ad223,g35bb328faa+b86e4b8053,g3a166c0a6a+b6588ad223,g461a3dce89+b86e4b8053,g52b1c1532d+b86e4b8053,g7f3b0d46df+ad13c1b82d,g80478fca09+f29c5d6c70,g858d7b2824+293f439f82,g8cd86fa7b1+af721d2595,g965a9036f2+293f439f82,g979bb04a14+51ed57f74c,g9ddcbc5298+f24b38b85a,gae0086650b+b86e4b8053,gbb886bcc26+b97e247655,gc28159a63d+b6588ad223,gc30aee3386+a2f0f6cab9,gcaf7e4fdec+293f439f82,gcd45df26be+293f439f82,gcdd4ae20e8+70b5def7e6,gce08ada175+da9c58a417,gcf0d15dbbd+70b5def7e6,gdaeeff99f8+006e14e809,gdbce86181e+6a170ce272,ge3d4d395c2+224150c836,ge5f7162a3a+bb2241c923,ge6cb8fbbf7+d119aed356,ge79ae78c31+b6588ad223,gf048a9a2f4+40ffced2b8,gf0baf85859+b4cca3d10f,w.2024.30
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.linearize.Linearizer Class Reference
Inheritance diagram for lsst.ip.isr.linearize.Linearizer:
lsst.ip.isr.calibType.IsrCalib

Public Member Functions

 __init__ (self, table=None, **kwargs)
 
 updateMetadata (self, setDate=False, **kwargs)
 
 fromDetector (self, detector)
 
 fromDict (cls, dictionary)
 
 toDict (self)
 
 fromTable (cls, tableList)
 
 toTable (self)
 
 getLinearityTypeByName (self, linearityTypeName)
 
 validate (self, detector=None, amplifier=None)
 
 applyLinearity (self, image, detector=None, log=None)
 

Public Attributes

 hasLinearity
 
 override
 
 ampNames
 
 linearityCoeffs
 
 linearityType
 
 linearityBBox
 
 fitParams
 
 fitParamsErr
 
 fitChiSq
 
 fitResiduals
 
 fitResidualsSigmaMad
 
 linearFit
 
 tableData
 

Protected Attributes

 _detectorName
 
 _detectorSerial
 
 _detectorId
 

Static Protected Attributes

str _OBSTYPE = "LINEARIZER"
 
str _SCHEMA = 'Gen3 Linearizer'
 
float _VERSION = 1.2
 

Detailed Description

Parameter set for linearization.

These parameters are included in `lsst.afw.cameraGeom.Amplifier`, but
should be accessible externally to allow for testing.

Parameters
----------
table : `numpy.array`, optional
    Lookup table; a 2-dimensional array of floats:

    - one row for each row index (value of coef[0] in the amplifier)
    - one column for each image value

    To avoid copying the table the last index should vary fastest
    (numpy default "C" order)
detector : `lsst.afw.cameraGeom.Detector`, optional
    Detector object.  Passed to self.fromDetector() on init.
log : `logging.Logger`, optional
    Logger to handle messages.
kwargs : `dict`, optional
    Other keyword arguments to pass to the parent init.

Raises
------
RuntimeError
    Raised if the supplied table is not 2D, or if the table has fewer
    columns than rows (indicating that the indices are swapped).

Notes
-----
The linearizer attributes stored are:

hasLinearity : `bool`
    Whether a linearity correction is defined for this detector.
override : `bool`
    Whether the detector parameters should be overridden.
ampNames : `list` [`str`]
    List of amplifier names to correct.
linearityCoeffs : `dict` [`str`, `numpy.array`]
    Coefficients to use in correction.  Indexed by amplifier
    names.  The format of the array depends on the type of
    correction to apply.
linearityType : `dict` [`str`, `str`]
    Type of correction to use, indexed by amplifier names.
linearityBBox : `dict` [`str`, `lsst.geom.Box2I`]
    Bounding box the correction is valid over, indexed by
    amplifier names.
fitParams : `dict` [`str`, `numpy.array`], optional
    Linearity fit parameters used to construct the correction
    coefficients, indexed as above.
fitParamsErr : `dict` [`str`, `numpy.array`], optional
    Uncertainty values of the linearity fit parameters used to
    construct the correction coefficients, indexed as above.
fitChiSq : `dict` [`str`, `float`], optional
    Chi-squared value of the linearity fit, indexed as above.
fitResiduals : `dict` [`str`, `numpy.array`], optional
    Residuals of the fit, indexed as above. Used for
    calculating photdiode corrections
fitResidualsSigmaMad : `dict` [`str`, `float`], optional
    Robust median-absolute-deviation of fit residuals, scaled
    by the signal level.
linearFit : The linear fit to the low flux region of the curve.
    [intercept, slope].
tableData : `numpy.array`, optional
    Lookup table data for the linearity correction.

Definition at line 39 of file linearize.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.ip.isr.linearize.Linearizer.__init__ ( self,
table = None,
** kwargs )

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

Definition at line 110 of file linearize.py.

110 def __init__(self, table=None, **kwargs):
111 self.hasLinearity = False
112 self.override = False
113
114 self.ampNames = list()
115 self.linearityCoeffs = dict()
116 self.linearityType = dict()
117 self.linearityBBox = dict()
118 self.fitParams = dict()
119 self.fitParamsErr = dict()
120 self.fitChiSq = dict()
121 self.fitResiduals = dict()
122 self.fitResidualsSigmaMad = dict()
123 self.linearFit = dict()
124 self.tableData = None
125 if table is not None:
126 if len(table.shape) != 2:
127 raise RuntimeError("table shape = %s; must have two dimensions" % (table.shape,))
128 if table.shape[1] < table.shape[0]:
129 raise RuntimeError("table shape = %s; indices are switched" % (table.shape,))
130 self.tableData = np.array(table, order="C")
131
132 super().__init__(**kwargs)
133 self.requiredAttributes.update(['hasLinearity', 'override',
134 'ampNames',
135 'linearityCoeffs', 'linearityType', 'linearityBBox',
136 'fitParams', 'fitParamsErr', 'fitChiSq',
137 'fitResiduals', 'fitResidualsSigmaMad', 'linearFit', 'tableData'])
138

Member Function Documentation

◆ applyLinearity()

lsst.ip.isr.linearize.Linearizer.applyLinearity ( self,
image,
detector = None,
log = None )
Apply the linearity to an image.

If the linearity parameters are populated, use those,
otherwise use the values from the detector.

Parameters
----------
image : `~lsst.afw.image.image`
    Image to correct.
detector : `~lsst.afw.cameraGeom.detector`, optional
    Detector to use to determine exposure trimmed state.  If
    supplied, but no other linearity information is provided
    by the calibration, then the static solution stored in the
    detector will be used.
log : `~logging.Logger`, optional
    Log object to use for logging.

Definition at line 460 of file linearize.py.

460 def applyLinearity(self, image, detector=None, log=None):
461 """Apply the linearity to an image.
462
463 If the linearity parameters are populated, use those,
464 otherwise use the values from the detector.
465
466 Parameters
467 ----------
468 image : `~lsst.afw.image.image`
469 Image to correct.
470 detector : `~lsst.afw.cameraGeom.detector`, optional
471 Detector to use to determine exposure trimmed state. If
472 supplied, but no other linearity information is provided
473 by the calibration, then the static solution stored in the
474 detector will be used.
475 log : `~logging.Logger`, optional
476 Log object to use for logging.
477 """
478 if log is None:
479 log = self.log
480 if detector and not self.hasLinearity:
481 self.fromDetector(detector)
482
483 self.validate(detector)
484
485 isTrimmed = None
486 if detector:
487 if detector.getBBox() == image.getBBox():
488 isTrimmed = True
489 else:
490 isTrimmed = False
491
492 numAmps = 0
493 numLinearized = 0
494 numOutOfRange = 0
495 for ampName in self.linearityType.keys():
496 linearizer = self.getLinearityTypeByName(self.linearityType[ampName])
497 numAmps += 1
498 if linearizer is not None:
499 match isTrimmed:
500 case True:
501 bbox = detector[ampName].getBBox()
502 case False:
503 bbox = detector[ampName].getRawBBox()
504 case None:
505 bbox = self.linearityBBox[ampName]
506
507 ampView = image.Factory(image, bbox)
508 success, outOfRange = linearizer()(ampView, **{'coeffs': self.linearityCoeffs[ampName],
509 'table': self.tableData,
510 'log': self.log})
511 numOutOfRange += outOfRange
512 if success:
513 numLinearized += 1
514 elif log is not None:
515 log.warning("Amplifier %s did not linearize.",
516 ampName)
517 return Struct(
518 numAmps=numAmps,
519 numLinearized=numLinearized,
520 numOutOfRange=numOutOfRange
521 )
522
523

◆ fromDetector()

lsst.ip.isr.linearize.Linearizer.fromDetector ( self,
detector )
Read linearity 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 159 of file linearize.py.

159 def fromDetector(self, detector):
160 """Read linearity parameters from a detector.
161
162 Parameters
163 ----------
164 detector : `lsst.afw.cameraGeom.detector`
165 Input detector with parameters to use.
166
167 Returns
168 -------
169 calib : `lsst.ip.isr.Linearizer`
170 The calibration constructed from the detector.
171 """
172 self._detectorName = detector.getName()
173 self._detectorSerial = detector.getSerial()
174 self._detectorId = detector.getId()
175 self.hasLinearity = True
176
177 # Do not translate Threshold, Maximum, Units.
178 for amp in detector.getAmplifiers():
179 ampName = amp.getName()
180 self.ampNames.append(ampName)
181 self.linearityType[ampName] = amp.getLinearityType()
182 self.linearityCoeffs[ampName] = amp.getLinearityCoeffs()
183 self.linearityBBox[ampName] = amp.getBBox()
184
185 return self
186

◆ fromDict()

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

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

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

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

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

Definition at line 188 of file linearize.py.

188 def fromDict(cls, dictionary):
189 """Construct a calibration from a dictionary of properties
190
191 Parameters
192 ----------
193 dictionary : `dict`
194 Dictionary of properties
195
196 Returns
197 -------
198 calib : `lsst.ip.isr.Linearity`
199 Constructed calibration.
200
201 Raises
202 ------
203 RuntimeError
204 Raised if the supplied dictionary is for a different
205 calibration.
206 """
207
208 calib = cls()
209
210 if calib._OBSTYPE != dictionary['metadata']['OBSTYPE']:
211 raise RuntimeError(f"Incorrect linearity supplied. Expected {calib._OBSTYPE}, "
212 f"found {dictionary['metadata']['OBSTYPE']}")
213
214 calib.setMetadata(dictionary['metadata'])
215
216 calib.hasLinearity = dictionary.get('hasLinearity',
217 dictionary['metadata'].get('HAS_LINEARITY', False))
218 calib.override = dictionary.get('override', True)
219
220 if calib.hasLinearity:
221 for ampName in dictionary['amplifiers']:
222 amp = dictionary['amplifiers'][ampName]
223 calib.ampNames.append(ampName)
224 calib.linearityCoeffs[ampName] = np.array(amp.get('linearityCoeffs', [0.0]))
225 calib.linearityType[ampName] = amp.get('linearityType', 'None')
226 calib.linearityBBox[ampName] = amp.get('linearityBBox', None)
227
228 calib.fitParams[ampName] = np.array(amp.get('fitParams', [0.0]))
229 calib.fitParamsErr[ampName] = np.array(amp.get('fitParamsErr', [0.0]))
230 calib.fitChiSq[ampName] = amp.get('fitChiSq', np.nan)
231 calib.fitResiduals[ampName] = np.array(amp.get('fitResiduals', [0.0]))
232 calib.fitResidualsSigmaMad[ampName] = np.array(amp.get('fitResidualsSigmaMad', np.nan))
233 calib.linearFit[ampName] = np.array(amp.get('linearFit', [0.0]))
234
235 calib.tableData = dictionary.get('tableData', None)
236 if calib.tableData:
237 calib.tableData = np.array(calib.tableData)
238
239 return calib
240

◆ fromTable()

lsst.ip.isr.linearize.Linearizer.fromTable ( cls,
tableList )
Read linearity from a FITS file.

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`]
    afwTable read from input file name.

Returns
-------
linearity : `~lsst.ip.isr.linearize.Linearizer``
    Linearity parameters.

Notes
-----
The method reads a FITS file with 1 or 2 extensions. The metadata is
read from the header of extension 1, which must exist.  Then the table
is loaded, and  the ['AMPLIFIER_NAME', 'TYPE', 'COEFFS', 'BBOX_X0',
'BBOX_Y0', 'BBOX_DX', 'BBOX_DY'] columns are read and used to set each
dictionary by looping over rows.
Extension 2 is then attempted to read in the try block (which only
exists for lookup tables). It has a column named 'LOOKUP_VALUES' that
contains a vector of the lookup entries in each row.

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

Definition at line 273 of file linearize.py.

273 def fromTable(cls, tableList):
274 """Read linearity from a FITS file.
275
276 This method uses the `fromDict` method to create the
277 calibration, after constructing an appropriate dictionary from
278 the input tables.
279
280 Parameters
281 ----------
282 tableList : `list` [`astropy.table.Table`]
283 afwTable read from input file name.
284
285 Returns
286 -------
287 linearity : `~lsst.ip.isr.linearize.Linearizer``
288 Linearity parameters.
289
290 Notes
291 -----
292 The method reads a FITS file with 1 or 2 extensions. The metadata is
293 read from the header of extension 1, which must exist. Then the table
294 is loaded, and the ['AMPLIFIER_NAME', 'TYPE', 'COEFFS', 'BBOX_X0',
295 'BBOX_Y0', 'BBOX_DX', 'BBOX_DY'] columns are read and used to set each
296 dictionary by looping over rows.
297 Extension 2 is then attempted to read in the try block (which only
298 exists for lookup tables). It has a column named 'LOOKUP_VALUES' that
299 contains a vector of the lookup entries in each row.
300 """
301 coeffTable = tableList[0]
302
303 metadata = coeffTable.meta
304 inDict = dict()
305 inDict['metadata'] = metadata
306 inDict['hasLinearity'] = metadata.get('HAS_LINEARITY', False)
307 inDict['amplifiers'] = dict()
308
309 for record in coeffTable:
310 ampName = record['AMPLIFIER_NAME']
311
312 fitParams = record['FIT_PARAMS'] if 'FIT_PARAMS' in record.columns else np.array([0.0])
313 fitParamsErr = record['FIT_PARAMS_ERR'] if 'FIT_PARAMS_ERR' in record.columns else np.array([0.0])
314 fitChiSq = record['RED_CHI_SQ'] if 'RED_CHI_SQ' in record.columns else np.nan
315 fitResiduals = record['FIT_RES'] if 'FIT_RES' in record.columns else np.array([0.0])
316 fitResidualsSigmaMad = record['FIT_RES_SIGMAD'] if 'FIT_RES_SIGMAD' in record.columns else np.nan
317 linearFit = record['LIN_FIT'] if 'LIN_FIT' in record.columns else np.array([0.0])
318
319 inDict['amplifiers'][ampName] = {
320 'linearityType': record['TYPE'],
321 'linearityCoeffs': record['COEFFS'],
322 'linearityBBox': Box2I(Point2I(record['BBOX_X0'], record['BBOX_Y0']),
323 Extent2I(record['BBOX_DX'], record['BBOX_DY'])),
324 'fitParams': fitParams,
325 'fitParamsErr': fitParamsErr,
326 'fitChiSq': fitChiSq,
327 'fitResiduals': fitResiduals,
328 'fitResidualsSigmaMad': fitResidualsSigmaMad,
329 'linearFit': linearFit,
330 }
331
332 if len(tableList) > 1:
333 tableData = tableList[1]
334 inDict['tableData'] = [record['LOOKUP_VALUES'] for record in tableData]
335
336 return cls().fromDict(inDict)
337

◆ getLinearityTypeByName()

lsst.ip.isr.linearize.Linearizer.getLinearityTypeByName ( self,
linearityTypeName )
Determine the linearity class to use from the type name.

Parameters
----------
linearityTypeName : str
    String name of the linearity type that is needed.

Returns
-------
linearityType : `~lsst.ip.isr.linearize.LinearizeBase`
    The appropriate linearity class to use.  If no matching class
    is found, `None` is returned.

Definition at line 376 of file linearize.py.

376 def getLinearityTypeByName(self, linearityTypeName):
377 """Determine the linearity class to use from the type name.
378
379 Parameters
380 ----------
381 linearityTypeName : str
382 String name of the linearity type that is needed.
383
384 Returns
385 -------
386 linearityType : `~lsst.ip.isr.linearize.LinearizeBase`
387 The appropriate linearity class to use. If no matching class
388 is found, `None` is returned.
389 """
390 for t in [LinearizeLookupTable,
391 LinearizeSquared,
392 LinearizePolynomial,
393 LinearizeProportional,
394 LinearizeSpline,
395 LinearizeNone]:
396 if t.LinearityType == linearityTypeName:
397 return t
398 return None
399

◆ toDict()

lsst.ip.isr.linearize.Linearizer.toDict ( self)
Return linearity parameters as a dict.

Returns
-------
outDict : `dict`:

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

Definition at line 241 of file linearize.py.

241 def toDict(self):
242 """Return linearity parameters as a dict.
243
244 Returns
245 -------
246 outDict : `dict`:
247 """
248 self.updateMetadata()
249
250 outDict = {'metadata': self.getMetadata(),
251 'detectorName': self._detectorName,
252 'detectorSerial': self._detectorSerial,
253 'detectorId': self._detectorId,
254 'hasTable': self.tableData is not None,
255 'amplifiers': dict(),
256 }
257 for ampName in self.linearityType:
258 outDict['amplifiers'][ampName] = {'linearityType': self.linearityType[ampName],
259 'linearityCoeffs': self.linearityCoeffs[ampName].tolist(),
260 'linearityBBox': self.linearityBBox[ampName],
261 'fitParams': self.fitParams[ampName].tolist(),
262 'fitParamsErr': self.fitParamsErr[ampName].tolist(),
263 'fitChiSq': self.fitChiSq[ampName],
264 'fitResiduals': self.fitResiduals[ampName].tolist(),
265 'fitResidualsSigmaMad': self.fitResiduals[ampName],
266 'linearFit': self.linearFit[ampName].tolist()}
267 if self.tableData is not None:
268 outDict['tableData'] = self.tableData.tolist()
269
270 return outDict
271

◆ toTable()

lsst.ip.isr.linearize.Linearizer.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` [`astropy.table.Table`]
    List of tables containing the linearity calibration
    information.

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

Definition at line 338 of file linearize.py.

338 def toTable(self):
339 """Construct a list of tables containing the information in this
340 calibration.
341
342 The list of tables should create an identical calibration
343 after being passed to this class's fromTable method.
344
345 Returns
346 -------
347 tableList : `list` [`astropy.table.Table`]
348 List of tables containing the linearity calibration
349 information.
350 """
351
352 tableList = []
353 self.updateMetadata()
354 catalog = Table([{'AMPLIFIER_NAME': ampName,
355 'TYPE': self.linearityType[ampName],
356 'COEFFS': self.linearityCoeffs[ampName],
357 'BBOX_X0': self.linearityBBox[ampName].getMinX(),
358 'BBOX_Y0': self.linearityBBox[ampName].getMinY(),
359 'BBOX_DX': self.linearityBBox[ampName].getWidth(),
360 'BBOX_DY': self.linearityBBox[ampName].getHeight(),
361 'FIT_PARAMS': self.fitParams[ampName],
362 'FIT_PARAMS_ERR': self.fitParamsErr[ampName],
363 'RED_CHI_SQ': self.fitChiSq[ampName],
364 'FIT_RES': self.fitResiduals[ampName],
365 'FIT_RES_SIGMAD': self.fitResidualsSigmaMad[ampName],
366 'LIN_FIT': self.linearFit[ampName],
367 } for ampName in self.ampNames])
368 catalog.meta = self.getMetadata().toDict()
369 tableList.append(catalog)
370
371 if self.tableData is not None:
372 catalog = Table([{'LOOKUP_VALUES': value} for value in self.tableData])
373 tableList.append(catalog)
374 return tableList
375

◆ updateMetadata()

lsst.ip.isr.linearize.Linearizer.updateMetadata ( self,
setDate = False,
** kwargs )
Update metadata keywords with new values.

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.

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

Definition at line 139 of file linearize.py.

139 def updateMetadata(self, setDate=False, **kwargs):
140 """Update metadata keywords with new values.
141
142 This calls the base class's method after ensuring the required
143 calibration keywords will be saved.
144
145 Parameters
146 ----------
147 setDate : `bool`, optional
148 Update the CALIBDATE fields in the metadata to the current
149 time. Defaults to False.
150 kwargs :
151 Other keyword parameters to set in the metadata.
152 """
153 kwargs['HAS_LINEARITY'] = self.hasLinearity
154 kwargs['OVERRIDE'] = self.override
155 kwargs['HAS_TABLE'] = self.tableData is not None
156
157 super().updateMetadata(setDate=setDate, **kwargs)
158

◆ validate()

lsst.ip.isr.linearize.Linearizer.validate ( self,
detector = None,
amplifier = None )
Validate linearity for a detector/amplifier.

Parameters
----------
detector : `lsst.afw.cameraGeom.Detector`, optional
    Detector to validate, along with its amplifiers.
amplifier : `lsst.afw.cameraGeom.Amplifier`, optional
    Single amplifier to validate.

Raises
------
RuntimeError
    Raised if there is a mismatch in linearity parameters, and
    the cameraGeom parameters are not being overridden.

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

Definition at line 400 of file linearize.py.

400 def validate(self, detector=None, amplifier=None):
401 """Validate linearity for a detector/amplifier.
402
403 Parameters
404 ----------
405 detector : `lsst.afw.cameraGeom.Detector`, optional
406 Detector to validate, along with its amplifiers.
407 amplifier : `lsst.afw.cameraGeom.Amplifier`, optional
408 Single amplifier to validate.
409
410 Raises
411 ------
412 RuntimeError
413 Raised if there is a mismatch in linearity parameters, and
414 the cameraGeom parameters are not being overridden.
415 """
416 amplifiersToCheck = []
417 if detector:
418 if self._detectorName != detector.getName():
419 raise RuntimeError("Detector names don't match: %s != %s" %
420 (self._detectorName, detector.getName()))
421 if int(self._detectorId) != int(detector.getId()):
422 raise RuntimeError("Detector IDs don't match: %s != %s" %
423 (int(self._detectorId), int(detector.getId())))
424 # TODO: DM-38778: This check fails on LATISS due to an
425 # error in the camera configuration.
426 # if self._detectorSerial != detector.getSerial():
427 # raise RuntimeError(
428 # "Detector serial numbers don't match: %s != %s" %
429 # (self._detectorSerial, detector.getSerial()))
430 if len(detector.getAmplifiers()) != len(self.linearityCoeffs.keys()):
431 raise RuntimeError("Detector number of amps = %s does not match saved value %s" %
432 (len(detector.getAmplifiers()),
433 len(self.linearityCoeffs.keys())))
434 amplifiersToCheck.extend(detector.getAmplifiers())
435
436 if amplifier:
437 amplifiersToCheck.extend(amplifier)
438
439 for amp in amplifiersToCheck:
440 ampName = amp.getName()
441 if ampName not in self.linearityCoeffs.keys():
442 raise RuntimeError("Amplifier %s is not in linearity data" %
443 (ampName, ))
444 if amp.getLinearityType() != self.linearityType[ampName]:
445 if self.override:
446 self.log.warning("Overriding amplifier defined linearityType (%s) for %s",
447 self.linearityType[ampName], ampName)
448 else:
449 raise RuntimeError("Amplifier %s type %s does not match saved value %s" %
450 (ampName, amp.getLinearityType(), self.linearityType[ampName]))
451 if (amp.getLinearityCoeffs().shape != self.linearityCoeffs[ampName].shape or not
452 np.allclose(amp.getLinearityCoeffs(), self.linearityCoeffs[ampName], equal_nan=True)):
453 if self.override:
454 self.log.warning("Overriding amplifier defined linearityCoeffs (%s) for %s",
455 self.linearityCoeffs[ampName], ampName)
456 else:
457 raise RuntimeError("Amplifier %s coeffs %s does not match saved value %s" %
458 (ampName, amp.getLinearityCoeffs(), self.linearityCoeffs[ampName]))
459

Member Data Documentation

◆ _detectorId

lsst.ip.isr.linearize.Linearizer._detectorId
protected

Definition at line 174 of file linearize.py.

◆ _detectorName

lsst.ip.isr.linearize.Linearizer._detectorName
protected

Definition at line 172 of file linearize.py.

◆ _detectorSerial

lsst.ip.isr.linearize.Linearizer._detectorSerial
protected

Definition at line 173 of file linearize.py.

◆ _OBSTYPE

str lsst.ip.isr.linearize.Linearizer._OBSTYPE = "LINEARIZER"
staticprotected

Definition at line 106 of file linearize.py.

◆ _SCHEMA

str lsst.ip.isr.linearize.Linearizer._SCHEMA = 'Gen3 Linearizer'
staticprotected

Definition at line 107 of file linearize.py.

◆ _VERSION

float lsst.ip.isr.linearize.Linearizer._VERSION = 1.2
staticprotected

Definition at line 108 of file linearize.py.

◆ ampNames

lsst.ip.isr.linearize.Linearizer.ampNames

Definition at line 114 of file linearize.py.

◆ fitChiSq

lsst.ip.isr.linearize.Linearizer.fitChiSq

Definition at line 120 of file linearize.py.

◆ fitParams

lsst.ip.isr.linearize.Linearizer.fitParams

Definition at line 118 of file linearize.py.

◆ fitParamsErr

lsst.ip.isr.linearize.Linearizer.fitParamsErr

Definition at line 119 of file linearize.py.

◆ fitResiduals

lsst.ip.isr.linearize.Linearizer.fitResiduals

Definition at line 121 of file linearize.py.

◆ fitResidualsSigmaMad

lsst.ip.isr.linearize.Linearizer.fitResidualsSigmaMad

Definition at line 122 of file linearize.py.

◆ hasLinearity

lsst.ip.isr.linearize.Linearizer.hasLinearity

Definition at line 111 of file linearize.py.

◆ linearFit

lsst.ip.isr.linearize.Linearizer.linearFit

Definition at line 123 of file linearize.py.

◆ linearityBBox

lsst.ip.isr.linearize.Linearizer.linearityBBox

Definition at line 117 of file linearize.py.

◆ linearityCoeffs

lsst.ip.isr.linearize.Linearizer.linearityCoeffs

Definition at line 115 of file linearize.py.

◆ linearityType

lsst.ip.isr.linearize.Linearizer.linearityType

Definition at line 116 of file linearize.py.

◆ override

lsst.ip.isr.linearize.Linearizer.override

Definition at line 112 of file linearize.py.

◆ tableData

lsst.ip.isr.linearize.Linearizer.tableData

Definition at line 124 of file linearize.py.


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