def plot_power_rose(wind_directions,power,num_wd_bins):
"""Plot a power rose. Kind of a hacked wind rose.
Arguments:
wind_directions -- a np array of wind directions filtered for icing
power -- a np array of percent power production corresponding to wind_directions
num_wd_bins -- the number of wind direction bins to include on the rose.
"""
dir_bins = np.array(np.linspace(0.0,360.0 - 360.0 / num_wd_bins,num_wd_bins))
#Find the total amount of power produced in each sector.
dir_power = np.array([np.nansum(filter_obstacles(power,wind_directions,(wd + 180.0) % 360.0, 360 - 360/float(num_wd_bins))) for wd in dir_bins])
dir_power = np.round(dir_power * 100.0 / np.nansum(dir_power), decimals=0) #Normalize it and round to nearest int.
proportional_wd = np.array([])
for i in range(len(dir_power)):
for n in range(int(dir_power[i])): #Loop as many times as the percent of power produced in this sector.
proportional_wd = np.append(proportional_wd,dir_bins[i]) #i.e., if 50% of power comes from the south, append 50 instances of 180.0 degrees.
ones = np.ones(len(proportional_wd))
ax = new_axes()
ax.bar(proportional_wd, ones,normed=False, opening=0.8, edgecolor='white', bins = [0.0,100.], cmap=cm.RdGy)
set_legend(ax)
评论列表
文章目录