Skip to content

Commit

Permalink
Align Struct doc strings with developer guide
Browse files Browse the repository at this point in the history
Plus several edits from review
  • Loading branch information
bsmartradio committed Sep 28, 2023
1 parent 58a77e4 commit a5f9b31
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 51 deletions.
25 changes: 12 additions & 13 deletions python/lsst/ap/association/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ def run(self,
result : `lsst.pipe.base.Struct`
Results struct with components.
- ``"matchedDiaSources"`` : DiaSources that were matched. Matched
- ``matchedDiaSources`` : DiaSources that were matched. Matched
Sources have their diaObjectId updated and set to the id of the
diaObject they were matched to. (`pandas.DataFrame`)
- ``"unAssocDiaSources"`` : DiaSources that were not matched.
- ``unAssocDiaSources`` : DiaSources that were not matched.
Unassociated sources have their diaObject set to 0 as they
were not associated with any existing DiaObjects.
(`pandas.DataFrame`)
- ``"nUpdatedDiaObjects"`` : Number of DiaObjects that were
- ``nUpdatedDiaObjects`` : Number of DiaObjects that were
matched to new DiaSources. (`int`)
- ``"nUnassociatedDiaObjects"`` : Number of DiaObjects that were
- ``nUnassociatedDiaObjects`` : Number of DiaObjects that were
not matched a new DiaSource. (`int`)
"""
diaSources = self.check_dia_source_radec(diaSources)
Expand All @@ -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 Expand Up @@ -189,11 +188,11 @@ def associate_sources(self, dia_objects, dia_sources):
result : `lsst.pipe.base.Struct`
Results struct with components.
- ``"diaSources"`` : Full set of diaSources both matched and not.
- ``diaSources`` : Full set of diaSources both matched and not.
(`pandas.DataFrame`)
- ``"nUpdatedDiaObjects"`` : Number of DiaObjects that were
- ``nUpdatedDiaObjects`` : Number of DiaObjects that were
associated. (`int`)
- ``"nUnassociatedDiaObjects"`` : Number of DiaObjects that were
- ``nUnassociatedDiaObjects`` : Number of DiaObjects that were
not matched a new DiaSource. (`int`)
"""
scores = self.score(
Expand Down Expand Up @@ -228,11 +227,11 @@ def score(self, dia_objects, dia_sources, max_dist):
result : `lsst.pipe.base.Struct`
Results struct with components:
- ``"scores"``: array of floats of match quality updated DIAObjects
- ``scores``: array of floats of match quality updated DIAObjects
(array-like of `float`).
- ``"obj_idxs"``: indexes of the matched DIAObjects in the catalog.
- ``obj_idxs``: indexes of the matched DIAObjects in the catalog.
(array-like of `int`)
- ``"obj_ids"``: array of floats of match quality updated DIAObjects
- ``obj_ids``: array of floats of match quality updated DIAObjects
(array-like of `int`).
Default values for these arrays are
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
8 changes: 4 additions & 4 deletions python/lsst/ap/association/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ def makeMeasurement(self, values):
A `dict` representation of the metadata. Each `dict` has the
following keys:
``"updatedObjects"``
``updatedObjects``
The number of DIAObjects updated for this image (`int` or
`None`). May be `None` if the image was not
successfully associated.
``"unassociatedObjects"``
``unassociatedObjects``
The number of DIAObjects not associated with a DiaSource in
this image (`int` or `None`). May be `None` if the image was
not successfully associated.
Expand Down Expand Up @@ -216,7 +216,7 @@ def makeMeasurement(self, values):
A `dict` representation of the metadata. Each `dict` has the
following key:
``"numTotalSolarSystemObjects"``
``numTotalSolarSystemObjects``
The number of SolarSystemObjects within the observable detector
area (`int` or `None`). May be `None` if solar system
association was not attempted or the image was not
Expand Down Expand Up @@ -264,7 +264,7 @@ def makeMeasurement(self, values):
A `dict` representation of the metadata. Each `dict` has the
following key:
``"numAssociatedSsObjects"``
``numAssociatedSsObjects``
The number of successfully associated SolarSystem Objects
(`int` or `None`). May be `None` if solar system association
was not attempted or the image was not successfully associated.
Expand Down
36 changes: 18 additions & 18 deletions python/lsst/ap/association/skyBotEphemerisQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,43 +126,43 @@ def run(self, visitInfos, visit):
details see
https://ssp.imcce.fr/webservices/skybot/api/conesearch/#output-results
``"Num"``
``Num``
object number (`int`, optional)
``"Name"``
``Name``
object name (`str`)
``"RA(h)"``
``RA(h)``
RA in HMS (`str`)
``"DE(deg)"``
``DE(deg)``
DEC in DMS (`str`)
``"Class"``
``Class``
Minor planet classification (`str`)
``"Mv"``
``Mv``
visual magnitude (`float`)
``"Err(arcsec)"``
``Err(arcsec)``
position error (`float`)
``"d(arcsec)"``
``d(arcsec)``
distance from exposure boresight (`float`)?
``"dRA(arcsec/h)"``
``dRA(arcsec/h)``
proper motion in RA (`float`)
``"dDEC(arcsec/h)"``
``dDEC(arcsec/h)``
proper motion in DEC (`float`)
``"Dg(ua)"``
``Dg(ua)``
geocentric distance (`float`)
``"Dh(ua)"``
``Dh(ua)``
heliocentric distance (`float`)
``"Phase(deg)"``
``Phase(deg)``
phase angle (`float`)
``"SunElong(deg)"``
``SunElong(deg)``
solar elongation (`float`)
``"ra"``
``ra``
RA in decimal degrees (`float`)
``"dec"``
``dec``
DEC in decimal degrees (`float`)
``"ssObjectId"``
``ssObjectId``
unique minor planet ID for internal use (`int`). Shared
across catalogs; the pair ``(ssObjectId, visitId)`` is
globally unique.
``"visitId"``
``visitId``
a copy of ``visit`` (`int`)
"""
# Grab the visitInfo from the raw to get the information needed on the
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 a5f9b31

Please sign in to comment.