-
Notifications
You must be signed in to change notification settings - Fork 2
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
DM-36238: Create AP Number of Dipoles and Number of DIA Sources metrics in analysis_tools. #34
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
72 changes: 72 additions & 0 deletions
72
python/lsst/analysis/tools/analysisMetrics/apDiaSourceMetrics.py
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,72 @@ | ||
# This file is part of analysis_tools. | ||
# | ||
# 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/>. | ||
from __future__ import annotations | ||
|
||
__all__ = ( | ||
"NumDiaSourcesMetric", | ||
"NumDipolesMetric", | ||
) | ||
|
||
from ..actions.scalar import CountAction | ||
from ..actions.vector import FlagSelector | ||
from ..interfaces import AnalysisMetric | ||
|
||
|
||
class NumDiaSourcesMetric(AnalysisMetric): | ||
"""Calculate the number of DIA Sources that do not have known | ||
bad/quality flags set to true. | ||
""" | ||
|
||
def setDefaults(self): | ||
super().setDefaults() | ||
|
||
# filter out DIA sources with bad flags | ||
self.prep.selectors.flagSelector = FlagSelector() | ||
self.prep.selectors.flagSelector.selectWhenFalse = [ | ||
"base_PixelFlags_flag_bad", | ||
"base_PixelFlags_flag_suspect", | ||
"base_PixelFlags_flag_saturatedCenter", | ||
"base_PixelFlags_flag_interpolated", | ||
"base_PixelFlags_flag_interpolatedCenter", | ||
"base_PixelFlags_flag_edge", | ||
] | ||
|
||
# Count the number of dia sources left after filtering | ||
self.process.calculateActions.numDiaSources = CountAction(vectorKey="diaSourceId") | ||
|
||
# the units for the quantity (count, an astropy quantity) | ||
self.produce.units = {"numDiaSources": "ct"} | ||
|
||
|
||
class NumDipolesMetric(AnalysisMetric): | ||
"""Calculate the number of dipoles.""" | ||
|
||
def setDefaults(self): | ||
super().setDefaults() | ||
|
||
# select all diaSources flagged as dipole | ||
self.prep.selectors.flags = FlagSelector(selectWhenTrue=["isDipole"]) | ||
|
||
# count the number of dipoles | ||
self.process.buildActions.numDipoles = CountAction(vectorKey="isDipole") | ||
|
||
# the units for the quantity (count, an astropy quantity) | ||
self.produce.units = {"numDipoles": "ct"} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now that I get down here, something like this for the
AnalysisTool
above