[SciPy-User] Re[SciPy-user] binning to polar coordinates

arsbbr arsbbr@gmx....
Tue Aug 28 05:33:11 CDT 2012


Hi,

I'm trying to rebin some uniform gridded data to polar coordinates. The
original data (Z) is noisy but on a fine grid. 

### snip

# define grid in cartesian coordinates
x = arange(-500, 500)
y = arange(-500, 500)
X, Y = meshgrid(x, y)
Z = X**2 + Y**2
Z += uniform(-5000, 5000, size=Z.shape))

# transform to polar coordinates

def cart2pol(x, y):
    theta = arctan2(y, x)
    rho = sqrt(x**2 + y**2)
    return (theta, rho)  

THETA_xy, RHO_xy = cart2pol(X, Y)

# define new polar grid
theta = arange(-pi, pi, 0.1)
rho = arange(0.1 ,500, 2.0)    

THETA, RHO = meshgrid(theta, rho)

# Tried to use griddata, but it gives of course very jumpy results, because
it 
# does not take the average over the pixels in a patch (dTHETA, dRHO) but an
interpolation at the
# exact new point.

interpolate.griddata((THETA_xy.ravel(), RHO_xy.ravel()), 
   Z.ravel(), (THETA, RHO), method='linear')
        
### snip

Is there a method that rebins the data to a new grid, possibly taking the
average 
of the Z-values inside a patch (dTHETA, dRHO)?

Thanks for any hints!



-- 
View this message in context: http://old.nabble.com/Rebinning-to-polar-coordinates-tp34348219p34348219.html
Sent from the Scipy-User mailing list archive at Nabble.com.



More information about the SciPy-User mailing list