-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from lsst/tickets/DM-41118
DM-41118: Add metrics from diffim task metadata
- Loading branch information
Showing
7 changed files
with
149 additions
and
3 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
39 changes: 39 additions & 0 deletions
39
python/lsst/analysis/tools/atools/diffimMetadataMetrics.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,39 @@ | ||
# 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__ = ("DiffimMetadataMetricTool",) | ||
|
||
from lsst.pex.config import DictField | ||
|
||
from ..actions.scalar import ValueAction | ||
from ..interfaces import AnalysisTool | ||
|
||
|
||
class DiffimMetadataMetricTool(AnalysisTool): | ||
"""This tool is designed to extract values from diffim task metadata""" | ||
|
||
metrics = DictField[str, str](doc="The metrics to calculate from the task metadata and their units") | ||
|
||
def finalize(self): | ||
for name, unit in self.metrics.items(): | ||
setattr(self.process.calculateActions, name, ValueAction(vectorKey=name)) | ||
self.produce.metric.units = dict(self.metrics.items()) |
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
69 changes: 69 additions & 0 deletions
69
python/lsst/analysis/tools/tasks/diffimTaskDetectorVisitAnalysis.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,69 @@ | ||
# 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__ = ("DiffimDetectorVisitAnalysisConfig", "DiffimDetectorVisitAnalysisTask") | ||
|
||
import pandas as pd | ||
from lsst.pipe.base import connectionTypes | ||
|
||
from ..interfaces import AnalysisBaseConfig, AnalysisBaseConnections, AnalysisPipelineTask | ||
|
||
|
||
class DiffimDetectorVisitAnalysisConnections( | ||
AnalysisBaseConnections, | ||
dimensions=("visit", "band", "detector"), | ||
): | ||
metadataSubtract = connectionTypes.Input( | ||
doc="Task metadata from image differencing", | ||
name="subtractImages_metadata", | ||
storageClass="TaskMetadata", | ||
dimensions=("visit", "band", "detector"), | ||
) | ||
metadataDetect = connectionTypes.Input( | ||
doc="Task metadata from DIA detection and measurement", | ||
name="detectAndMeasure_metadata", | ||
storageClass="TaskMetadata", | ||
dimensions=("visit", "band", "detector"), | ||
) | ||
|
||
|
||
class DiffimDetectorVisitAnalysisConfig( | ||
AnalysisBaseConfig, pipelineConnections=DiffimDetectorVisitAnalysisConnections | ||
): | ||
pass | ||
|
||
|
||
class DiffimDetectorVisitAnalysisTask(AnalysisPipelineTask): | ||
ConfigClass = DiffimDetectorVisitAnalysisConfig | ||
_DefaultName = "DiffimDetectorVisitAnalysis" | ||
|
||
def runQuantum(self, butlerQC, inputRefs, outputRefs): | ||
inputs = butlerQC.get(inputRefs) | ||
metadata = inputs["metadataDetect"].metadata["detectAndMeasure"].to_dict() | ||
inputs.pop("metadataDetect") | ||
metadata |= inputs["metadataSubtract"].metadata["subtractImages"].to_dict() | ||
inputs.pop("metadataSubtract") | ||
df = pd.DataFrame(metadata) | ||
|
||
inputs["data"] = df | ||
outputs = self.run(**inputs) | ||
butlerQC.put(outputs, outputRefs) |