astropy WCS infomation different to header values in fits files

280 views Asked by At

I am having an issue while working with fits files. The problem has to do with the wcs and the header of my file, and for information, the axes of my fits files are velocity and degrees.

The problem is that there is a discrepancy between what WCS says and what my header (which is correct) says.

In particular, if I do:

fits.open('file.fits')[0].header['CRVAL2']

, I get 6012.0, and for

fits.open('pv749290_gu.fits')[0].header['CDELT2']

, I get 4.0

So far so good. The problem arises when I do

w = WCS('file.fits')

, because I get:

 CRVAL : 0.0  6012000.0 

 CDELT : 2.999833375699044  4000.0  

So, as you can see the values that I originally had for CRVAL2 and CDELT2 are suddenly 3 orders of magnitude larger, and then this affects then plotting my image because I use "w" as a projection to plot my axes. Could someone help me to solve this problem? Thanks in advance!

1

There are 1 answers

1
Enrique On

So, if anyone ever has the same problem one day:

The problem was that, in my attempt to be as clear as possible, I was adding a value to CUNIT2 of my file, even when originally that keyword was not in the header. In this case, I was using hdr['CUNIT2']='KM/S', but when looking at WCS(file.fits), the value of CRVAL2 seemed to be in m/s instead of km/s, so I think there was some tension between the defaults of WCS and the units I was giving(?).

In any case, by removing again the label of CUNIT2 of the header, and reading again WCS(file.fits) the discrepancies between WCS and the header were gone and the file has now the correct dimension, although the units are not specified in a keyword (but of course you can add a comment to CRVAL2 explicitly saying the units.)