def _cart2polar(x, y, center): xx = x - center[0] yy = y - center[1] phi = np.arctan2(yy, xx) r = np.hypot(xx, yy) return r, phi