Skip to content

Instantly share code, notes, and snippets.

@bsipocz
Last active August 29, 2015 14:11
Show Gist options
  • Save bsipocz/82afbf783f888230946e to your computer and use it in GitHub Desktop.
Save bsipocz/82afbf783f888230946e to your computer and use it in GitHub Desktop.
Test showing that non fixed scale results different photometric flux depending on the number of positions
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment