0

I am trying to do a 2d polar histogram. my data are 2 np.arrays:

azim = [azimuth angles -180 to +180 degrees]
zenith = [zenith angles 0 to 90 degrees]

This is the code i have so far :

# 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()

And the plot that i get:

it looks as if part of it is missing and i am not sure why. Also i would like to normalize the zenith angles to solid angle instead of normilizing to one. the formula for the normalization is this, where θ1, θ2 are the bin edges. but i'm not sure how to do the actual normalization:

any suggestions would be really helpful

1 Answers1

0

You have to convert your angles in radiant before using polar plots in maptlotlib.

Liris
  • 1,399
  • 3
  • 11
  • 29
  • should have thought of that. thanks. Got anything on normalization too? – Konstantina Sep 14 '20 at 16:01
  • I'am not sure about the normalization you mention, but if you add the keyword `density = 1` in the call of `np.histogram2d`, then your histogram is normalized to one. Your solid angle is actually an array too if it depends on the bin edges right ? It is not a constant for every bins ? – Liris Sep 14 '20 at 16:15
  • Yes it is an array. According to my professor, after the normalization the whole zenith angle distribution should shift towards lower values. but i don't know of a way to normalize each bin separately or if it is even possible. – Konstantina Sep 14 '20 at 16:22