-
Notifications
You must be signed in to change notification settings - Fork 18
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-46966: Make calibrating pixel values optional in CalibrateImageTask #996
Conversation
a337ece
to
8b8725f
Compare
default=True, | ||
doc=( | ||
"If True, apply the photometric calibration to the image pixels " | ||
"and background model, and attach an identify PhotoCalib to " |
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.
Identity not identify
---------- | ||
exposure : `lsst.afw.image.Exposure` | ||
Exposure with the target `lsst.afw.image.PhotoCalib` attached. | ||
On return, pixel values will be calibrated and an identify |
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.
Identity
8b8725f
to
112fb5d
Compare
112fb5d
to
19ee100
Compare
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.
Should setting this new config to False also require changing the exposure output name to something other than initial_pvi
, so that we can keep track of which ones were calibrated and which not? That's my main worry here, since right now the only way to know is to check whether the attached PhotoCalib is ==1
.
doc=( | ||
"If True, apply the photometric calibration to the image pixels " | ||
"and background model, and attach an identity PhotoCalib to " | ||
"the output image to reflect this." |
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.
Maybe add something like "Otherwise, leave the image and background uncalibrated and attach the PhotoCalib that would calibrate them."
|
||
This is `None` if ``config.do_calibrate_pixels`` is `False`. |
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.
Is a newline allowed here? I've never done that before.
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.
I think so, but it doesn't really do any harm to drop it, and I'll do that since apparently package-docs build
is messed up somehow for me locally and I don't want to wade into that.
background : `lsst.afw.math.BackgroundList` | ||
Background model to convert to nanojansky units in place. |
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.
You got rid of this parameter, no?
|
||
Returns | ||
------- | ||
calibrated_stars : `lsst.afw.table.SourceCatalog` | ||
Star catalog with flux/magnitude columns computed from the fitted | ||
photoCalib. | ||
photoCalib (instFlux columns are retained as well). | ||
matches : `list` [`lsst.afw.table.ReferenceMatch`] | ||
Reference/stars matches used in the fit. |
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.
It looks like we need to also add matchMeta
to this output list, too. Sorry I'd neglected that.
background : `lsst.afw.math.BackgroundList` | ||
Background model to convert to nanojansky units in place. | ||
""" | ||
photo_calib = exposure.getPhotoCalib() |
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.
Why not use exposure.photoCalib
below, instead of assigning it? Doesn't really matter, I just don't like proliferating the getX
when we don't have to.
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.
It's because I was going to need this as a local variable anyway later in the method, after exposure.photoCalib
has been set to the identity.
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.
Oh, right, good point.
# TODO investigation: because this takes the photoCalib from the | ||
# exposure, photometric summary values may be "incorrect" (i.e. they | ||
# will reflect the ==1 nJy calibration on the exposure, not the | ||
# applied calibration). This needs to be checked. |
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.
Well, at least I'd left a TODO to reflect this that can be retired!
tests/test_calibrateImage.py
Outdated
self.assertEqual(result.exposure.getPhotoCalib().getCalibrationMean(), 1.0) | ||
else: | ||
self.assertIsNone(result.applied_photo_calib) | ||
photo_calib = result.exposure.getPhotoCalib() |
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.
photo_calib = result.exposure.getPhotoCalib() | |
photo_calib = result.exposure.photoCalib |
tests/test_calibrateImage.py
Outdated
# Fit photoCalib should be the applied value if we calibrated | ||
# pixels, not the ==1 one on the exposure. | ||
photo_calib = result.applied_photo_calib | ||
self.assertEqual(result.exposure.getPhotoCalib().getCalibrationMean(), 1.0) |
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.
self.assertEqual(result.exposure.getPhotoCalib().getCalibrationMean(), 1.0) | |
self.assertEqual(result.exposure.photoCalib.getCalibrationMean(), 1.0) |
tests/test_calibrateImage.py
Outdated
"""Test that run() returns reasonable values to be butler put when | ||
do_calibrate_pixels=False. |
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.
I guess this came from my original wording, but this is much clearer.
"""Test that run() returns reasonable values to be butler put when | |
do_calibrate_pixels=False. | |
"""Test that run() returns reasonable values when | |
``do_calibrate_pixels=False``. |
@@ -595,6 +616,36 @@ def test_runQuantum_no_optional_outputs(self): | |||
# Restore the one we removed for the next test. | |||
connections[optional] = temp | |||
|
|||
def test_runQuantum_no_calibrate_pixels(self): |
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.
Should note in the test docstring that this is testing that the applied_photo_calib
output has been removed.
19ee100
to
b51942e
Compare
I'm a little worried about this, but I think putting constraints on the dataset type name might be the kind of fix that's worse than the problem, especially with the names still somewhat in flux. To get at the root issue, what do you think about setting |
@@ -949,6 +949,7 @@ def _apply_photometry(self, exposure, background): | |||
photo_calib.getCalibrationErr(), | |||
bbox=exposure.getBBox()) | |||
exposure.setPhotoCalib(identity) | |||
exposure.metadata["BUNIT"] = "nJy" |
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.
Although I'd much rather have this done within PhotoCalib itself, I guess it's not the worst thing to do it here, even better if we also do it in reprocessVisitImage
, and the diffim and coadd code.
You don't have to do it on this ticket, but please file a ticket about setting BUNIT everywhere we're writing an nJy image, and/or getting PhotoCalib to do it automatically if possible. |
As you might have seen, I've already added |
This resolves a TODO comment wondering whether computing summary stats after applying the photometric calibration would be a problem, because it is - at least for DRP, where FGCM depends on some quantities being in instrumental units. I'm guessing AP doesn't care, but this needs to be verified.
b2c0eac
to
36afc7d
Compare
No description provided.