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-33960: Add astrometry residuals with refcat plots #22

Merged
merged 3 commits into from
Jun 20, 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
4 changes: 3 additions & 1 deletion pipelines/LSSTCam-imSim/analysis_drp_plots.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ imports:
- "$ANALYSIS_DRP_DIR/pipelines/generic_visit_plots.yaml"

description: |
analysis drp plot pipeline specialized for imsim
analysis drp plot pipeline specialized for imsim

instrument: lsst.obs.lsst.LsstCamImSim
2 changes: 2 additions & 0 deletions pipelines/LSSTCam-imSim/dc2_coadd_plots.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ imports:

description: |
Coadd analysis drp plots specialized for LSSTCam

instrument: lsst.obs.lsst.LsstCamImSim
74 changes: 74 additions & 0 deletions pipelines/coaddQAPlots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,77 @@ tasks:
selectorActions.SnSelector.bands: ["g", "r", "i"]
python: >
from lsst.analysis.drp.dataSelectors import FlagSelector, CoaddPlotFlagSelector, SnSelector

plot_astromRefCat_sky_tract_dRA:
class: lsst.analysis.drp.skyPlot.SkyPlotTask
config:
connections.catPlot: objectTable_tract_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_sky_ra_coadd_i
axisActions.zAction: AstromDiff
axisActions.zAction.col1: "coord_ra_target"
axisActions.zAction.col2: "coord_ra_ref"
axisActions.xAction.column: "coord_ra_ref"
axisActions.yAction.column: "coord_dec_ref"
selectorActions.flagSelector: CoaddPlotFlagSelector
selectorActions.flagSelector.bands: ["i"]
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: "i"
axisLabels: {"x": "R.A. (Degrees)", "y": "Dec. (Degrees)", "z": "$RA_{target} - RA_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import CoaddPlotFlagSelector, StarIdentifier, SnSelector
from lsst.analysis.drp.calcFunctors import AstromDiff

plot_astromRefCat_sky_tract_dDec:
class: lsst.analysis.drp.skyPlot.SkyPlotTask
config:
connections.catPlot: objectTable_tract_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_sky_dec_coadd_i
axisActions.zAction: AstromDiff
axisActions.zAction.col1: "coord_dec_target"
axisActions.zAction.col2: "coord_dec_ref"
axisActions.xAction.column: "coord_ra_ref"
axisActions.yAction.column: "coord_dec_ref"
selectorActions.flagSelector: CoaddPlotFlagSelector
selectorActions.flagSelector.bands: ["i"]
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: "i"
axisLabels: {"x": "R.A. (Degrees)", "y": "Dec. (Degrees)", "z": "$Dec_{target} - Dec_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import CoaddPlotFlagSelector, StarIdentifier, SnSelector
from lsst.analysis.drp.calcFunctors import AstromDiff

plot_astromRefCat_scatter_tract_dRA:
class: lsst.analysis.drp.scatterPlot.ScatterPlotWithTwoHistsTask
config:
connections.catPlot: objectTable_tract_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_scatter_ra_coadd_i
axisActions.yAction: AstromDiff
axisActions.yAction.col1: "coord_ra_target"
axisActions.yAction.col2: "coord_ra_ref"
selectorActions.flagSelector: CoaddPlotFlagSelector
selectorActions.flagSelector.bands: ["i"]
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: "i"
axisLabels: {"x": "PSF Magnitude (mag)", "mag": "PSF Magnitude (mag)",
"y": "$RA_{target} - RA_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import CoaddPlotFlagSelector, StarIdentifier
from lsst.analysis.drp.calcFunctors import AstromDiff

plot_astromRefCat_scatter_tract_dDec:
class: lsst.analysis.drp.scatterPlot.ScatterPlotWithTwoHistsTask
config:
connections.catPlot: objectTable_tract_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_scatter_dec_coadd_i
axisActions.yAction: AstromDiff
axisActions.yAction.col1: "coord_dec_target"
axisActions.yAction.col2: "coord_dec_ref"
selectorActions.flagSelector: CoaddPlotFlagSelector
selectorActions.flagSelector.bands: ["i"]
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: "i"
axisLabels: {"x": "PSF Magnitude (mag)", "mag": "PSF Magnitude (mag)",
"y": "$Dec_{target} - Dec_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import CoaddPlotFlagSelector, StarIdentifier
from lsst.analysis.drp.calcFunctors import AstromDiff
1 change: 1 addition & 0 deletions pipelines/generic_coadd_plots.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ imports:
- "$ANALYSIS_DRP_DIR/pipelines/coaddQAPlots.yaml"
- "$ANALYSIS_DRP_DIR/pipelines/coaddQAEllipPlots.yaml"
- "$ANALYSIS_DRP_DIR/pipelines/stellarLocusPlots.yaml"
- "$ANALYSIS_DRP_DIR/pipelines/matchCoaddCatalogs.yaml"

description: |
Coadd level analysis drp plots
1 change: 1 addition & 0 deletions pipelines/generic_visit_plots.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
imports:
- "$ANALYSIS_DRP_DIR/pipelines/visitQAEllipPlots.yaml"
- "$ANALYSIS_DRP_DIR/pipelines/visitQAPlots.yaml"
- "$ANALYSIS_DRP_DIR/pipelines/matchVisitCatalogs.yaml"

description: |
Visit level analysis drp plots
7 changes: 7 additions & 0 deletions pipelines/matchCoaddCatalogs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: |
Match coadd level catalogs with reference catalogs for QA.
parameters:
band: i
tasks:
match_astromRefCat_objectTable:
class: lsst.analysis.drp.catalogMatch.CatalogMatchTask
15 changes: 15 additions & 0 deletions pipelines/matchVisitCatalogs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
description: |
Match visit level catalogs with reference catalogs for QA.
For visit level tasks the bands needs to be set to [""] to allow the code to be reused between
the coadd level tables, which have band_ prepended to their column names, and the visit level
tables which do not.
parameters:
band: i
tasks:
match_astromRefCat_visit:
class: lsst.analysis.drp.catalogMatch.CatalogMatchVisitTask
config:
selectorActions.flagSelector: VisitPlotFlagSelector
sourceSelectorActions.sourceSelector.band: ""
python: |
from lsst.analysis.drp.dataSelectors import VisitPlotFlagSelector
71 changes: 71 additions & 0 deletions pipelines/visitQAPlots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,74 @@ tasks:
axisLabels: {"x": "R.A. (Degrees)", "y": "Dec. (Degrees)", "z": "Sky Object Flux (nJy)"}
python: |
from lsst.analysis.drp.dataSelectors import (FlagSelector)

plot_astromRefCat_sky_visit_dRA:
class: lsst.analysis.drp.skyPlotVisit.SkyPlotVisitTask
config:
connections.catPlot: sourceTable_visit_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_sky_ra_visit
axisActions.zAction: AstromDiff
axisActions.zAction.col1: "coord_ra_target"
axisActions.zAction.col2: "coord_ra_ref"
axisActions.xAction.column: "coord_ra_ref"
axisActions.yAction.column: "coord_dec_ref"
selectorActions.flagSelector: VisitPlotFlagSelector
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: ""
axisLabels: {"x": "R.A. (Degrees)", "y": "Dec. (Degrees)", "z": "$RA_{target} - RA_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import VisitPlotFlagSelector, StarIdentifier
from lsst.analysis.drp.calcFunctors import AstromDiff

plot_astromRefCat_sky_visit_dDec:
class: lsst.analysis.drp.skyPlotVisit.SkyPlotVisitTask
config:
connections.catPlot: sourceTable_visit_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_sky_dec_visit
axisActions.zAction: AstromDiff
axisActions.zAction.col1: "coord_dec_target"
axisActions.zAction.col2: "coord_dec_ref"
axisActions.xAction.column: "coord_ra_ref"
axisActions.yAction.column: "coord_dec_ref"
selectorActions.flagSelector: VisitPlotFlagSelector
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: ""
axisLabels: {"x": "R.A. (Degrees)", "y": "Dec. (Degrees)",
"z": "$Dec_{target} - Dec_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import VisitPlotFlagSelector, StarIdentifier
from lsst.analysis.drp.calcFunctors import AstromDiff

plot_astromRefCat_scatter_visit_dRA:
class: lsst.analysis.drp.scatterPlotVisit.ScatterPlotVisitTask
config:
connections.catPlot: sourceTable_visit_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_scatter_ra_visit
axisActions.yAction: AstromDiff
axisActions.yAction.col1: "coord_ra_target"
axisActions.yAction.col2: "coord_ra_ref"
selectorActions.flagSelector: VisitPlotFlagSelector
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: ""
axisLabels: {"x": "PSF Magnitude (mag)", "mag": "PSF Magnitude (mag)",
"y": "$RA_{target} - RA_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import VisitPlotFlagSelector, StarIdentifier
from lsst.analysis.drp.calcFunctors import AstromDiff

plot_astromRefCat_scatter_visit_dDec:
class: lsst.analysis.drp.scatterPlotVisit.ScatterPlotVisitTask
config:
connections.catPlot: sourceTable_visit_astrometryRefCat_match
connections.plotName: astromRefCatResiduals_scatter_dec_visit
axisActions.yAction: AstromDiff
axisActions.yAction.col1: "coord_dec_target"
axisActions.yAction.col2: "coord_dec_ref"
selectorActions.flagSelector: VisitPlotFlagSelector
sourceSelectorActions.sourceSelector: StarIdentifier
sourceSelectorActions.sourceSelector.band: ""
axisLabels: {"x": "PSF Magnitude (mag)", "mag": "PSF Magnitude (mag)",
"y": "$Dec_{target} - Dec_{ref}$ (marcsec)"}
python: |
from lsst.analysis.drp.dataSelectors import VisitPlotFlagSelector, StarIdentifier
from lsst.analysis.drp.calcFunctors import AstromDiff
46 changes: 46 additions & 0 deletions python/lsst/analysis/drp/calcFunctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,49 @@ def __call__(self, df):
pull = color_diff/np.sqrt(err1_sq + err2_sq)

return pull


class AstromDiff(MultiColumnAction):
"""Calculate the difference between two columns, assuming their units
are degrees, and convert the difference to arcseconds.

Parameters
----------
df : `pandas.core.frame.DataFrame`
The catalog to calculate the position difference from.

Returns
-------
The difference.

Notes
-----
The columns need to be in units (specifiable in
the radecUnits1 and 2 config options) that can be converted
to arcseconds. This action doesn't have any calibration
information and assumes that the positions are already
calibrated.
"""

col1 = Field(doc="Column to subtract from", dtype=str)
radecUnits1 = Field(doc="Units for col1", dtype=str, default="degree")
col2 = Field(doc="Column to subtract", dtype=str)
radecUnits2 = Field(doc="Units for col2", dtype=str, default="degree")
returnMilliArcsecs = Field(doc="Use marcseconds or not?", dtype=bool, default=True)

@property
def columns(self):
return (self.col1, self.col2)

def __call__(self, df):
angle1 = df[self.col1].values * u.Unit(self.radecUnits1)

angle2 = df[self.col2].values * u.Unit(self.radecUnits2)

angleDiff = angle1 - angle2

if self.returnMilliArcsecs:
angleDiffValue = angleDiff.to(u.arcsec) * 1000
else:
angleDiffValue = angleDiff.value
return angleDiffValue