回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有一个名为“我的”的FITS文件_立方体拟合'与WCS。该文件包含轴1和轴2(X和Y)的空间信息和轴3(Z)的光谱信息。当我用<strong>astropy.io.适合</strong>,谱轴为0,空间轴为1和2。文件的加载方式如下:</p>
<pre><code> import astropy.io.fits as pyfits
filename = 'my_cube.fits'
my_data = pyfits.getdata(filename)
my_header = pyfits.getheader(filename)
</code></pre>
<p>我一直在使用matplotlib来显示数据,我想知道如何使用WCS显示数据立方体的单个光谱帧。比如说:</p>
^{pr2}$
<p>如果我这么做,我有:</p>
<pre><code> ...
File "/usr/local/lib/python3.4/dist-packages/matplotlib/figure.py", line 1005, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/matplotlib/axes/_subplots.py", line 73, in __init__
self._axes_class.__init__(self, fig, self.figbox, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/core.py", line 49, in __init__
self.patch = self.coords.frame.patch
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 129, in patch
self._update_patch_path()
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 115, in _update_patch_path
self.update_spines()
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 192, in update_spines
self['b'].data = np.array(([xmin, ymin], [xmax, ymin]))
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 40, in data
self._world = self.transform.transform(self._data)
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/transforms.py", line 166, in transform
world = self.wcs.wcs_pix2world(pixel_full, 1)
File "/usr/local/lib/python3.4/dist-packages/astropy/wcs/wcs.py", line 1329, in wcs_pix2world
'output', *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/astropy/wcs/wcs.py", line 1231, in _array_converter
return _return_single_array(xy, origin)
File "/usr/local/lib/python3.4/dist-packages/astropy/wcs/wcs.py", line 1212, in _return_single_array
"of shape (N, {0})".format(self.naxis))
ValueError: When providing two arguments, the array must be of shape (N, 3)
</code></pre>