Hi,
I hope this is the correct place to pose a question about a method in photutils ?
I get this error, althought I (try to) use the methods as documented in :
https://photutils.readthedocs.io/en/stable/aperture.html#aperture-masks
This is (a piece of) my code, the annulus_aperture is used in other places of my code, where it works fine.
annulus_aperture = CircularAnnulus(starinfile[‘sky_pix_midden’], r_in=radius_in2, r_out=radius_out)
masks = annulus_aperture.to_mask(method=‘exact’)
at this line it goes wrong, image2 is my fits photo where I do succesfull photometry on :
data_weighted = masks[0].multiply(image2)
Thanks in advance.
1 Like
I do not have a direct explanation about why the .to_mask
sometimes returns an Aperture/Annulus instead of a list (default for my expectations).
I did make a workaround that allowed me to avoid the error, without understanding why the error is happening:
aperture = CircularAperture([ycenter, xcenter], aper_rad)
aper_mask = aperture.to_mask(method='exact')
if isinstance(aper_mask, (list, tuple, np.ndarray)):
aper_mask = aper_mask[0]
image_mask = aper_mask.to_image(image_shape)
An Aperture instance can have one or more positions. An Aperture object with a single position is “scalar” and its to_mask
method will return a single ApertureMask
object. An Aperture object with multiple positions is not scalar and its to_mask
method will return a list of ApertureMask
objects, one for each position. You can use the Aperture isscalar
attribute to determine if an aperture is scalar or not.