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-10765: Replace existing WCS classes with SkyWcs #42

Merged
merged 8 commits into from Feb 16, 2018
Merged

Conversation

r-owen
Copy link
Contributor

@r-owen r-owen commented Dec 12, 2017

No description provided.

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)

Copy link
Contributor

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..."

Copy link
Contributor Author

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.

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'll add that I think your fix, or some variant of it, would work. I just don't like relying on undocumented features.

@@ -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
Copy link
Contributor

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

if camera is None:
raise RuntimeError("camera is None")
detector = exposure.getDetector()
if wcs is None:
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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)

@@ -0,0 +1,124 @@
#
# LSST Data Management System
# Copyright 2017 LSST Corporation.
Copy link
Contributor

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)
Copy link
Contributor

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"?

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 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.

Copy link
Contributor

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.

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 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.

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
Copy link
Contributor

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).

self.detector = DetectorWrapper().detector
self.crpix = afwGeom.Point2D(50, 100)
self.crval = IcrsCoord(36 * afwGeom.degrees, 71 * afwGeom.degrees)
scale = 1.0 * afwGeom.arcseconds
Copy link
Contributor

Choose a reason for hiding this comment

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

@r-owen r-owen force-pushed the tickets/DM-10765 branch 4 times, most recently from d36dec0 to 9306588 Compare January 22, 2018 16:51
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.
@r-owen r-owen merged commit 9646733 into master Feb 16, 2018
@ktlim ktlim deleted the tickets/DM-10765 branch August 25, 2018 06:44
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

3 participants