-1

I am currently trying to display this fits image, but I keep running into different errors. At first it couldn't print the non-ASCII characters in the header so I went ahead and deleted them (they seemed like just blank spaces in the header, it started a ' but didn't it close it with another ' so I figured it was that and put another ' to close it (?), specifically in the "BUNIT" section and the "INSTRU" one). This is how I'm trying to show the image:

from astropy.io import fits
from astropy import wcs
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_axes(111, projection=wcs.WCS('uwc.fits'))

ax.imshow(fits.getdata('uwc.fits'))

This is how the header looked after I deleted the whole BUNIT and INSTRU thing:

SIMPLE  =                    T          / FILE IN FITS FORMAT
BITPIX  =                   16          / SIZE OF PIXELS
NAXIS   =                    3          / NUMBER OF AXES
NAXIS1  =                  181          /
NAXIS2  =                   91          /
NAXIS3  =                    1          /
BSCALE  =          .831495E-02          / REAL = TAPE*BSCALE+BZERO
BZERO   =          .319702E+02          / ZERO CORRECTION
BUNIT   = '        '                    / UNITS OF BRIGHTNESS
DATAMAX =          .302206E+03          / MAXIMUM DATA VALUE IN FILE
DATAMIN =          .319702E+02          / MINIMUM DATA VALUE IN FILE
BLANK   =               -15751          / BLANK VALUE (C279 HEX)
OBJECT  = 'C Band   (0.16-0.2'          / IMAGE NAME
DATE    = '05/02/89'                    / DATE
DATOBS  = '        '                    / DATE OBJECT OBSERVED
INSTRU  = '                  '          / INSTRUMENT
OBSERV  = '                  '          / NAME OF OBSERVER
ORIGIN  = 'PENN STATE'                  / TAPE ORIGIN
CTYPE1  = 'GLON-AIT'                    /
CRVAL1  =              .000000          /
CRPIX1  =            91.000010          /
CDELT1  =            -1.800000          /
CROTA1  =              .000000          /
CTYPE2  = 'GLAT-AIT'                    /
CRVAL2  =              .000000          /
CRPIX2  =            46.000000          /
CDELT2  =             1.800000          /
CROTA2  =              .000000          /
CTYPE3  = '        '                    /
CRVAL3  =              .000000          /
CRPIX3  =              .000000          /
CDELT3  =              .000000          /
CROTA3  =              .000000          /
END

Then it had another error. Specifically it looked like this:

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


<Figure size 432x288 with 0 Axes>

I don't know what this error means and I don't know how to fix the header anymore. I had tried deleting the whole CTYPE3 to CROTA3 section but it didn't work out because a "TypeError: from_bounds() argument after * must be an iterable, not int" came up. Any help or reference here will be appreciated, thank you!!

1 Answers1

2

You can tell WCS which axis to use with the naxis parameter:

In [1]: from astropy.wcs import WCS

In [2]: from astropy.io import fits

In [3]: hdr = fits.Header.fromstring('''
   ...: SIMPLE  =                    T          / FILE IN FITS FORMAT
   ...: BITPIX  =                   16          / SIZE OF PIXELS
   ...: NAXIS   =                    3          / NUMBER OF AXES
   ...: NAXIS1  =                  181          /
   ...: NAXIS2  =                   91          /
   ...: NAXIS3  =                    1          /
   ...: BSCALE  =          .831495E-02          / REAL = TAPE*BSCALE+BZERO
   ...: BZERO   =          .319702E+02          / ZERO CORRECTION
   ...: BUNIT   = '        '                    / UNITS OF BRIGHTNESS
   ...: DATAMAX =          .302206E+03          / MAXIMUM DATA VALUE IN FILE
   ...: DATAMIN =          .319702E+02          / MINIMUM DATA VALUE IN FILE
   ...: BLANK   =               -15751          / BLANK VALUE (C279 HEX)
   ...: OBJECT  = 'C Band   (0.16-0.2'          / IMAGE NAME
   ...: DATE    = '05/02/89'                    / DATE
   ...: DATOBS  = '        '                    / DATE OBJECT OBSERVED
   ...: INSTRU  = '                  '          / INSTRUMENT
   ...: OBSERV  = '                  '          / NAME OF OBSERVER
   ...: ORIGIN  = 'PENN STATE'                  / TAPE ORIGIN
   ...: CTYPE1  = 'GLON-AIT'                    /
   ...: CRVAL1  =              .000000          /
   ...: CRPIX1  =            91.000010          /
   ...: CDELT1  =            -1.800000          /
   ...: CROTA1  =              .000000          /
   ...: CTYPE2  = 'GLAT-AIT'                    /
   ...: CRVAL2  =              .000000          /
   ...: CRPIX2  =            46.000000          /
   ...: CDELT2  =             1.800000          /
   ...: CROTA2  =              .000000          /
   ...: CTYPE3  = '        '                    /
   ...: CRVAL3  =              .000000          /
   ...: CRPIX3  =              .000000          /
   ...: CDELT3  =              .000000          /
   ...: CROTA3  =              .000000          /
   ...: END
   ...: ''', sep='\n')

In [4]: WCS(hdr, naxis=(1,2))
Out[4]: 
WCS Keywords

Number of WCS axes: 2
CTYPE : 'GLON-AIT'  'GLAT-AIT'  
CRVAL : 0.0  0.0  
CRPIX : 91.00001  46.0  
NAXIS : 181  91  1
saimn
  • 443
  • 2
  • 10