astropy/astropy — pull request #2463 by embray (2014-05-09 17:29:46+00:00)
Title: Astropy.io.fits and DS9

I am trying to run some code that takes an fits image and displays it in ds9 (pyds9 version 1.7, astropy version 0.3.1)

```
from math import *
import astropy.io.fits as pyfits
import ds9

print ds9.__version__
d = ds9.ds9()
d.set("frame frameno 1")
fname = "02530a148-w3-int-1b_ra82.4458_dec21.8963_asec600.000.fits"
img = pyfits.open(fname)
d.set_pyfits(img)
```

But the code results in this error message

```
Traceback (most recent call last):
File "test.py", line 10, in
d.set_pyfits(img)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ds9.py", line 474, in set_pyfits
hdul.writeto(newFitsFile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/hdu/hdulist.py", line 655, in writeto
hdu._writeto(hdulist.__file)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/hdu/base.py", line 695, in _writeto
self._writedata(fileobj)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/hdu/base.py", line 642, in _writedata
size += self._writedata_direct_copy(fileobj)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/hdu/base.py", line 682, in _writedata_direct_copy
_array_to_file(raw, fileobj)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/util.py", line 536, in _array_to_file
write(arr, outfile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/util.py", line 517, in write
f.write(a.flatten().view(np.ubyte))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/file.py", line 274, in write
_write_string(self.__file, string)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.5-intel.egg/astropy/io/fits/util.py", line 553, in _write_string
f.write(s)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/StringIO.py", line 214, in write
if not s: return
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```