1

I'm trying to convert some RA and Dec I have to pixels to cutout a fits image and I keep getting the following error:

NoConvergence: 'WCS.all_world2pix' failed to converge to the requested accuracy. After 2 iterations, the solution is diverging at least for one input point.

This is the code i'm using:

coordinates_ID = zip(ID, RA, Dec)  
pixRA = []
pixDec = []
for i in coordinates_ID:
    pixra, pixdec = w.all_world2pix(i[1], i[2], 1)
    pixRA.append(pixra)
    pixDec.append(pixdec)


test = (pixRA[35], pixDec[35])

size = (200, 200)

cut = Cutout2D(sciim[0].data, test, size).data

plt.imshow(cut, origin='lower', cmap='viridis')
plt.colorbar()

img_file = "/home/myname/test.fits"
img_hdu = fits.PrimaryHDU(cut, header=sciimheader)
img_hdu.writeto(img_file, overwrite=True)

I must state that coordinates_id is 3 zipped tables (like three lists) of the coordinates of objects in my image and the corresponding names. Can anyone spot what could cause me to get the error i'm getting?

0 Answers0