Skip to content

Commit

Permalink
Merge pull request #362 from lsst/tickets/DM-42553
Browse files Browse the repository at this point in the history
DM-42553: Add check for finite ra/dec in ReferenceSourceSelectorTask
  • Loading branch information
erykoff authored Jan 19, 2024
2 parents 20694e4 + d71756a commit e9028ae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions python/lsst/meas/algorithms/sourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={},
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
14 changes: 14 additions & 0 deletions tests/test_sourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit e9028ae

Please sign in to comment.