简体   繁体   English

MontageError:无效的表文件

[英]MontageError: Invalid table file

I'm using Python 2.7.3 on my Debian server. 我在我的Debian服务器上使用Python 2.7.3。 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. 一切正常,直到我启动代码的aplpy.make_rgb_cube()部分。 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创建了蒙太奇mMakeHdr使用的几个文件,作为生成多维数据集的一个步骤。
aplpy.make_rgb_cube gets past all the steps up to mMakeHdr. aplpy.make_rgb_cube超过了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. mMakeHdr尝试读取其中一个名为/tmp/tmpmyYyN7/images_raw.tbl的已创建文件。读取文件失败,因为该文件无效。 An invalid file could be on with bad contents, could also mean that the file doesn't exist. 无效文件可能打开,内容不正确,也可能意味着该文件不存在。

  1. Did /tmp/tmpmyYyN7/images_raw.tbl actually get created? /tmp/tmpmyYyN7/images_raw.tbl实际上是否已创建?
  2. If it is created, does it contain a list of image file names? 如果它已创建,它是否包含图像文件名列表?
  3. Check the creation date and see if this is the file you created or an older one that you can't overwrite. 检查创建日期,看看这是您创建的文件还是不能覆盖的旧文件。
  4. Check that you have read and write permissions to /tmp and /tmp/tmpmyYyN7 检查您是否具有/ tmp和/ tmp / tmpmyYyN7的读写权限
  5. If the file isn't there, but you have write permission to the temporary folder, check and see if a file named images_raw.tbl was written anywhere on your harddrive. 如果文件不存在,但您对临时文件夹具有写入权限,请检查并查看名为images_raw.tbl的文件是否写入了硬盘驱动器的任何位置。
  6. Check if you have more than one Montage installation on your system: Run "which mProjectPP" from a shell command line 检查系统上是否安装了多个Montage:从shell命令行运行“which mProjectPP”

    In Python do: import os os.system('which mProjectPP') Both should deliver the same answer. 在Python中执行:import os os.system('which mProjectPP')两者都应该提供相同的答案。 If not, you've got two Montage installations, and they are getting mixed up. 如果没有,你有两个蒙太奇安装,他们正在混淆。

  1. I went to /tmp/tmpmyYyN7/ and images_raw.tbl is there. 我去了/ tmp / tmpmyYyN7 /和images_raw.tbl就在那里。
  2. If I type "nano images_raw.tbl" it contains nothing...does that mean it doesn't contain any image file names? 如果我输入“nano images_raw.tbl”它不包含任何内容......这是否意味着它不包含任何图像文件名?
  3. I changed read/write permissions with "chmod 777" and it still didn't work when I ran it, just resulted in the same output. 我使用“chmod 777”更改了读/写权限,当我运行它时它仍然无效,只是产生了相同的输出。
  4. typing "stat images_raw.tbl" results in the following: 输入“stat images_raw.tbl”会产生以下结果:

    root@jarvis:/tmp/tmpmyYyN7# stat images_raw.tbl File: `images_raw.tbl' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: 801h/2049d Inode: 5772965 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-08-15 04:40:25.433245271 -0400 Modify: 2014-08-15 04:40:25.429245244 -0400 Change: 2014-08-15 04:40:25.429245244 -0400 Birth: - root @jabvis:/ tmp / tmpmyYyN7#stat images_raw.tbl文件:`images_raw.tbl'大小:0块:0 IO块:4096常规空文件设备:801h / 2049d索引:5772965链接:1访问:(0644 / - rw-r - r--)Uid:(0 / root)Gid:(0 / root)访问次数:2014-08-15 04:40:25.433245271 -0400修改时间:2014-08-15 04:40:25.429245244 - 0400更改:2014-08-15 04:40:25.429245244 -0400出生: -

  5. This is the output: 这是输出:

    root@jarvis:/tmp/tmpmyYyN7# which mProjectPP /home/python_lib/Montage_v3.3/Montage//mProjectPP root @jarvis:/ tmp / tmpmyYyN7 #mProjectPP /home/python_lib/Montage_v3.3/Montage//mProjectPP

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: 然后,当我再次点击“n”“输入”时,它会发出错误:

(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: 我遇到的.fits图像的问题是每个图像都有多个“图像”文件:

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. 上面是我打印Hubble IR .fits标题时的输出,显示有几个HDU,但我唯一想要的是#1,这是该字段的图像。 The same follows for the UVIS and VLA images. UVIS和VLA图像也是如此。 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 我能想到选择其中一个的唯一方法是用PyFITS打开它们,然后用一行代码选择每一个

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. 我猜大多数.fits图像没有这个多图像设置到一个文件。 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. 选择上面的行后,我只需将其单独保存为.fits图像。

Brandon Doyle 布兰登道尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM