-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make trailedAssociatorTask which filters out trails whose lengths are above 0.416 arcseconds/second in length. Update unit test Update Docstrings
- Loading branch information
1 parent
e97dcde
commit 56c586d
Showing
6 changed files
with
215 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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 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/>. | ||
|
||
"""A simple implementation of source association task for ap_verify. | ||
""" | ||
|
||
__all__ = ["TrailedSourceFilterTask", "TrailedSourceFilterConfig"] | ||
|
||
import lsst.pex.config as pexConfig | ||
import lsst.pipe.base as pipeBase | ||
from lsst.utils.timer import timeMethod | ||
|
||
# import numpy as np | ||
import pandas as pd | ||
|
||
# Enforce an error for unsafe column/array value setting in pandas. | ||
pd.options.mode.chained_assignment = 'raise' | ||
|
||
|
||
class TrailedSourceFilterConfig(pexConfig.Config): | ||
"""Config class for TrailedSourceFilterTask. | ||
""" | ||
maxTrailLength = pexConfig.Field( | ||
dtype=float, | ||
doc='Maximum trail length permitted is less than 10 degrees/day. This is a rate ' | ||
'of 0.416 arcseconds per second.As trail length is measured in ' | ||
'arcseconds, it is dependant on the length of the exposure.', | ||
default=0.416, # HSC Default. Should Decam and LSST defaults be passed? Does it change possibly? | ||
) | ||
|
||
|
||
class TrailedSourceFilterTask(pipeBase.Task): | ||
"""Find trailed sources in DIAObjects. | ||
""" | ||
|
||
ConfigClass = TrailedSourceFilterConfig | ||
_DefaultName = "trailedAssociation" | ||
|
||
@timeMethod | ||
def run(self, | ||
dia_sources, exposure): | ||
"""Find trailed sources which have not been filtered out and will | ||
not be included in the diaSource catalog. | ||
Parameters | ||
---------- | ||
dia_sources : `pandas.DataFrame` | ||
New DIASources to be checked for trailed sources. | ||
exposure : `pandas.DataFrame` | ||
Calibrated exposure differenced with a template image during | ||
image differencing. | ||
Returns | ||
------- | ||
result : `lsst.pipe.base.Struct` | ||
Results struct with components. | ||
- ``"dia_sources"`` : DiaSource table that is free from unwanted | ||
trailed sources (`pandas.DataFrame`) | ||
- ``"trailed_dia_sources"`` : DiaSources that have trailed more than | ||
0.416 arcseconds/second*exposure_time(`pandas.DataFrame`) | ||
""" | ||
trail_mask = self.check_dia_source_trail(dia_sources, exposure) | ||
|
||
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): | ||
"""Check that all DiaSources have trails. | ||
Creates a mask for sources with lengths greater than 0.416 arcseconds/second*exposure time. | ||
Parameters | ||
---------- | ||
dia_sources : `pandas.DataFrame` | ||
Input DiaSources to check for trail lengths. | ||
exposure : `pandas.DataFrame` | ||
Calibrated exposure differenced with a template image during | ||
image differencing. | ||
Returns | ||
------- | ||
trail_mask : `pandas.DataFrame` | ||
Boolean mask for dia_sources which are greater than the cuttoff length. | ||
""" | ||
exposure_time = exposure.getInfo().getVisitInfo().getExposureTime() | ||
trail_mask = (dia_sources.loc[:, "trailLength"].values[:] >= self.config.maxTrailLength*exposure_time) | ||
|
||
return trail_mask |
This file contains 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 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