Skip to content

Instantly share code, notes, and snippets.

@barentsen
Created March 28, 2017 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barentsen/548f88ef38f645276fccea1481c76fc3 to your computer and use it in GitHub Desktop.
Save barentsen/548f88ef38f645276fccea1481c76fc3 to your computer and use it in GitHub Desktop.
Simple example for conversion from pixel (x,y) to celestial (ra,dec) using astropy
"""Example conversion from pixel coordinates to ra/dec."""
from astropy.io import fits
from astropy.wcs import WCS
x, y = 250, 250
f = fits.open('f242_e0_c98.fits')
mywcs = WCS(f[0].header)
ra, dec = mywcs.all_pix2world([[x, y]], 0)[0]
@alisson26
Copy link

x, y = 250, 250 are the length of data in axis 1 and 2 of the fits file?

This script can be applied to fits file with header like this in attach image?

Captura de tela de 2024-04-29 11-35-22

Thanks in advanced for u help, dear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment