I'm using Python 2.7.3 on my Debian server. Here is the input code:
import aplpy
import pyfits
from numpy import *
import matplotlib as plt
import montage as montage_wrapper
import PIL
r = pyfits.open('3c324IR.fits')
b = pyfits.open('3c324UVIS.fits')
g = pyfits.open('3c5GHZ.fits')
r.info()
g.info()
b.info()
print(r[1].header)
print(g[1].header)
print(b[1].header)
r1 = r[1].data
g1 = g[0].data
b1 = b[1].data
hdu = pyfits.PrimaryHDU(r1)
hdulist = pyfits.HDUList([hdu])
hdulist.writeto('r.fits')
hdu = pyfits.PrimaryHDU(g1)
hdulist = pyfits.HDUList([hdu])
hdulist.writeto('g.fits')
hdu = pyfits.PrimaryHDU(b1)
hdulist = pyfits.HDUList([hdu])
hdulist.writeto('b.fits')
aplpy.make_rgb_cube(['r.fits','g.fits','b.fits'], '3c_324_rgb.fits')
aplpy.make_rgb_image('3c_324_rgb.fits','3c_324_rgb.png')
f = aplpy.FITSFigure('3c_324_rgb.fits')
f.show_rgb()
f.save('3c_324_rgb2.png')
print 'END'
Everything works fine until I start the aplpy.make_rgb_cube() portion of the code. I know this because when I start it and cut that out it works through fine (until it realizes there's no output from this piece to continue). Here's the mess in the terminal:
Traceback (most recent call last):
File "test9.py", line 47, in <module>
aplpy.make_rgb_cube(['r.fits','g.fits','b.fits'], '3c_324_rgb.fits')
File "/usr/local/lib/python2.7/dist-packages/aplpy/rgb.py", line 309, in make_rgb_cube
montage.mMakeHdr(images_raw_tbl, header_hdr, north_aligned=north, system=system, equinox=equinox)
File "/usr/local/lib/python2.7/dist-packages/montage_wrapper/commands.py", line 1468, in mMakeHdr
return status.parse_struct("mMakeHdr", p.stdout.read().strip())
File "/usr/local/lib/python2.7/dist-packages/montage_wrapper/status.py", line 33, in parse_struct
result = Struct(command, string)
File "/usr/local/lib/python2.7/dist-packages/montage_wrapper/status.py", line 70, in __init__
raise MontageError("%s: %s" % (command, self.msg))
montage_wrapper.status.MontageError: mMakeHdr: Invalid table file: /tmp/tmpmyYyN7/images_raw.tbl
I don't know what the above means. I've looked through it for something to look around for in Google and I've come up empty. What is this error and how can I fix it?
aplpy.make_rgb_cube creates several files that are used by Montage mMakeHdr as a step along the way to generating your cube.
aplpy.make_rgb_cube gets past all the steps up to mMakeHdr.
mMakeHdr tries to read one of the created files named /tmp/tmpmyYyN7/images_raw.tbl Reading the file fails because the file ist invalid. An invalid file could be on with bad contents, could also mean that the file doesn't exist.
Check if you have more than one Montage installation on your system: Run "which mProjectPP" from a shell command line
In Python do: import os os.system('which mProjectPP') Both should deliver the same answer. If not, you've got two Montage installations, and they are getting mixed up.