diff --git a/python/lsst/meas/algorithms/sourceSelector.py b/python/lsst/meas/algorithms/sourceSelector.py index b35ce74e8..3000540d0 100644 --- a/python/lsst/meas/algorithms/sourceSelector.py +++ b/python/lsst/meas/algorithms/sourceSelector.py @@ -646,9 +646,13 @@ class ReferenceSourceSelectorConfig(pexConfig.Config): 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?") + doRequireFiniteRaDec = pexConfig.Field(dtype=bool, default=True, + doc="Apply finite sky coordinate check?") 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") + requireFiniteRaDec = pexConfig.ConfigField(dtype=RequireFiniteRaDec, + doc="Finite sky coordinate criteria 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={}, @@ -698,6 +702,8 @@ def selectSources(self, sourceCat, matches=None, exposure=None): selected &= self.config.signalToNoise.apply(sourceCat) if self.config.doMagError: selected &= self.config.magError.apply(sourceCat) + if self.config.doRequireFiniteRaDec: + selected &= self.config.requireFiniteRaDec.apply(sourceCat) for limit in self.config.colorLimits.values(): selected &= limit.apply(sourceCat) diff --git a/tests/test_curve.py b/tests/test_curve.py index 461ded679..529311315 100755 --- a/tests/test_curve.py +++ b/tests/test_curve.py @@ -50,7 +50,7 @@ class CurveTestCase(lsst.utils.tests.TestCase): def setUp(self): self.wavelength = np.linspace(3000, 5000, 150)*u.angstrom - self.efficiency = signal.gaussian(len(self.wavelength), std=100)*u.percent + self.efficiency = signal.windows.gaussian(len(self.wavelength), std=100)*u.percent self.metadata = dict([('MODE', 'AMP'), ('TYPE', 'QE'), ('CALIBDATE', '1970-01-01T00:00:00'), ('INSTRUME', 'ts8'), ('OBSTYPE', 'qe_curve'), ('DETECTOR', 99), ('DATE', '2019-09-27T22:15:13.518320'), ('CALIB_CREATION_DATE', '2019-09-27'), diff --git a/tests/test_sourceSelector.py b/tests/test_sourceSelector.py index 620121453..6ded09172 100644 --- a/tests/test_sourceSelector.py +++ b/tests/test_sourceSelector.py @@ -225,6 +225,7 @@ def setUp(self): self.config.doMagLimit = True self.config.doFlags = True self.config.doUnresolved = False + self.config.doRequireFiniteRaDec = False def testMagnitudeLimit(self): tooBright = self.catalog.addNew() @@ -329,6 +330,19 @@ def testUnresolved(self): self.config.unresolved.maximum = None self.check((starGalaxy > minimum).tolist()) + def testFiniteRaDec(self): + "Test that non-finite RA and Dec values are caught." + num = 5 + for _ in range(num): + self.catalog.addNew() + self.catalog["coord_ra"][:] = 1.0 + self.catalog["coord_dec"][:] = 1.0 + self.catalog["coord_ra"][0] = np.nan + self.catalog["coord_dec"][1] = np.inf + self.config.doRequireFiniteRaDec = True + + self.check([False, False, True, True, True]) + class TestBaseSourceSelector(lsst.utils.tests.TestCase): """Test the API of the Abstract Base Class with a trivial example."""