GalSim-developers/GalSim — pull request #489 by rmjarvis (2013-11-23 21:51:46+00:00)
Title: #488 Support astropy.io.fits

This is a quick pull request for supporting astropy.io.fits in addition to the regular pyfits. According to [their webpage](http://www.stsci.edu/institute/software_hardware/pyfits), pyfits is deprecated as a standalone package, so this is where the functionality will live going forward.

The code first checks if astropy.io.fits is available, and if so, it imports it `as pyfits`. Then if doesn't find it, it tries to `import pyfits` itself.

Erin made the good suggestion of doing this once in our `__init__.py` file, so everywhere else we can just do `from galsim import pyfits` to get the right module.

Since we have varied functionality to workaround various pyfits bugs in various versions, I mocked up the pyfits version for `astropy.io.fits` as 4.0. The module doesn't have a `__version__` defined, so this is just set to be after all the checks that we do for various pyfits 2.x and 3.x versions. If we eventually have to have different functionality for different versions of astropy, we might need to revisit this. But for now it works.

Finally, since I was testing this at BNL, which doesn't have PyYAML available (allowed under our current dependency list), I fixed some places in the test suite that required `import yaml` to succeed.

I think this PR deserves to be included in the 1.0.1 release, since this is all API preserving.