Coverage for python/lsst/meas/base/pluginRegistry.py : 70%

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 meas_base. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (https://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 <https://www.gnu.org/licenses/>.
"""
"""Generate a name for an algorithm.
This generates a short name for an algorithmic class that strips away terms that are generally redundant while remaining easy to trace to the code.
Parameters ---------- AlgClass : subclass of `BaseAlgorithm` The class to generate a name for.
Returns ------- name : `str` A short name for the algorithm.
Notes ----- The returned name will cobmine the package name, with any ``lsst`` and/or ``meas`` prefix removed, with the class name, with any ``Algorithm`` suffix removed. For instance, ``lsst.meas.base.SdssShapeAlgorithm`` becomes ``base_SdssShape``. """ # Hide private module name only if it's part of a public package terms = terms[:-1] terms = terms[:-1]
"""Base class for plugin registries.
Notes ----- The class of plugins allowed in the registry is defined in the constructor of the registry.
Single-frame and forced plugins have different registries. """
"""Class used as the element in the plugin registry.
Parameters ---------- name : `str` Name under which the plugin is registerd. PluginClass : subclass of `BasePlugin` The class of plugin which can be stored in the registry.
Notes ----- Rather than constructing a Plugin instance, its __call__ method (invoked by RegistryField.apply) returns a tuple of ``(executionOrder, name, config, PluginClass)``, which can then be sorted before the plugins are instantiated. """
def ConfigClass(self):
return (self.PluginClass.getExecutionOrder(), self.name, config, self.PluginClass)
"""Register a plugin class with the given name.
Parameters ---------- name : `str` The name of the plugin. This is used as a prefix for all fields produced by the plugin, and it should generally contain the name of the plugin or algorithm class itself as well as enough of the namespace to make it clear where to find the code. For example ``base_GaussianFlux`` indicates an algorithm in `lsst.meas.base` that measures Gaussian Flux and produces fields such as ``base_GaussianFlux_instFlux``, ``base_GaussianFlux_instFluxErr`` and ``base_GaussianFlux_flag``. shouldApCorr : `bool` If `True`, then this algorithm measures an instFlux that should be aperture corrected. This is shorthand for ``apCorrList=[name]`` and is ignored if ``apCorrList`` is specified. apCorrList : `list` of `str` List of field name prefixes for instFlux fields to be aperture corrected. If an algorithm produces a single instFlux that should be aperture corrected then it is simpler to set ``shouldApCorr=True``. But if an algorithm produces multiple such fields then it must specify ``apCorrList`` instead. For example, ``modelfit_CModel`` produces three such fields: ``apCorrList=("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def")``. If ``apCorrList`` is not empty then shouldApCorr is ignored.
Notes ----- The same plugin may be registered multiple times with different names; this can be useful if we often want to run it multiple times with different configuration. """ apCorrList = [name] addApCorrName(prefix)
"""A decorator to register a plugin class in its base class's registry.
Parameters ---------- shouldApCorr : `bool` If `True`, then this algorithm measures an instFlux that should be aperture corrected. This is shorthand for ``apCorrList=[name]`` and is ignored if ``apCorrList`` is specified. apCorrList : `list` of `str` List of field name prefixes for instFlux fields to be aperture corrected. If an algorithm produces a single instFlux that should be aperture corrected then it is simpler to set ``shouldApCorr=True``. But if an algorithm produces multiple such fields then it must specify ``apCorrList`` instead. For example, ``modelfit_CModel`` produces three such fields: ``apCorrList=("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def")``. If ``apCorrList`` is not empty then shouldApCorr is ignored.
"""
"""Map of plugins to be run for a given task.
Notes ----- Plugins are classes derived from `BasePlugin`.
We assume plugins are added to the plugin map according to their "Execution Order", so this class doesn't actually do any of the sorting (though it does have to maintain that order, which it does by inheriting from `collections.OrderedDict`). """
"""Return an iterator over plugins for use in single-object mode.
Notes ----- Plugins which should be used in single-object mode are identified by having the `doMeasure` config attribute evaluate to `True`. This is usually a simple boolean class attribute. """ for plugin in self.values(): if plugin.config.doMeasure: yield plugin
"""Return an iterator over plugins for use in multi-object mode.
Notes ----- Plugins which should be used in multi-object mode are identified by having the `doMeasureN` config attribute evaluate to `True`. This is usually a simple boolean class attribute. """ for plugin in self.values(): if plugin.config.doMeasureN: yield plugin |