astropy: Singular matrix error when setting WCS

Description

I have a series of images, all of which produce an error when trying to set a WCS:

SingularMatrixError: ERROR 3 in wcsset() at line 2395 of file cextern/wcslib/C/wcs.c:
Linear transformation matrix is singular.
ERROR 3 in linset() at line 677 of file cextern/wcslib/C/lin.c:
PCi_ja matrix is singular.

Expected behavior

I expected to get an astropy.wcs.WCS object to use to convert sky and pixel coordinates.

Actual behavior

When reading the image either with CCDData (which creates a WCS automatically) or with astropy.io.fits.open(<filename>), and then passing the header to astropy.wcs.WCS myself, I get the SingularMatrixError message above.

I also get a related error if I just run wcslint on the fits file directly:

  WCS key ' ':
    - RADECSYS= 'FK5' / Coordinate system, per TCC ObjSys
      the RADECSYS keyword is deprecated, use RADESYSa.
    - 'datfix' made the change 'Invalid parameter values: MJD-OBS and
      DATE-OBS are inconsistent'.
    - 'celfix' made the change 'Linear transformation matrix is
      singular'.

HDU 1 (LAST_FRAME):
  WCS key ' ':
    - 'datfix' made the change 'Invalid parameter values: MJD-OBS and
      DATE-OBS are inconsistent'.
    - 'celfix' made the change 'Linear transformation matrix is
      singular'.

Steps to Reproduce

Example image is available at https://epyc.astro.washington.edu/~lynnej/astropy_issue2_image.fits

Either just opening the file and passing the header to WCS directly, or first editing the header for the issues that wcslint reported result in the SingularMatrixError.

import os
from astropy.io import fits 
from astropy import wcs

d = fits.open(os.path.join(ddir, imname))
header = d[0].header
del header['MJD-OBS']
header['RADESYSa'] = header['RADECSYS']
del header['RADECSYS']
header
wcs.WCS(header, naxis=(1,2))

System Details

Darwin-19.2.0-x86_64-i386-64bit Python 3.7.6 (default, Jan 8 2020, 13:42:34) [Clang 4.0.1 (tags/RELEASE_401/final)] Numpy 1.18.1 astropy 4.0 Scipy 1.3.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (19 by maintainers)

Most upvoted comments

Looks like the data creator made invalid WCS? Should we close?

I think my question should be rephrased as : “given that CNPIX* header keywords imply that you should have additional specific keys, could an error be given that indicates such?” something like “CNPIXi header keywords imply that a DSS WCS is in use and requires AMD* or ?PIXELSZ coefficients, but these are missing.”

I can send a message to our local APO people and see if I can find out more.

@dhomeier A valid set of WCS keywords is defined in the WCS papers which is what wcslib imlements. wcslib also is capable of reading some non-standard conventions. CNPIX1/2 are definitely part of a non-standard convention but I am not sure which one. Perhaps @rhiannonlynne can point us to this WCS convention? All I found through google is https://iraf.net/forum/viewtopic.php?showtopic=104279