def setUp(self):
     class Configurable(object):
         class ConfigClass(pexConf.Config):
             v = pexConf.Field(dtype=int, doc="dummy int field for registry configurable", default=0)
         def __init__(self, cfg):
             self.value = cfg.v
     self.registry = pexConf.makeRegistry("registry for Configurable", Configurable.ConfigClass)
     self.registry.register("C1", Configurable)
     self.registry.register("C2", Configurable)
Exemple #2
0
    def setUp(self):
        """Note: the classes are defined here in order to test the register
        decorator.
        """
        class ParentConfig(pexConfig.Config):
            pass

        self.registry = pexConfig.makeRegistry(doc="unit test configs",
                                               configBaseType=ParentConfig)

        class FooConfig1(ParentConfig):
            pass

        self.fooConfig1Class = FooConfig1

        class FooConfig2(ParentConfig):
            pass

        self.fooConfig2Class = FooConfig2

        class Config1(pexConfig.Config):
            pass

        self.config1Class = Config1

        class Config2(pexConfig.Config):
            pass

        self.config2Class = Config2

        @pexConfig.registerConfigurable("foo1", self.registry)
        class FooAlg1:
            ConfigClass = FooConfig1

            def __init__(self, config):
                self.config = config

            def foo(self):
                pass

        self.fooAlg1Class = FooAlg1

        class FooAlg2:
            ConfigClass = FooConfig2

            def __init__(self, config):
                self.config = config

            def foo(self):
                pass

        self.registry.register("foo2", FooAlg2, FooConfig2)
        self.fooAlg2Class = FooAlg2

        # override Foo2 with FooConfig1
        self.registry.register("foo21", FooAlg2, FooConfig1)
