-
Notifications
You must be signed in to change notification settings - Fork 3
DM-38850: Make trailedAssociatorTask #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,110 @@ | ||||||||
# 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/>. | ||||||||
|
||||||||
__all__ = ("TrailedSourceFilterTask", "TrailedSourceFilterConfig") | ||||||||
|
||||||||
import lsst.pex.config as pexConfig | ||||||||
import lsst.pipe.base as pipeBase | ||||||||
from lsst.utils.timer import timeMethod | ||||||||
|
||||||||
|
||||||||
class TrailedSourceFilterConfig(pexConfig.Config): | ||||||||
"""Config class for TrailedSourceFilterTask. | ||||||||
""" | ||||||||
|
||||||||
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/24 arcsec/second, or roughly" | ||||||||
"0.416 arcseconds per second.", | ||||||||
default=36000/3600.0/24.0, | ||||||||
) | ||||||||
|
||||||||
|
||||||||
class TrailedSourceFilterTask(pipeBase.Task): | ||||||||
"""Find trailed sources in DIASources and filter them as per DMTN-199 | ||||||||
guidelines. | ||||||||
|
||||||||
This task checks the length of trailLength in the DIASource catalog using | ||||||||
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 max_trail_length is | ||||||||
outlined in DMTN-199 and determines the default value. | ||||||||
""" | ||||||||
|
||||||||
ConfigClass = TrailedSourceFilterConfig | ||||||||
_DefaultName = "trailedSourceFilter" | ||||||||
|
||||||||
@timeMethod | ||||||||
def run(self, dia_sources, exposure_time): | ||||||||
"""Remove trailed sources longer than ``config.max_trail_length`` from | ||||||||
the input catalog. | ||||||||
|
||||||||
Parameters | ||||||||
---------- | ||||||||
dia_sources : `pandas.DataFrame` | ||||||||
New DIASources to be checked for trailed sources. | ||||||||
exposure_time : `float` | ||||||||
Exposure time from difference image. | ||||||||
|
||||||||
Returns | ||||||||
------- | ||||||||
result : `lsst.pipe.base.Struct` | ||||||||
Results struct with components. | ||||||||
|
||||||||
- ``dia_sources`` : DIASource table that is free from unwanted | ||||||||
trailed sources. (`pandas.DataFrame`) | ||||||||
Comment on lines
+75
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no newline here |
||||||||
- ``trailed_dia_sources`` : DIASources that have trails which | ||||||||
exceed max_trail_length/second*exposure_time. | ||||||||
(`pandas.DataFrame`) | ||||||||
""" | ||||||||
trail_mask = self._check_dia_source_trail(dia_sources, exposure_time) | ||||||||
|
||||||||
return pipeBase.Struct( | ||||||||
diaSources=dia_sources[~trail_mask].reset_index(drop=True), | ||||||||
trailedDiaSources=dia_sources[trail_mask].reset_index(drop=True)) | ||||||||
|
||||||||
def _check_dia_source_trail(self, dia_sources, exposure_time): | ||||||||
"""Find DiaSources that have long trails. | ||||||||
|
||||||||
Return a mask of sources with lengths greater than | ||||||||
``config.max_trail_length`` multiplied by the exposure time. | ||||||||
|
||||||||
Parameters | ||||||||
---------- | ||||||||
dia_sources : `pandas.DataFrame` | ||||||||
Input DIASources to check for trail lengths. | ||||||||
exposure_time : `float` | ||||||||
Exposure time from difference image. | ||||||||
|
||||||||
Returns | ||||||||
------- | ||||||||
trail_mask : `pandas.DataFrame` | ||||||||
Boolean mask for DIASources which are greater than the | ||||||||
cutoff length. | ||||||||
""" | ||||||||
trail_mask = (dia_sources.loc[:, "trailLength"].values[:] | ||||||||
>= (self.config.max_trail_length*exposure_time)) | ||||||||
|
||||||||
return trail_mask |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.