lsst.cp.pipe  21.0.0-4-g42917e2+78c1d8e8b8
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, dataRefList)
 
def makePairs (self, dataRefList)
 
def fitCovariancesAstier (self, dataset, covariancesWithTagsArray)
 
def getOutputPtcDataCovAstier (self, dataset, covFits, covFitsNoB)
 
def measureMeanVarCov (self, exposure1, exposure2, region=None, covAstierRealSpace=False)
 
def computeCovDirect (self, diffImage, weightImage, maxRange)
 
def covDirectValue (self, diffImage, weightImage, dx, dy)
 
def fitPtc (self, dataset, ptcFitType)
 
def fillBadAmp (self, dataset, ptcFitType, ampName)
 

Static Public Attributes

 RunnerClass = DataRefListRunner
 
 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). If ptcFitType is "EXPAPPROXIMATION" or "POLYNOMIAL",  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.

If ptcFitType is "FULLCOVARIANCE", the covariances of the difference images are calculated via the
DFT methods described in Astier+19 and the variances for the PTC are given by the cov[0,0] elements
at each signal level. The full model in Equation 20 of Astier+19 is fit to the PTC to get the gain
and the noise.

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 198 of file ptc.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 237 of file ptc.py.

Member Function Documentation

◆ computeCovDirect()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.computeCovDirect (   self,
  diffImage,
  weightImage,
  maxRange 
)
Compute covariances of diffImage in real space.

For lags larger than ~25, it is slower than the FFT way.
Taken from https://github.com/PierreAstier/bfptc/

Parameters
----------
diffImage : `numpy.array`
    Image to compute the covariance of.

weightImage : `numpy.array`
    Weight image of diffImage (1's and 0's for good and bad pixels, respectively).

maxRange : `int`
    Last index of the covariance to be computed.

Returns
-------
outList : `list`
    List with tuples of the form (dx, dy, var, cov, npix), where:
dx : `int`
    Lag in x
dy : `int`
    Lag in y
var : `float`
    Variance at (dx, dy).
cov : `float`
    Covariance at (dx, dy).
nPix : `int`
    Number of pixel pairs used to evaluate var and cov.

Definition at line 720 of file ptc.py.

◆ covDirectValue()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.covDirectValue (   self,
  diffImage,
  weightImage,
  dx,
  dy 
)
Compute covariances of diffImage in real space at lag (dx, dy).

Taken from https://github.com/PierreAstier/bfptc/ (c.f., appendix of Astier+19).

Parameters
----------
diffImage : `numpy.array`
    Image to compute the covariance of.

weightImage : `numpy.array`
    Weight image of diffImage (1's and 0's for good and bad pixels, respectively).

dx : `int`
    Lag in x.

dy : `int`
    Lag in y.

Returns
-------
cov : `float`
    Covariance at (dx, dy)

nPix : `int`
    Number of pixel pairs used to evaluate var and cov.

Definition at line 770 of file ptc.py.

◆ fillBadAmp()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.fillBadAmp (   self,
  dataset,
  ptcFitType,
  ampName 
)
Fill the dataset with NaNs if there are not enough good points.

Parameters
----------
dataset : `lsst.ip.isr.ptcDataset.PhotonTransferCurveDataset`
    The dataset containing the means, variances and exposure times.

ptcFitType : `str`
    Fit a 'POLYNOMIAL' (degree: 'polynomialFitDegree') or
    'EXPAPPROXIMATION' (Eq. 16 of Astier+19) to the PTC.

ampName : `str`
    Amplifier name.

Definition at line 1126 of file ptc.py.

◆ fitCovariancesAstier()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.fitCovariancesAstier (   self,
  dataset,
  covariancesWithTagsArray 
)
Fit measured flat covariances to full model in Astier+19.

Parameters
----------
dataset : `lsst.ip.isr.ptcDataset.PhotonTransferCurveDataset`
    The dataset containing information such as the means, variances and exposure times.

covariancesWithTagsArray : `numpy.recarray`
    Tuple with at least (mu, cov, var, i, j, npix), where:
    mu : 0.5*(m1 + m2), where:
mu1: mean value of flat1
mu2: mean value of flat2
    cov: covariance value at lag(i, j)
    var: variance(covariance value at lag(0, 0))
    i: lag dimension
    j: lag dimension
    npix: number of pixels used for covariance calculation.