Exemple #3
0
    def setUp(self):
        class Configurable:
            class ConfigClass(pexConf.Config):
                v = pexConf.Field(dtype=int, doc="dummy int field for registry configurable", default=0)

            def __init__(self, cfg):
                self.value = cfg.v
        self.registry = pexConf.makeRegistry("registry for Configurable", Configurable.ConfigClass)
        self.registry.register("C1", Configurable)
        self.registry.register("C2", Configurable)
    def setUp(self):
        """Note: the classes are defined here in order to test the register decorator
        """
        class ParentConfig(pexConfig.Config):
            pass

        self.registry = pexConfig.makeRegistry(doc="unit test configs", configBaseType=ParentConfig)

        class FooConfig1(ParentConfig):
            pass
        self.fooConfig1Class = FooConfig1

        class FooConfig2(ParentConfig):
            pass
        self.fooConfig2Class = FooConfig2

        class Config1(pexConfig.Config):
            pass
        self.config1Class = Config1

        class Config2(pexConfig.Config):
            pass
        self.config2Class = Config2

        @pexConfig.registerConfigurable("foo1", self.registry)
        class FooAlg1:
            ConfigClass = FooConfig1

            def __init__(self, config):
                self.config = config

            def foo(self):
                pass
        self.fooAlg1Class = FooAlg1

        class FooAlg2:
            ConfigClass = FooConfig2

            def __init__(self, config):
                self.config = config

            def foo(self):
                pass
        self.registry.register("foo2", FooAlg2, FooConfig2)
        self.fooAlg2Class = FooAlg2

        # override Foo2 with FooConfig1
        self.registry.register("foo21", FooAlg2, FooConfig1)
            The exposure the catalog was built from; used for debug display.

        Return
        ------
        struct : `lsst.pipe.base.Struct`
            The struct contains the following data:

            - selected : `numpy.ndarray` of `bool``
                Boolean array of sources that were selected, same length as
                sourceCat.
        """
        raise NotImplementedError("BaseSourceSelectorTask is abstract")


sourceSelectorRegistry = pexConfig.makeRegistry(
    doc="A registry of source selectors (subclasses of "
        "BaseSourceSelectorTask)",
)


class BaseLimit(pexConfig.Config):
    """Base class for selecting sources by applying a limit

    This object can be used as a `lsst.pex.config.Config` for configuring
    the limit, and then the `apply` method can be used to identify sources
    in the catalog that match the configured limit.

    This provides the `maximum` and `minimum` fields in the Config, and
    a method to apply the limits to an array of values calculated by the
    subclass.
    """
    minimum = pexConfig.Field(dtype=float, optional=True, doc="Select objects with value greater than this")
Exemple #6
0
class ComputeVisitRegionsTask(Task, metaclass=ABCMeta):
    """Abstract base class for the subtask of `DefineVisitsTask` that is
    responsible for extracting spatial regions for visits and visit+detector
    combinations.

    Subclasses should be registered with `ComputeVisitRegionsTask.registry` to
    enable use by `DefineVisitsTask`.

    Parameters
    ----------
    config : `ComputeVisitRegionsConfig`
        Configuration information.
    butler : `lsst.daf.butler.Butler`
        The butler to use.
    **kwargs
        Additional keyword arguments forwarded to the `Task` constructor.
    """
    def __init__(self, config: ComputeVisitRegionsConfig, *, butler: Butler,
                 **kwargs: Any):
        Task.__init__(self, config=config, **kwargs)
        self.butler = butler
        self.instrumentMap = {}

    ConfigClass = ComputeVisitRegionsConfig

    _DefaultName = "computeVisitRegions"

    registry = makeRegistry(
        doc=("Registry of algorithms for computing on-sky regions for visits "
             "and visit+detector combinations."),
        configBaseType=ComputeVisitRegionsConfig,
    )

    def getInstrument(self, instrumentName) -> Instrument:
        """Retrieve an `~lsst.obs.base.Instrument` associated with this
        instrument name.

        Parameters
        ----------
        instrumentName : `str`
            The name of the instrument.

        Returns
        -------
        instrument : `~lsst.obs.base.Instrument`
            The associated instrument object.

        Notes
        -----
        The result is cached.
        """
        instrument = self.instrumentMap.get(instrumentName)
        if instrument is None:
            instrument = Instrument.fromName(instrumentName,
                                             self.butler.registry)
            self.instrumentMap[instrumentName] = instrument
        return instrument

    @abstractmethod
    def compute(self,
                visit: VisitDefinitionData,
                *,
                collections: Any = None) -> Tuple[Region, Dict[int, Region]]:
        """Compute regions for the given visit and all detectors in that visit.

        Parameters
        ----------
        visit : `VisitDefinitionData`
            Struct describing the visit and the exposures associated with it.
        collections : Any, optional
            Collections to be searched for raws and camera geometry, overriding
            ``self.butler.collections``.
            Can be any of the types supported by the ``collections`` argument
            to butler construction.

        Returns
        -------
        visitRegion : `lsst.sphgeom.Region`
            Region for the full visit.
        visitDetectorRegions : `dict` [ `int`, `lsst.sphgeom.Region` ]
            Dictionary mapping detector ID to the region for that detector.
            Should include all detectors in the visit.
        """
        raise NotImplementedError()
Exemple #7
0
                                   dtype=float,
                                   default=2.5)


class MultTask(pipeBase.Task):
    ConfigClass = MultConfig

    @pipeBase.timeMethod
    def run(self, val):
        self.metadata.add("mult", self.config.multiplicand)
        return pipeBase.Struct(val=val * self.config.multiplicand, )


# prove that registry fields can also be used to hold subtasks
# by using a registry to hold MultTask
multRegistry = pexConfig.makeRegistry("Registry for Mult-like tasks")
multRegistry.register("stdMult", MultTask)


class AddMultConfig(pexConfig.Config):
    add = AddTask.makeField("add task")
    mult = multRegistry.makeField("mult task", default="stdMult")


class AddMultTask(pipeBase.Task):
    ConfigClass = AddMultConfig
    _DefaultName = "addMult"
    """First add, then multiply"""
    def __init__(self, **keyArgs):
        pipeBase.Task.__init__(self, **keyArgs)
        self.makeSubtask("add")
Exemple #8
0
        # URC
        templateLimit = templateWcs.pixelToSky(afwGeom.Point2D(templateBBox.getEnd()))
        scienceLimit = scienceWcs.pixelToSky(afwGeom.Point2D(scienceBBox.getEnd()))

        self.log.info("Template Wcs : %f,%f -> %f,%f",
                      templateOrigin[0], templateOrigin[1],
                      templateLimit[0], templateLimit[1])
        self.log.info("Science Wcs : %f,%f -> %f,%f",
                      scienceOrigin[0], scienceOrigin[1],
                      scienceLimit[0], scienceLimit[1])

        templateBBox = afwGeom.Box2D(templateOrigin.getPosition(afwGeom.degrees),
                                     templateLimit.getPosition(afwGeom.degrees))
        scienceBBox = afwGeom.Box2D(scienceOrigin.getPosition(afwGeom.degrees),
                                    scienceLimit.getPosition(afwGeom.degrees))
        if not (templateBBox.overlaps(scienceBBox)):
            raise RuntimeError("Input images do not overlap at all")

        if ((templateOrigin != scienceOrigin) or
            (templateLimit != scienceLimit) or
                (templateExposure.getDimensions() != scienceExposure.getDimensions())):
            return False
        return True


subtractAlgorithmRegistry = pexConfig.makeRegistry(
    doc="A registry of subtraction algorithms for use as a subtask in imageDifference",
)

subtractAlgorithmRegistry.register('al', ImagePsfMatchTask)
Exemple #9
0
class GroupExposuresTask(Task, metaclass=ABCMeta):
    """Abstract base class for the subtask of `DefineVisitsTask` that is
    responsible for grouping exposures into visits.

    Subclasses should be registered with `GroupExposuresTask.registry` to
    enable use by `DefineVisitsTask`, and should generally correspond to a
    particular 'visit_system' dimension value.  They are also responsible for
    defining visit IDs and names that are unique across all visit systems in
    use by an instrument.

    Parameters
    ----------
    config : `GroupExposuresConfig`
        Configuration information.
    **kwargs
        Additional keyword arguments forwarded to the `Task` constructor.
    """
    def __init__(self, config: GroupExposuresConfig, **kwargs: Any):
        Task.__init__(self, config=config, **kwargs)

    ConfigClass = GroupExposuresConfig

    _DefaultName = "groupExposures"

    registry = makeRegistry(
        doc="Registry of algorithms for grouping exposures into visits.",
        configBaseType=GroupExposuresConfig,
    )

    @abstractmethod
    def group(
            self,
            exposures: List[DimensionRecord]) -> Iterable[VisitDefinitionData]:
        """Group the given exposures into visits.

        Parameters
        ----------
        exposures : `list` [ `DimensionRecord` ]
            DimensionRecords (for the 'exposure' dimension) describing the
            exposures to group.

        Returns
        -------
        visits : `Iterable` [ `VisitDefinitionData` ]
            Structs identifying the visits and the exposures associated with
            them.  This may be an iterator or a container.
        """
        raise NotImplementedError()

    @abstractmethod
    def getVisitSystem(self) -> Tuple[int, str]:
        """Return identifiers for the 'visit_system' dimension this
        algorithm implements.

        Returns
        -------
        id : `int`
            Integer ID for the visit system (given an instrument).
        name : `str`
            Unique string identifier for the visit system (given an
            instrument).
        """
        raise NotImplementedError()
Exemple #10
0
import importlib

import lsst.pex.config as pexConfig

from lsst.sims.ocs.configuration.proposal import General, Sequence

__all__ = ["general_prop_reg", "load_class", "sequence_prop_reg"]

general_prop_reg = pexConfig.makeRegistry('A registry for general proposals.',
                                          General)
sequence_prop_reg = pexConfig.makeRegistry(
    'A registry for sequence proposals.', Sequence)


def load_class(full_class_string):
    """Dynamically load a class from a string.

    This funtion is taken from the following blog:
    http://thomassileo.com/blog/2012/12/21/dynamically-load-python-modules-or-classes/

    Parameters
    ----------
    full_class_string : str
        A standard import like call.

    Returns
    -------
    cls
        An instance of the class.
    """
    class_data = full_class_string.split(".")
Exemple #11
0
        outerBBox.grow(self.getPatchBorder())
        # We do not clip the patch for cell-based tracts.
        return PatchInfo(
            index=_index,
            innerBBox=innerBBox,
            outerBBox=outerBBox,
            sequentialIndex=self.getSequentialPatchIndexFromPair(_index),
            tractWcs=tractWcs,
            cellInnerDimensions=self._cellInnerDimensions,
            cellBorder=self._cellBorder,
            numCellsPerPatchInner=self._numCellsPerPatchInner,
            numCellsInPatchBorder=self._numCellsInPatchBorder)

    def getPackedConfig(self, config):
        subConfig = config.tractBuilder[config.tractBuilder.name]
        configPacked = struct.pack(
            "<iiiiidd3sd", subConfig.cellInnerDimensions[0],
            subConfig.cellInnerDimensions[1], subConfig.cellBorder,
            subConfig.numCellsPerPatchInner, subConfig.numCellsInPatchBorder,
            config.tractOverlap, config.pixelScale,
            config.projection.encode('ascii'), config.rotation)

        return configPacked


tractBuilderRegistry = pexConfig.makeRegistry(
    doc="A registry of Tract Builders (subclasses of BaseTractBuilder)", )

tractBuilderRegistry.register("legacy", LegacyTractBuilder)
tractBuilderRegistry.register("cells", CellTractBuilder)
Exemple #12
0
            geom.Point2D(templateBBox.getEnd()))
        scienceLimit = scienceWcs.pixelToSky(geom.Point2D(
            scienceBBox.getEnd()))

        self.log.info("Template Wcs : %f,%f -> %f,%f", templateOrigin[0],
                      templateOrigin[1], templateLimit[0], templateLimit[1])
        self.log.info("Science Wcs : %f,%f -> %f,%f", scienceOrigin[0],
                      scienceOrigin[1], scienceLimit[0], scienceLimit[1])

        templateBBox = geom.Box2D(templateOrigin.getPosition(geom.degrees),
                                  templateLimit.getPosition(geom.degrees))
        scienceBBox = geom.Box2D(scienceOrigin.getPosition(geom.degrees),
                                 scienceLimit.getPosition(geom.degrees))
        if not (templateBBox.overlaps(scienceBBox)):
            raise RuntimeError("Input images do not overlap at all")

        if ((templateOrigin != scienceOrigin)
                or (templateLimit != scienceLimit)
                or (templateExposure.getDimensions() !=
                    scienceExposure.getDimensions())):
            return False
        return True


subtractAlgorithmRegistry = pexConfig.makeRegistry(
    doc=
    "A registry of subtraction algorithms for use as a subtask in imageDifference",
)

subtractAlgorithmRegistry.register('al', ImagePsfMatchTask)

class MultTask(pipeBase.Task):
    ConfigClass = MultConfig

    @pipeBase.timeMethod
    def run(self, val):
        self.metadata.add("mult", self.config.multiplicand)
        return pipeBase.Struct(
            val=val * self.config.multiplicand,
        )


# prove that registry fields can also be used to hold subtasks
# by using a registry to hold MultTask
multRegistry = pexConfig.makeRegistry("Registry for Mult-like tasks")
multRegistry.register("stdMult", MultTask)


class AddMultConfig(pexConfig.Config):
    add = AddTask.makeField("add task")
    mult = multRegistry.makeField("mult task", default="stdMult")


class AddMultTask(pipeBase.Task):
    ConfigClass = AddMultConfig
    _DefaultName = "addMult"

    """First add, then multiply"""

    def __init__(self, **keyArgs):
from .sizeMagnitudeStarSelectorFactory import sizeMagnitudeStarSelectorFactory

__all__ = ["starSelectorRegistry"]

starSelectorRegistry = makeRegistry(
    '''A registry of star selector factories
    
        A star selector factory makes a class with the following API:
        
        def __init__(self, config):
            """Construct a star selector
            
            @param[in] config: an instance of pexConfig.Config that configures this algorithm
            """
        
        def selectStars(self, exposure, sourceList):
            """Return a list of PSF candidates that represent likely stars
            
            The list of PSF candidates may be used by a PSF fitter to construct a PSF.
            
            @param[in] exposure: the exposure containing the sources (lsst.afw.image.Exposure)
            @param[in] sourceList: a list of sources that may be stars (lsst.afw.detection.SourceSet)
            
            @return psfCandidateList: a list of PSF candidates (each an lsst.meas.algorithms.PsfCandidate)
            """
        '''
)

starSelectorRegistry.register("secondMoment", SecondMomentStarSelector)
starSelectorRegistry.register("sizeMagnitude", sizeMagnitudeStarSelectorFactory)
Exemple #15
0
# 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/>.
#
import numpy
from lsst.pex.config import Config, ListField, makeRegistry, ConfigDictField, ConfigurableField
from .xyTransform import IdentityXYTransform, InvertedXYTransform, RadialXYTransform, \
    MultiXYTransform, AffineXYTransform
from .affineTransform import AffineTransform

__all__ = ["xyTransformRegistry", "OneXYTransformConfig"]

xyTransformRegistry = makeRegistry('''A registry of XYTransform factories

        An XYTransform factory is a function that obeys these rules:
        - has an attribute ConfigClass
        - takes one argument, config (an instance of ConfigClass) by name
        - returns an XYTransform
        ''')


def makeIdentityTransform(config=None):
    """Make an IdentityXYTransform (which has no config parameters)
    """
    return IdentityXYTransform()


makeIdentityTransform.ConfigClass = Config
xyTransformRegistry.register("identity", makeIdentityTransform)

psfDeterminerRegistry = makeRegistry(
    '''A registry of PSF determiner factories

    A PSF determiner factory makes a class with the following API:

    def __init__(self, config, schema=None):
        """Construct a PSF Determiner

        @param[in]       config   an instance of pexConfig.Config that configures this algorithm
        @param[in,out]   schema   an instance of afw.table.Schema used for sources; passing a
                                  schema allows the determiner to reserve a flag field to mark
                                  stars used in PSF measurement
        """

    def determinePsf(exposure, psfCandidateList, metadata=None):
        """Determine a PSF model

        @param[in] exposure            exposure containing the psf candidates (lsst.afw.image.Exposure)
        @param[in] psfCandidateList:   a sequence of PSF candidates (each an
                                       lsst.meas.algorithms.PsfCandidate); typically obtained by
                                       detecting sources and then running them through a star selector
        @param[in,out] metadata        a place to save interesting items

        @return
            - psf: the fit PSF; a subclass of lsst.afw.detection.Psf
            - cellSet: the spatial cell set used to determine the PSF (lsst.afw.math.SpatialCellSet)
        """
'''
)
Exemple #17
0
from .secondMomentStarSelector import SecondMomentStarSelector
from .sizeMagnitudeStarSelectorFactory import sizeMagnitudeStarSelectorFactory

__all__ = ["starSelectorRegistry"]

starSelectorRegistry = makeRegistry('''A registry of star selector factories
    
        A star selector factory makes a class with the following API:
        
        def __init__(self, config):
            """Construct a star selector
            
            @param[in] config: an instance of pexConfig.Config that configures this algorithm
            """
        
        def selectStars(self, exposure, sourceList):
            """Return a list of PSF candidates that represent likely stars
            
            The list of PSF candidates may be used by a PSF fitter to construct a PSF.
            
            @param[in] exposure: the exposure containing the sources (lsst.afw.image.Exposure)
            @param[in] sourceList: a list of sources that may be stars (lsst.afw.detection.SourceSet)
            
            @return psfCandidateList: a list of PSF candidates (each an lsst.meas.algorithms.PsfCandidate)
            """
        ''')

starSelectorRegistry.register("secondMoment", SecondMomentStarSelector)
starSelectorRegistry.register("sizeMagnitude",
                              sizeMagnitudeStarSelectorFactory)
Exemple #18
0
__all__ = ["psfDeterminerRegistry"]

psfDeterminerRegistry = makeRegistry('''A registry of PSF determiner factories

    A PSF determiner factory makes a class with the following API:

    def __init__(self, config, schema=None):
        """Construct a PSF Determiner
        
        @param[in]       config   an instance of pexConfig.Config that configures this algorithm
        @param[in,out]   schema   an instance of afw.table.Schema used for sources; passing a
                                  schema allows the determiner to reserve a flag field to mark
                                  stars used in PSF measurement
        """
        
    def determinePsf(exposure, psfCandidateList, metadata=None):
        """Determine a PSF model
            
        @param[in] exposure            exposure containing the psf candidates (lsst.afw.image.Exposure)
        @param[in] psfCandidateList:   a sequence of PSF candidates (each an
                                       lsst.meas.algorithms.PsfCandidate); typically obtained by
                                       detecting sources and then running them through a star selector
        @param[in,out] metadata        a place to save interesting items
        
        @return
            - psf: the fit PSF; a subclass of lsst.afw.detection.Psf
            - cellSet: the spatial cell set used to determine the PSF (lsst.afw.math.SpatialCellSet)
        """
''')

psfDeterminerRegistry.register("pca", PcaPsfDeterminer)
# (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/>.
#
from lsst.pex.config import makeRegistry
from .dodecaSkyMap import DodecaSkyMap
from .equatSkyMap import EquatSkyMap
from .discreteSkyMap import DiscreteSkyMap
from .ringsSkyMap import RingsSkyMap
from .healpixSkyMap import HealpixSkyMap

__all__ = ["skyMapRegistry"]

skyMapRegistry = makeRegistry(
    """A registry of sky maps
    """
)

skyMapRegistry.register("dodeca", DodecaSkyMap)
skyMapRegistry.register("equat", EquatSkyMap)
skyMapRegistry.register("discrete", DiscreteSkyMap)
skyMapRegistry.register("rings", RingsSkyMap)
skyMapRegistry.register("healpix", HealpixSkyMap)
Exemple #20
0
import importlib

import lsst.pex.config as pexConfig

from lsst.sims.ocs.configuration.proposal import General

__all__ = ["general_prop_reg", "load_class"]

general_prop_reg = pexConfig.makeRegistry('A registry for general proposals.', General)

def load_class(full_class_string):
    """Dynamically load a class from a string.

    This funtion is taken from the following blog:
    http://thomassileo.com/blog/2012/12/21/dynamically-load-python-modules-or-classes/

    Parameters
    ----------
    full_class_string : str
        A standard import like call.

    Returns
    -------
    cls
        An instance of the class.
    """
    class_data = full_class_string.split(".")
    module_path = ".".join(class_data[:-1])
    class_str = class_data[-1]

    module = importlib.import_module(module_path)
import lsst.geom
from lsst.pex.config import Config, ListField, makeRegistry, \
    ConfigDictField, ConfigurableField
from .transformFactory import makeTransform, makeIdentityTransform, \
    makeRadialTransform

__all__ = ["transformRegistry", "OneTransformConfig", "TransformConfig",
           "IdentityTransformConfig", "AffineTransformConfig", "RadialTransformConfig",
           "MultiTransformConfig"]

transformRegistry = makeRegistry(
    """"A registry of ``Transform`` factories

    A ``Transform`` factory is a function that obeys these rules:
    - has an attribute ``ConfigClass``
    - takes one argument, ``config`` (an instance of ``ConfigClass``) by name
    - returns a ``Transform``
    """
)


class IdentityTransformConfig(Config):
    """A Config representing a ``Transform`` that does nothing.

    See Also
    --------
    lsst.afw.geom.makeIdentityTransform
    """
    pass
Exemple #22
0
#
# 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/>.
#
from lsst.pex.config import Config, makeRegistry, Field
from .htmIndexer import HtmIndexer

__all__ = ["IndexerRegistry"]

IndexerRegistry = makeRegistry("""Registry of indexing algorithms
    """)


class HtmIndexerConfig(Config):
    depth = Field(
        doc="""Depth of the HTM tree to make.  Default is depth=7 which gives
              ~ 0.3 sq. deg. per trixel.""",
        dtype=int,
        default=7,
    )


def makeHtmIndexer(config):
    """Make an HtmIndexer
    """
    return HtmIndexer(depth=config.depth)
Exemple #23
0
            The exposure the catalog was built from; used for debug display.

        Return
        ------
        struct : `lsst.pipe.base.Struct`
            The struct contains the following data:

            - selected : `numpy.ndarray` of `bool``
                Boolean array of sources that were selected, same length as
                sourceCat.
        """
        raise NotImplementedError("BaseSourceSelectorTask is abstract")


sourceSelectorRegistry = pexConfig.makeRegistry(
    doc="A registry of source selectors (subclasses of "
        "BaseSourceSelectorTask)",
)


class BaseLimit(pexConfig.Config):
    """Base class for selecting sources by applying a limit

    This object can be used as a `lsst.pex.config.Config` for configuring
    the limit, and then the `apply` method can be used to identify sources
    in the catalog that match the configured limit.

    This provides the `maximum` and `minimum` fields in the Config, and
    a method to apply the limits to an array of values calculated by the
    subclass.
    """
    minimum = pexConfig.Field(dtype=float, optional=True, doc="Select objects with value greater than this")
Exemple #24
0
#
# 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/>.
#

__all__ = ["skyMapRegistry"]

from lsst.pex.config import makeRegistry
from .dodecaSkyMap import DodecaSkyMap
from .equatSkyMap import EquatSkyMap
from .discreteSkyMap import DiscreteSkyMap
from .ringsSkyMap import RingsSkyMap
from .healpixSkyMap import HealpixSkyMap

skyMapRegistry = makeRegistry(
    """A registry of sky maps
    """
)

skyMapRegistry.register("dodeca", DodecaSkyMap)
skyMapRegistry.register("equat", EquatSkyMap)
skyMapRegistry.register("discrete", DiscreteSkyMap)
skyMapRegistry.register("rings", RingsSkyMap)
skyMapRegistry.register("healpix", HealpixSkyMap)
Exemple #25
0
                # (and hence psfCandidate's exact type)
                if not didSetSize:
                    psfCandidate.setBorderWidth(self.config.borderWidth)
                    psfCandidate.setWidth(self.config.kernelSize +
                                          2 * self.config.borderWidth)
                    psfCandidate.setHeight(self.config.kernelSize +
                                           2 * self.config.borderWidth)
                    didSetSize = True

                im = psfCandidate.getMaskedImage().getImage()
            except Exception as err:
                self.log.debug(
                    "Failed to make a psfCandidate from star %d: %s",
                    star.getId(), err)
                continue

            vmax = afwMath.makeStatistics(im, afwMath.MAX).getValue()
            if not np.isfinite(vmax):
                continue
            psfCandidateList.append(psfCandidate)
            goodStarCat.append(star)

        return pipeBase.Struct(
            psfCandidates=psfCandidateList,
            goodStarCat=goodStarCat,
        )


starSelectorRegistry = pexConfig.makeRegistry(
    doc="A registry of star selectors (subclasses of BaseStarSelectorTask)", )
Exemple #26
0
import lsst.geom
from lsst.pex.config import Config, ListField, makeRegistry, \
    ConfigDictField, ConfigurableField
from .transformFactory import makeTransform, makeIdentityTransform, \
    makeRadialTransform

__all__ = [
    "transformRegistry", "OneTransformConfig", "TransformConfig",
    "IdentityTransformConfig", "AffineTransformConfig",
    "RadialTransformConfig", "MultiTransformConfig"
]

transformRegistry = makeRegistry(""""A registry of ``Transform`` factories

    A ``Transform`` factory is a function that obeys these rules:
    - has an attribute ``ConfigClass``
    - takes one argument, ``config`` (an instance of ``ConfigClass``) by name
    - returns a ``Transform``
    """)


class IdentityTransformConfig(Config):
    """A Config representing a ``Transform`` that does nothing.

    See Also
    --------
    lsst.afw.geom.makeIdentityTransform
    """
    pass

Exemple #27
0
    def __init__(self, config, schema=None, **kwds):
        """Construct a PSF Determiner

        @param[in]       config   an instance of pexConfig.Config that configures this algorithm
        @param[in,out]   schema   an instance of afw.table.Schema used for sources; passing a
                                  schema allows the determiner to reserve a flag field to mark stars
                                  used in PSF measurement, but some PSF determiners ignore this argument
        """
        pipeBase.Task.__init__(self, config=config, **kwds)

    @abc.abstractmethod
    def determinePsf(exposure, psfCandidateList, metadata=None):
        """Determine a PSF model

        @param[in] exposure            exposure containing the psf candidates (lsst.afw.image.Exposure)
        @param[in] psfCandidateList:   a sequence of PSF candidates (each an
                                       lsst.meas.algorithms.PsfCandidate); typically obtained by
                                       detecting sources and then running them through a star selector
        @param[in,out] metadata        a place to save interesting items

        @return
            - psf: the fit PSF; a subclass of lsst.afw.detection.Psf
            - cellSet: the spatial cell set used to determine the PSF (lsst.afw.math.SpatialCellSet)
        """
        raise NotImplementedError("BasePsfDeterminerTask is abstract, subclasses must override this method")


psfDeterminerRegistry = pexConfig.makeRegistry(
    doc="A registry of PSF determiners (subclasses of BasePsfDeterminerTask)",
)
# 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/>.
#
import numpy
from lsst.pex.config import Config, ListField, makeRegistry, ConfigDictField, ConfigurableField
from .geomLib import IdentityXYTransform, InvertedXYTransform, \
    AffineTransform, AffineXYTransform, RadialXYTransform, MultiXYTransform

__all__ = ["xyTransformRegistry", "OneXYTransformConfig"]

xyTransformRegistry = makeRegistry(
    '''A registry of XYTransform factories

        An XYTransform factory is a function that obeys these rules:
        - has an attribute ConfigClass
        - takes one argument, config (an instance of ConfigClass) by name
        - returns an XYTransform
        '''
)

def makeIdentityTransform(config=None):
    """Make an IdentityXYTransform (which has no config parameters)
    """
    return IdentityXYTransform()
makeIdentityTransform.ConfigClass = Config
xyTransformRegistry.register("identity", makeIdentityTransform)

class OneXYTransformConfig(Config):
    transform = ConfigurableField(
        doc = "XYTransform factory",