问题描述:

i am using pyplot.imshow() to plot the color map of a galaxy, the data is a 50x50 array (2500 spectral pixels) for a data cube, but the galaxy itself only spans a small portion of the frame at an angle, i would like to apply an elliptical aperture onto the frame (at (25,25) ) and select only the data within the ellipse as the data outside the galaxy is quite noisy, so far i have only been able to apply a square aperture, below is what i have done.

`def distribution(infile):`

hdulist = pf.open(infile)

HaS=hdulist['HALPHA'].data[0, l, :][:, l]

#l is the width of the square aperture, l=50 means full frame

py.figure().suptitle('%s'%(infile))

py.imshow(HaS,interpolation='gaussian')

py.xlabel('Continuum')

py.colorbar()

here is the plot i have, i wish to apply an ELLIPTICAL aperture, is there any python functions for that?

Maybe not exactly what you need, but here is something to consider:

I have created a sample 2d distribution (galaxy)

```
x=linspace(-100,100, 1000)
y=linspace(-100,100, 1000)
x,y=meshgrid(x,y)
f=exp(-(x**2+y**2)/70**2)
imshow(f)
```

Then you can apply your filter:

```
f[(x**2+y**2)<10**2]=0
```

After that everything inside the circle with radius 10 will become 0 (I guess you can also copy the data somewhere):

Hope this helps