Open esoPanda opened 9 years ago
The 4th axis is degenerate but has no type. It actually looks like SpectralCube
is generally handling this. Could you print out the result of the cube's __repr__
? To do this, just enter the cube variable name on the command line, e.g. if you did cube = SpectralCube.read('file.fits')
, just enter cube
and print the results.
To fix the cube and get rid of the warnings, drop the degenerate axis and change BUNIT
f = fits.open('file.fits')
f[0].data = f[0].data.squeeze()
for k in f[0].header.keys():
if k[0] == 'C' and k[-1] == '4':
del f[0].header[k]
f[0].header['BUNIT'] = 'K'
cube = SpectralCube.read(f)
<bound method SpectralCube.__repr__ of SpectralCube with shape=(200, 158, 107):
n_x: 107 type_x: RA---SFL unit_x: deg
n_y: 158 type_y: DEC--SFL unit_y: deg
n_s: 200 type_s: VOPT unit_s: m / s>
25 f[0].data = f[0].data.squeeze()
26 for k in f[0].header.keys():
---> 27 if k[0] == 'C' and k[-1] == '4':
28 del f[0].header[k]
29 f[0].header['BUNIT'] = 'K'
IndexError: string index out of range
Based on the output you showed, you are not on the most up-to-date version of spectral_cube
. Try pip install https://github.com/radio-astro-tools/spectral-cube/archive/master.zip
. If that doesn't work, try pip install --upgrade https://github.com/radio-astro-tools/spectral-cube/archive/master.zip