PhotonTransferCurveDataset#
- class lsst.ip.isr.PhotonTransferCurveDataset(ampNames=[], ptcFitType=None, covMatrixSide=1, covMatrixSideFullCovFit=None, **kwargs)#
Bases:
IsrCalibA simple class to hold the output data from the PTC task.
The dataset is made up of a dictionary for each item, keyed by the amplifiers’ names, which much be supplied at construction time. New items cannot be added to the class to save accidentally saving to the wrong property, and the class can be frozen if desired. inputExpIdPairs records the exposures used to produce the data. When fitPtc() or fitCovariancesAstier() is run, a mask is built up, which is by definition always the same length as inputExpIdPairs, rawExpTimes, rawMeans and rawVars, and is a list of bools, which are incrementally set to False as points are discarded from the fits.
Parameters#
- ampNames
list List with the names of the amplifiers of the detector at hand.
- ptcFitType
str, optional Type of model fitted to the PTC: “EXPAPPROXIMATION”, or “FULLCOVARIANCE” or “FULLCOVARIANCE_NO_B”.
- covMatrixSide
int, optional Maximum lag of measured covariances (size of square covariance matrices).
- covMatrixSideFullCovFit
int, optional Maximum covariances lag for FULLCOVARIANCE fit. It should be less or equal than covMatrixSide.
- kwargs
dict, optional Other keyword arguments to pass to the parent init.
Notes#
The stored attributes are:
- badAmps
list[str] List with bad amplifiers names.
- inputExpIdPairs
dict, [str,list] Dictionary keyed by amp names containing the input exposures IDs.
- inputExpPairMjdStartList
dict, [str,np.ndarray] Dictionary keyed by amp names containing the start mjd from the first exposure in each flat pair.
- expIdMask
dict, [str,np.ndarray] Dictionary keyed by amp names containing the mask produced after outlier rejection. The mask produced by the “FULLCOVARIANCE” option may differ from the one produced in the other two PTC fit types.
- expIdRolloffMask
dict, [str,np.ndarray] Dictionary keyed by amp names containing the mask produced after outlier rejection and extended to fit the PTC rolloff.
- rawExpTimes
dict, [str,np.ndarray] Dictionary keyed by amp names containing the unmasked exposure times.
- rawMeans
dict, [str,np.ndarray] Dictionary keyed by amp names containing the unmasked average of the means of the exposures in each flat pair (units: adu).
- rawVars
dict, [str,np.ndarray] Dictionary keyed by amp names containing the variance of the difference image of the exposures in each flat pair (units: adu^2).
- rawDeltas
dict, [str,np.ndarray] Dictionary keyed by amp names containing the scaled unmasked delta of the means of the exposures in each flat pair (mean2 - mean1) (units: adu).
- rowMeanVariance
dict, [str,np.ndarray] Dictionary keyed by amp names containing the variance of the means of the rows of the difference image of the exposures in each flat pair (units: adu^2).
- histVars
dict, [str,np.ndarray] Dictionary keyed by amp names containing the variance of the difference image of the exposures in each flat pair estimated by fitting a Gaussian model.
- histChi2Dofs
dict, [str,np.ndarray] Dictionary keyed by amp names containing the chi-squared per degree of freedom fitting the difference image to a Gaussian model.
- kspValues
dict, [str,np.ndarray] Dictionary keyed by amp names containing the KS test p-value from fitting the difference image to a Gaussian model.
- gain
dict, [str,float] Dictionary keyed by amp names containing the fitted gains. May be adjusted by amp-offset gain ratios if configured in PTC solver.
- gainUnadjusted
dict, [str,float] Dictionary keyed by amp names containing unadjusted (raw) fit gain values. May be the same as gain values if amp-offset adjustment is not turned on.
- gainErr
dict, [str,float] Dictionary keyed by amp names containing the errors on the fitted gains.
- gainList
dict, [str,np.ndarray] Dictionary keyed by amp names containing the gain estimated from each flat pair.
- overscanMedianLevelList
dict, [str,np.ndarray] Dictionary keyed by amp names containing the median overscan level from each input flat pair (units: adu).
- overscanMedian
dict `, [`str,float] Dictionary keyed by amp names containing the median of overscanMedianLevelList[expIdMask] (units: adu).
- overscanMedianSigma
dict `, [`str,float] Dictionary keyed by amp names containing the median absolute deviation of overscanMedianLevelList[expIdMask] (units: adu).
- noiseList
dict, [str,np.ndarray] Dictionary keyed by amp names containing the mean overscan standard deviation from each flat pair (units: adu).
- noise
dict, [str,float] Dictionary keyed by amp names containing the fitted noise (units: electron).
- noiseErr
dict, [str,float] Dictionary keyed by amp names containing the errors on the fitted noise (units: electron).
- ampOffsets
dict, [str,float] Dictionary keyed by amp names containing amp-to-amp offsets (units: adu).
- ptcFitPars
dict, [str,np.ndarray] Dictionary keyed by amp names containing the raveled array fitted parameters of the PTC model.
- ptcFitParsError
dict, [str,np.ndarray] Dictionary keyed by amp names containing the raveled array errors on the fitted parameters of the PTC model for ptcFitType.
- ptcFitChiSq
dict, [str,float] Dictionary keyed by amp names containing the reduced chi squared of the fit.
- ptcTurnoff
dict[str, `float] Flux value (in adu) where the variance of the PTC curve starts decreasing consistently.
- ptcTurnoffSamplingError
dict[str,float] Samplingerror on the ptcTurnoff, based on the flux sampling of the input PTC (units: adu).- ptcRolloff
dict[str, `float] Flux value (in adu) where the variance of the PTC curve begins starts to move away from the PTC model by some threshold.
- ptcRolloffError
dict[str,float] Covariance error from the fit to the PTC rolloff (units: adu).
- ptcRolloff
dict[str, `float] Curvature parameter of the PTC rolloff.
- ptcRolloffError
dict[str,float] Fitting error of the curvature parameter of the PTC rolloff.
- nPixelCovariances
dict, [str,int] Dictionary keyed by amp names containing the number of pixels that were used to measure the covariances.
- covariances
dict, [str,np.ndarray] Dictionary keyed by amp names containing a list of measured covariances per mean flux (units: adu^2).
- covariancesModel
dict, [str,np.ndarray] Dictionary keyed by amp names containinging covariances model (Eq. 20 of Astier+19) per mean flux (units: adu^2).
- covariancesSqrtWeights
dict, [str,np.ndarray] Dictionary keyed by amp names containinging sqrt. of covariances weights (units: 1/adu).
- aMatrix
dict, [str,np.ndarray] Dictionary keyed by amp names containing the “a” parameters from the model in Eq. 20 of Astier+19 (units: 1/electron).
- bMatrix
dict, [str,np.ndarray] Dictionary keyed by amp names containing the “b” parameters from the model in Eq. 20 of Astier+19 (units: 1/electron).
- noiseMatrix
dict, [str,np.ndarray] Dictionary keyed by amp names containing the “noise” parameters from the model in Eq. 20 of Astier+19 (units: electron^2).
- covariancesModelNoB
dict, [str,np.ndarray] Dictionary keyed by amp names containing covariances model (with ‘b’=0 in Eq. 20 of Astier+19) per mean flux (units: adu^2). Will be removed after v29.
- aMatrixNoB
dict, [str,np.ndarray] Dictionary keyed by amp names containing the “a” parameters from the model in Eq. 20 of Astier+19 (and ‘b’ = 0) (units: 1/electron). Will be removed after v29.
- noiseMatrixNoB
dict, [str,np.ndarray] Dictionary keyed by amp names containing the “noise” parameters from the model in Eq. 20 of Astier+19, with ‘b’ = 0 (units: electron^2). Will be removed after v29.
- finalVars
dict, [str,np.ndarray] Dictionary keyed by amp names containing the masked variance of the difference image of each flat pair. If needed, each array will be right-padded with np.nan to match the length of rawExpTimes.
- finalModelVars
dict, [str,np.ndarray] Dictionary keyed by amp names containing the masked modeled variance of the difference image of each flat pair. If needed, each array will be right-padded with np.nan to match the length of rawExpTimes.
- finalMeans
dict, [str,np.ndarray] Dictionary keyed by amp names containing the masked average of the means of the exposures in each flat pair. If needed, each array will be right-padded with np.nan to match the length of rawExpTimes.
- photoCharges
dict, [str,np.ndarray] Dictionary keyed by amp names containing the integrated photocharge for linearity calibration.
- photoChargeDeltas
dict, [str,np.ndarray] Dictionary keyed by amp names containing the delta for the integrated photocharge (photocharge2 - photocharge1).
- auxValues
dict, [str,np.ndarray] Dictionary of per-detector auxiliary header values that can be used for PTC, linearity computation.
Version 1.1 adds the
ptcTurnoffattribute. Version 1.2 adds thehistVars,histChi2Dofs, andkspValuesattributes.
Version 1.3 adds the
noiseMatrixandnoiseMatrixNoBattributes. Version 1.4 adds theauxValuesattribute. Version 1.5 adds thecovMatrixSideFullCovFitattribute. Version 1.6 adds therowMeanVarianceattribute. Version 1.7 adds thenoiseListattribute. Version 1.8 adds theptcTurnoffSamplingErrorattribute. Version 1.9 standardizes PTC noise units to electron. Version 2.0 adds theampOffsets,gainUnadjusted, andgainListattributes.- Version 2.1 deprecates the
covariancesModelNoB,aMatrixNoB, and noiseMatrixNoBattributes.- Version 2.2 adds the
overscanMedianLevelListand inputExpPairMjdStartListattributes.- Version 2.3 adds the
overscanMedianand overscanMedianSigmaattrbutes.
Version 2.4 adds the
nPixelCovariancesattribute. Version 2.5 adds therawDeltasandphotoChargeDeltasattributes. Version 2.6 adds theexpIdRolloffMask,ptcRolloff,ptcRolloffError,ptcRolloffTau, andptcRolloffTauErrorattributes. Also deprecates the POLYNOMIAL fit type.Methods Summary
appendPartialPtc(partialPtc)Append a partial PTC dataset to this dataset.
evalPtcModel(mu)Computes the covariance model at specific signal levels.
fromDetector(detector)Read metadata parameters from a detector.
fromDict(dictionary)Construct a calibration from a dictionary of properties.
fromTable(tableList)Construct calibration from a list of tables.
getExpIdsUsed(ampName)Get the exposures used, i.e. not discarded, for a given amp.
Get the good amps from this PTC.
getGoodPoints(ampName)Get the good points used for a given amp in the PTC.
setAmpValuesPartialDataset(ampName[, ...])Set the amp values for a partial PTC Dataset (from cpExtractPtcTask).
setAuxValuesPartialDataset(auxDict)Set a dictionary of auxiliary values for a partial dataset.
sort(sortIndex)Sort the components of the PTC by a given sort index.
toDict()Return a dictionary containing the calibration properties.
toTable()Construct a list of tables containing the information in this calibration.
updateMetadata(**kwargs)Update calibration metadata.
validateGainNoiseTurnoffValues(ampName[, doWarn])Ensure the gain, read noise, and PTC turnoff have sensible values.
Methods Documentation
- appendPartialPtc(partialPtc)#
Append a partial PTC dataset to this dataset.
Parameters#
- partialPtc
lsst.ip.isr.PhotonTransferCurveDataset Partial PTC to append. Should only have one element.
- partialPtc
- evalPtcModel(mu)#
Computes the covariance model at specific signal levels.
Parameters#
- mu
numpy.array, (N,) List of mean signals in ADU.
Raises#
- RuntimeError
Raised if ptcFitType is invalid.
Returns#
- covModel
numpy.array, (N, M, M) Covariances model at mu (in ADU^2).
Notes#
Computes the covModel for all mu, and it returns cov[N, M, M], where the variance model is cov[:,0,0]. Both mu and cov are in ADUs and ADUs squared. This routine evaluates the approximation in Eq. 16 of Astier+19 (1905.08677) if self.ptcFitType == EXPAPPROXIMATION, and Eq. 20 of Astier+19 if self.ptcFitType == FULLCOVARIANCE(_NO_B).
The EXPAPPROXIMATION model (Eq. 16 of Astier+19) is only an approximation for the variance (cov[0,0]), so the function returns covModel of shape (N,), representing an array of [C_{00}] if self.ptcFitType == EXPAPPROXIMATION.
- mu
- fromDetector(detector)#
Read metadata parameters from a detector.
Parameters#
- detector
lsst.afw.cameraGeom.detector Input detector with parameters to use.
Returns#
- calib
lsst.ip.isr.PhotonTransferCurveDataset The calibration constructed from the detector.
- detector
- classmethod fromDict(dictionary)#
Construct a calibration from a dictionary of properties. Must be implemented by the specific calibration subclasses.
Parameters#
- dictionary
dict Dictionary of properties.
Returns#
- calib
lsst.ip.isr.PhotonTransferCurveDataset Constructed calibration.
Raises#
- RuntimeError
Raised if the supplied dictionary is for a different calibration.
- dictionary
- classmethod fromTable(tableList)#
Construct calibration from a list of tables. This method uses the
fromDictmethod 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 datasetPtc.
Returns#
- calib
lsst.ip.isr.PhotonTransferCurveDataset The calibration defined in the tables.
- tableList
- getExpIdsUsed(ampName)#
Get the exposures used, i.e. not discarded, for a given amp. If no mask has been created yet, all exposures are returned.
Parameters#
ampName :
strReturns#
- expIdsUsed
list[tuple] List of pairs of exposure ids used in PTC.
- expIdsUsed
- getGoodAmps()#
Get the good amps from this PTC.
- getGoodPoints(ampName)#
Get the good points used for a given amp in the PTC.
Parameters#
- ampName
str Amplifier’s name.
Returns#
- goodPoints
np.ndarray Boolean array of good points used in PTC.
- ampName
- setAmpValuesPartialDataset(ampName, inputExpIdPair=(-1, -1), inputExpPairMjdStart=nan, rawExpTime=nan, rawMean=nan, rawVar=nan, rawDelta=nan, rowMeanVariance=nan, photoCharge=nan, photoChargeDelta=nan, ampOffset=nan, expIdMask=False, expIdRolloffMask=False, nPixelCovariance=-1, covariance=None, covSqrtWeights=None, gain=nan, noise=nan, overscanMedianLevel=nan, histVar=nan, histChi2Dof=nan, kspValue=0.0)#
Set the amp values for a partial PTC Dataset (from cpExtractPtcTask).
Parameters#
- ampName
str Name of the amp to set the values.
- inputExpIdPair
tuple[int] Exposure IDs of input pair.
- inputExpPairMjdStart
float, optional The start MJD of first exposure in the flat pair.
- rawExpTime
float, optional Exposure time for this exposure pair (units: sec).
- rawMean
float, optional Average of the means of the exposures in this pair (units: adu).
- rawVar
float, optional Variance of the difference of the exposures in this pair (units: adu^2).
- rawDelta
float, optional Delta of the means of the exposure in this pair (units: adu).
- rowMeanVariance
float, optional Variance of the means of the rows in the difference image of the exposures in this pair (units: adu^2).
- photoCharge
float, optional Integrated photocharge for flat pair for linearity calibration (arbitrary units).
- photoChargeDelta
float, optional Delta between integrated photocharge for the flat pair (arbitrary units).
- ampOffset
float, optional Amp offset for this amplifier.
- expIdMask
bool, optional Flag setting if this exposure pair should be used (True) or not used (False).
- expIdRolloffMask
bool, optional Flag setting if this exposure pair should be used (True) or not used for rolloff search (False).
- nPixelCovariance
int, optional Number of pixels that went into the covariance measurement.
- covariance
np.ndarrayor None, optional Measured covariance for this exposure pair (units: adu^2).
- covSqrtWeights
np.ndarrayor None, optional Measured sqrt of covariance weights in this exposure pair (units: 1/adu).
- gain
float, optional Estimated gain for this exposure pair (units: electron/adu).
- noise
float, optional Estimated read noise for this exposure pair (units: electron).
- overscanMedianLevel
float, optional Average of the median overscan levels for this exposure pair. (units: adu)
- histVar
float, optional Variance estimated from fitting a histogram with a Gaussian model (units: adu).
- histChi2Dof
float, optional Chi-squared per degree of freedom from Gaussian histogram fit.
- kspValue
float, optional KS test p-value from the Gaussian histogram fit.
- ampName
- setAuxValuesPartialDataset(auxDict)#
Set a dictionary of auxiliary values for a partial dataset.
Parameters#
- auxDict
dict[str,float] Dictionary of float values.
- auxDict
- sort(sortIndex)#
Sort the components of the PTC by a given sort index.
The PTC is sorted in-place.
Parameters#
- sortIndex
listornp.ndarray The sorting index, which must be the same length as the number of elements of the PTC.
- sortIndex
- toDict()#
Return a dictionary containing the calibration properties. The dictionary should be able to be round-tripped through
fromDict.Returns#
- dictionary
dict Dictionary of properties.
- dictionary
- toTable()#
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.
- tableList
- updateMetadata(**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.
- setDate
- ampNames