CARTAvis / carta-backend

Source code repository for the backend component of CARTA, a new visualization tool designed for the ALMA, the VLA and the SKA pathfinders.
https://cartavis.github.io/
GNU General Public License v3.0
22 stars 11 forks source link

TabularCoordinate - start and end values in table must differ #373

Closed teuben closed 3 years ago

teuben commented 5 years ago

I have a FITS file, which to me looks quite ok. It works in ds9, but carta refuses to load it with the error:

Failed to open image at specified HDU: TabularCoordinate - start and end values in table must differ

The fitsheader reads as follows (file available upon request):

SIMPLE = T / conforms to FITS standard
BITPIX = -64 / array data type
NAXIS = 4 / number of array dimensions
NAXIS1 = 384
NAXIS2 = 384
NAXIS3 = 50
NAXIS4 = 1
CDELT1 = -0.0027777777777778
CRPIX1 = 192.5
CRVAL1 = 0.0
CTYPE1 = 'RA---TAN'
CUNIT1 = 'deg '
CDELT2 = 0.0027777777777778
CRPIX2 = 192.5
CRVAL2 = 0.0
CTYPE2 = 'DEC--TAN'
CUNIT2 = 'deg '
CDELT3 = 16000.0
CRPIX3 = 25.0
CRVAL3 = 271079.99324799
CTYPE3 = 'VOPT '
CUNIT3 = 'm s-1 '
CDELT4 = 1.0
CRPIX4 = 0.0
CRVAL4 = 0.0
CTYPE4 = 'STOKES '
CUNIT4 = 'PAR '
EPOCH = 2000
INSTRUME= 'MARTINI ' / 1.0.5_commit_3e93a1a
DATAMAX = 488.6826746584455
DATAMIN = -0.5763670411812526
ORIGIN = 'astropy v3.1.2'
OBJECT = 'MOCK '
BPA = 0.0
OBSERVER= 'K. Oman '
BUNIT = 'beam-1 Jy'
DATE-OBS= '2019-11-04T12:44:05.4'
BMAJ = 0.008333333333333333
BMIN = 0.008333333333333333
BTYPE = 'Intensity'
SPECSYS = 'TOPOCENT'
END

veggiesaurus commented 5 years ago

@teuben is there only one hdu in the file?

kswang1029 commented 5 years ago

Should CRVAL4 be 1 instead of 0 to represent Stokes = I?And CRPIX4 to be 1 instead of 0?

veggiesaurus commented 5 years ago

Should CRVAL4 be 1 instead of 0 to represent Stokes = I?And CRPIX4 to be 1 instead of 0?

I don' think that should cause a problem. Since CDELT4 is 1.0, the two options are equivalent (either way, w=1 => Stokes = I)

I've seen this issue before, but I can't remember where it cropped up.

teuben commented 5 years ago

it's a simple single HDU unit. I can make the file available, but I was hoping the header would give the clue.

On Mon, Nov 4, 2019 at 8:08 AM Angus Comrie notifications@github.com wrote:

@teuben https://github.com/teuben is there only one hdu in the file?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CARTAvis/carta-frontend/issues/593?email_source=notifications&email_token=AAZ4MGKZO2GJMVBBYNVH2CTQSANERA5CNFSM4JITFU32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC7FRQI#issuecomment-549345473, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ4MGJBBRRZRCUFAICL36LQSANERANCNFSM4JITFU3Q .

teuben commented 5 years ago

Here's the fits file I tried to view: ftp://ftp.astro.umd.edu/pub/teuben/eagle/eagle_martini_demo.fits

kswang1029 commented 5 years ago

