PlotPhotonTransferCurveTask

class lsst.cp.pipe.PlotPhotonTransferCurveTask(*, config: Optional[PipelineTaskConfig] = None, log: Optional[Union[logging.Logger, LsstLogAdapter]] = None, initInputs: Optional[Dict[str, Any]] = None, **kwargs)

Bases: lsst.pipe.base.PipelineTask

A class to plot the dataset from MeasurePhotonTransferCurveTask.

Parameters:
outDir : str, optional

Path to the output directory where the final PDF will be placed.

signalElectronsRelativeA : float, optional

Signal value for relative systematic bias between different methods of estimating a_ij (Fig. 15 of Astier+19).

plotNormalizedCovariancesNumberOfBins : float, optional

Number of bins in plotNormalizedCovariancesNumber function (Fig. 8, 10., of Astier+19).

Attributes Summary

canMultiprocess

Methods Summary

ab_vs_dist(aDict, bDict[, bRange]) Fig.
binData(x, y, binIndex[, wy]) Bin data (usually for display purposes).
covAstierMakeAllPlots(dataset) Make plots for MeasurePhotonTransferCurve task when doCovariancesAstier=True.
emptyMetadata() Empty (clear) the metadata for this Task and all sub-Tasks.
getFullMetadata() Get metadata for all tasks.
getFullName() Get the task name as a hierarchical name including parent task names.
getName() Get the name of the task.
getResourceConfig() Return resource configuration for this task.
getTaskDict() Get a dictionary of all tasks as a shallow copy.
indexForBins(x, nBins) Builds an index with regular binning.
makeField(doc) Make a lsst.pex.config.ConfigurableField for this task.
makeSubtask(name, **keyArgs) Create a subtask as a new instance as the name attribute of this task.
plotAcoeffsSum(aDict, bDict) Fig.
plotCovariances(mu, covs, covsModel, …) Plot covariances and models: Cov00, Cov10, Cov01.
plotNormalizedCovariances(i, j, inputMu, …) Plot C_ij/mu vs mu.
plotRelativeBiasACoeffs(aDict, aDictNoB, …) Fig.
plot_a_b(aDict, bDict[, bRange]) Fig.
run(inputPtcDataset[, dummyExposure, camera]) Make the plots for the PTC task.
runQuantum(butlerQC, inputRefs, outputRefs) Method to do butler IO and or transforms to provide in memory objects for tasks run method
timer(name, logLevel) Context manager to log performance data for an arbitrary block of code.

Attributes Documentation

canMultiprocess = True

Methods Documentation

static ab_vs_dist(aDict, bDict, bRange=4)

Fig. 13 of Astier+19.

Values of a and b arrays fits, averaged over amplifiers, as a function of distance.

Parameters:
aDict : dict [numpy.array]

Dictionary keyed by amp names containing the fitted ‘a’ coefficients from the model in Eq. 20 of Astier+19 (if ptcFitType is FULLCOVARIANCE).

bDict : dict [numpy.array]

Dictionary keyed by amp names containing the fitted ‘b’ coefficients from the model in Eq. 20 of Astier+19 (if ptcFitType is FULLCOVARIANCE).

bRange : int

Maximum lag for b arrays.

static binData(x, y, binIndex, wy=None)

Bin data (usually for display purposes).

Parameters:
x : numpy.array

Data to bin.

y : numpy.array

Data to bin.

binIdex : list

Bin number of each datum.

wy : numpy.array

Inverse rms of each datum to use when averaging (the actual weight is wy**2).

Returns:
xbin : numpy.array

Binned data in x.

ybin : numpy.array

Binned data in y.

wybin : numpy.array

Binned weights in y, computed from wy’s in each bin.

sybin : numpy.array

Uncertainty on the bin average, considering actual scatter, and ignoring weights.

covAstierMakeAllPlots(dataset)

Make plots for MeasurePhotonTransferCurve task when doCovariancesAstier=True.

This function call other functions that mostly reproduce the plots in Astier+19. Most of the code is ported from Pierre Astier’s repository https://github.com/PierreAstier/bfptc

Parameters:
dataset : lsst.ip.isr.PhotonTransferCurveDataset

The dataset containing the necessary information to produce the plots.

emptyMetadata() → None

Empty (clear) the metadata for this Task and all sub-Tasks.

getFullMetadata() → lsst.pipe.base._task_metadata.TaskMetadata

Get metadata for all tasks.

Returns:
metadata : TaskMetadata

The keys are the full task name. Values are metadata for the top-level task and all subtasks, sub-subtasks, etc.

Notes

The returned metadata includes timing information (if @timer.timeMethod is used) and any metadata set by the task. The name of each item consists of the full task name with . replaced by :, followed by . and the name of the item, e.g.:

