Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion python/lsst/meas/algorithms/sourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import astropy.units as u
import pandas
import astropy.table
import warnings

import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
Expand Down Expand Up @@ -339,7 +340,12 @@ def apply(self, catalog):
flux = _getFieldFromCatalog(catalog, self.fluxField)
err = _getFieldFromCatalog(catalog, self.errField)

signalToNoise = flux/err
with warnings.catch_warnings():
# Suppress NaN warnings; these will be filtered below.
warnings.simplefilter("ignore")
signalToNoise = flux/err

selected &= ~np.isnan(signalToNoise)
selected &= BaseLimit.apply(self, signalToNoise)
return selected

Expand Down
13 changes: 13 additions & 0 deletions tests/test_sourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import unittest
import numpy as np
import astropy.units as u
import warnings

import lsst.afw.table
import lsst.meas.algorithms
Expand Down Expand Up @@ -117,6 +118,18 @@ def testSignalToNoise(self):
self.config.signalToNoise.maximum = 100.0
self.check([False, True, False])

def testSignalToNoiseNoWarn(self):
low = self.catalog.addNew()
low.set("other_flux", np.nan)
low.set("other_fluxErr", np.nan)
self.config.doSignalToNoise = True
self.config.signalToNoise.fluxField = "other_flux"
self.config.signalToNoise.errField = "other_fluxErr"
# Ensure no warnings are raised.
with warnings.catch_warnings():
warnings.simplefilter("error")
self.check([False])


class ScienceSourceSelectorTaskTest(SourceSelectorTester, lsst.utils.tests.TestCase):
Task = lsst.meas.algorithms.ScienceSourceSelectorTask
Expand Down