lsst.cp.pipe  19.0.0-19-g32a200e+8
Public Member Functions | Static Public Attributes | List of all members
lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask Class Reference
Inheritance diagram for lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask:

Public Member Functions

def __init__ (self, *args, **kwargs)
 
def runDataRef (self, dataRef, visitPairs)
 
def buildLinearizerObject (self, dataset, detector, calibDate, linearizerType, instruName='', tableArray=None, log=None)
 
def measureMeanVarPair (self, exposure1, exposure2, region=None)
 
def funcPolynomial (self, pars, x)
 
def funcAstier (self, pars, x)
 
def calculateLinearityResidualAndLinearizers (self, exposureTimeVector, meanSignalVector)
 
def fitPtcAndNonLinearity (self, dataset, ptcFitType, tableArray=None)
 
def plot (self, dataRef, dataset, ptcFitType)
 

Static Public Attributes

 RunnerClass = PairedVisitListTaskRunner
 
 ConfigClass = MeasurePhotonTransferCurveTaskConfig
 

Detailed Description

A class to calculate, fit, and plot a PTC from a set of flat pairs.

The Photon Transfer Curve (var(signal) vs mean(signal)) is a standard tool
used in astronomical detectors characterization (e.g., Janesick 2001,
Janesick 2007). This task calculates the PTC from a series of pairs of
flat-field images; each pair taken at identical exposure times. The
difference image of each pair is formed to eliminate fixed pattern noise,
and then the variance of the difference image and the mean of the average image
are used to produce the PTC. An n-degree polynomial or the approximation in Equation
16 of Astier+19 ("The Shape of the Photon Transfer Curve of CCD sensors",
arXiv:1905.08677) can be fitted to the PTC curve. These models include
parameters such as the gain (e/DN) and readout noise.

Linearizers to correct for signal-chain non-linearity are also calculated.
The `Linearizer` class, in general, can support per-amp linearizers, but in this
task this is not supported.
Parameters
----------

*args: `list`
    Positional arguments passed to the Task constructor. None used at this
    time.
**kwargs: `dict`
    Keyword arguments passed on to the Task constructor. None used at this
    time.

Definition at line 285 of file ptc.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.__init__ (   self,
args,
**  kwargs 
)

Definition at line 318 of file ptc.py.

Member Function Documentation

◆ buildLinearizerObject()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.buildLinearizerObject (   self,
  dataset,
  detector,
  calibDate,
  linearizerType,
  instruName = '',
  tableArray = None,
  log = None 
)
Build linearizer object to persist.

Parameters
----------
dataset : `lsst.cp.pipe.ptc.PhotonTransferCurveDataset`
    The dataset containing the means, variances, and exposure times
detector : `lsst.afw.cameraGeom.Detector`
    Detector object
calibDate : `datetime.datetime`
    Calibration date
linearizerType : `str`
    'LOOKUPTABLE', 'LINEARIZESQUARED', or 'LINEARIZEPOLYNOMIAL'
instruName : `str`, optional
    Instrument name
tableArray : `np.array`, optional
    Look-up table array with size rows=nAmps and columns=DN values
log : `lsst.log.Log`, optional
    Logger to handle messages

Returns
-------
linearizer : `lsst.ip.isr.Linearizer`
    Linearizer object

Definition at line 444 of file ptc.py.

◆ calculateLinearityResidualAndLinearizers()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.calculateLinearityResidualAndLinearizers (   self,
  exposureTimeVector,
  meanSignalVector 
)
Calculate linearity residual and fit an n-order polynomial to the mean vs time curve
to produce corrections (deviation from linear part of polynomial) for a particular amplifier
to populate LinearizeLookupTable.
Use the coefficients of this fit to calculate the correction coefficients for  LinearizePolynomial
and LinearizeSquared."

Parameters
---------

exposureTimeVector: `list` of `float`
    List of exposure times for each flat pair

meanSignalVector: `list` of `float`
    List of mean signal from diference image of flat pairs

Returns
-------
dataset : `lsst.cp.pipe.ptc.LinearityResidualsAndLinearizersDataset`
    The dataset containing the fit parameters, the NL correction coefficients, and the
    LUT row for the amplifier at hand. Explicitly:

dataset.polynomialLinearizerCoefficients : `list` of `float`
    Coefficients for LinearizePolynomial, where corrImage = uncorrImage + sum_i c_i uncorrImage^(2 +
    i).
    c_(j-2) = -k_j/(k_1^j) with units (DN^(1-j)). The units of k_j are DN/t^j, and they are fit from
    meanSignalVector = k0 + k1*exposureTimeVector + k2*exposureTimeVector^2 +...
             + kn*exposureTimeVector^n, with n = "polynomialFitDegreeNonLinearity".
    k_0 and k_1 and degenerate with bias level and gain, and are not used by the non-linearity
    correction. Therefore, j = 2...n in the above expression (see `LinearizePolynomial` class in
    `linearize.py`.)