topLevelTaskName:subtaskName:subsubtaskName.itemName

using : in the full task name disambiguates the rare situation that a task has a subtask and a metadata item with the same name.

getFullName() → str

Get the task name as a hierarchical name including parent task names.

Returns:
fullName : str

The full name consists of the name of the parent task and each subtask separated by periods. For example:

  • The full name of top-level task “top” is simply “top”.
  • The full name of subtask “sub” of top-level task “top” is “top.sub”.
  • The full name of subtask “sub2” of subtask “sub” of top-level task “top” is “top.sub.sub2”.
getName() → str

Get the name of the task.

Returns:
taskName : str

Name of the task.

See also

getFullName
getResourceConfig() → Optional[ResourceConfig]

Return resource configuration for this task.

Returns:
Object of type ResourceConfig or None if resource
configuration is not defined for this task.
getTaskDict() → Dict[str, weakref.ReferenceType[lsst.pipe.base.task.Task]]

Get a dictionary of all tasks as a shallow copy.

Returns:
taskDict : dict

Dictionary containing full task name: task object for the top-level task and all subtasks, sub-subtasks, etc.

static indexForBins(x, nBins)

Builds an index with regular binning. The result can be fed into binData.

Parameters:
x : numpy.array

Data to bin.

nBins : int

Number of bin.

Returns:
np.digitize(x, bins): numpy.array

Bin indices.

classmethod makeField(doc: str) → lsst.pex.config.configurableField.ConfigurableField

Make a lsst.pex.config.ConfigurableField for this task.

Parameters:
doc : str

Help text for the field.

Returns:
configurableField : lsst.pex.config.ConfigurableField

A ConfigurableField for this task.

Examples

Provides a convenient way to specify this task is a subtask of another task.

Here is an example of use:

class OtherTaskConfig(lsst.pex.config.Config):
    aSubtask = ATaskClass.makeField("brief description of task")
makeSubtask(name: str, **keyArgs) → None

Create a subtask as a new instance as the name attribute of this task.

Parameters:
name : str

Brief name of the subtask.

keyArgs

Extra keyword arguments used to construct the task. The following arguments are automatically provided and cannot be overridden:

  • “config”.
  • “parentTask”.

Notes

The subtask must be defined by Task.config.name, an instance of ConfigurableField or RegistryField.

static plotAcoeffsSum(aDict, bDict)

Fig. 14. of Astier+19

Cumulative sum of a_ij as a function of maximum separation. This plot displays the average over channels.

Parameters:
aDict : dict [numpy.array]

Dictionary keyed by amp names containing the fitted ‘a’ coefficients from the model in Eq. 20 of Astier+19 (if ptcFitType is FULLCOVARIANCE).

bDict : dict [numpy.array]

Dictionary keyed by amp names containing the fitted ‘b’ coefficients from the model in Eq. 20 of Astier+19 (if ptcFitType is FULLCOVARIANCE).

static plotCovariances(mu, covs, covsModel, covsWeights, covsNoB, covsModelNoB, covsWeightsNoB, gainDict, noiseDict, aDict, bDict)

Plot covariances and models: Cov00, Cov10, Cov01.

Figs. 6 and 7 of Astier+19

Parameters:
mu : dict [str, list]

Dictionary keyed by amp name with mean signal values.

covs : dict [str, list]

Dictionary keyed by amp names containing a list of measued covariances per mean flux.

covsModel : dict [str, list]

Dictionary keyed by amp names containinging covariances model (Eq. 20 of Astier+19) per mean flux.

covsWeights : dict [str, list]

Dictionary keyed by amp names containinging sqrt. of covariances weights.

covsNoB : dict [str, list]

Dictionary keyed by amp names containing a list of measued covariances per mean flux (‘b’=0 in Astier+19).

covsModelNoB : dict [str, list]

Dictionary keyed by amp names containing covariances model (with ‘b’=0 in Eq. 20 of Astier+19) per mean flux.

covsWeightsNoB : dict [str, list]

Dictionary keyed by amp names containing sqrt. of covariances weights (‘b’ = 0 in Eq. 20 of Astier+19).

gainDict : dict [str, float]

Dictionary keyed by amp names containing the gains in e-/ADU.

noiseDict : dict [str, float]

Dictionary keyed by amp names containing the rms redout noise in e-.

aDict : dict [str, numpy.array]

Dictionary keyed by amp names containing ‘a’ coefficients (Eq. 20 of Astier+19).

bDict : dict [str, numpy.array]

Dictionary keyed by amp names containing ‘b’ coefficients (Eq. 20 of Astier+19).

plotNormalizedCovariances(i, j, inputMu, covs, covsModel, covsWeights, covsNoB, covsModelNoB, covsWeightsNoB, offset=0.004, numberOfBins=10, plotData=True, topPlot=False)

