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-10765: Replace existing WCS classes with SkyWcs #42
Conversation
130b1e8
to
ebdbbb5
Compare
ebdbbb5
to
83c2a69
Compare
dbfd1c5
to
1631b07
Compare
kernelPickleString = kernel.getArray().dumps() | ||
# kernel.getArray().dump(self.filename) triggers an "unclosed file" warning with numpy 1.13.1 | ||
with open(self.filename, 'wb') as f: | ||
f.write(kernelPickleString) | ||
|
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 there a reason you didn't just fix this as:
with open(self.filename, 'wb') as f:
kernel.getArray().dump(f)
?
Also, typo in your commit message: "it turns out numpy..."
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.
numpy.dump is only documented to accept file path string, not a file object.
I'll fix the commit message.
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'll add that I think your fix, or some variant of it, would work. I just don't like relying on undocumented features.
python/lsst/ip/isr/isrTask.py
Outdated
@@ -404,6 +410,8 @@ def run(self, ccdExposure, bias=None, linearizer=None, dark=None, flat=None, def | |||
\param[in] fringes -- a pipeBase.Struct with field fringes containing | |||
exposure of fringe frame or list of fringe exposure | |||
\param[in] bfKernel -- kernel for brighter-fatter correction | |||
\param[in] camera -- camera geometry, an lsst.afw.cameraGeom.Camera; | |||
used by addDistortionModel |
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.
Spacing should line up as, e.g. fringes
python/lsst/ip/isr/isrTask.py
Outdated
if camera is None: | ||
raise RuntimeError("camera is None") | ||
detector = exposure.getDetector() | ||
if wcs is None: |
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.
wcs --> detector
(you've already checked for the wcs)
Also, should you move the check for the camera to the list here:
03dc329#diff-3a9973baa2fe4526d09a95e405f90269R443
i.e.
if self.config.doAddDistortionModel and camera is None:
raise RuntimeError("Must supply a camera if config.doAddDistortionModel True")
in order to bail out earlier?
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.
Thanks for catching that bug. I'll add the test you suggest. I wish it didn't have to be in 3 places, but I think you are right.
@@ -789,6 +804,27 @@ def overscanCorrection(self, exposure, amp): | |||
collapseRej=self.config.overscanRej, | |||
) | |||
|
|||
def addDistortionModel(self, exposure, camera): | |||
"""!Update the WCS in exposure with a distortion model based on camera geometry |
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.
A tad more detail would be nice here (i.e. expand a bit on the "based on camera geometry" statement)
tests/test_addDistortionModel.py
Outdated
@@ -0,0 +1,124 @@ | |||
# | |||
# LSST Data Management System | |||
# Copyright 2017 LSST Corporation. |
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.
2018 (darn slow reviewers...!)
isrConfig = IsrTask.ConfigClass() | ||
for name in isrConfig: | ||
if name.startswith("do"): | ||
setattr(isrConfig, name, 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 it guaranteed that all boolean flags will always start with "do"?
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 it is guaranteed that all flags that control whether an operation is to be performed will start with do
, and that is what matters here. The idea is to minimally process the data.
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.
That may be an informal convention that we've adopted, but it's not "guaranteed". If you think it should be, you need to RFC it.
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 don't think it matters in this case. If the test passes, great. If not, the test an easily be updated to add any new flags that control which stages get performed. In any case, the rule need only apply to IsrTask for this test, and self-consistency within one task is more likely that from task to task. It certainly doesn't rise to the level of an RFC.
tests/test_addDistortionModel.py
Outdated
import lsst.afw.geom as afwGeom | ||
from lsst.afw.coord import IcrsCoord | ||
from lsst.afw.image import ExposureF, ExposureInfo, Calib, VisitInfo | ||
from lsst.afw.geom import makeCdMatrix, makeSkyWcs |
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 just seems silly to me to have these individual imports in addition to afwGeom. I will again state my preference for the import ... as ...
style so that it is clear where the functions came from when they are used lower down in a file without having to look back up to the top (in addition to being consistent with a lot of existing code).
tests/test_addDistortionModel.py
Outdated
self.detector = DetectorWrapper().detector | ||
self.crpix = afwGeom.Point2D(50, 100) | ||
self.crval = IcrsCoord(36 * afwGeom.degrees, 71 * afwGeom.degrees) | ||
scale = 1.0 * afwGeom.arcseconds |
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.
d36dec0
to
9306588
Compare
9306588
to
0e48ede
Compare
test_brighterFatter.py was warning about an unclosed file and this was real: it turns out numpy 1.13.1 (at least) has a bug whereby numpy.dump(path) does not close the file it opens.
and enable it by default. This adds a distortion model based on camera geometry (much as some tasks used to do). This is the logical place for it, and the only reason it was not done earlier is that DistortedTanWcs could not be peristed.
Python was warning about invalid backslash sequences for Doxygen commands. Use `@` instead of backslash
This is a separate commit from adding addDistortionModel because the doxygen command cleanup commit made rebasing too much work.
0e48ede
to
9646733
Compare
No description provided.