带有Python的2d极坐标直方图

问题描述

我正在尝试制作二维极坐标直方图。我的数据是2个np.arrays:

方位角= [方位角-180至+180度]
天顶= [天顶角度0到90度]

这是我到目前为止的代码

# define binning
rbins = np.linspace(0,90,10)
abins = np.linspace(-180,180,30)

#calculate histogram
hist,_,_ = np.histogram2d(azim,zenith,bins=(abins,rbins))
A,R = np.meshgrid(abins,rbins)

# plot
fig,ax = plt.subplots(subplot_kw=dict(projection="polar"))

pc = ax.pcolormesh(A,R,hist.T,cmap="magma_r")
fig.colorbar(pc)
ax.grid(True)
plt.show()

我得到的情节:

它看起来好像缺少了一部分,我不确定为什么。 我也想将天顶角标准化为立体角,而不是标准化为一个。 归一化的公式是这样,其中θ1,θ2是面元边缘。但我不确定如何进行实际的归一化:

任何建议都会很有帮助

解决方法

在maptlotlib中使用极坐标图之前,必须转换辐射角。