Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. from astropy.io import fits
  2. from astropy.wcs import WCS
  3. import numpy as np
  4. import astropy.units as u
  5.  
  6. from photutils import SkyCircularAperture, aperture_photometry
  7. from photutils.extern.wcs_utils import pixel_to_skycoord
  8.  
  9. image_shape = (100, 200)
  10. header = WCS({'CTYPE1': 'RA---TAN',
  11. 'CTYPE2': 'DEC--TAN',
  12. 'CRPIX1': int(image_shape[1] / 2),
  13. 'CRPIX2': int(image_shape[0] / 2)}, ).to_header()
  14.  
  15. hdu = fits.ImageHDU(np.ones(image_shape), header=header)
  16.  
  17. pos_p = u.Quantity(([150., 20., 150., 150.],
  18. [65., 20., 6., 35.]), unit=u.pixel)
  19. pos_p_s = u.Quantity(([150., ], [65., ]), unit=u.pixel)
  20.  
  21. pos = pixel_to_skycoord(pos_p[0], pos_p[1], WCS(hdu.header))
  22. pos_s = pixel_to_skycoord(pos_p_s[0], pos_p_s[1], WCS(hdu.header))
  23.  
  24. photometry_skycoord_circ = aperture_photometry(
  25. hdu, SkyCircularAperture(pos, 3 * u.deg))
  26. photometry_skycoord_circ_s = aperture_photometry(
  27. hdu, SkyCircularAperture(pos_s, 3 * u.deg))
  28.  
  29. print photometry_skycoord_circ
  30. print photometry_skycoord_circ_s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement