Skip to content

Commit a5f9b31

Browse files
committed
Align Struct doc strings with developer guide
Plus several edits from review
1 parent 58a77e4 commit a5f9b31

File tree

6 files changed

+69
-51
lines changed

6 files changed

+69
-51
lines changed

python/lsst/ap/association/association.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@ def run(self,
101101
result : `lsst.pipe.base.Struct`
102102
Results struct with components.
103103
104-
- ``"matchedDiaSources"`` : DiaSources that were matched. Matched
104+
- ``matchedDiaSources`` : DiaSources that were matched. Matched
105105
Sources have their diaObjectId updated and set to the id of the
106106
diaObject they were matched to. (`pandas.DataFrame`)
107-
- ``"unAssocDiaSources"`` : DiaSources that were not matched.
107+
- ``unAssocDiaSources`` : DiaSources that were not matched.
108108
Unassociated sources have their diaObject set to 0 as they
109109
were not associated with any existing DiaObjects.
110110
(`pandas.DataFrame`)
111-
- ``"nUpdatedDiaObjects"`` : Number of DiaObjects that were
111+
- ``nUpdatedDiaObjects`` : Number of DiaObjects that were
112112
matched to new DiaSources. (`int`)
113-
- ``"nUnassociatedDiaObjects"`` : Number of DiaObjects that were
113+
- ``nUnassociatedDiaObjects`` : Number of DiaObjects that were
114114
not matched a new DiaSource. (`int`)
115115
"""
116116
diaSources = self.check_dia_source_radec(diaSources)
@@ -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)
@@ -189,11 +188,11 @@ def associate_sources(self, dia_objects, dia_sources):
189188
result : `lsst.pipe.base.Struct`
190189
Results struct with components.
191190
192-
- ``"diaSources"`` : Full set of diaSources both matched and not.
191+
- ``diaSources`` : Full set of diaSources both matched and not.
193192
(`pandas.DataFrame`)
194-
- ``"nUpdatedDiaObjects"`` : Number of DiaObjects that were
193+
- ``nUpdatedDiaObjects`` : Number of DiaObjects that were
195194
associated. (`int`)
196-
- ``"nUnassociatedDiaObjects"`` : Number of DiaObjects that were
195+
- ``nUnassociatedDiaObjects`` : Number of DiaObjects that were
197196
not matched a new DiaSource. (`int`)
198197
"""
199198
scores = self.score(
@@ -228,11 +227,11 @@ def score(self, dia_objects, dia_sources, max_dist):
228227
result : `lsst.pipe.base.Struct`
229228
Results struct with components:
230229
231-
- ``"scores"``: array of floats of match quality updated DIAObjects
230+
- ``scores``: array of floats of match quality updated DIAObjects
232231
(array-like of `float`).
233-
- ``"obj_idxs"``: indexes of the matched DIAObjects in the catalog.
232+
- ``obj_idxs``: indexes of the matched DIAObjects in the catalog.
234233
(array-like of `int`)
235-
- ``"obj_ids"``: array of floats of match quality updated DIAObjects
234+
- ``obj_ids``: array of floats of match quality updated DIAObjects
236235
(array-like of `int`).
237236
238237
Default values for these arrays are

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/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ def makeMeasurement(self, values):
156156
A `dict` representation of the metadata. Each `dict` has the
157157
following keys:
158158
159-
``"updatedObjects"``
159+
``updatedObjects``
160160
The number of DIAObjects updated for this image (`int` or
161161
`None`). May be `None` if the image was not
162162
successfully associated.
163-
``"unassociatedObjects"``
163+
``unassociatedObjects``
164164
The number of DIAObjects not associated with a DiaSource in
165165
this image (`int` or `None`). May be `None` if the image was
166166
not successfully associated.
@@ -216,7 +216,7 @@ def makeMeasurement(self, values):
216216
A `dict` representation of the metadata. Each `dict` has the
217217
following key:
218218
219-
``"numTotalSolarSystemObjects"``
219+
``numTotalSolarSystemObjects``
220220
The number of SolarSystemObjects within the observable detector
221221
area (`int` or `None`). May be `None` if solar system
222222
association was not attempted or the image was not
@@ -264,7 +264,7 @@ def makeMeasurement(self, values):
264264
A `dict` representation of the metadata. Each `dict` has the
265265
following key:
266266
267-
``"numAssociatedSsObjects"``
267+
``numAssociatedSsObjects``
268268
The number of successfully associated SolarSystem Objects
269269
(`int` or `None`). May be `None` if solar system association
270270
was not attempted or the image was not successfully associated.

python/lsst/ap/association/skyBotEphemerisQuery.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,43 +126,43 @@ def run(self, visitInfos, visit):
126126
details see
127127
https://ssp.imcce.fr/webservices/skybot/api/conesearch/#output-results
128128
129-
``"Num"``
129+
``Num``
130130
object number (`int`, optional)
131-
``"Name"``
131+
``Name``
132132
object name (`str`)
133-
``"RA(h)"``
133+
``RA(h)``
134134
RA in HMS (`str`)
135-
``"DE(deg)"``
135+
``DE(deg)``
136136
DEC in DMS (`str`)
137-
``"Class"``
137+
``Class``
138138
Minor planet classification (`str`)
139-
``"Mv"``
139+
``Mv``
140140
visual magnitude (`float`)
141-
``"Err(arcsec)"``
141+
``Err(arcsec)``
142142
position error (`float`)
143-
``"d(arcsec)"``
143+
``d(arcsec)``
144144
distance from exposure boresight (`float`)?
145-
``"dRA(arcsec/h)"``
145+
``dRA(arcsec/h)``
146146
proper motion in RA (`float`)
147-
``"dDEC(arcsec/h)"``
147+
``dDEC(arcsec/h)``
148148
proper motion in DEC (`float`)
149-
``"Dg(ua)"``
149+
``Dg(ua)``
150150
geocentric distance (`float`)
151-
``"Dh(ua)"``
151+
``Dh(ua)``
152152
heliocentric distance (`float`)
153-
``"Phase(deg)"``
153+
``Phase(deg)``
154154
phase angle (`float`)
155-
``"SunElong(deg)"``
155+
``SunElong(deg)``
156156
solar elongation (`float`)
157-
``"ra"``
157+
``ra``
158158
RA in decimal degrees (`float`)
159-
``"dec"``
159+
``dec``
160160
DEC in decimal degrees (`float`)
161-
``"ssObjectId"``
161+
``ssObjectId``
162162
unique minor planet ID for internal use (`int`). Shared
163163
across catalogs; the pair ``(ssObjectId, visitId)`` is
164164
globally unique.
165-
``"visitId"``
165+
``visitId``
166166
a copy of ``visit`` (`int`)
167167
"""
168168
# Grab the visitInfo from the raw to get the information needed on the

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)