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-32649: Add psf size and shape residual statistics to visitSummary #604

Merged
merged 5 commits into from Nov 23, 2021

Conversation

erykoff
Copy link
Contributor

@erykoff erykoff commented Nov 19, 2021

This PR moves the gen3 PsfWcsSelectImagesTask to using the visitSummary table and removes the source connection, which should speed up i/o.

For gen2, we don't have the visitSummary tables so I left in the legacy computation, and this can be removed with the rest of the gen2 code when the time comes.

doc="Name of psf shape",
dtype=str,
default='base_SdssShape_psf'
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pet peeve: why mix between single and double quotes for strings (I generally prefer the latter).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...because I literally cut-and-pasted from the prior art which had the mix. And while I have a lot of code style opinions, strangely single-or-double spaces is not something I notice. Anyway, I'll fix to double quotes.

@@ -53,6 +54,21 @@ class ComputeExposureSummaryStatsConfig(pexConfig.Config):
doc="Mask planes that, if set, the associated pixel should not be included sky noise calculation.",
default=("NO_DATA", "SUSPECT"),
)
starSelection = pexConfig.Field(
doc="Field to select stars.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a tad more descriptive, e.g.:
"Field to select sources to be used in the PSF statistics computation."?

default='calib_psf_used'
)
starShape = pexConfig.Field(
doc="Name of star shape",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a tad more descriptive, e.g.:
"Name of column to use for the source shape in the PSF statistics computation"?

default='base_SdssShape'
)
psfShape = pexConfig.Field(
doc="Name of psf shape",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a tad more descriptive, e.g.:
"Name of column to use for the PSF shape in the PSF statistics computation"?

@@ -191,6 +207,9 @@ def run(self, exposure, sources, background):
astromOffsetMean = np.nan
astromOffsetStd = np.nan

psfStats = self._computePsfStats(sources)
scaledSize = psfStats.psfStarScaledDeltaSizeScatter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just because of line-length issues? It looks like a snowflake ❄️ ! Would flake8 (and you!) be OK with carriage returning after the opening bracket?, I.e.

summary = afwImage.ExposureSummaryStats(
    psfSigma=float(psfSigma),
    psfArea=float(psfArea),
    psfIxx=float(psfIxx),
    psfIyy=float(psfIyy),
    psfIxy=float(psfIxy),
    ra=float(ra),
    decl=float(decl),
    zenithDistance=float(zenithDistance),
    zeroPoint=float(zeroPoint),
    skyBg=float(skyBg),
    skyNoise=float(skyNoise),
    meanVar=float(meanVar),
    raCorners=raCorners,
    decCorners=decCorners,
    astromOffsetMean=astromOffsetMean,
    astromOffsetStd=astromOffsetStd,
    nPsfStar=psfStats.nPsfStar,
    psfStarDeltaE1Median=psfStats.psfStarDeltaE1Median,
    psfStarDeltaE2Median=psfStats.psfStarDeltaE2Median,
    psfStarDeltaE1Scatter=psfStats.psfStarDeltaE1Scatter,
    psfStarDeltaE2Scatter=psfStats.psfStarDeltaE2Scatter,
    psfStarDeltaSizeMedian=psfStats.psfStarDeltaSizeMedian,
    psfStarDeltaSizeScatter=psfStats.psfStarDeltaSizeScatter,
    psfStarScaledDeltaSizeScatter=psfStats.psfStarScaledDeltaSizeScatter,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point!

psfStats.psfStarDeltaE2Scatter = float(psfStarDeltaE2Scatter)
psfStats.psfStarDeltaSizeMedian = float(psfStarDeltaSizeMedian)
psfStats.psfStarDeltaSizeScatter = float(psfStarDeltaSizeScatter)
psfStats.psfStarScaledDeltaSizeScatter = float(psfStarScaledDeltaSizeScatter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, why is all this casting needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment that we must cast to python quantities rather than numpy so that these can get serialized as yaml.

if config.select.target != lsst.pipe.tasks.selectImages.PsfWcsSelectImagesTask:
self.inputs.remove("srcList")
self.inputs.remove("visitSummary")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the comment that you removed implies to me that this connection should actually be added to the PsfWcsSelectImagesTask itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I should not have removed that to-do.

self.log.info("Removing visit %d detector %d because scaled size scatter too large: %f vs %f",
row['visit'], detectorId, scaledScatterSize, self.config.maxScaledSizeScatter)
valid = False

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again with the single & double quote mixing for strings (throughout)!

"""Should this ccd be selected based on its PSF shape information.

This routine is only used in Gen2 processing, and can be
removed when Gen2 is retired.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

psfStarDeltaE2Scatter=psfStats.psfStarDeltaE2Scatter,
psfStarDeltaSizeMedian=psfStats.psfStarDeltaSizeMedian,
psfStarDeltaSizeScatter=psfStats.psfStarDeltaSizeScatter,
psfStarScaledDeltaSizeScatter=scaledSize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the new entries to the class description?

Also, maybe that line should now read "...at the detector centers or averaged over a detector..."?

@erykoff erykoff merged commit 6cddff1 into master Nov 23, 2021
@erykoff erykoff deleted the tickets/DM-32649 branch November 23, 2021 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants