PhotonTransferCurveDataset¶
-
class
lsst.ip.isr.
PhotonTransferCurveDataset
(ampNames=[], ptcFitType=None, covMatrixSide=1, **kwargs)¶ Bases:
lsst.ip.isr.IsrCalib
A 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. PTC fit parameters for polynomials are stored in a list in ascending order of polynomial term, i.e. par[0]*x^0 + par[1]*x + par[2]*x^2 etc with the length of the list corresponding to the order of the polynomial plus one.
Parameters: - ampNames :
list
List with the names of the amplifiers of the detector at hand.
- ptcFitType :
str
Type of model fitted to the PTC: “POLYNOMIAL”, “EXPAPPROXIMATION”, or “FULLCOVARIANCE”.
- covMatrixSide :
int
Maximum lag of covariances (size of square covariance matrices).
- kwargs :
dict
, optional Other keyword arguments to pass to the parent init.
Notes
The stored attributes are:
- badAmps :
list
- List with bad amplifiers names.
- inputExpIdPairs :
dict
, [str
,list
] - Dictionary keyed by amp names containing the input exposures IDs.
- expIdMask :
dict
, [str
,list
] - 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.
- rawExpTimes :
dict
, [str
,list
] - Dictionary keyed by amp names containing the unmasked exposure times.
- rawMeans :
dict
, [str
,list
] - Dictionary keyed by amp namescontaining the unmasked average of the means of the exposures in each flat pair.
- rawVars :
dict
, [str
,list
] - Dictionary keyed by amp names containing the variance of the difference image of the exposures in each flat pair.
- gain :
dict
, [str
,list
] - Dictionary keyed by amp names containing the fitted gains.
- gainErr :
dict
, [str
,list
] - Dictionary keyed by amp names containing the errors on the fitted gains.
- noise :
dict
, [str
,list
] - Dictionary keyed by amp names containing the fitted noise.
- noiseErr :
dict
, [str
,list
] - Dictionary keyed by amp names containing the errors on the fitted noise.
- ptcFitPars :
dict
, [str
,list
] - Dictionary keyed by amp names containing the fitted parameters of the PTC model for ptcFitTye in [“POLYNOMIAL”, “EXPAPPROXIMATION”].
- ptcFitParsError :
dict
, [str
,list
] - Dictionary keyed by amp names containing the errors on the fitted parameters of the PTC model for ptcFitTye in [“POLYNOMIAL”, “EXPAPPROXIMATION”].
- ptcFitChiSq :
dict
, [str
,list
] - Dictionary keyed by amp names containing the reduced chi squared of the fit for ptcFitTye in [“POLYNOMIAL”, “EXPAPPROXIMATION”].
- ptcTurnoff :
float
- Flux value (in ADU) where the variance of the PTC curve starts decreasing consistently.
- covariances :
dict
, [str
,list
] - Dictionary keyed by amp names containing a list of measured covariances per mean flux.
- covariancesModel :
dict
, [str
,list
] - Dictionary keyed by amp names containinging covariances model (Eq. 20 of Astier+19) per mean flux.
- covariancesSqrtWeights :
dict
, [str
,list
] - Dictionary keyed by amp names containinging sqrt. of covariances weights.
- aMatrix :
dict
, [str
,list
] - Dictionary keyed by amp names containing the “a” parameters from the model in Eq. 20 of Astier+19.
- bMatrix :
dict
, [str
,list
] - Dictionary keyed by amp names containing the “b” parameters from the model in Eq. 20 of Astier+19.
- covariancesModelNoB :
dict
, [str
,list
] - Dictionary keyed by amp names containing covariances model (with ‘b’=0 in Eq. 20 of Astier+19) per mean flux.
- aMatrixNoB :
dict
, [str
,list
] - Dictionary keyed by amp names containing the “a” parameters from the model in Eq. 20 of Astier+19 (and ‘b’ = 0).
- finalVars :
dict
, [str
,list
] - 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
,list
] - 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
,list
] - 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.
- photoCharge :
dict
, [str
,list
] - Dictionary keyed by amp names containing the integrated photocharge for linearity calibration.
Version 1.1 adds the
ptcTurnoff
attribute.Attributes Summary
requiredAttributes
Methods Summary
apply
(target)Method to apply the calibration to the target object. calibInfoFromDict
(dictionary)Handle common keywords. determineCalibClass
(metadata, message)Attempt to find calibration class in metadata. 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. getGoodAmps
()getMetadata
()Retrieve metadata associated with this calibration. readFits
(filename, **kwargs)Read calibration data from a FITS file. readText
(filename, **kwargs)Read calibration representation from a yaml/ecsv file. setAmpValues
(ampName[, inputExpIdPair, …])Function to initialize an amp of a PhotonTransferCurveDataset. setMetadata
(metadata)Store a copy of the supplied metadata with this calibration. 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. validate
([other])Validate that this calibration is defined and can be used. writeFits
(filename)Write calibration data to a FITS file. writeText
(filename[, format])Write the calibration data to a text file. Attributes Documentation
-
requiredAttributes
¶
Methods Documentation
-
apply
(target)¶ Method to apply the calibration to the target object.
Parameters: - target :
object
Thing to validate against.
Returns: - valid :
bool
Returns true if the calibration was applied correctly.
Raises: - NotImplementedError
Raised if not implemented.
- target :
-
calibInfoFromDict
(dictionary)¶ Handle common keywords.
This isn’t an ideal solution, but until all calibrations expect to find everything in the metadata, they still need to search through dictionaries.
Parameters: - dictionary :
dict
orlsst.daf.base.PropertyList
Source for the common keywords.
Raises: - RuntimeError
Raised if the dictionary does not match the expected OBSTYPE.
- dictionary :
-
classmethod
determineCalibClass
(metadata, message)¶ Attempt to find calibration class in metadata.
Parameters: Returns: - calibClass :
object
The class to use to read the file contents. Should be an
lsst.ip.isr.IsrCalib
subclass.
Raises: - ValueError
Raised if the resulting calibClass is the base
lsst.ip.isr.IsrClass
(which does not implement the content methods).
- calibClass :
-
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
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 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.
-
getGoodAmps
()¶
-
getMetadata
()¶ Retrieve metadata associated with this calibration.
Returns: - meta :
lsst.daf.base.PropertyList
Metadata. The returned
PropertyList
can be modified by the caller and the changes will be written to external files.
- meta :
-
classmethod
readFits
(filename, **kwargs)¶ Read calibration data from a FITS file.
Parameters: Returns: - calib :
lsst.ip.isr.IsrCalib
Calibration contained within the file.
- calib :
-
classmethod
readText
(filename, **kwargs)¶ Read calibration representation from a yaml/ecsv file.
Parameters: Returns: - calib :
IsrCalibType
Calibration class.
Raises: - RuntimeError
Raised if the filename does not end in “.ecsv” or “.yaml”.
- calib :
-
setAmpValues
(ampName, inputExpIdPair=[(nan, nan)], expIdMask=[nan], rawExpTime=[nan], rawMean=[nan], rawVar=[nan], photoCharge=[nan], gain=nan, gainErr=nan, noise=nan, noiseErr=nan, ptcFitPars=[nan], ptcFitParsError=[nan], ptcFitChiSq=nan, ptcTurnoff=nan, covArray=[], covArrayModel=[], covSqrtWeights=[], aMatrix=[], bMatrix=[], covArrayModelNoB=[], aMatrixNoB=[], finalVar=[nan], finalModelVar=[nan], finalMean=[nan])¶ Function to initialize an amp of a PhotonTransferCurveDataset.
Notes
The parameters are all documented in
init
.
-
setMetadata
(metadata)¶ Store a copy of the supplied metadata with this calibration.
Parameters: - metadata :
lsst.daf.base.PropertyList
Metadata to associate with the calibration. Will be copied and overwrite existing metadata.
- metadata :
-
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 :
-
validate
(other=None)¶ Validate that this calibration is defined and can be used.
Parameters: - other :
object
, optional Thing to validate against.
Returns: - valid :
bool
Returns true if the calibration is valid and appropriate.
- other :
-
writeFits
(filename)¶ Write calibration data to a FITS file.
Parameters: - filename :
str
Filename to write data to.
Returns: - used :
str
The name of the file used to write the data.
- filename :
-
writeText
(filename, format='auto')¶ Write the calibration data to a text file.
Parameters: Returns: - used :
str
The name of the file used to write the data. This may differ from the input if the format is explicitly chosen.
Raises: - RuntimeError
Raised if filename does not end in a known extension, or if all information cannot be written.
Notes
The file is written to YAML/ECSV format and will include any associated metadata.
- used :
- ampNames :