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
97 stars 65 forks source link

Add StokesCube that's <4D #736

Open keflavich opened 3 years ago

keflavich commented 3 years ago

Right now, we can handle 4D stokes cubes, where we have (spatial, spatial, spectral, stokes). We should also support continuum stokes, i.e., (spatial, spatial, stokes). This is related to https://github.com/radio-astro-tools/spectral-cube/issues/732

chukus commented 2 years ago

Hello, I am trying to use spectralcube to open a 4D cube, where the stokes parameter is basically null, but is present. I think it should be fine, has the hdu info is ok. But SpectralCube.read gives an error. What can I do about this? Thanks

hdul = fits.open('rift-13co-all-3d--28-28_hr.fits')

hdul.info() Filename: rift-13co-all-3d--28-28_hr.fits No. Name Ver Type Cards Dimensions Format 0 PRIMARY 1 PrimaryHDU 46 (1183, 1446, 282, 1) int32 (rescales to float64)

Later...

Traceback (most recent call last): File "cubehandler.py", line 17, in cube=SpectralCube.read('rift-13co-all-3d--28-28_hr.fits', 'spectral_cube') File "/media/croman/DATA/anaconda3/lib/python3.8/site-packages/spectral_cube/io/core.py", line 118, in call return registry.read(BaseSpectralCube, filename, *args, kwargs) File "/media/croman/DATA/anaconda3/lib/python3.8/site-packages/astropy/io/registry/compat.py", line 43, in wrapper return getattr(registry, method_name)(*args, *kwargs) File "/media/croman/DATA/anaconda3/lib/python3.8/site-packages/astropy/io/registry/core.py", line 199, in read data = reader(args, kwargs) File "/media/croman/DATA/anaconda3/lib/python3.8/site-packages/spectral_cube/io/fits.py", line 204, in load_fits_cube wcs = WCS(header) File "/media/croman/DATA/anaconda3/lib/python3.8/site-packages/astropy/wcs/wcs.py", line 531, in init self.wcs.set() astropy.wcs._wcs.SingularMatrixError: ERROR 3 in wcsset() at line 2739 of file cextern/wcslib/C/wcs.c: Linear transformation matrix is singular. ERROR 3 in linset() at line 674 of file cextern/wcslib/C/lin.c: PCi_ja matrix is singular.

e-koch commented 2 years ago

Hi @chukus -- This may be an issue with the header in the file.

Do you get the same error with:

from astropy.wcs import WCS
mywcs = WCS(hdul[0])

?

chukus commented 2 years ago

Dang!. Found I had a similar problem before and I have no memory of it! #445. I set cdelt4=1.0 instead of 0.0 and it works now. Thanks, sorry for the lapsus.