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-17917: Add doUnresolved to ReferenceSourceSelectorTask #153

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions python/lsst/meas/algorithms/sourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,12 @@ def selectSources(self, sourceCat, matches=None, exposure=None):
class ReferenceSourceSelectorConfig(pexConfig.Config):
doMagLimit = pexConfig.Field(dtype=bool, default=False, doc="Apply magnitude limit?")
doFlags = pexConfig.Field(dtype=bool, default=False, doc="Apply flag limitation?")
doUnresolved = pexConfig.Field(dtype=bool, default=False, doc="Apply unresolved limitation?")
doSignalToNoise = pexConfig.Field(dtype=bool, default=False, doc="Apply signal-to-noise limit?")
doMagError = pexConfig.Field(dtype=bool, default=False, doc="Apply magnitude error limit?")
magLimit = pexConfig.ConfigField(dtype=MagnitudeLimit, doc="Magnitude limit to apply")
flags = pexConfig.ConfigField(dtype=RequireFlags, doc="Flags to require")
unresolved = pexConfig.ConfigField(dtype=RequireUnresolved, doc="Star/galaxy separation to apply")
signalToNoise = pexConfig.ConfigField(dtype=SignalToNoiseLimit, doc="Signal-to-noise limit to apply")
magError = pexConfig.ConfigField(dtype=MagnitudeErrorLimit, doc="Magnitude error limit to apply")
colorLimits = pexConfig.ConfigDictField(keytype=str, itemtype=ColorLimit, default={},
Expand Down Expand Up @@ -596,6 +598,8 @@ def selectSources(self, sourceCat, matches=None, exposure=None):
selected &= self.config.magLimit.apply(sourceCat)
if self.config.doFlags:
selected &= self.config.flags.apply(sourceCat)
if self.config.doUnresolved:
selected &= self.config.unresolved.apply(sourceCat)
if self.config.doSignalToNoise:
selected &= self.config.signalToNoise.apply(sourceCat)
if self.config.doMagError:
Expand Down
24 changes: 24 additions & 0 deletions tests/test_sourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def setUp(self):
self.config.magLimit.fluxField = "flux"
self.config.doMagLimit = True
self.config.doFlags = True
self.config.doUnresolved = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but I'm following the redundancy in the ScienceSourceSelectorTask test.


def testMagnitudeLimit(self):
tooBright = self.catalog.addNew()
Expand Down Expand Up @@ -268,6 +269,29 @@ def testColorLimits(self):
self.config.colorLimits["other"] = ColorLimit(primary="flux", secondary="other_flux", minimum=0.1)
self.check([False]*num)

def testUnresolved(self):
num = 5
for _ in range(num):
self.catalog.addNew()
self.catalog["flux"] = 1.0
starGalaxy = np.linspace(0.0, 1.0, num, False)
self.catalog["starGalaxy"] = starGalaxy
self.config.doUnresolved = True
self.config.unresolved.name = "starGalaxy"
minimum, maximum = 0.3, 0.7
self.config.unresolved.minimum = minimum
self.config.unresolved.maximum = maximum
self.check(((starGalaxy > minimum) & (starGalaxy < maximum)).tolist())

# Works with no minimum set?
self.config.unresolved.minimum = None
self.check((starGalaxy < maximum).tolist())

# Works with no maximum set?
self.config.unresolved.minimum = minimum
self.config.unresolved.maximum = None
self.check((starGalaxy > minimum).tolist())


class TrivialSourceSelector(lsst.meas.algorithms.BaseSourceSelectorTask):
"""Return true for every source. Purely for testing."""
Expand Down