-
Notifications
You must be signed in to change notification settings - Fork 4
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-7261: Port to Python 3 #3
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
083d180
Run autopep8 on Python code
r-owen 0edcd0b
Update .gitignore
r-owen 5850a14
Run futurize -1 -w .
r-owen ea3d370
Run futurize -2 -x division_safe -w .
r-owen fb68e4b
Add python_future to required packages
r-owen 0190ec3
Standardize imports
r-owen 008459f
Fix wrapping and indentation
r-owen 9bcb9e2
Change "== None" to "is None"
r-owen File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
#!/usr/bin/env python | ||
|
||
# | ||
# | ||
# LSST Data Management System | ||
# Copyright 2008, 2009, 2010 LSST Corporation. | ||
# | ||
# | ||
# This product includes software developed by the | ||
# LSST Project (http://www.lsst.org/). | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the LSST License Statement and | ||
# the GNU General Public License along with this program. If not, | ||
# | ||
# You should have received a copy of the LSST License Statement and | ||
# the GNU General Public License along with this program. If not, | ||
# see <http://www.lsstcorp.org/LegalNotices/>. | ||
# | ||
|
||
from __future__ import with_statement | ||
"""Make a coadd from gaussian noise images | ||
""" | ||
from __future__ import print_function | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually put the |
||
import os | ||
import sys | ||
|
||
import numpy | ||
from builtins import range | ||
import numpy as np | ||
|
||
import lsst.afw.image as afwImage | ||
import lsst.afw.image.testUtils as afwTestUtils | ||
import lsst.coadd.chisquared as coaddChiSq | ||
from noiseCoaddConfig import NoiseCoaddConfig | ||
|
||
if __name__ == "__main__": | ||
# pexLog.Trace.setVerbosity('lsst.coadd', 5) | ||
# pexLog.Trace.setVerbosity('lsst.coadd', 5) | ||
helpStr = """Usage: makeCoadd.py coaddPath numImages | ||
|
||
where: | ||
|
@@ -48,12 +49,12 @@ | |
Run the resulting coadd through makeHistogram to see this. | ||
""" | ||
if len(sys.argv) != 3: | ||
print helpStr | ||
print(helpStr) | ||
sys.exit(0) | ||
|
||
coaddPath = sys.argv[1] | ||
weightPath = os.path.splitext(coaddPath)[0] + "_weight.fits" | ||
|
||
numImages = int(sys.argv[2]) | ||
|
||
config = NoiseCoaddConfig() | ||
|
@@ -65,31 +66,31 @@ | |
imageSigma = %0.1f | ||
variance = %0.1f | ||
""" % (coaddPath, numImages, config.imageShape, config.imageSigma, config.variance)) | ||
numpy.random.seed(0) | ||
|
||
np.random.seed(0) | ||
|
||
coadd = None | ||
for imInd in range(numImages): | ||
print >> sys.stderr, "Create exposure %d" % (imInd,) | ||
print("Create exposure %d" % (imInd,), file=sys.stderr) | ||
maskedImage = afwTestUtils.makeGaussianNoiseMaskedImage( | ||
dimensions=config.imageShape, sigma=config.imageSigma, variance=config.variance) | ||
# the WCS doesn't matter; the default will do | ||
wcs = afwImage.Wcs() | ||
exposure = afwImage.ExposureF(maskedImage, wcs) | ||
|
||
if not coadd: | ||
print >> sys.stderr, "Create coadd" | ||
print("Create coadd", file=sys.stderr) | ||
coadd = coaddChiSq.Coadd.fromConfig( | ||
bbox = exposure.getBBox(), | ||
wcs = exposure.getWcs(), | ||
config = config.coadd) | ||
print >> sys.stderr, "badPixelMask=", coadd.getBadPixelMask() | ||
bbox=exposure.getBBox(), | ||
wcs=exposure.getWcs(), | ||
config=config.coadd) | ||
print("badPixelMask=", coadd.getBadPixelMask(), file=sys.stderr) | ||
|
||
coadd.addExposure(exposure) | ||
|
||
print >> sys.stderr, "Save weight map as %s" % (weightPath,) | ||
print("Save weight map as %s" % (weightPath,), file=sys.stderr) | ||
weightMap = coadd.getWeightMap() | ||
weightMap.writeFits(weightPath) | ||
coaddExposure = coadd.getCoadd() | ||
print >> sys.stderr, "Save coadd as %s" % (coaddPath,) | ||
print("Save coadd as %s" % (coaddPath,), file=sys.stderr) | ||
coaddExposure.writeFits(coaddPath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Also
tests/.cache
I think.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 should add that. Oddly enough when I run py.test I don't see this; I'm not sure why