Coverage for python/lsst/meas/algorithms/reserveSourcesTask.py : 100%

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
# # LSST Data Management System # # Copyright 2008-2017 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 <https://www.lsstcorp.org/LegalNotices/>. #
"""Configuration for reserving sources""" doc="Fraction of candidates to reserve from fitting; none if <= 0") doc=("This number will be added to the exposure ID to set the random seed for " "reserving candidates"))
"""Reserve sources from analysis
We randomly select a fraction of sources that will be reserved from analysis. This allows evaluation of the quality of model fits using sources that were not involved in the fitting process.
Constructor parameters ---------------------- columnName : `str`, required Name of flag column to add; we will suffix this with "_reserved". schema : `lsst.afw.table.Schema`, required Catalog schema. doc : `str` Documentation for column to add. config : `ReserveSourcesConfig` Configuration. """
"""Select sources to be reserved
Reserved sources will be flagged in the catalog, and we will return boolean arrays that identify the sources to be reserved from and used in the analysis. Typically you'll want to use the sources from the `use` array in your fitting, and use the sources from the `reserved` array as an independent test of your fitting.
Parameters ---------- sources : `lsst.afw.table.Catalog` or `list` of `lsst.afw.table.Record` Sources from which to select some to be reserved. prior : `numpy.ndarray` of type `bool`, optional Prior selection of sources. Should have the same length as `sources`. If set, we will only consider for reservation sources that are flagged `True` in this array. expId : `int` Exposure identifier; used for seeding the random number generator.
Return struct contents ---------------------- reserved : `numpy.ndarray` of type `bool` Sources to be reserved are flagged `True` in this array. use : `numpy.ndarray` of type `bool` Sources the user should use in analysis are flagged `True`. """ else: use=prior & ~selection if prior is not None else np.logical_not(selection))
"""Randomly select some sources
We return a boolean array with a random selection. The fraction of sources selected is specified by the config parameter `fraction`.
Parameters ---------- numSources : `int` Number of sources in catalog from which to select. expId : `int` Exposure identifier; used for seeding the random number generator.
Returns ------- selection : `numpy.ndarray` of type `bool` Selected sources are flagged `True` in this array. """
"""Apply selection to full catalog
The `select` method makes a random selection of sources. If those sources don't represent the full population (because a sub-selection has already been made), then we need to generate a selection covering the entire population.
Parameters ---------- prior : `numpy.ndarray` of type `bool` Prior selection of sources, identifying the subset from which the random selection has been made. selection : `numpy.ndarray` of type `bool` Selection of sources in subset identified by `prior`.
Returns ------- full : `numpy.ndarray` of type `bool` Selection applied to full population. """
"""Mark sources in a list or catalog
This requires iterating through the list and setting the flag in each source individually. Even if the `sources` is a `Catalog` with contiguous records, it's not currently possible to set a boolean column (DM-6981) so we need to iterate.
Parameters ---------- catalog : `lsst.afw.table.Catalog` or `list` of `lsst.afw.table.Record` Catalog in which to flag selected sources. selection : `numpy.ndarray` of type `bool` Selection of sources to mark. """ |