PhotoCalTask#
- class lsst.pipe.tasks.photoCal.PhotoCalTask(refObjLoader=None, schema=None, **kwds)#
Bases:
TaskCalculate an Exposure’s zero-point given a set of flux measurements of stars matched to an input catalogue.
Parameters#
- refObjLoader
lsst.meas.algorithms.ReferenceObjectLoader A reference object loader object; gen3 pipeline tasks will pass
Noneand callmatch.setRefObjLoaderinrunQuantum.- schema
lsst.afw.table.Schema, optional The schema of the detection catalogs used as input to this task.
- **kwds
Additional keyword arguments.
Notes#
The type of flux to use is specified by PhotoCalConfig.fluxField.
The algorithm clips outliers iteratively, with parameters set in the configuration.
This task can adds fields to the schema, so any code calling this task must ensure that these columns are indeed present in the input match list; see
pipe_tasks_photocal_Example.Debugging:
The available
lsstDebugvariables in PhotoCalTask are:- display :
If True enable other debug outputs.
- displaySources :
If True, display the exposure on ds9’s frame 1 and overlay the source catalogue.
- red o :
Reserved objects.
- green o :
Objects used in the photometric calibration.
- scatterPlot :
Make a scatter plot of flux v. reference magnitude as a function of reference magnitude:
good objects in blue
rejected objects in red
(if scatterPlot is 2 or more, prompt to continue after each iteration)
Methods Summary
displaySources(exposure, matches, reserved)Display sources we'll use for photocal.
extractMagArrays(matches, filterLabel, ...)Extract magnitude and magnitude error arrays from the given matches.
getSourceKeys(schema)Return a struct containing the source catalog keys for fields used by PhotoCalTask.
getZeroPoint(src, ref[, srcErr, zp0])Flux calibration code, returning (ZeroPoint, Distribution Width, Number of stars).
run(exposure, sourceCat[, expId])Do photometric calibration - select matches to use and (possibly iteratively) compute the zero point.
Methods Documentation
- displaySources(exposure, matches, reserved, frame=1)#
Display sources we’ll use for photocal.
Sources that will be actually used will be green. Sources reserved from the fit will be red.
Parameters#
- exposure
lsst.afw.image.ExposureF Exposure to display.
- matches
listoflsst.afw.table.RefMatch Matches used for photocal.
- reserved
numpy.ndarrayof typebool Boolean array indicating sources that are reserved.
- frame
int, optional Frame number for display.
- exposure
- extractMagArrays(matches, filterLabel, sourceKeys)#
Extract magnitude and magnitude error arrays from the given matches.
Parameters#
- matches
lsst.afw.table.ReferenceMatchVector Reference/source matches.
- filterLabel
str Label of filter being calibrated.
- sourceKeys
lsst.pipe.base.Struct Struct of source catalog keys, as returned by getSourceKeys().
Returns#
- result
lsst.pipe.base.Struct Results as a struct with attributes:
srcMagSource magnitude (
np.array).refMagReference magnitude (
np.array).srcMagErrSource magnitude error (
np.array).refMagErrReference magnitude error (
np.array).magErrAn error in the magnitude; the error in
srcMag-refMag. If nonzero,config.magErrFloorwill be added tomagErronly (notsrcMagErrorrefMagErr), asmagErris what is later used to determine the zero point (np.array).refFluxFieldListA list of field names of the reference catalog used for fluxes (1 or 2 strings) (
list).
- matches
- getSourceKeys(schema)#
Return a struct containing the source catalog keys for fields used by PhotoCalTask.
Parameters#
- schema
lsst.afw.table.schema Schema of the catalog to get keys from.
Returns#
- result
lsst.pipe.base.Struct Results as a struct with attributes:
instFluxInstrument flux key.
instFluxErrInstrument flux error key.
- schema
- getZeroPoint(src, ref, srcErr=None, zp0=None)#
Flux calibration code, returning (ZeroPoint, Distribution Width, Number of stars).
Returns#
- result
lsst.pipe.base.Struct Results as a struct with attributes:
zpPhotometric zero point (mag,
float).sigmaStandard deviation of fit of photometric zero point (mag,
float).ngoodNumber of sources used to fit photometric zero point (
int).
Notes#
We perform nIter iterations of a simple sigma-clipping algorithm with a couple of twists: - We use the median/interquartile range to estimate the position to clip around, and the “sigma” to use. - We never allow sigma to go _above_ a critical value sigmaMax — if we do, a sufficiently large estimate will prevent the clipping from ever taking effect. - Rather than start with the median we start with a crude mode. This means that a set of magnitude residuals with a tight core and asymmetrical outliers will start in the core. We use the width of this core to set our maximum sigma (see second bullet).
- result
- run(exposure, sourceCat, expId=0)#
Do photometric calibration - select matches to use and (possibly iteratively) compute the zero point.
Parameters#
- exposure
lsst.afw.image.Exposure Exposure upon which the sources in the matches were detected.
- sourceCat
lsst.afw.table.SourceCatalog Good stars selected for use in calibration.
- expId
int, optional Exposure ID.
Returns#
- result
lsst.pipe.base.Struct Results as a struct with attributes:
photoCalibObject containing the zero point (
lsst.afw.image.Calib).arraysMagnitude arrays returned be
PhotoCalTask.extractMagArrays.matchesReferenceMatchVector, as returned by the matcher
matchMetametadata needed to unpersist matches, as returnedby the matcher (
lsst.daf.base.PropertyList)zpPhotometric zero point (mag,
float).sigmaStandard deviation of fit of photometric zero point (mag,
float).ngoodNumber of sources used to fit photometric zero point (
int).
Raises#
- RuntimeError
Raised if any of the following occur: - No matches to use for photocal. - No matches are available (perhaps no sources/references were selected by the matcher). - No reference stars are available. - No matches are available from which to extract magnitudes.
Notes#
The exposure is only used to provide the name of the filter being calibrated (it may also be used to generate debugging plots).
The reference objects: - Must include a field
photometric; True for objects which should be considered as photometric standards. - Must include a fieldflux; the flux used to impose a magnitude limit and also to calibrate the data to (unless a color term is specified, in which case ColorTerm.primary is used; See https://jira.lsstcorp.org/browse/DM-933). - May include a fieldstargal; if present, True means that the object is a star. - May include a fieldvar; if present, True means that the object is variable.The measured sources: - Must include PhotoCalConfig.fluxField; the flux measurement to be used for calibration.
- exposure
- refObjLoader