def all_sta_wind_rose(): fig = plt.figure(figsize=(16, 16)) rect = [[0.05, 0.55, 0.35, 0.35], [0.55, 0.55, 0.35, 0.35], [0.05, 0.05, 0.35, 0.35], [0.55, 0.05,0.35, 0.35]] plot = 0 for station in station_dict.keys(): wa = WindroseAxes(fig, rect[plot]) fig.add_axes(wa) ANN, DJF, MAM, JJA, SON = load_AWS(station) # define data limits max_mod = max(ANN['FF_10m']) wa.set_title(station_dict[station], fontsize=28, color='dimgrey', pad=50) wa.axes.spines['polar'].set_visible(False) wa.tick_params(axis='both', which='both', labelsize=20, tick1On=False, tick2On=False, labelcolor='dimgrey', pad=10) wa.bar(ANN['WD'], ANN['FF_10m'], bins=np.arange(0, 20, 4), cmap=plt.get_cmap('viridis'), normed=True, opening=0.8, edgecolor='white') wa.set_yticks([5,10,15]) wa.set_yticklabels([ '', '10%', '15%']) plot = plot + 1 lgd = wa.set_legend(bbox_to_anchor=(-0.45, 1.)) frame = lgd.get_frame() frame.set_facecolor('white') for ln in lgd.get_texts(): plt.setp(ln, color='dimgrey', fontsize=24) lgd.get_frame().set_linewidth(0.0) if host == 'bsl': plt.savefig('/users/ellgil82/figures/Hindcast/Validation/wind_rose_all_stations_all_years.png') plt.savefig('/users/ellgil82/figures/Hindcast/Validation/wind_rose_all_stations_all_years.eps') elif host == 'jasmin': plt.savefig('/gws/nopw/j04/bas_climate/users/ellgil82/hindcast/figures/wind_rose_all_stations_all_years.png') plt.savefig('/gws/nopw/j04/bas_climate/users/ellgil82/hindcast/figures/wind_rose_all_stations_all_years.eps') plt.show()
def plot_roses(filename, vdir, mag, nsector=16, bins=10, title=None, legtitle=None, dpi=150, figsize=(10, 10), tfont=17, lfont=14): """ Plots the rose chart from wind data and saves it to png file. """ fig = plt.figure(figsize=figsize) # [left, bottom, width, height] as a fraction of total figure size right_rectangle = [0.05, 0.05, 0.85, 0.8] ax = WindroseAxes(fig, right_rectangle) fig.add_axes(ax) # ax.bar(wind['dir'], wind['sp'], normed=True, opening=0.9, edgecolor='white', bins=np.logspace(-1,1.3, 10), nsector=16) # ax.bar(wind['dir'], wind['sp'], normed=True, opening=0.9, edgecolor='white', bins=np.linspace(0,max(wind['sp']), 10), nsector=16) ax.bar(vdir, mag, normed=True, opening=0.9, edgecolor='white', bins=bins, nsector=nsector) if title: ax.set_title("{}".format(title), position=(0.5, 1.1), fontsize=tfont) cfont = max([8, lfont - 2]) ax.tick_params(axis='both', which='major', labelsize=cfont) ax.set_legend() if legtitle: ax.legend(title='{}'.format(legtitle), loc=(0.0, 0.0)) #used to pretty up the printing around of wind occurent frequencies tictic = ax.get_yticks() ax.set_yticks(np.arange(0, tictic[-1], tictic[-1] / len(tictic))) ax.yaxis.set_major_formatter(tkr.FormatStrFormatter('%2.0f')) if isinstance(filename, list): for item in filename: fig.savefig(item, dpi=dpi) else: fig.savefig(filename, dpi=dpi) plt.close() return 0
fig.add_axes(ax) ax.bar(mto[wdir], mto[wsp], normed=True, opening=0.8, edgecolor='white', bins=np.logspace(-1, 1, 10)) ax.set_title("annual", position=(0.5, 1.1)) ax.set_legend() ax.legend(title="wind speed (m/s)", loc=(1.1, 0)) #used to pretty up the printing around of wind occurenc frequencies import matplotlib.ticker as tkr ax.set_yticks(np.arange(0, 15, 3)) ax.yaxis.set_major_formatter(tkr.FormatStrFormatter('%2.0f')) ###################################################################### # If now we want to combine subplots for windroses (using rectangles as # shown above) and monthly averages (or any kind of grouping), then we'll # want to create a grid of rectangles defining subplots. # # This is the role of *gridspec* in the matplotlib library. # from windrose import WindroseAxes import matplotlib.ticker as tkr import matplotlib.gridspec as gridspec