Returns
-------
dataset: `lsst.ip.isr.ptcDataset.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 476 of file ptc.py.

◆ fitPtc()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.fitPtc (   self,
  dataset,
  ptcFitType 
)
Fit the photon transfer curve to a polynimial or to Astier+19 approximation.

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.ip.isr.ptcDataset.PhotonTransferCurveDataset`
    The dataset containing the means, variances and exposure times

ptcFitType : `str`
    Fit a 'POLYNOMIAL' (degree: 'polynomialFitDegree') or
    'EXPAPPROXIMATION' (Eq. 16 of Astier+19) to the PTC

Returns
-------
dataset: `lsst.ip.isr.ptcDataset.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 942 of file ptc.py.

◆ getOutputPtcDataCovAstier()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.getOutputPtcDataCovAstier (   self,
  dataset,
  covFits,
  covFitsNoB 
)
Get output data for PhotonTransferCurveCovAstierDataset from CovFit objects.

Parameters
----------
dataset : `lsst.ip.isr.ptcDataset.PhotonTransferCurveDataset`
    The dataset containing information such as the means, variances and exposure times.

covFits: `dict`
    Dictionary of CovFit objects, with amp names as keys.

covFitsNoB : `dict`
     Dictionary of CovFit objects, with amp names as keys, and 'b=0' in Eq. 20 of Astier+19.

Returns
-------
dataset : `lsst.ip.isr.ptcDataset.PhotonTransferCurveDataset`
    This is the same dataset as the input paramter, however, it has been modified
    to include extra information such as the mask 1D array, gains, reoudout noise, measured signal,
    measured variance, modeled variance, a, and b coefficient matrices (see Astier+19) per amplifier.
    See the class `PhotonTransferCurveDatase`.

Definition at line 509 of file ptc.py.

◆ makePairs()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.makePairs (   self,
  dataRefList 
)
Produce a list of flat pairs indexed by exposure time.

Parameters
----------
dataRefList : `list` [`lsst.daf.peristence.ButlerDataRef`]
    Data references for exposures for detectors to process.

Return
------
flatPairs : `dict` [`float`, `lsst.afw.image.exposure.exposure.ExposureF`]
  Dictionary that groups flat-field exposures that have the same exposure time (seconds).

Notes
-----
We use the difference of one pair of flat-field images taken at the same exposure time when
calculating the PTC to reduce Fixed Pattern Noise. If there are > 2 flat-field images with the
same exposure time, the first two are kept and the rest discarded.

Definition at line 420 of file ptc.py.

◆ measureMeanVarCov()

def lsst.cp.pipe.ptc.MeasurePhotonTransferCurveTask.measureMeanVarCov (   self,
  exposure1,
  exposure2,
  region = None,
  covAstierRealSpace = False 
)
Calculate the mean of each of two exposures and the variance and covariance of their difference.

The variance is calculated via afwMath, and the covariance via the methods in Astier+19 (appendix A).
In theory, var = covariance[0,0]. This should be validated, and in the future, we may decide to just
keep one (covariance).

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`, optional
    Region of each exposure where to perform the calculations (e.g, an amplifier).

covAstierRealSpace : `bool`, optional
    Should the covariannces in Astier+19 be calculated in real space or via FFT?
    See Appendix A of Astier+19.

Returns
-------
mu : `float` or `NaN`
    0.5*(mu1 + mu2), where mu1, and mu2 are the clipped means of the regions in
    both exposures. If either mu1 or m2 are NaN's, the returned value is NaN.

varDiff : `float` or `NaN`
    Half of the clipped variance of the difference of the regions inthe two input
    exposures. If either mu1 or m2 are NaN's, the returned value is NaN.

covDiffAstier : `list` or `None`
    List with tuples of the form (dx, dy, var, cov, npix), where:
dx : `int`
    Lag in x
dy : `int`
    Lag in y
var : `float`
    Variance at (dx, dy).
cov : `float`
    Covariance at (dx, dy).
nPix : `int`
    Number of pixel pairs used to evaluate var and cov.
    If either mu1 or m2 are NaN's, the returned value is None.

Definition at line 598 of file ptc.py.

◆ runDataRef()

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

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

Parameters
----------
dataRefList : `list` [`lsst.daf.peristence.ButlerDataRef`]
    Data references for exposures for detectors to process.

Definition at line 245 of file ptc.py.

Member Data Documentation

◆ ConfigClass

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

Definition at line 234 of file ptc.py.

◆ RunnerClass

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

Definition at line 233 of file ptc.py.


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