barnabytprowe/great3-public

Update required in example scripts due to change in galsim.Image() initialization syntax

Closed this issue · 7 comments

I think one or more of the example scripts might need updating in the light of recent changes to GalSim (specifically to the galsim.Image API: GalSim-developers/GalSim#495)

I know for a fact that coadd_multiepoch.py needs updating, because the following line (and those like it) is out of date:

    # Load full image array into an ImageF instance
    image = galsim.ImageViewF(
        pyfits.getdata(inprefix+"%03d-%1d.fits" % (field, 0)).astype(numpy.float32), scale=1.)

as the galsim.ImageViewF() way of initializing images has gone the way of the Dinosaur since GalSim-developers/GalSim#495 was merged in. I think that similar things may be found in the other codes, but part of this issue will see me check that.

My hacky solution is a try:, except: block:

    # Load full image array into an ImageF instance
    try:
        image = galsim.ImageViewF(
            pyfits.getdata(inprefix+"%03d-%1d.fits" % (field, 0)).astype(numpy.float32), scale=1.)
    except: # For those users who have a newer version of GalSim than v1.0.1...
        image = galsim.ImageF(
            pyfits.getdata(inprefix+"%03d-%1d.fits" % (field, 0)).astype(numpy.float32), scale=1.)

I generally don't like to use a bare except:, but to be honest there is very little else here that can be going wrong assuming that correct GREAT3 images are being used, so I don't think it is a real problem. (The Boost.Python-thrown exception claims to be an ArgumentError but this is not defined at the Python level. I don't think it's a big issue to use the catch-all as above for these simple, uni-purpose scripts. If it's a pyfits exception that was thrown in the first place, it will still trigger after the except: anyway.)

Comments welcome.

Or, just say that all the great3-public stuff require galsim 1.0. I don't think anything in great3-public needs any of the new stuff that is currently on master.

That is true; it would require a minor documentation edit but that's it.

@rmandelb , @msimet , any objection to simply modifying the documentation for the example scripts to require GalSim v0.4-1.0 rather than GalSim 0.4+?

No objection at all!

I would change it to 1.0, not 0.4-1.0. I believe there were bugs in the 0.4 and 0.5 versions that could be relevant, so best to encourage people to upgrade to 1.0 if they haven't already.

Good point. I agree. Also I believe the shear estimation codes have been optimized significantly since 0.4…

OK cool, I think I'll do this on master then close the issue.