astropy / astropy

Astronomy and astrophysics core library
https://www.astropy.org
BSD 3-Clause "New" or "Revised" License
4.42k stars 1.77k forks source link

SingularMatrixError in WCS #5829

Closed nienie86 closed 7 years ago

nienie86 commented 7 years ago

I recently upgraded astropy to v1.3, but now I have problems with the WCS module (astropy.wcs.WCS). With some FITS files (but not all) I get the following error:

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.

I cannot figure out what the problem is or how to fix this. Has anyone encountered this issue before?

pllim commented 7 years ago

Could you please provide a file (or just the header) for the problematic WCS?

nienie86 commented 7 years ago

This is the header:

SIMPLE  =                    T / file does conform to FITS standard             
BITPIX  =                  -32 / number of bits per data pixel                  
NAXIS   =                    3 / number of data axes                            
NAXIS1  =                  400 / length of data axis 1                          
NAXIS2  =                  400 / length of data axis 2                          
NAXIS3  =                    1 / length of data axis 3                          
EXTEND  =                    T / FITS dataset may contain extensions            
COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H 
CTYPE1  = 'RA---SIN'                                                            
CTYPE2  = 'DEC--SIN'                                                            
CDELT1  = -2.78473963018089E-06                                                 
CDELT2  = 2.78473963018089E-06                                                  
CRPIX1  =                200.5                                                  
CRPIX2  =                200.5                                                  
CRVAL1  =                   0.                                                  
CRVAL2  =                   0.                                                  
CTYPE3  = 'VELO-LSR'                                                            
CDELT3  =                   0.                                                  
CRPIX3  =                   1.                                                  
CRVAL3  =                   0.                                                  
BUNIT   = 'K       '                                                            
OBJECT  = 'model   '                                                            
END                                                                             
nden commented 7 years ago

I think CDELT3=0 is what causes the problem. The PC matrix is not specified, so it is internally set to identity. Then it's multiplied by CDELT3 and becomes non-singular. What was the intended use of CDELT3 (the default value is 1)?