New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add aperture masks #453
Add aperture masks #453
Conversation
@larrybradley hi, how exactly can I now use this method to perform the procedure described in #8 ? Despite many functions documented here, and an attempted implementation of the method described above I am unable to perform (what should be straightforward) Median background subtraction through an annulus. It may be a lack of understanding of what exactly the ApertureMask object is returning on my half, as 'm0.shape' is returning a 2d array of mostly zeros (despite the fact the pixels inside the annulus certainly are not zero). Any direct answers to #8 ? Cheers |
@tnorth2 Thanks for your question and reminding me that I need to expand the aperture mask documentation.
Here's a quick example: from photutils.datasets import make_100gaussians_image
from photutils import CircularAnnulus
data = make_100gaussians_image()
xypos = (291, 113.5)
ann = CircularAnnulus(xypos, r_in=10, r_out=15)
method = 'exact'
ann_mask = ann.to_mask(method=method)[0] # only one xypos
plt.imshow(ann_mask.data) Here's what the annulus mask looks like: Note that with Weighted mean: weighted_data = ann_mask.apply(data)
np.average(weighted_data, weights=ann_mask)
4.6969601309256248 If you want to simply use from photutils.datasets import make_100gaussians_image
from photutils import CircularAnnulus
data = make_100gaussians_image()
xypos = (291, 113.5)
ann = CircularAnnulus(xypos, r_in=10, r_out=15)
method = 'center'
ann_mask = ann.to_mask(method=method)[0] # only one xypos
weighted_data = ann_mask.apply(data)
np.median(weighted_data[weighted_data != 0])
5.0622323212147089 EDIT: I should also note that the |
`photutils` defaults made this somewhat nontrivial, but it can be done by following astropy/photutils#453
This PR is a significant refactoring of the aperture subpackage to add the ability to get aperture masks. It a continuation of the initial work in #446.
While there are many new features, there are only a few user-facing API changes:
source_id
keyword was renamed toindices
in the apertureplot()
method (because apertures are independent of sources or data).get_fractions()
) were removed.Here are the highlights of the other changes:
do_photometry()
method.do_photometry()
is now defined only once, in thePixelAperture
class.to_mask()
method. This method is provided by new Mixin classes for each of thePixelAperture
shapes.to_mask()
method returns a newApertureMask
object.do_photometry()
method now hasmask
andunit
keywords._slices
and_geom_slices
properties.Example usage: