From 76a54540a5f6cbfdc1d81f7c2bedd3a19605ea79 Mon Sep 17 00:00:00 2001 From: Brianna Smart Date: Fri, 20 Oct 2023 15:48:23 -0700 Subject: [PATCH] Review comment updates --- python/lsst/ap/association/association.py | 17 ++++++++++------- .../lsst/ap/association/trailedSourceFilter.py | 8 ++++---- tests/test_trailedSourceFilter.py | 18 +++++++++--------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/python/lsst/ap/association/association.py b/python/lsst/ap/association/association.py index a1db5118..d100fa48 100644 --- a/python/lsst/ap/association/association.py +++ b/python/lsst/ap/association/association.py @@ -112,6 +112,9 @@ 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) @@ -119,15 +122,15 @@ def run(self, 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 " + "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( @@ -135,7 +138,7 @@ def run(self, unAssocDiaSources=diaSources, nUpdatedDiaObjects=0, nUnassociatedDiaObjects=0, - longTrailedSources=trailedSources) + longTrailedSources=longTrailedSources) matchResult = self.associate_sources(diaObjects, diaSources) @@ -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. diff --git a/python/lsst/ap/association/trailedSourceFilter.py b/python/lsst/ap/association/trailedSourceFilter.py index 5bc19c74..a3e00e60 100644 --- a/python/lsst/ap/association/trailedSourceFilter.py +++ b/python/lsst/ap/association/trailedSourceFilter.py @@ -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`) """ @@ -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 diff --git a/tests/test_trailedSourceFilter.py b/tests/test_trailedSourceFilter.py index 96bfc318..0f13bd97 100644 --- a/tests/test_trailedSourceFilter.py +++ b/tests/test_trailedSourceFilter.py @@ -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):