0

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!

Enrique
  • 55
  • 7
  • What are the units of the WCS (`CUNIT1` and `CUNIT2`) ? Do you have an older style WCS with `CDELT` and `CROTA` or a newer style with a `CDi_j` matrix ? Can you post the full WCS somewhere...? – astrosnapper Nov 13 '18 at 01:00
  • Hi @astrosnapper, many thanks for willing to help. Actually your comment made me think a bit more on my CUNITn and I found the problem! – Enrique Nov 13 '18 at 09:48

1 Answers1

1

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.)

Enrique
  • 55
  • 7
  • 1
    Well, you should always try to make the data/FITS header as clear as possible... If you set `CUNIT2` to `'m/s'` (lower case), does it work ? According to https://github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive – astrosnapper Nov 13 '18 at 16:12