Saturday, 1 March 2014

python - MontageError: Invalid table file

Here is the output using the debugger:



> /home/python_lib/test10.py(59)<module>()
-> aplpy.make_rgb_cube(['/tmp/tmpmyYyN7/r.fits','/tmp/tmpmyYyN7/g.fits'], '3c_324_rgb.fits')
(Pdb) n
MontageError: MontageE...aw.tbl',)
> /home/python_lib/test10.py(59)<module>()
-> aplpy.make_rgb_cube(['/tmp/tmpmyYyN7/r.fits','/tmp/tmpmyYyN7/g.fits'], '3c_324_rgb.fits')
(Pdb) n
--Return--
> /home/python_lib/test10.py(59)<module>()->None
-> aplpy.make_rgb_cube(['/tmp/tmpmyYyN7/r.fits','/tmp/tmpmyYyN7/g.fits'], '3c_324_rgb.fits')


Then when I hit "n" "enter" again it shoots out the error:



(Pdb) n
Traceback (most recent call last):
File "test10.py", line 59, in <module>
aplpy.make_rgb_cube(['/tmp/tmpmyYyN7/r.fits','/tmp/tmpmyYyN7/g.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/tmpQILi76/images_raw.tbl
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x7f7ad03c2668> ignored


I'll look it over and see if I can make sense of it...I inserted the



pdb.set_trace()


line just before



aplpy.make_rgb_cube


and sure enough, that's where the error is. Is it possible that it's because of the way I've "sliced" the images in the previous code? The problem with the .fits images I'm running into is that there's multiple "image" files to each one:



Filename: 3c324IR.fits
No. Name Type Cards Dimensions Format
0 PRIMARY PrimaryHDU 748 ()
1 SCI ImageHDU 144 (1091, 966) float32
2 WHT ImageHDU 48 (1091, 966) float32
3 CTX ImageHDU 43 (1091, 966) int32
4 HDRTAB BinTableHDU 557 2R x 274C [9A, 3A, J, D, D, D, D, D, D, D, D, D, D, D, D, J, 6A, 9A, 7A, 18A, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, J, J, D, D, D, D, D, D, J, J, 8A, 23A, 11A, 18A, 4A, D, D, J, J, D, D, D, D, 23A, D, D, D, D, J, J, D, 23A, 8A, J, D, D, D, 23A, 1A, D, D, D, D, D, D, 12A, 12A, 8A, 23A, D, D, 10A, 10A, D, D, D, 2A, 3A, 3A, 4A, 8A, 7A, D, J, D, 6A, 9A, D, D, D, 4A, 18A, 3A, J, 5A, D, D, D, 8A, D, D, D, D, D, 23A, 1A, D, 23A, D, D, D, 3A, J, 1A, 4A, D, 3A, 6A, D, D, D, D, D, 23A, D, D, D, D, D, 1A, J, J, J, J, 8A, 23A, J, J, 10A, 7A, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, 12A, D, 24A, 23A, D, 2A, 8A, D, J, D, D, 6A, 4A, D, D, D, D, D, D, D, D, D, D, D, 19A, D, J, 23A, D, 8A, D, D, 13A, D, D, J, D, D, 5A, 9A, 1A, 4A, D, 1A, J, 1A, 1A, 1A, 1A, D, D, D, D, D, D, 4A, D, D, 4A, 3A, 1A, J, 3A, 6A, J, D, D, D, 4A, J, D, D, D, J, J, J, 1A, D, D, D, D, J, J, 6A, J, 8A, D, D, 1A, 5A, J, 3A, 8A, 8A, D, J, D, 8A, 8A]
5 WCSCORR BinTableHDU 59 7R x 24C [40A, I, 1A, 24A, 24A, 24A, 24A, D, D, D, D, D, D, D, D, 24A, 24A, D, D, D, D, J, 40A, 128A]


Above is the output when I print the Hubble IR .fits header, which shows there are several HDU's, but the only one I want is #1, which is the image of the field. The same follows for the UVIS and VLA images. The only way I could think to select one of them is by opening them with PyFITS, and then selecting each one with a line like



r1 = r[1].data


Is this the proper way to go about this? I guess most .fits images don't have this multi-image setup to one file. When I try running it the other way, open on the original file though it definitely doesn't like it.



After selecting with the line above I simply save it, individually, back as a .fits image.



Brandon Doyle

No comments:

Post a Comment