1

I posted another question a little while ago, but have since tried a different technique for plotting the windrose pollution rose. I am, however, still having issues with it. I found the template for this technique from this post I'm not sure where I am going wrong with the instructions, and am getting a weird looking plot.

Any help with where I'm going wrong would be greatly appreciated!

Here's the code:

wd = list(merge_all_apr['Wind Dir (10s deg)'])
conc = list(merge_all_apr['Mean_CO2'])
ws = list(merge_all_apr['Wind Spd (km/h)'])

wd_rad = np.radians(np.array(wd))

wind_dir, wind_speed = np.meshgrid(wd_rad, ws)

C = np.sinc(wind_dir-2)+(5-np.sqrt(wind_speed))+conc
C = np.ma.masked_less_equal(C,2)


fig, ax = plt.subplots(figsize=(20, 10), subplot_kw={"projection": "polar"})
cmap = plt.get_cmap('jet')
img = ax.pcolormesh(wind_dir, wind_speed, C, cmap=cmap, vmin=0, vmax=20, alpha = 0.70)
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1) 
ax.set_ylim(0,50)

ax.set_yticks(np.arange(0,50,5))

#move yticks to different radial position
ax.set_rlabel_position(40)

plt.colorbar(img)
plt.show()

And here's the plot result: (https://stackoverflow.com/image.jpg)

poolcheck
  • 77
  • 6
  • Can you share the data, maybe something wrong with it, not the code? – Evgeny Jul 07 '20 at 21:21
  • The line `C = np.sinc(wind_dir-2)+(5-np.sqrt(wind_speed))+conc` doesn't make sense. The linked post uses `sinc` only to create random data with some structure, it is not meant to use `sinc` with real data. `wind_dir, wind_speed = np.meshgrid(wd_rad, ws)` doesn't work if `wd` and `ws` are lists of related values. Could you comment about the difference between this question and [your very similar previous question](https://stackoverflow.com/questions/62781558/how-to-get-rid-of-discontinuity-on-windrose-pcolormap-plot-python)? Did you test the answer with your data? – JohanC Jul 07 '20 at 22:12
  • Thank you for the info about sinc! I was a bit confused about that line as well. The answer to my other question worked amazingly with the data! However, the issue with that technique is it is not as physically accurate as the result should be with this technique (as in the other interpolates data, and this should leave gaps where there are gaps). I'll edit the post with the data if that helps! – poolcheck Jul 08 '20 at 00:36
  • I think my main issue is with getting the concentration data into a form that the plotting function likes (a 2D array) without changing the data in any way. I seem to be missing the mechanism for modifying my list in a way which agrees with the wind speed and wind direction arrays – poolcheck Jul 08 '20 at 00:55
  • The [windrose library](https://windrose.readthedocs.io/en/latest/index.html) seems to have useful functions for your use case. – JohanC Jul 08 '20 at 08:02

0 Answers0