kvmstickers.blogg.se

Python polar to cartesian with math
Python polar to cartesian with math













python polar to cartesian with math

Just posting the code in case it is useful to anyone else. Which is not strictly re-gridding, but works fine for what I need.

python polar to cartesian with math

# Interpolate polar grid to cartesian grid (cubic spline)Īx.imshow(polar2cartesian(r, t, z, x, y, order=3), interpolation='nearest') # Interpolate polar grid to cartesian grid (nearest neighbor)Īx.imshow(polar2cartesian(r, t, z, x, y, order=0), interpolation='nearest') Ir = interp1d(r, np.arange(len(r)), bounds_error=False) Thanks for your answers - after thinking a bit more about this I came up with the following code: import numpy as npįrom scipy.ndimage import map_coordinatesĭef polar2cartesian(r, t, grid, x, y, order=3):















Python polar to cartesian with math