Coverage for python/lsst/ip/diffim/metrics.py : 57%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of ip_diffim. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. #
"NumberSciSourcesMetricTask", "NumberSciSourcesMetricConfig", "FractionDiaSourcesToSciSourcesMetricTask", "FractionDiaSourcesToSciSourcesMetricConfig", ]
MetricComputationError
MetricConnections, defaultTemplates={"package": "ip_diffim", "metric": "numSciSources"}, dimensions={"Instrument", "Exposure", "Detector"}, ): doc="The catalog of science sources.", name="src", storageClass="SourceCatalog", dimensions={"Instrument", "Exposure", "Detector"}, )
MetricConfig, pipelineConnections=NumberSciSourcesMetricConnections):
"""Task that computes the number of cataloged science sources. """
"""Count the number of science sources.
Parameters ---------- sources : `lsst.afw.table.SourceCatalog` or `None` A science source catalog, which may be empty or `None`.
Returns ------- result : `lsst.pipe.base.Struct` A `~lsst.pipe.base.Struct` containing the following component:
``measurement`` the total number of science sources (`lsst.verify.Measurement` or `None`) """ if sources is not None: nSciSources = len(sources) meas = Measurement(self.config.metricName, nSciSources * u.count) else: self.log.info("Nothing to do: no catalogs found.") meas = None return Struct(measurement=meas)
MetricTask.ConfigClass.ConnectionsClass, dimensions={"Instrument", "Exposure", "Detector"}, defaultTemplates={"coaddName": "deep", "package": "ip_diffim", "metric": "fracDiaSourcesToSciSources"}): doc="The catalog of science sources.", name="src", storageClass="SourceCatalog", dimensions={"Instrument", "Exposure", "Detector"}, ) doc="The catalog of DIASources.", name="{coaddName}Diff_diaSrc", storageClass="SourceCatalog", dimensions={"Instrument", "Exposure", "Detector"}, )
MetricTask.ConfigClass, pipelineConnections=FractionDiaSourcesToSciSourcesMetricConnections):
"""Task that computes the ratio of difference image sources to science sources in an image, visit, etc. """
"""Compute the ratio of DIASources to science sources.
Parameters ---------- sciSources : `lsst.afw.table.SourceCatalog` or `None` A science source catalog, which may be empty or `None`. diaSources : `lsst.afw.table.SourceCatalog` or `None` A DIASource catalog for the same unit of processing as ``sciSources``.
Returns ------- result : `lsst.pipe.base.Struct` A `~lsst.pipe.base.Struct` containing the following component:
``measurement`` the ratio (`lsst.verify.Measurement` or `None`) """ if diaSources is not None and sciSources is not None: nSciSources = len(sciSources) nDiaSources = len(diaSources) metricName = self.config.metricName if nSciSources <= 0.0: raise MetricComputationError( "No science sources found; ratio of DIASources to science sources ill-defined.") else: meas = Measurement(metricName, nDiaSources / nSciSources * u.dimensionless_unscaled) else: self.log.info("Nothing to do: no catalogs found.") meas = None return Struct(measurement=meas) |