Skip to content

Instantly share code, notes, and snippets.

@wkerzendorf
Created April 20, 2016 11:44
Show Gist options
  • Save wkerzendorf/eddf21e9ba1202a5e903a3ccd9a0268a to your computer and use it in GitHub Desktop.
Save wkerzendorf/eddf21e9ba1202a5e903a3ccd9a0268a to your computer and use it in GitHub Desktop.
WCS fit pseudo code
from astropy import wcs
from scipy import optimize
# this doesn't include the precise function names - just look them up on the astropy wcs website
def fit_func(crval1, crval2, x, y, ra, dec):
w = wcs.WCS(naxis=2)
w.wcs.crval = [crval1, crval2]
ra_wcs, dec_wcs = w.pix_to_world(x, y)
return (ra_wcs - ra)**2 + (dec_wcs - dec)**2
result = optimize.minimize(fit_func, [200, 45], args=(ref_x, ref_y, ref_ra, ref_dec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment