PhotoCalTask¶
- class lsst.pipe.tasks.photoCal.PhotoCalTask(refObjLoader=None, schema=None, **kwds)¶
Bases:
Task
Calculate 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
None
and callmatch.setRefObjLoader
inrunQuantum
.- schema
lsst.afw.table.Schema
, optional The schema of the detection catalogs used as input to this task.
- **kwds
Additional keyword arguments.
- refObjLoader
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
lsstDebug
variables 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.
Empty (clear) the metadata for this Task and all sub-Tasks.
extractMagArrays
(matches, filterLabel, ...)Extract magnitude and magnitude error arrays from the given matches.
Get metadata for all tasks.
Get the task name as a hierarchical name including parent task names.
getName
()Get the name of the task.
getSourceKeys
(schema)Return a struct containing the source catalog keys for fields used by PhotoCalTask.
Get a dictionary of all tasks as a shallow copy.
getZeroPoint
(src, ref[, srcErr, zp0])Flux calibration code, returning (ZeroPoint, Distribution Width, Number of stars).
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.run
(exposure, sourceCat[, expId])Do photometric calibration - select matches to use and (possibly iteratively) compute the zero point.
timer
(name[, logLevel])Context manager to log performance data for an arbitrary block of code.
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
list
oflsst.afw.table.RefMatch
Matches used for photocal.
- reserved
numpy.ndarray
of 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().
- matches
- Returns:
- result
lsst.pipe.base.Struct
Results as a struct with attributes:
srcMag
Source magnitude (
np.array
).refMag
Reference magnitude (
np.array
).srcMagErr
Source magnitude error (
np.array
).refMagErr
Reference magnitude error (
np.array
).magErr
An error in the magnitude; the error in
srcMag
-refMag
. If nonzero,config.magErrFloor
will be added tomagErr
only (notsrcMagErr
orrefMagErr
), asmagErr
is what is later used to determine the zero point (np.array
).refFluxFieldList
A list of field names of the reference catalog used for fluxes (1 or 2 strings) (
list
).
- result
- getFullMetadata() 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.
- metadata
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”.
- fullName
- getName() str ¶
Get the name of the task.
- Returns:
- taskName
str
Name of the task.
- taskName
See also
getFullName
Get the full name of the task.
- 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.
- schema
- Returns:
- result
lsst.pipe.base.Struct
Results as a struct with attributes:
instFlux
Instrument flux key.
instFluxErr
Instrument flux error key.
- result
- 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.
- taskDict
- 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:
- result
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).
- classmethod makeField(doc: str) ConfigurableField ¶
Make a
lsst.pex.config.ConfigurableField
for this task.- Parameters:
- doc
str
Help text for the field.
- doc
- Returns:
- configurableField
lsst.pex.config.ConfigurableField
A
ConfigurableField
for this task.
- configurableField
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: Any) 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
.
- name
Notes
The subtask must be defined by
Task.config.name
, an instance ofConfigurableField
orRegistryField
.
- 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.image.SourceCatalog
A catalog of sources to use in the calibration (i.e. a
list
oflsst.afw.table.Match
with first being of typelsst.afw.table.SimpleRecord
and second typelsst.afw.table.SourceRecord
the reference object and matched object respectively). Will not be modified except to set the outputField if requested.- expId
int
, optional Exposure ID.
- exposure
- Returns:
- result
lsst.pipe.base.Struct
Results as a struct with attributes:
photoCalib
Object containing the zero point (
lsst.afw.image.Calib
).arrays
Magnitude arrays returned be
PhotoCalTask.extractMagArrays
.matches
ReferenceMatchVector, as returned by the matcher
matchMeta
metadata needed to unpersist matches, as returnedby the matcher (
lsst.daf.base.PropertyList
)zp
Photometric zero point (mag,
float
).sigma
Standard deviation of fit of photometric zero point (mag,
float
).ngood
Number of sources used to fit photometric zero point (
int
).
- result
- 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.