Created
          April 20, 2016 11:44 
        
      - 
      
- 
        Save wkerzendorf/eddf21e9ba1202a5e903a3ccd9a0268a to your computer and use it in GitHub Desktop. 
    WCS fit pseudo code
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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