Skip to content
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 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions pipelines/apCcdVisitQualityCore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ tasks:
analyzeDiaSourceTableCore:
class: lsst.analysis.tools.tasks.DiaSourceTableCcdVisitAnalysisTask
config:
metrics.numDiaSources: NumDiaSourcesMetric
metrics.numDipoles: NumDipolesMetric
metrics.numSsObjects: NumSsObjectsMetric
connections.outputName: diaSourceTableCore
plots.simpleDiaPlot: SimpleDiaPlot
Expand Down
1 change: 1 addition & 0 deletions python/lsst/analysis/tools/analysisMetrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# 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 .analysisMetrics import *
from .apDiaSourceMetrics import *
from .apSsoMetrics import *
from .limitingMagnitudeMetric import *
from .metricMeasurementBundle import *
Expand Down
72 changes: 72 additions & 0 deletions python/lsst/analysis/tools/analysisMetrics/apDiaSourceMetrics.py
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()
Copy link
Contributor

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


# 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"}