I have a 2d Gaussian that is defined as:
import numpy as np
import matplotlib.pyplot as plt
max_val, x_mean, y_mean, sig_x, sig_y, alpha = [1, 0, 0, 0.01, 0.01, 0]
xline = np.arange(-0.5, 0.5, 0.001)
yline = np.arange(-0.5, 0.5, 0.001)
x_grid, y_grid = np.meshgrid(xline, yline)
n_grid = max_val * np.exp(-((x_grid - x_mean) ** 2 / (2 * sig_x) + (y_grid - y_mean) ** 2 / (2 * sig_y)))
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('2D view (upper view)');
ax.set_xlabel('x')
ax.set_ylabel('y')
plt.pcolor(x_grid, y_grid, n_grid, cmap='seismic', vmin=-3, vmax=3)
plt.colorbar()
plt.show()
and I would like to transform it to polar coordinates, so it looks like the following polar Gaussian [1]:
The cartesian2polar transformation functions that I find on the internet transform the Cartesian (x_grid and y_grid) to rho and phi, but this does not rearrange my ngrid data as desired. How could I transform the ngrid data to the desired polar Gaussian?