[AstroPy] Sigma clipping along an axis?

Erik Tollerud erik.tollerud at gmail.com
Mon Apr 29 19:48:34 EDT 2013


So what do you want as the output?  If you want only the *values* that
are clipped/not clipped, you can't get an array back, because each of
the 60x60 sub-arrays will give you *different* lengths of clipped
arrays back.  So perhaps you want the mask of clipped arrays?  If so,
most straightforward is probably (unfortunately) nested for loops:


from astropy.stats import sigma_clip

frames = *your 60x60xN array*

masks = [[sigma_clip(subarrj, ...)[1]  for  subarrj in subarri] for
subarri in frames] #gmail will probably break this into multiple
line... but it's supposed to be all one line

maskarr = np.array(masks)


After that, maskarr will be a 60x60xN boolean array that is *False*
where the data was clipped, and *True* where it is valid.

There's also probably a way to adjust the astropy.stats.sigma_clip
function to do this automatically and in a more numpy-optimized way.
Feel free to add this as an issue for
astropy (https://github.com/astropy/astropy/issues).


On Mon, Apr 29, 2013 at 7:21 PM, Lisa Fogarty
<l.fogarty at physics.usyd.edu.au> wrote:
> Hi All,
>
> I would like to perform a sigma-clipped sum of several data frames (60x60
> pixels each). I have put the frames into a 3D array - so if I have N frames
> the array is 60x60xN. I therefore want to sigma clip along the z-axis. As
> far as I can see the astropy.stats.sigma_clip function ravels the data
> before performing the sigma clip (i.e. it clips in the whole array, where I
> want to clip pixel-by-pixel). Is there a pythonic way I can accomplish what
> I want to do?
>
> Many thanks,
> Lisa.
>
> --
> Dr Lisa Fogarty | Postdoctoral Research Associate, SIfA, Sydney Institute
> for Astronomy
> School of Physics | Faculty of Science
>
> THE UNIVERSITY OF SYDNEY
> Rm 464, Physics Building A29 | The University of Sydney | NSW | 2006
> | AUSTRALIA
>
> T +61 2 935 13112
> E  l.fogarty at physics.usyd.edu.au | W  http://sydney.edu.au/science/physics
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>



--
Erik



More information about the AstroPy mailing list