378 """Construct a calibration from a dictionary of properties.
379 Must be implemented by the specific calibration subclasses.
384 Dictionary of properties.
388 calib : `lsst.ip.isr.PhotonTransferCurveDataset`
389 Constructed calibration.
394 Raised if the supplied dictionary is for a different
398 if calib._OBSTYPE != dictionary[
'metadata'][
'OBSTYPE']:
399 raise RuntimeError(f
"Incorrect Photon Transfer Curve dataset supplied. "
400 f
"Expected {calib._OBSTYPE}, found {dictionary['metadata']['OBSTYPE']}")
401 calib.setMetadata(dictionary[
'metadata'])
402 calib.ptcFitType = dictionary[
'ptcFitType']
403 calib.covMatrixSide = dictionary[
'covMatrixSide']
404 calib.covMatrixSideFullCovFit = dictionary[
'covMatrixSideFullCovFit']
405 calib.badAmps = np.array(dictionary[
'badAmps'],
'str').tolist()
409 covMatrixSide = calib.covMatrixSide
410 covMatrixSideFullCovFit = calib.covMatrixSideFullCovFit
412 covDimensionsProduct = len(np.array(list(dictionary[
'covariances'].values())[0]).ravel())
413 nSignalPoints = int(covDimensionsProduct/(covMatrixSide*covMatrixSide))
415 for ampName
in dictionary[
'ampNames']:
416 calib.ampNames.append(ampName)
417 calib.inputExpIdPairs[ampName] = dictionary[
'inputExpIdPairs'][ampName]
418 calib.expIdMask[ampName] = np.array(dictionary[
'expIdMask'][ampName])
419 calib.rawExpTimes[ampName] = np.array(dictionary[
'rawExpTimes'][ampName], dtype=np.float64)
420 calib.rawMeans[ampName] = np.array(dictionary[
'rawMeans'][ampName], dtype=np.float64)
421 calib.rawVars[ampName] = np.array(dictionary[
'rawVars'][ampName], dtype=np.float64)
422 calib.rowMeanVariance[ampName] = np.array(dictionary[
'rowMeanVariance'][ampName],
424 calib.gain[ampName] = float(dictionary[
'gain'][ampName])
425 calib.gainErr[ampName] = float(dictionary[
'gainErr'][ampName])
426 calib.noiseList[ampName] = np.array(dictionary[
'noiseList'][ampName], dtype=np.float64)
427 calib.noise[ampName] = float(dictionary[
'noise'][ampName])
428 calib.noiseErr[ampName] = float(dictionary[
'noiseErr'][ampName])
429 calib.histVars[ampName] = np.array(dictionary[
'histVars'][ampName], dtype=np.float64)
430 calib.histChi2Dofs[ampName] = np.array(dictionary[
'histChi2Dofs'][ampName], dtype=np.float64)
431 calib.kspValues[ampName] = np.array(dictionary[
'kspValues'][ampName], dtype=np.float64)
432 calib.ptcFitPars[ampName] = np.array(dictionary[
'ptcFitPars'][ampName], dtype=np.float64)
433 calib.ptcFitParsError[ampName] = np.array(dictionary[
'ptcFitParsError'][ampName],
435 calib.ptcFitChiSq[ampName] = float(dictionary[
'ptcFitChiSq'][ampName])
436 calib.ptcTurnoff[ampName] = float(dictionary[
'ptcTurnoff'][ampName])
437 if nSignalPoints > 0:
439 calib.covariances[ampName] = np.array(dictionary[
'covariances'][ampName],
440 dtype=np.float64).reshape(
441 (nSignalPoints, covMatrixSide, covMatrixSide))
442 calib.covariancesModel[ampName] = np.array(
443 dictionary[
'covariancesModel'][ampName],
444 dtype=np.float64).reshape(
445 (nSignalPoints, covMatrixSideFullCovFit, covMatrixSideFullCovFit))
446 calib.covariancesSqrtWeights[ampName] = np.array(
447 dictionary[
'covariancesSqrtWeights'][ampName],
448 dtype=np.float64).reshape(
449 (nSignalPoints, covMatrixSide, covMatrixSide))
450 calib.aMatrix[ampName] = np.array(dictionary[
'aMatrix'][ampName],
451 dtype=np.float64).reshape(
452 (covMatrixSideFullCovFit, covMatrixSideFullCovFit))
453 calib.bMatrix[ampName] = np.array(dictionary[
'bMatrix'][ampName],
454 dtype=np.float64).reshape(
455 (covMatrixSideFullCovFit, covMatrixSideFullCovFit))
456 calib.covariancesModelNoB[ampName] = np.array(
457 dictionary[
'covariancesModelNoB'][ampName], dtype=np.float64).reshape(
458 (nSignalPoints, covMatrixSideFullCovFit, covMatrixSideFullCovFit))
459 calib.aMatrixNoB[ampName] = np.array(
460 dictionary[
'aMatrixNoB'][ampName],
461 dtype=np.float64).reshape((covMatrixSideFullCovFit, covMatrixSideFullCovFit))
462 calib.noiseMatrix[ampName] = np.array(
463 dictionary[
'noiseMatrix'][ampName],
464 dtype=np.float64).reshape((covMatrixSideFullCovFit, covMatrixSideFullCovFit))
465 calib.noiseMatrixNoB[ampName] = np.array(
466 dictionary[
'noiseMatrixNoB'][ampName],
467 dtype=np.float64).reshape((covMatrixSideFullCovFit, covMatrixSideFullCovFit))
470 calib.covariances[ampName] = np.array([], dtype=np.float64)
471 calib.covariancesModel[ampName] = np.array([], dtype=np.float64)
472 calib.covariancesSqrtWeights[ampName] = np.array([], dtype=np.float64)
473 calib.aMatrix[ampName] = np.array([], dtype=np.float64)
474 calib.bMatrix[ampName] = np.array([], dtype=np.float64)
475 calib.covariancesModelNoB[ampName] = np.array([], dtype=np.float64)
476 calib.aMatrixNoB[ampName] = np.array([], dtype=np.float64)
477 calib.noiseMatrix[ampName] = np.array([], dtype=np.float64)
478 calib.noiseMatrixNoB[ampName] = np.array([], dtype=np.float64)
480 calib.finalVars[ampName] = np.array(dictionary[
'finalVars'][ampName], dtype=np.float64)
481 calib.finalModelVars[ampName] = np.array(dictionary[
'finalModelVars'][ampName], dtype=np.float64)
482 calib.finalMeans[ampName] = np.array(dictionary[
'finalMeans'][ampName], dtype=np.float64)
483 calib.photoCharges[ampName] = np.array(dictionary[
'photoCharges'][ampName], dtype=np.float64)
485 for key, value
in dictionary[
'auxValues'].
items():
486 calib.auxValues[key] = np.atleast_1d(np.array(value, dtype=np.float64))
488 calib.updateMetadata()
492 """Return a dictionary containing the calibration properties.
493 The dictionary should be able to be round-tripped through
499 Dictionary of properties.
505 outDict[
'metadata'] = metadata
507 def _dictOfArraysToDictOfLists(dictOfArrays):
509 for key, value
in dictOfArrays.items():
510 dictOfLists[key] = value.ravel().tolist()
518 outDict[
'badAmps'] = self.
badAmps
520 outDict[
'expIdMask'] = _dictOfArraysToDictOfLists(self.
expIdMask)
521 outDict[
'rawExpTimes'] = _dictOfArraysToDictOfLists(self.
rawExpTimes)
522 outDict[
'rawMeans'] = _dictOfArraysToDictOfLists(self.
rawMeans)
523 outDict[
'rawVars'] = _dictOfArraysToDictOfLists(self.
rawVars)
524 outDict[
'rowMeanVariance'] = _dictOfArraysToDictOfLists(self.
rowMeanVariance)
525 outDict[
'gain'] = self.
gain
526 outDict[
'gainErr'] = self.
gainErr
527 outDict[
'noiseList'] = _dictOfArraysToDictOfLists(self.
noiseList)
528 outDict[
'noise'] = self.
noise
533 outDict[
'ptcFitPars'] = _dictOfArraysToDictOfLists(self.
ptcFitPars)
534 outDict[
'ptcFitParsError'] = _dictOfArraysToDictOfLists(self.
ptcFitParsError)
537 outDict[
'covariances'] = _dictOfArraysToDictOfLists(self.
covariances)
538 outDict[
'covariancesModel'] = _dictOfArraysToDictOfLists(self.
covariancesModel)
540 outDict[
'aMatrix'] = _dictOfArraysToDictOfLists(self.
aMatrix)
541 outDict[
'bMatrix'] = _dictOfArraysToDictOfLists(self.
bMatrix)
542 outDict[
'noiseMatrix'] = _dictOfArraysToDictOfLists(self.
noiseMatrix)
544 outDict[
'aMatrixNoB'] = _dictOfArraysToDictOfLists(self.
aMatrixNoB)
545 outDict[
'noiseMatrixNoB'] = _dictOfArraysToDictOfLists(self.
noiseMatrixNoB)
546 outDict[
'finalVars'] = _dictOfArraysToDictOfLists(self.
finalVars)
547 outDict[
'finalModelVars'] = _dictOfArraysToDictOfLists(self.
finalModelVars)
548 outDict[
'finalMeans'] = _dictOfArraysToDictOfLists(self.
finalMeans)
549 outDict[
'photoCharges'] = _dictOfArraysToDictOfLists(self.
photoCharges)
550 outDict[
'auxValues'] = _dictOfArraysToDictOfLists(self.
auxValues)