Skip to content

Commit

Permalink
Review edits
Browse files Browse the repository at this point in the history
flake8
  • Loading branch information
bsmartradio committed Sep 26, 2023
1 parent 20baae2 commit a907931
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
5 changes: 2 additions & 3 deletions python/lsst/ap/association/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ 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 "
"from source catalog."
% len(diaTrailedResult.trailedDiaSources))
self.log.info("%i DIASources exceed max_trail_length, dropping "
"from source catalog." % len(diaTrailedResult.trailedDiaSources))

else:
matchResult = self.associate_sources(diaObjects, diaSources)
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 9 additions & 11 deletions python/lsst/ap/association/trailedSourceFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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.
"""

Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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
----------
Expand All @@ -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
29 changes: 25 additions & 4 deletions tests/test_trailedSourceFilter.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

import unittest
from lsst.ap.association import TrailedSourceFilterTask
import numpy as np
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit a907931

Please sign in to comment.