Plot C_ij/mu vs mu.

Figs. 8, 10, and 11 of Astier+19

Parameters:
i : int

Covariance lag.

j : int

Covariance lag.

inputMu : dict [str, list]

Dictionary keyed by amp name with mean signal values.

covs : dict [str, list]

Dictionary keyed by amp names containing a list of measued covariances per mean flux.

covsModel : dict [str, list]

Dictionary keyed by amp names containinging covariances model (Eq. 20 of Astier+19) per mean flux.

covsWeights : dict [str, list]

Dictionary keyed by amp names containinging sqrt. of covariances weights.

covsNoB : dict [str, list]

Dictionary keyed by amp names containing a list of measued covariances per mean flux (‘b’=0 in Astier+19).

covsModelNoB : dict [str, list]

Dictionary keyed by amp names containing covariances model (with ‘b’=0 in Eq. 20 of Astier+19) per mean flux.

covsWeightsNoB : dict [str, list]

Dictionary keyed by amp names containing sqrt. of covariances weights (‘b’ = 0 in Eq. 20 of Astier+19).

expIdMask : dict [str, list]

Dictionary keyed by amp names containing the masked exposure pairs.

offset : float, optional

Constant offset factor to plot covariances in same panel (so they don’t overlap).

numberOfBins : int, optional

Number of bins for top and bottom plot.

plotData : bool, optional

Plot the data points?

topPlot : bool, optional

Plot the top plot with the covariances, and the bottom plot with the model residuals?

static plotRelativeBiasACoeffs(aDict, aDictNoB, fullCovsModel, fullCovsModelNoB, signalElectrons, gainDict, maxr=None)

Fig. 15 in Astier+19.

Illustrates systematic bias from estimating ‘a’ coefficients from the slope of correlations as opposed to the full model in Astier+19.

Parameters:
aDict : dict

Dictionary of ‘a’ matrices (Eq. 20, Astier+19), with amp names as keys.

aDictNoB : dict

Dictionary of ‘a’ matrices (‘b’= 0 in Eq. 20, Astier+19), with amp names as keys.

fullCovsModel : dict [str, list]

Dictionary keyed by amp names containing covariances model per mean flux.

fullCovsModelNoB : dict [str, list]

Dictionary keyed by amp names containing covariances model (with ‘b’=0 in Eq. 20 of Astier+19) per mean flux.

signalElectrons : float

Signal at which to evaluate the a_ij coefficients.

gainDict : dict [str, float]

Dicgionary keyed by amp names with the gains in e-/ADU.

maxr : int, optional

Maximum lag.

static plot_a_b(aDict, bDict, bRange=3)

Fig. 12 of Astier+19

Color display of a and b arrays fits, averaged over channels.

Parameters:
aDict : dict [numpy.array]

Dictionary keyed by amp names containing the fitted ‘a’ coefficients from the model in Eq. 20 of Astier+19 (if ptcFitType is FULLCOVARIANCE).

bDict : dict [numpy.array]

Dictionary keyed by amp names containing the fitted ‘b’ coefficients from the model in Eq. 20 of Astier+19 (if ptcFitType is FULLCOVARIANCE).

bRange : int

Maximum lag for b arrays.

run(inputPtcDataset, dummyExposure=None, camera=None)

Make the plots for the PTC task.

Parameters:
inputPtcDataset : lsst.ip.isr.PhotonTransferCurveDataset

Output dataset from Photon Transfer Curve task.

dummyExposure : lsst.afw.image.Exposure

The exposure used to select the appropriate PTC dataset.

camera : lsst.afw.cameraGeom.Camera

Camera to use for camera geometry information.

runQuantum(butlerQC, inputRefs, outputRefs)

Method to do butler IO and or transforms to provide in memory objects for tasks run method

Parameters:
butlerQC : ButlerQuantumContext

A butler which is specialized to operate in the context of a lsst.daf.butler.Quantum.

inputRefs : InputQuantizedConnection

Datastructure whose attribute names are the names that identify connections defined in corresponding PipelineTaskConnections class. The values of these attributes are the lsst.daf.butler.DatasetRef objects associated with the defined input/prerequisite connections.

outputRefs : OutputQuantizedConnection

Datastructure whose attribute names are the names that identify connections defined in corresponding PipelineTaskConnections class. The values of these attributes are the lsst.daf.butler.DatasetRef objects associated with the defined output connections.

timer(name: str, logLevel: int = 10) → Iterator[None]

Context manager to log performance data for an arbitrary block of code.

Parameters:
name : str

Name of code being timed; data will be logged using item name: Start and End.

logLevel

A logging level constant.

See also

timer.logInfo

Examples

Creating a timer context:

with self.timer("someCodeToTime"):
    pass  # code to time