dataset.quadraticPolynomialLinearizerCoefficient : `float`
    Coefficient for LinearizeSquared, where corrImage = uncorrImage + c0*uncorrImage^2.
    c0 = -k2/(k1^2), where k1 and k2 are fit from
    meanSignalVector = k0 + k1*exposureTimeVector + k2*exposureTimeVector^2 +...
               + kn*exposureTimeVector^n, with n = "polynomialFitDegreeNonLinearity".

dataset.linearizerTableRow : `list` of `float`
   One dimensional array with deviation from linear part of n-order polynomial fit
   to mean vs time curve. This array will be one row (for the particular amplifier at hand)
   of the table array for LinearizeLookupTable.

dataset.linearityResidual : `list` of `float`
    Linearity residual from the mean vs time curve, defined as
    100*(1 - meanSignalReference/expTimeReference/(meanSignal/expTime).

dataset.meanSignalVsTimePolyFitPars  : `list` of `float`
    Parameters from n-order polynomial fit to meanSignalVector vs exposureTimeVector.

dataset.meanSignalVsTimePolyFitParsErr : `list` of `float`
    Parameters from n-order polynomial fit to meanSignalVector vs exposureTimeVector.

dataset.fractionalNonLinearityResidual : `list` of `float`
    Fractional residuals from the meanSignal vs exposureTime curve with respect to linear part of
    polynomial fit: 100*(linearPart - meanSignal)/linearPart, where
    linearPart = k0 + k1*exposureTimeVector.

dataset.meanSignalVsTimePolyFitReducedChiSq  : `float`
    Reduced unweighted chi squared from polynomial fit to meanSignalVector vs exposureTimeVector.

Definition at line 761 of file ptc.py.

◆ fitPtcAndNonLinearity()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.fitPtcAndNonLinearity (   self,
  dataset,
  ptcFitType,
  tableArray = None 
)
Fit the photon transfer curve and calculate linearity and residuals.

Fit the photon transfer curve with either a polynomial of the order
specified in the task config, or using the Astier approximation.

Sigma clipping is performed iteratively for the fit, as well as an
initial clipping of data points that are more than
config.initialNonLinearityExclusionThreshold away from lying on a
straight line. This other step is necessary because the photon transfer
curve turns over catastrophically at very high flux (because saturation
drops the variance to ~0) and these far outliers cause the initial fit
to fail, meaning the sigma cannot be calculated to perform the
sigma-clipping.

Parameters
----------
dataset : `lsst.cp.pipe.ptc.PhotonTransferCurveDataset`
    The dataset containing the means, variances and exposure times
ptcFitType : `str`
    Fit a 'POLYNOMIAL' (degree: 'polynomialFitDegree') or
    'ASTIERAPPROXIMATION' to the PTC
tableArray : `np.array`
    Optional. Look-up table array with size rows=nAmps and columns=DN values.
    It will be modified in-place if supplied.

Returns
-------
dataset: `lsst.cp.pipe.ptc.PhotonTransferCurveDataset`
    This is the same dataset as the input paramter, however, it has been modified
    to include information such as the fit vectors and the fit parameters. See
    the class `PhotonTransferCurveDatase`.

Definition at line 882 of file ptc.py.

◆ funcAstier()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.funcAstier (   self,
  pars,
  x 
)
Single brighter-fatter parameter model for PTC; Equation 16 of Astier+19

Definition at line 694 of file ptc.py.

◆ funcPolynomial()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.funcPolynomial (   self,
  pars,
  x 
)
Polynomial function definition

Definition at line 690 of file ptc.py.

◆ measureMeanVarPair()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.measureMeanVarPair (   self,
  exposure1,
  exposure2,
  region = None 
)
Calculate the mean signal of two exposures and the variance of their difference.

Parameters
----------
exposure1 : `lsst.afw.image.exposure.exposure.ExposureF`
    First exposure of flat field pair.

exposure2 : `lsst.afw.image.exposure.exposure.ExposureF`
    Second exposure of flat field pair.

region : `lsst.geom.Box2I`
    Region of each exposure where to perform the calculations (e.g, an amplifier).

Return
------

mu : `float`
    0.5*(mu1 + mu2), where mu1, and mu2 are the clipped means of the regions in
    both exposures.

varDiff : `float`
    Half of the clipped variance of the difference of the regions inthe two input
    exposures.

Definition at line 511 of file ptc.py.

◆ plot()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.plot (   self,
  dataRef,
  dataset,
  ptcFitType 
)

Definition at line 1056 of file ptc.py.

◆ runDataRef()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.runDataRef (   self,
  dataRef,
  visitPairs 
)
Run the Photon Transfer Curve (PTC) measurement task.

For a dataRef (which is each detector here),
and given a list of visit pairs at different exposure times,
measure the PTC.

Parameters
----------
dataRef : list of lsst.daf.persistence.ButlerDataRef
    dataRef for the detector for the visits to be fit.
visitPairs : `iterable` of `tuple` of `int`
    Pairs of visit numbers to be processed together

Definition at line 339 of file ptc.py.

Member Data Documentation

◆ ConfigClass

lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.ConfigClass = MeasurePhotonTransferCurveTaskConfig
static

Definition at line 315 of file ptc.py.

◆ RunnerClass

lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.RunnerClass = PairedVisitListTaskRunner
static

Definition at line 314 of file ptc.py.


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