24 "NumberSciSourcesMetricTask",
"NumberSciSourcesMetricConfig",
25 "FractionDiaSourcesToSciSourcesMetricTask",
"FractionDiaSourcesToSciSourcesMetricConfig",
29 import astropy.units
as u
32 from lsst.verify
import Measurement
33 from lsst.verify.gen2tasks
import MetricTask, register
34 from lsst.verify.tasks
import MetricComputationError
39 doc=
"The catalog of science sources.",
41 storageClass=
"SourceCatalog",
42 dimensions={
"Instrument",
"Exposure",
"Detector"},
48 """Task that computes the number of cataloged science sources. 50 _DefaultName =
"numSciSources" 51 ConfigClass = NumberSciSourcesMetricConfig
53 def run(self, sources):
54 """Count the number of science sources. 58 sources : iterable of `lsst.afw.table.SourceCatalog` 59 A collection of science source catalogs, one for each unit of 60 processing to be incorporated into this metric. Its elements may 61 be `None` to represent missing data. 65 result : `lsst.pipe.base.Struct` 66 A `~lsst.pipe.base.Struct` containing the following component: 69 the total number of science sources (`lsst.verify.Measurement` 74 for catalog
in sources:
75 if catalog
is not None:
76 nSciSources += len(catalog)
82 self.log.
info(
"Nothing to do: no catalogs found.")
84 return Struct(measurement=meas)
88 return "ip_diffim.numSciSources" 93 doc=
"The catalog of science sources.",
95 storageClass=
"SourceCatalog",
96 dimensions={
"Instrument",
"Exposure",
"Detector"},
99 doc=
"The catalog of DIASources.",
100 name=
"deepDiff_diaSrc",
101 nameTemplate=
"{coaddName}Diff_diaSrc",
102 storageClass=
"SourceCatalog",
103 dimensions={
"Instrument",
"Exposure",
"Detector"},
107 @
register(
"fracDiaSourcesToSciSources")
109 """Task that computes the ratio of difference image sources to science 110 sources in an image, visit, etc. 112 _DefaultName =
"fracDiaSourcesToSciSources" 113 ConfigClass = FractionDiaSourcesToSciSourcesMetricConfig
115 def run(self, sciSources, diaSources):
116 """Compute the ratio of DIASources to science sources. 120 sciSources : iterable of `lsst.afw.table.SourceCatalog` 121 A collection of science source catalogs, one for each unit of 122 processing to be incorporated into this metric. Its elements may 123 be `None` to represent missing data. 124 diaSources : iterable of `lsst.afw.table.SourceCatalog` 125 A collection of difference imaging catalogs similar to 130 result : `lsst.pipe.base.Struct` 131 A `~lsst.pipe.base.Struct` containing the following component: 134 the ratio (`lsst.verify.Measurement` or `None`) 140 for sciCatalog, diaCatalog
in zip(sciSources, diaSources):
141 if diaCatalog
is not None and sciCatalog
is not None:
142 nSciSources += len(sciCatalog)
143 nDiaSources += len(diaCatalog)
148 if nSciSources <= 0.0:
149 raise MetricComputationError(
150 "No science sources found; ratio of DIASources to science sources ill-defined.")
151 meas = Measurement(metricName, 0.0 * u.dimensionless_unscaled)
153 meas = Measurement(metricName, nDiaSources / nSciSources * u.dimensionless_unscaled)
155 self.log.
info(
"Nothing to do: no catalogs found.")
157 return Struct(measurement=meas)
161 return "ip_diffim.fracDiaSourcesToSciSources"
def run(self, sciSources, diaSources)
def getOutputMetricName(cls, config)
def getOutputMetricName(cls, config)