Skip to content

Commit a907931

Browse files
committed
Review edits
flake8
1 parent 20baae2 commit a907931

File tree

4 files changed

+37
-19
lines changed

4 files changed

+37
-19
lines changed

python/lsst/ap/association/association.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ def run(self,
125125
diaTrailedResult = self.trailedSourceFilter.run(diaSources, exposure_time)
126126
matchResult = self.associate_sources(diaObjects, diaTrailedResult.diaSources)
127127

128-
self.log.warning("%i DIASources exceed maxTrailLength, dropping "
129-
"from source catalog."
130-
% len(diaTrailedResult.trailedDiaSources))
128+
self.log.info("%i DIASources exceed max_trail_length, dropping "
129+
"from source catalog." % len(diaTrailedResult.trailedDiaSources))
131130

132131
else:
133132
matchResult = self.associate_sources(diaObjects, diaSources)

python/lsst/ap/association/diaPipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def run(self,
368368

369369
# Associate new DiaSources with existing DiaObjects.
370370
assocResults = self.associator.run(diaSourceTable, loaderResult.diaObjects,
371-
exposure_time=diffIm.getInfo().getVisitInfo().getExposureTime())
371+
exposure_time=diffIm.visitInfo.exposureTime)
372372
if self.config.doSolarSystemAssociation:
373373
ssoAssocResult = self.solarSystemAssociator.run(
374374
assocResults.unAssocDiaSources,

python/lsst/ap/association/trailedSourceFilter.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class TrailedSourceFilterConfig(pexConfig.Config):
3030
"""Config class for TrailedSourceFilterTask.
3131
"""
3232

33-
maxTrailLength = pexConfig.Field(
33+
max_trail_length = pexConfig.Field(
3434
dtype=float,
3535
doc="Length of long trailed sources to remove from the input catalog, "
3636
"in arcseconds per second. Default comes from DMTN-199, which "
3737
"requires removal of sources with trails longer than 10 "
38-
"degrees/day, which is 36000/3600/24arcsec/second, or roughly"
38+
"degrees/day, which is 36000/3600/24 arcsec/second, or roughly"
3939
"0.416 arcseconds per second.",
4040
default=36000/3600.0/24.0,
4141
)
@@ -46,9 +46,9 @@ class TrailedSourceFilterTask(pipeBase.Task):
4646
guidelines.
4747
4848
This task checks the length of trailLength in the DIASource catalog using
49-
a given arcsecond/second rate from maxTrailLength and the exposure time.
49+
a given arcsecond/second rate from max_trail_length and the exposure time.
5050
The two values are used to calculate the maximum allowed trail length and
51-
filters out any trail longer than the maximum. The maxTrailLength is
51+
filters out any trail longer than the maximum. The max_trail_length is
5252
outlined in DMTN-199 and determines the default value.
5353
"""
5454

@@ -57,7 +57,7 @@ class TrailedSourceFilterTask(pipeBase.Task):
5757

5858
@timeMethod
5959
def run(self, dia_sources, exposure_time):
60-
"""Remove trailed sources longer than ``config.maxTrailLength`` from
60+
"""Remove trailed sources longer than ``config.max_trail_length`` from
6161
the input catalog.
6262
6363
Parameters
@@ -76,10 +76,9 @@ def run(self, dia_sources, exposure_time):
7676
trailed sources. (`pandas.DataFrame`)
7777
7878
- ``trailed_dia_sources`` : DIASources that have trails which
79-
exceed maxTrailLength/second*exposure_time.
79+
exceed max_trail_length/second*exposure_time.
8080
(`pandas.DataFrame`)
8181
"""
82-
8382
trail_mask = self._check_dia_source_trail(dia_sources, exposure_time)
8483

8584
return pipeBase.Struct(
@@ -89,8 +88,8 @@ def run(self, dia_sources, exposure_time):
8988
def _check_dia_source_trail(self, dia_sources, exposure_time):
9089
"""Find DiaSources that have long trails.
9190
92-
Creates a mask for sources with lengths greater than 0.416
93-
arcseconds/second multiplied by the exposure time.
91+
Return a mask of sources with lengths greater than
92+
``config.max_trail_length`` multiplied by the exposure time.
9493
9594
Parameters
9695
----------
@@ -105,8 +104,7 @@ def _check_dia_source_trail(self, dia_sources, exposure_time):
105104
Boolean mask for DIASources which are greater than the
106105
cutoff length.
107106
"""
108-
109107
trail_mask = (dia_sources.loc[:, "trailLength"].values[:]
110-
>= (self.config.maxTrailLength*exposure_time))
108+
>= (self.config.max_trail_length*exposure_time))
111109

112110
return trail_mask

tests/test_trailedSourceFilter.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# This file is part of ap_association.
2+
#
3+
# Developed for the LSST Data Management System.
4+
# This product includes software developed by the LSST Project
5+
# (https://www.lsst.org).
6+
# See the COPYRIGHT file at the top-level directory of this distribution
7+
# for details of code ownership.
8+
#
9+
# This program is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
122
import unittest
223
from lsst.ap.association import TrailedSourceFilterTask
324
import numpy as np
@@ -40,13 +61,13 @@ def test_run(self):
4061
def test_run_short_max_trail(self):
4162
"""Run trailedSourceFilterTask with aggressive trail length cutoff
4263
43-
With a maxTrailLength config of 0.01 arcseconds/second and an
64+
With a max_trail_length config of 0.01 arcseconds/second and an
4465
exposure of 30 seconds,the max trail length is 0.3 arcseconds. Only the
4566
source with a trail of 0 stays in the catalog and the rest are filtered
4667
out and put into results.trailedSources.
4768
"""
4869
config = TrailedSourceFilterTask.ConfigClass()
49-
config.maxTrailLength = 0.01
70+
config.max_trail_length = 0.01
5071
trailedSourceFilterTask = TrailedSourceFilterTask(config=config)
5172
results = trailedSourceFilterTask.run(self.diaSources, self.exposure_time)
5273

@@ -58,13 +79,13 @@ def test_run_no_trails(self):
5879
"""Run trailedSourceFilterTask with a long trail length so that
5980
every source in the catalog is in the final diaSource catalog.
6081
61-
With a maxTrailLength config of 10 arcseconds/second and an
82+
With a max_trail_length config of 10 arcseconds/second and an
6283
exposure of 30 seconds,the max trail length is 300 arcseconds. All
6384
sources in the initial catalog should be in the final diaSource
6485
catalog.
6586
"""
6687
config = TrailedSourceFilterTask.ConfigClass()
67-
config.maxTrailLength = 10.00
88+
config.max_trail_length = 10.00
6889
trailedSourceFilterTask = TrailedSourceFilterTask(config=config)
6990
results = trailedSourceFilterTask.run(self.diaSources, self.exposure_time)
7091

0 commit comments

Comments
 (0)