Skip to content

Commit

Permalink
Split base.py into pluginRegistry.py and apCorrRegistry.py
Browse files Browse the repository at this point in the history
  • Loading branch information
r-owen committed Jul 28, 2015
1 parent 7131476 commit b6d951f
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 36 deletions.
3 changes: 2 additions & 1 deletion python/lsst/meas/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .base import *
from .apCorrRegistry import *
from .pluginRegistry import *
from .baseMeasurement import *
from .sfm import *
from .plugins import *
Expand Down
48 changes: 48 additions & 0 deletions python/lsst/meas/base/apCorrRegistry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
#
# LSST Data Management System
# Copyright 2008-2015 AURA/LSST.
#
# This product includes software developed by the
# LSST Project (http://www.lsst.org/).
#
# 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 LSST License Statement and
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
"""Registry for names of flux fields that should be aperture corrected
"""

__all__ = ("addApCorrName", "getApCorrNameSet")

# Set of names of algorithms that measure fluxes that can be aperture corrected
_ApCorrNameSet = set()

def addApCorrName(name):
"""!Add to the set of field name prefixes for fluxes that should be aperture corrected
@param[in] name field name prefix for a flux that should be aperture corrected.
The corresponding field names are {name}_flux, {name}_fluxSigma and {name}_flag.
For example name "base_PsfFlux" corresponds to fields base_PsfFlux_flux,
base_PsfFlux_fluxSigma and base_PsfFlux_flag.
"""
global _ApCorrNameSet
_ApCorrNameSet.add(str(name))

def getApCorrNameSet():
"""!Return a copy of the set of field name prefixes for fluxes that should be aperture corrected
For example the returned set will likely include "base_PsfFlux" and "base_GaussianFlux".
"""
global _ApCorrNameSet
return _ApCorrNameSet.copy()
2 changes: 1 addition & 1 deletion python/lsst/meas/base/applyApCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import lsst.pex.exceptions
import lsst.afw.image
import lsst.pipe.base
from .base import getApCorrNameSet
from .apCorrRegistry import getApCorrNameSet

# If True then scale flux sigma by apCorr; if False then use a more complex computation
# that over-estimates flux error (often grossly so) because it double-counts photon noise.
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/base/baseMeasurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import lsst.pex.config

from .applyApCorr import ApplyApCorrTask
from .base import PluginMap
from .pluginRegistry import PluginMap
from .baseLib import FatalAlgorithmError, MeasurementError
from .noiseReplacer import NoiseReplacerConfig
from .transforms import PassThroughTransform
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/base/forcedMeasurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import lsst.pex.config
import lsst.pipe.base

from .base import PluginRegistry
from .pluginRegistry import PluginRegistry
from .baseMeasurement import BasePluginConfig, BasePlugin, BaseMeasurementConfig, BaseMeasurementTask
from .noiseReplacer import NoiseReplacer, DummyNoiseReplacer

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/base/measureApCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from lsst.afw.image import ApCorrMap
from lsst.afw.math import ChebyshevBoundedField, ChebyshevBoundedFieldConfig
from lsst.pipe.base import Task, Struct
from .base import getApCorrNameSet
from .apCorrRegistry import getApCorrNameSet

__all__ = ("MeasureApCorrConfig", "MeasureApCorrTask")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,16 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
"""Base and utility classes for measurement frameworks
This includes base classes for plugins and tasks and utility classes such as PluginMap
that are shared by the single-frame measurement framework and the forced measurement framework.
"""Registry for measurement plugins and associated utilities generateAlgorithmName and PluginMap
"""

import collections

import lsst.pipe.base
import lsst.pex.config
from .apCorrRegistry import addApCorrName

__all__ = ("addApCorrName", "getApCorrNameSet", "generateAlgorithmName", "PluginRegistry", "register",
"PluginMap")

# Set of names of algorithms that measure fluxes that can be aperture corrected
_ApCorrNameSet = set()

def addApCorrName(name):
"""!Add to the set of field name prefixes for fluxes that should be aperture corrected
@param[in] name field name prefix for a flux that should be aperture corrected.
The corresponding field names are {name}_flux, {name}_fluxSigma and {name}_flag.
For example name "base_PsfFlux" corresponds to fields base_PsfFlux_flux,
base_PsfFlux_fluxSigma and base_PsfFlux_flag.
"""
global _ApCorrNameSet
_ApCorrNameSet.add(str(name))

def getApCorrNameSet():
"""!Return a copy of the set of field name prefixes for fluxes that should be aperture corrected
For example the returned set will likely include "base_PsfFlux" and "base_GaussianFlux".
"""
global _ApCorrNameSet
return _ApCorrNameSet.copy()
__all__ = ("generateAlgorithmName", "PluginRegistry", "register", "PluginMap")

def generateAlgorithmName(AlgClass):
"""Generate a string name for an algorithm class that strips away terms that are generally redundant
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/base/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import lsst.pex.exceptions
import lsst.afw.detection

from .base import register
from .pluginRegistry import register
from . import baseLib as bl
from .baseMeasurement import BasePlugin
from .sfm import SingleFramePluginConfig, SingleFramePlugin
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/base/sfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
to avoid information loss (this should, of course, be indicated in the field documentation).
"""

from .base import PluginRegistry
from .pluginRegistry import PluginRegistry
from .baseMeasurement import BasePluginConfig, BasePlugin, BaseMeasurementConfig, BaseMeasurementTask
from .noiseReplacer import NoiseReplacer, DummyNoiseReplacer

Expand Down
3 changes: 2 additions & 1 deletion python/lsst/meas/base/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import lsst.pex.config

from .base import generateAlgorithmName, addApCorrName
from .pluginRegistry import generateAlgorithmName
from .apCorrRegistry import addApCorrName
from .sfm import SingleFramePlugin
from .forcedMeasurement import ForcedPlugin

Expand Down

0 comments on commit b6d951f

Please sign in to comment.