From 5f3e4081b7214a648f33aafcd019ebfb0ac352ce Mon Sep 17 00:00:00 2001 From: Brianna Smart Date: Tue, 26 Sep 2023 16:37:57 -0700 Subject: [PATCH] Review edits --- python/lsst/ap/association/association.py | 2 +- python/lsst/ap/association/diaPipe.py | 2 +- .../ap/association/trailedSourceFilter.py | 20 ++++++------- tests/test_trailedSourceFilter.py | 29 ++++++++++++++++--- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/python/lsst/ap/association/association.py b/python/lsst/ap/association/association.py index 797b3476..cb7e7c83 100644 --- a/python/lsst/ap/association/association.py +++ b/python/lsst/ap/association/association.py @@ -125,7 +125,7 @@ def run(self, diaTrailedResult = self.trailedSourceFilter.run(diaSources, exposure_time) matchResult = self.associate_sources(diaObjects, diaTrailedResult.diaSources) - self.log.warning("%i DIASources exceed maxTrailLength, dropping " + self.log.info("%i DIASources exceed max_trail_length, dropping " "from source catalog." % len(diaTrailedResult.trailedDiaSources)) diff --git a/python/lsst/ap/association/diaPipe.py b/python/lsst/ap/association/diaPipe.py index 92bd31f7..30409eee 100644 --- a/python/lsst/ap/association/diaPipe.py +++ b/python/lsst/ap/association/diaPipe.py @@ -368,7 +368,7 @@ def run(self, # Associate new DiaSources with existing DiaObjects. assocResults = self.associator.run(diaSourceTable, loaderResult.diaObjects, - exposure_time=diffIm.getInfo().getVisitInfo().getExposureTime()) + exposure_time=diffIm.visitInfo.exposureTime) if self.config.doSolarSystemAssociation: ssoAssocResult = self.solarSystemAssociator.run( assocResults.unAssocDiaSources, diff --git a/python/lsst/ap/association/trailedSourceFilter.py b/python/lsst/ap/association/trailedSourceFilter.py index f05afda4..6eb20920 100644 --- a/python/lsst/ap/association/trailedSourceFilter.py +++ b/python/lsst/ap/association/trailedSourceFilter.py @@ -30,12 +30,12 @@ class TrailedSourceFilterConfig(pexConfig.Config): """Config class for TrailedSourceFilterTask. """ - maxTrailLength = pexConfig.Field( + max_trail_length = pexConfig.Field( dtype=float, doc="Length of long trailed sources to remove from the input catalog, " "in arcseconds per second. Default comes from DMTN-199, which " "requires removal of sources with trails longer than 10 " - "degrees/day, which is 36000/3600/24arcsec/second, or roughly" + "degrees/day, which is 36000/3600/24 arcsec/second, or roughly" "0.416 arcseconds per second.", default=36000/3600.0/24.0, ) @@ -46,9 +46,9 @@ class TrailedSourceFilterTask(pipeBase.Task): guidelines. This task checks the length of trailLength in the DIASource catalog using - a given arcsecond/second rate from maxTrailLength and the exposure time. + a given arcsecond/second rate from max_trail_length and the exposure time. The two values are used to calculate the maximum allowed trail length and - filters out any trail longer than the maximum. The maxTrailLength is + filters out any trail longer than the maximum. The max_trail_length is outlined in DMTN-199 and determines the default value. """ @@ -57,7 +57,7 @@ class TrailedSourceFilterTask(pipeBase.Task): @timeMethod def run(self, dia_sources, exposure_time): - """Remove trailed sources longer than ``config.maxTrailLength`` from + """Remove trailed sources longer than ``config.max_trail_length`` from the input catalog. Parameters @@ -76,10 +76,9 @@ def run(self, dia_sources, exposure_time): trailed sources. (`pandas.DataFrame`) - ``trailed_dia_sources`` : DIASources that have trails which - exceed maxTrailLength/second*exposure_time. + exceed max_trail_length/second*exposure_time. (`pandas.DataFrame`) """ - trail_mask = self._check_dia_source_trail(dia_sources, exposure_time) return pipeBase.Struct( @@ -89,8 +88,8 @@ def run(self, dia_sources, exposure_time): def _check_dia_source_trail(self, dia_sources, exposure_time): """Find DiaSources that have long trails. - Creates a mask for sources with lengths greater than 0.416 - arcseconds/second multiplied by the exposure time. + Return a mask of sources with lengths greater than + ``config.max_trail_length`` multiplied by the exposure time. Parameters ---------- @@ -105,8 +104,7 @@ def _check_dia_source_trail(self, dia_sources, exposure_time): Boolean mask for DIASources which are greater than the cutoff length. """ - trail_mask = (dia_sources.loc[:, "trailLength"].values[:] - >= (self.config.maxTrailLength*exposure_time)) + >= (self.config.max_trail_length*exposure_time)) return trail_mask diff --git a/tests/test_trailedSourceFilter.py b/tests/test_trailedSourceFilter.py index 35b6205f..62b6e7e0 100644 --- a/tests/test_trailedSourceFilter.py +++ b/tests/test_trailedSourceFilter.py @@ -1,3 +1,24 @@ +# This file is part of ap_association. +# +# Developed for the LSST Data Management System. +# This product includes software developed by the LSST Project +# (https://www.lsst.org). +# See the COPYRIGHT file at the top-level directory of this distribution +# for details of code ownership. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + import unittest from lsst.ap.association import TrailedSourceFilterTask import numpy as np @@ -40,13 +61,13 @@ def test_run(self): def test_run_short_max_trail(self): """Run trailedSourceFilterTask with aggressive trail length cutoff - With a maxTrailLength config of 0.01 arcseconds/second and an + With a max_trail_length config of 0.01 arcseconds/second and an exposure of 30 seconds,the max trail length is 0.3 arcseconds. Only the source with a trail of 0 stays in the catalog and the rest are filtered out and put into results.trailedSources. """ config = TrailedSourceFilterTask.ConfigClass() - config.maxTrailLength = 0.01 + config.max_trail_length = 0.01 trailedSourceFilterTask = TrailedSourceFilterTask(config=config) results = trailedSourceFilterTask.run(self.diaSources, self.exposure_time) @@ -58,13 +79,13 @@ def test_run_no_trails(self): """Run trailedSourceFilterTask with a long trail length so that every source in the catalog is in the final diaSource catalog. - With a maxTrailLength config of 10 arcseconds/second and an + With a max_trail_length config of 10 arcseconds/second and an exposure of 30 seconds,the max trail length is 300 arcseconds. All sources in the initial catalog should be in the final diaSource catalog. """ config = TrailedSourceFilterTask.ConfigClass() - config.maxTrailLength = 10.00 + config.max_trail_length = 10.00 trailedSourceFilterTask = TrailedSourceFilterTask(config=config) results = trailedSourceFilterTask.run(self.diaSources, self.exposure_time)