Hello. I am writing some unit tests for a bit of software I’m working on, and one of the functions I’ve written uses astropy.wcs to create image headers. I’ve written a simple unit test to validate the output, but it’s failing for reasons I can’t quite understand. Here is some sample code to reproduce the problem:
from astropy.wcs import WCS
pxScale = 1/3600.
wcs_dict = {'CTYPE1': 'RA---TAN',
'CTYPE2': 'DEC--TAN',
'CRVAL1': 180.,
'CRVAL2': 0.,
'CRPIX1': 250,
'CRPIX2': 300,
'CD1_1': -pxScale,
'CD1_2': 0.0,
'CD2_1': 0.0,
'CD2_2': pxScale}
w = WCS(wcs_dict)
cen = w.wcs_world2pix(180., 0., 1)
assert cen[0] == 250.
assert cen[1] == 300.
The first assertion succeeds for me, but the second fails. cen[1]
here seems to be exactly the same data type as cen[0]
(numpy.ndarray
), so I can’t imagine why the first would succeed but the second wouldn’t.
Does anyone have a good explanation for this?