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 wind_rose(station, AWS_var, model_var):
    fig = plt.figure(figsize = (16,8))
    rect = [0.05, 0.1, 0.45, 0.6]
    wa = WindroseAxes(fig, rect)
    fig.add_axes(wa)
    # define data limits
    max_mod = max(np.mean(vars_yr['FF_10m'][:,lat_index14-1:lat_index14+1, lon_index14-1:lon_index14+1].data, axis = (1,2)))
    max_obs = max(AWS_var['FF'])
    wa.set_title('Observed', fontsize = 28, color = 'dimgrey', pad = 50)
    wa.axes.spines['polar'].set_visible(False)
    wa.tick_params(axis='both', which='both', labelsize=24, tick1On=False, tick2On=False, labelcolor='dimgrey', pad=10)
    wa.bar(AWS_var['WD'], AWS_var['FF'], bins = np.arange(0, max(max_mod, max_obs),4), cmap = plt.get_cmap('viridis'), normed = True,opening=0.8, edgecolor='white')
    wa.set_yticklabels([])
    rect = [0.55, 0.1, 0.45, 0.6]
    wa = WindroseAxes(fig, rect)
    fig.add_axes(wa)
    wa.set_title('Modelled', fontsize=28, color='dimgrey', pad = 50)
    wa.bar(np.mean(vars_yr['WD'][:,lat_index14-1:lat_index14+1, lon_index14-1:lon_index14+1].data, axis = (1,2)),
           np.mean(vars_yr['FF_10m'][:,lat_index14-1:lat_index14+1, lon_index14-1:lon_index14+1].data, axis = (1,2)),
           bins = np.arange(0, max(max_mod, max_obs),4), cmap = plt.get_cmap('viridis'),  normed = True, opening=0.8, edgecolor='white')
    lgd = wa.set_legend( bbox_to_anchor=(-0.5, 0.9))
    frame = lgd.get_frame()
    frame.set_facecolor('white')
    for ln in lgd.get_texts():
        plt.setp(ln, color='dimgrey', fontsize = 18)
    lgd.get_frame().set_linewidth(0.0)
    wa.axes.spines['polar'].set_visible(False)
    wa.set_yticklabels([])
    wa.tick_params(axis='both', which='both', labelsize=24, tick1On=False, tick2On=False, labelcolor='dimgrey', pad=10)
    plt.savefig('/users/ellgil82/figures/Hindcast/validation/wind_rose_' + station + '_' + year + '.png')
    plt.savefig('/users/ellgil82/figures/Hindcast/validation/wind_rose_' + station + '_' + year + '.eps')
    plt.show()
def main(filename):
    fig = plt.figure(figsize=(12, 8), dpi=80, facecolor='w', edgecolor='w')
    ax = WindroseAxes(fig, [0.1, 0.1, 0.8, 0.8], facecolor='w')
    fig.add_axes(ax)
    windRose = np.loadtxt(filename)
    indexes = np.where(windRose[:, 1] > 0.1)
    windDirections = windRose[indexes[0], 0]
    windSpeeds = windRose[indexes[0], 1]
    # windSpeeds = windRose[indexes[0], 1] * 2 / np.sqrt(np.pi)  # convert from mean wind speed to weibull scale factor
    windFrequencies = windRose[indexes[0], 2]
    # size = len(windDirections)
    ax.box(windDirections, windSpeeds, frequency=windFrequencies, mean_values=1, bins=[15, 18, 20, 23, 25], nsector=72)
    # ax.box(windDirections, [[windSpeeds[i], 2] for i in range(len(windSpeeds))], frequency=windFrequencies, weibull_factors=1, bins=[15, 18, 20, 23, 25], nsector=72)
    ax.set_yticklabels([])
    plt.show()
Example #4
0
       normed=True,
       nsector=36,
       bins=np.arange(0, 14, 2))  #summer
plt.text(-0.06,
         1,
         '(a)',
         ha='left',
         va='center',
         transform=ax.transAxes,
         fontsize=bx_fs + 3)
plt.tick_params(axis='x', which='major', labelsize=tk_fs + 3)

ax.set_rlabel_position(340)  #122, 344, 198, 340
ax.set_rmax(10)  #8, 10
ax.set_rticks(np.arange(0, 11, 2))
ax.set_yticklabels(['', '  2%', '  4%', '  6%', '  8%', '  10%'],
                   fontsize=tk_fs)
#ax.set_yticklabels(['','2%','4%','6%','8%','10%'], fontsize=tk_fs)

rect = [0.52, 0, 0.5, 1]
ax = WindroseAxes(fig, rect)
fig.add_axes(ax)

ax.bar(WD_b,
       WS_b,
       cmap=cm.viridis,
       normed=True,
       nsector=36,
       bins=np.arange(0, 14, 2))  #summer
plt.text(-0.06,
         1,
         '(b)',