eteq/astropysics — pull request #11 by mwcraig (2012-01-16 20:39:19+00:00)
Title: Fix fits image init from data

Hi,

I think there is a bug in the way a `ccd.FitsImage()` is initialized from an array; the transposition in the underlying FITS data isn't handled consistently, so that the code below fails:

```python
import pyfits
from astropysics import ccd
import numpy as np

an_image = np.random.uniform(size=(300,400))
fname = 'img_400_x_300.fit'
hdu = pyfits.PrimaryHDU(an_image)
hdu.writeto(fname, clobber=True)

ccd_image = ccd.FitsImage(fname)
new_ccd_image = ccd.FitsImage(ccd_image.data)
assert ccd_image.shape == new_ccd_image.shape
```

This pul request includes a fix for all of the cases in which the `FitsImage` is initialized form data, though *I have only tested it for the case when initialization is from a single array*.

It seemed better to implement the fix by calling `ccd.FitsImage._applyArray` rather than adding `.T.view(np.ndarray)` to all of the initializations in the event the underlying implementation changes down the road.

Matt

PS Sorry this branch also includes the changes in the previous pull request!