marvin
marvin copied to clipboard
define, or link to, attributes on MarvinAperture
Is your feature request related to a problem? Please describe.
I'm having trouble figuring out what I can and can't do with MarvinAperture
. I was trying to use the getAperture
feature to define an aperture around the center coordinate and retrieve a list of the indices (or pixel) coordinates in the resulting aperture, without grabbing spaxels. Is that possible? The positions
attribute seems like it does that but only returns the main pixel I asked for, e.g. [[17, 17]]
Describe the solution you'd like
Define remaining attributes that aren't already defined. Or if these are standard photutils
attributes, link to their documentation in the docstring in addition to the main photutils
doc page. The attributes that don't have information or aren't obvious are area
, positions
, and plot()
.
Additional context
I attempted to plot()
the aperture from the example, to see the aperture, and got a blank image.
Regarding the plot
method, it comes directly from photutils
and does what it is supposed to do there, for better or worse. We could consider overriding it but I'm not sure we should. It seems plot
does not set autoscale for the axes, so you need to adjust it manually. If you do
cube = marvin.tools.Cube('8485-1901')
ap = cube.getAperture([14, 12], 2)
fig, ax = plt.subplots()
ap.plot(ax=ax)
you probably won't see anything because the range is set to [0, 1]. If you then do ax.set_xlim(0, 34); ax.set_ylim(0, 34)
you should see the aperture.
About how to get the indices of the spaxels in there aperture, the thing is that there is no absolute answer to that question, because it depends on the threshold of what you consider a pixel included in the aperture. But ultimately it's easy to get the indices from the mask. For instance, to get all the indices of the pixels that overlap even a little with the aperture
numpy.where(ap.mask > 0)
I can add something to the documentation about this in case it is not clear. I'll also check but I'm fairly sure the documentation makes quite clear that MarvinAperture
is just a wrapper around photutils Aperture
except for the .mask
property and the .getSpaxel
method, and the photutils documentation is linked. But maybe it can be made more clear.
Regarding plot
, I think we don't want to override it. It's easy enough to do what you did in your example documentation. I do think people will do what I did, and just start using the tool, trying it out, and find it doesn't work as they might naively think. And only then start reading through the documentation. Since it is broken for us, do we want to remove it from the dir
?
Regarding the positions, that's also fine. I think it would be useful to add an example with coords = zip(*np.where(ap.mask))
or something like that. Yeah, you do mention that it is a wrapper. I followed the link and drilled down through their docs to find what I was looking for. We might want to add a specific link to the aperture page, http://photutils.readthedocs.io/en/stable/aperture.html
Yes, those are good points. I'll add those to the documentation.
I'm not sure about removing plot
. I agree it's a not a very well written photutil method (unless I'm missing some subtlety). Maybe we want to wrap it so that it does the same thing but we set the autoscale limits. I kind of feel it's a useful method if it worked a bit more intuitively.