Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-9840: Update psfexStarSelector to new SourceSelector API #43

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 26 additions & 23 deletions python/lsst/meas/extensions/psfex/psfexStarSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@
except ImportError:
plt = None

from lsst.afw.table import SourceCatalog
from lsst.pipe.base import Struct
import lsst.pex.config as pexConfig
import lsst.afw.display.ds9 as ds9
from lsst.meas.algorithms import BaseStarSelectorTask, starSelectorRegistry
from lsst.meas.algorithms import BaseSourceSelectorTask, sourceSelectorRegistry
from . import psfexLib
from .psfex import compute_fwhmrange

__all__ = ["PsfexStarSelectorConfig", "PsfexStarSelectorTask"]


class PsfexStarSelectorConfig(BaseStarSelectorTask.ConfigClass):
class PsfexStarSelectorConfig(BaseSourceSelectorTask.ConfigClass):
fluxName = pexConfig.Field(
dtype=str,
doc="Name of photometric flux key ",
Expand Down Expand Up @@ -197,7 +196,8 @@ def plot(mag, width, centers, clusterId, marker="o", markersize=2, markeredgewid
## \}


class PsfexStarSelectorTask(BaseStarSelectorTask):
@pexConfig.registerConfigurable("psfex", sourceSelectorRegistry)
class PsfexStarSelectorTask(BaseSourceSelectorTask):
"""A star selector whose algorithm is not yet documented.

@anchor PsfexStarSelectorTask_
Expand Down Expand Up @@ -261,15 +261,27 @@ def DebugInfo(name):
ConfigClass = PsfexStarSelectorConfig
usesMatches = False # selectStars does not use its matches argument

def selectStars(self, exposure, sourceCat, matches=None):
"""!Select stars from source catalog

@param[in] exposure the exposure containing the sources
@param[in] sourceCat catalog of sources that may be stars (an lsst.afw.table.SourceCatalog)
@param[in] matches astrometric matches; ignored by this star selector

@return a Struct containing:
- starCat a subset of sourceCat containing the selected stars
def selectSources(self, sourceCat, matches=None, exposure=None):
"""Return a selection of psf-like objects.

Parameters
----------
sourceCat : `lsst.afw.table.SourceCatalog`
Catalog of sources to select from.
This catalog must be contiguous in memory.
matches : `list` of `lsst.afw.table.ReferenceMatch` or None
Ignored by this source selector.
exposure : `lsst.afw.image.Exposure` or None
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.
"""
import lsstDebug
display = lsstDebug.Info(__name__).display
Expand Down Expand Up @@ -455,13 +467,4 @@ def selectStars(self, exposure, sourceCat, matches=None):
else:
break

starCat = SourceCatalog(sourceCat.schema)
for source, isGood in zip(sourceCat, good):
if isGood:
starCat.append(source)

return Struct(
starCat=starCat,
)

starSelectorRegistry.register("psfex", PsfexStarSelectorTask)
return Struct(selected=good)