additional information from CASA importfits task: 2019-11-05 04:43:26 WARN importfits::FITSCoordinateUtil::fromFITSHeader Zero or no rest frequency provided for velocity axis. 2019-11-05 04:43:26 WARN importfits::::ImageFITSConverter This HDU (0) did not contain a legible image. 2019-11-05 04:43:26 WARN importfits::::ImageFITSConverter Next candidate image HDU is CARTAvis/carta-frontend#1 2019-11-05 04:43:26 WARN importfits::::ImageFITSConverter+ (note: use the whichhdu parameter to address HDUs directly) 2019-11-05 04:43:26 SEVERE importfits::image::fromfits (file ../../tools/images/image_cmpt.cc, line 2380) Exception Reported: Exception: There are 1 HDUs in FITS file eagle_martini_demo.fits . None of them is a legible image.. 2019-11-05 04:43:26 SEVERE importfits::image::fromfits (file ../../tools/images/image_cmpt.cc, line 2380)+ ... thrown by static SPIIF casa::ImageFactory::fromFITS(const casacore::String &, const casacore::String &, const Int, const Int, const Bool, const Bool) at File: ../../imageanalysis/ImageAnalysis/ImageFactory2.cc, line: 370 2019-11-05 04:43:26 SEVERE importfits:::: Error Exception: There are 1 HDUs in FITS file eagle_martini_demo.fits . None of them is a legible image.. 2019-11-05 04:43:26 SEVERE importfits::::+ ... thrown by static SPIIF casa::ImageFactory::fromFITS(const casacore::String &, const casacore::String &, const Int, const Int, const Bool, const Bool) at File: ../../imageanalysis/ImageAnalysis/ImageFactory2.cc, line: 370 2019-11-05 04:43:26 SEVERE importfits:::: An error occurred running task importfits.

veggiesaurus commented 5 years ago

I'll transfer this issue to carta-backend and assign @pford to it

veggiesaurus commented 5 years ago

Did some digging, the error shows up in the following line:

casacore::FITSImage fits_img(_filename, 0, hdu_num);

so it's a casacore error, rather than a CARTA error :thinking: @pford will you look into this?

pford commented 4 years ago

FITSImage tries to create a casacore::CoordinateSystem with a casacore::SpectralCoordinate by parsing the FITS headers with WCSLIB. Then the optical velocities are converted to frequencies using: frequencies(i) = restFrequency/(vel/C::c+1.); // in Hz restFrequency is determined from the FITS headers restfreq or restwav, but since these headers do not exist all frequencies for the spectral axis are 0 Hz. These frequencies are given to the TabularCoordinate class, resulting in the error message.

The CASA viewer, which also uses casacore, gives the same error.

veggiesaurus commented 4 years ago

@pford so what are the next steps? Do we file a casa bug and keep this in the icebox? @kswang1029 do we mark this as a known issue?

is there a default restfreq or restwav value we could insert?

kswang1029 commented 4 years ago

I can mark this as a known issue in the user manual.

veggiesaurus commented 4 years ago

@pford can we try to work around this? Preventing users from opening certain FITS files entirely is quite an issue.

Here's a simple example of the type of header that is causing this issue:

SIMPLE  =                    T / conforms to FITS standard                      
BITPIX  =                  -32 / array data type                                
NAXIS   =                    3 / number of array dimensions                     
NAXIS1  =                  472                                                  
NAXIS2  =                  392                                                  
NAXIS3  =                 2048                                                  
CRPIX3  =                  1.0                                                  
EQUINOX =                 2000                                                  
CTYPE1  = 'RA---TAN'                                                            
CRPIX2  =                196.5                                                  
CRVAL1  =        128.943935587                                                  
CDELT1  =         -0.006666667                                                  
CROTA2  = '359.984194193'                                                       
CTYPE2  = 'DEC--TAN'                                                            
CRVAL2  =        -55.583803136                                                  
CDELT3  =     -11027.522471028                                                  
CDELT2  =          0.006666667                                                  
CRPIX1  =                236.5                                                  
CRVAL3  =      23182194.541397                                                  
CTYPE3  = 'VELO-HEL'                                                            
END                                                                             
veggiesaurus commented 3 years ago

@pford can we work around casa for this case?