Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from astropy.io import fits
- from astropy.wcs import WCS
- import numpy as np
- import astropy.units as u
- from photutils import SkyCircularAperture, aperture_photometry
- from photutils.extern.wcs_utils import pixel_to_skycoord
- image_shape = (100, 200)
- header = WCS({'CTYPE1': 'RA---TAN',
- 'CTYPE2': 'DEC--TAN',
- 'CRPIX1': int(image_shape[1] / 2),
- 'CRPIX2': int(image_shape[0] / 2)}, ).to_header()
- hdu = fits.ImageHDU(np.ones(image_shape), header=header)
- pos_p = u.Quantity(([150., 20., 150., 150.],
- [65., 20., 6., 35.]), unit=u.pixel)
- pos_p_s = u.Quantity(([150., ], [65., ]), unit=u.pixel)
- pos = pixel_to_skycoord(pos_p[0], pos_p[1], WCS(hdu.header))
- pos_s = pixel_to_skycoord(pos_p_s[0], pos_p_s[1], WCS(hdu.header))
- photometry_skycoord_circ = aperture_photometry(
- hdu, SkyCircularAperture(pos, 3 * u.deg))
- photometry_skycoord_circ_s = aperture_photometry(
- hdu, SkyCircularAperture(pos_s, 3 * u.deg))
- print photometry_skycoord_circ
- print photometry_skycoord_circ_s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement