Skip to content

Commit

Permalink
Review comment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmartradio committed Oct 20, 2023
1 parent 907a45f commit 76a5454
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
17 changes: 10 additions & 7 deletions python/lsst/ap/association/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,33 @@ def run(self,
matched to new DiaSources. (`int`)
- ``nUnassociatedDiaObjects`` : Number of DiaObjects that were
not matched a new DiaSource. (`int`)
- ``longTrailedSources`` : DiaSources which have trail lengths
greater than max_trail_length/second*exposure_time.
(`pandas.DataFrame``)
"""
diaSources = self.check_dia_source_radec(diaSources)

if self.config.doTrailedSourceFilter:
diaTrailedResult = self.trailedSourceFilter.run(diaSources,
exposure_time)
diaSources = diaTrailedResult.diaSources
trailedSources = diaTrailedResult.trailedDiaSources
longTrailedSources = diaTrailedResult.longTrailedDiaSources

self.log.info(
"%i DIASources exceed max_trail_length, dropping fromsource catalog." % len(
diaTrailedResult.trailedDiaSources))
"%I Found one or more DiaSources that exceeds max_trail_length, dropping "

Check failure on line 128 in python/lsst/ap/association/association.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

F509

'...' % ... has unsupported format character 'I'
"from source catalog." % len(diaTrailedResult.longTrailedDiaSources))
self.metadata.add("num_filtered",
len(diaTrailedResult.trailedDiaSources))
len(diaTrailedResult.longTrailedDiaSources))
else:
trailedSources = pd.DataFrame(columns=diaSources.columns)
longTrailedSources = pd.DataFrame(columns=diaSources.columns)

if len(diaObjects) == 0:
return pipeBase.Struct(
matchedDiaSources=pd.DataFrame(columns=diaSources.columns),
unAssocDiaSources=diaSources,
nUpdatedDiaObjects=0,
nUnassociatedDiaObjects=0,
longTrailedSources=trailedSources)
longTrailedSources=longTrailedSources)

matchResult = self.associate_sources(diaObjects, diaSources)

Expand All @@ -146,7 +149,7 @@ def run(self,
unAssocDiaSources=matchResult.diaSources[~mask].reset_index(drop=True),
nUpdatedDiaObjects=matchResult.nUpdatedDiaObjects,
nUnassociatedDiaObjects=matchResult.nUnassociatedDiaObjects,
longTrailedSources=trailedSources)
longTrailedSources=longTrailedSources)

def check_dia_source_radec(self, dia_sources):
"""Check that all DiaSources have non-NaN values for RA/DEC.
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/ap/association/trailedSourceFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def run(self, dia_sources, exposure_time):
result : `lsst.pipe.base.Struct`
Results struct with components.
- ``dia_sources`` : DIASource table that is free from unwanted
- ``diaSources`` : DIASource table that is free from unwanted
trailed sources. (`pandas.DataFrame`)
- ``trailed_dia_sources`` : DIASources that have trails which
- ``longTrailedDiaSources`` : DIASources that have trails which
exceed max_trail_length/second*exposure_time.
(`pandas.DataFrame`)
"""
Expand All @@ -93,13 +93,13 @@ def run(self, dia_sources, exposure_time):

return pipeBase.Struct(
diaSources=dia_sources[~trail_mask].reset_index(drop=True),
trailedDiaSources=dia_sources[trail_mask].reset_index(drop=True))
longTrailedDiaSources=dia_sources[trail_mask].reset_index(drop=True))

def _check_dia_source_trail(self, dia_sources, exposure_time, flags):
"""Find DiaSources that have long trails.
Return a mask of sources with lengths greater than
``config.max_trail_length`` multiplied by the exposure time and
``config.max_trail_length`` multiplied by the exposure time or
have ext_trailedSources_Naive_flag_edge set.
Parameters
Expand Down
18 changes: 9 additions & 9 deletions tests/test_trailedSourceFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,21 @@ def test_check_dia_source_trail(self):
flag_map = os.path.join(utils.getPackageDir("ap_association"), "data/association-flag-map.yaml")
unpacker = UnpackApdbFlags(flag_map, "DiaSource")
flags = unpacker.unpack(self.diaSources["flags"], "flags")
mask = trailedSourceFilterTask._check_dia_source_trail(self.diaSources, self.exposure_time,
flags)
trailed_source_mask = trailedSourceFilterTask._check_dia_source_trail(self.diaSources,
self.exposure_time, flags)

np.testing.assert_array_equal(mask, [False, False, False, True, True])
np.testing.assert_array_equal(trailed_source_mask, [False, False, False, True, True])

flags = unpacker.unpack(self.edgeDiaSources["flags"], "flags")
mask = trailedSourceFilterTask._check_dia_source_trail(self.edgeDiaSources, self.exposure_time,
flags)
np.testing.assert_array_equal(mask, [False, True, False, False, True])
trailed_source_mask = trailedSourceFilterTask._check_dia_source_trail(self.edgeDiaSources,
self.exposure_time, flags)
np.testing.assert_array_equal(trailed_source_mask, [False, True, False, False, True])

# Mixing the flags from edgeDiaSources and diaSources means the mask
# will be set using both criteria.
mask = trailedSourceFilterTask._check_dia_source_trail(self.diaSources, self.exposure_time,
flags)
np.testing.assert_array_equal(mask, [False, True, False, True, True])
trailed_source_mask = trailedSourceFilterTask._check_dia_source_trail(self.diaSources,
self.exposure_time, flags)
np.testing.assert_array_equal(trailed_source_mask, [False, True, False, True, True])


class MemoryTester(lsst.utils.tests.MemoryTestCase):
Expand Down

0 comments on commit 76a5454

Please sign in to comment.