radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
98 stars 65 forks source link

cube not loading #445

Closed chukus closed 6 years ago

chukus commented 6 years ago

Not happy with my cube. I include here the error output and also a print of the header. Thanks for any help/advice you can provide

In [10]: cube=SpectralCube.read('./13co10_cygnus_south.fits')

SingularMatrixError Traceback (most recent call last)

in () ----> 1 cube=SpectralCube.read('./13co10_cygnus_south.fits') /Users/croman/TRABAJO/anaconda/lib/python2.7/site-packages/spectral_cube/spectral_cube.pyc in read(cls, filename, format, hdu, **kwargs) 1906 from .io.core import read 1907 from .stokes_spectral_cube import StokesSpectralCube -> 1908 cube = read(filename, format=format, hdu=hdu, **kwargs) 1909 if isinstance(cube, StokesSpectralCube): 1910 if hasattr(cube, 'I'): /Users/croman/TRABAJO/anaconda/lib/python2.7/site-packages/spectral_cube/io/core.pyc in read(filename, format, hdu, **kwargs) 31 if format == 'fits': 32 from .fits import load_fits_cube ---> 33 return load_fits_cube(filename, hdu=hdu, **kwargs) 34 elif format == 'casa_image': 35 from .casa_image import load_casa_image /Users/croman/TRABAJO/anaconda/lib/python2.7/site-packages/spectral_cube/io/fits.pyc in load_fits_cube(input, hdu, meta, **kwargs) 145 meta['BUNIT'] = header['BUNIT'] 146 --> 147 wcs = WCS(header) 148 149 if wcs.wcs.naxis == 3: /Users/croman/TRABAJO/anaconda/lib/python2.7/site-packages/astropy/wcs/wcs.pyc in __init__(self, header, fobj, key, minerr, relax, naxis, keysel, colsel, fix, translate_units, _do_set) 501 502 if _do_set: --> 503 self.wcs.set() 504 505 for fd in close_fds: SingularMatrixError: ERROR 3 in wcsset() at line 2213 of file cextern/wcslib/C/wcs.c: Linear transformation matrix is singular. ERROR 3 in linset() at line 607 of file cextern/wcslib/C/lin.c: PCi_ja matrix is singular. ================ SIMPLE = T / BITPIX = -32 / NAXIS = 4 / NAXIS1 = 849 / NAXIS2 = 506 / NAXIS3 = 169 / NAXIS4 = 1 / DATAMIN = -0.3528173217773E+03 / DATAMAX = 0.2820169677734E+03 / BUNIT = 'K ' / CTYPE1 = 'RA---GLS ' / CRVAL1 = 0.3070000000000E+03 / CDELT1 = -0.6249836533973E-02 / CRPIX1 = 0.4699934086951E+03 / CROTA1 = 0.0000000000000E+00 / CTYPE2 = 'DEC--GLS ' / CRVAL2 = 0.3950000000000E+02 / CDELT2 = 0.6249836533973E-02 / CRPIX2 = 0.2390117482326E+03 / CROTA2 = 0.0000000000000E+00 / CTYPE3 = 'VRAD ' / CRVAL3 = 0.5000076037599E+04 / CDELT3 = 0.3320007324219E+03 / CRPIX3 = 0.9990000152588E+02 / CROTA3 = 0.0000000000000E+00 / CTYPE4 = ' ' / CRVAL4 = 0.0000000000000E+00 / CDELT4 = 0.0000000000000E+00 / CRPIX4 = 0.0000000000000E+00 / CROTA4 = 0.0000000000000E+00 / OBJECT = 'RIFTnorth' / RA = 0.3070000000000E+03 / Right Ascension DEC = 0.3950000000000E+02 / Declination EQUINOX = 0.2000000000000E+04 / LINE = '13CO(1-0) ' ALTRVAL = 0.1102013700000E+12 / ALTRPIX = 0.9990000152588E+02 / RESTFREQ= 0.1102013700000E+12 / VELO-LSR= 0.5000000000000E+04 / VELREF = 257 ORIGIN = 'GILDAS Consortium ' / DATE = '2014-03-19T00:00:00.00' / Date written END
e-koch commented 6 years ago

Hi @chukus -- It looks the issue is occurring in astropy.wcs, not spectral-cube.

The issue is with CDELT4=0.0. See this issue: https://github.com/astropy/astropy/issues/5829. Setting it to something non-zero will hopefully fix the problem (though you may want to remove the redundant 4th axis if it isn't needed).

chukus commented 6 years ago

this worked! thanks!!