示例#1
0
def main():

    loc = 'fl0'
    weatherDir = '/data1/ancillary_data/fl0/eol/'
    weatherFileTag = 'v2'
    iyear = 2010
    fyear = 2010

    wdir, wspeed, temp, rh, dtw = weatherout(loc, weatherDir, weatherFileTag,
                                             iyear, fyear)

    hours = []
    for k in dtw:
        hours.append(k.hour)

    hours = np.asarray(hours)

    inds = np.where((wspeed <= 10.0) & (hours > 8) & (hours < 18))[0]

    fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
    rect = [0.1, 0.1, 0.8, 0.8]
    ax = WindroseAxes(fig, rect, axisbg='w')
    fig.add_axes(ax)

    ax.bar(wdir[inds],
           wspeed[inds],
           normed=True,
           opening=0.9,
           edgecolor='white')
    ax.set_legend()

    #fig2 = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
    ax2 = WindAxes.from_ax()
    bins = np.arange(0, 10, 0.5)
    bins = bins[1:]
    ax2, params = ax2.pdf(wspeed[inds], bins=bins)

    ax3 = WindAxes.from_ax()
    bins = np.arange(0, 360, 15)
    bins = bins[1:]
    ax3, params = ax3.pdf(wdir[inds], bins=bins)

    # fig2,  ax2   = plt.subplots(figsize=(8,6))
    # ax2.scatter(wdir, wspeed, facecolors='red', edgecolors='black', s=35)
    # ax2.grid(True)

    plt.show(block=False)

    pdfsav = PdfPages('/data/iortega/results/fl0/windrose.pdf')
    pdfsav.savefig(fig, dpi=200)
    pdfsav.close()
    user_input = raw_input('Press any key to exit >>> ')
    sys.exit()
示例#2
0
def main():

    loc = 'fl0'
    weatherDir     = '/data1/ancillary_data/fl0/eol/'
    weatherFileTag = 'v2'
    iyear = 2010
    fyear = 2016


    wdir, wspeed, temp, rh, dtw = weatherout(loc, weatherDir, weatherFileTag, iyear, fyear )
   
    hours = []
    for k in dtw:
        hours.append(k.hour)

    hours = np.asarray(hours)
    
    inds = np.where( (wspeed <= 10.0) & (hours > 8) & (hours < 18) )[0]
    

    fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
    rect = [0.1, 0.1, 0.8, 0.8]
    ax = WindroseAxes(fig, rect, axisbg='w')
    fig.add_axes(ax)

    ax.bar(wdir[inds], wspeed[inds], normed=True, opening=0.9, edgecolor='white')
    ax.set_legend()

    #fig2 = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
    ax2 = WindAxes.from_ax()
    bins = np.arange(0, 10 , 0.5)
    bins = bins[1:]
    ax2, params = ax2.pdf(wspeed[inds], bins=bins)

    ax3 = WindAxes.from_ax()
    bins = np.arange(0, 360, 15)
    bins = bins[1:]
    ax3, params = ax3.pdf(wdir[inds], bins=bins)

    # fig2,  ax2   = plt.subplots(figsize=(8,6))
    # ax2.scatter(wdir, wspeed, facecolors='red', edgecolors='black', s=35)
    # ax2.grid(True)        

    plt.show(block=False)

    pdfsav = PdfPages('/data/iortega/results/fl0/windrose.pdf')
    pdfsav.savefig(fig,dpi=200)
    pdfsav.close()
    user_input = raw_input('Press any key to exit >>> ')
    sys.exit()    
示例#3
0
def test_windrose_np_mpl_oo():
    bins = np.arange(0, 8, 1)

    # windrose with scatter plot
    ax = WindroseAxes.from_ax()
    ax.scatter(wd, ws, alpha=0.2)
    ax.set_legend()
    plt.savefig("tests/output/oo/scatter.png")
    plt.close()

    # windrose like a stacked histogram with normed (displayed in percent) results
    ax = WindroseAxes.from_ax()
    ax.bar(wd, ws, normed=True, opening=0.8, edgecolor="white")
    ax.set_legend()
    plt.savefig("tests/output/oo/bar.png")
    plt.close()

    # Another stacked histogram representation, not normed, with bins limits
    ax = WindroseAxes.from_ax()
    ax.box(wd, ws, bins=bins)
    ax.set_legend()
    plt.savefig("tests/output/oo/box.png")
    plt.close()

    # A windrose in filled representation, with a controled colormap
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.set_legend()
    plt.savefig("tests/output/oo/contourf.png")
    plt.close()

    # Same as above, but with contours over each filled region...
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.contour(wd, ws, bins=bins, colors="black")
    ax.set_legend()
    plt.savefig("tests/output/oo/contourf-contour.png")
    plt.close()

    # ...or without filled regions
    ax = WindroseAxes.from_ax()
    ax.contour(wd, ws, bins=bins, cmap=cm.hot, lw=3)
    ax.set_legend()
    plt.savefig("tests/output/oo/contour.png")
    plt.close()

    # print ax._info
    # plt.show()

    ax = WindAxes.from_ax()
    bins = bins[1:]
    ax.pdf(ws, bins=bins)
    plt.savefig("tests/output/oo/pdf.png")
    plt.close()
示例#4
0
def plot_weibull(ws,diro,file_Merge):
    '''画weibull分布图''' 
    ws.values[ws.values==0]=np.nan
    ws=ws.dropna()
    binn = np.arange(0.0, 30.0, 1)
    ax2, params = wrpdf(ws, bins=binn, Nx=100, bar_color='darkgreen', \
                        plot_color='royalblue', Nbins=26, \
                        ax = WindAxes.from_ax(fig = plt.figure(figsize=(6,4))))
    ax2.text(15, 0.1,"A = %.2f, K = %.2f" % (params[3],params[1]),fontsize=12)
    ax2.set_title(file_Merge[6:10]+'_'+ws.name[3:])
    plt.savefig(diro+'\\'+file_Merge[6:10]+'_'+ws.name[3:]+'Weibull.png',bbox_inches='tight',dpi=96)
    plt.show()
def test_windrose_np_mpl_oo():
    bins = np.arange(0, 8, 1)

    #windrose with scatter plot
    ax = WindroseAxes.from_ax()
    ax.scatter(wd, ws, alpha=0.2)
    ax.set_legend()
    plt.savefig('tests/output/oo/scatter.png')

    #windrose like a stacked histogram with normed (displayed in percent) results
    ax = WindroseAxes.from_ax()
    ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
    ax.set_legend()
    plt.savefig('tests/output/oo/bar.png')

    #Another stacked histogram representation, not normed, with bins limits
    ax = WindroseAxes.from_ax()
    ax.box(wd, ws, bins=bins)
    ax.set_legend()
    plt.savefig('tests/output/oo/box.png')

    #A windrose in filled representation, with a controled colormap
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.set_legend()
    plt.savefig('tests/output/oo/contourf.png')

    #Same as above, but with contours over each filled region...
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.contour(wd, ws, bins=bins, colors='black')
    ax.set_legend()
    plt.savefig('tests/output/oo/contourf-contour.png')

    #...or without filled regions
    ax = WindroseAxes.from_ax()
    ax.contour(wd, ws, bins=bins, cmap=cm.hot, lw=3)
    ax.set_legend()
    plt.savefig('tests/output/oo/contour.png')

    #print ax._info
    #plt.show()

    ax = WindAxes.from_ax()
    bins = bins[1:]
    ax.pdf(ws, bins=bins)
    plt.savefig('tests/output/oo/pdf.png')
def main():
    # Create wind speed and direction variables
    N = 500
    ws = np.random.random(N) * 6
    wd = np.random.random(N) * 360

    ax = WindroseAxes.from_ax()
    ax.scatter(wd, ws, alpha=0.2)
    ax.set_legend()

    # windrose like a stacked histogram with normed (displayed in percent) results
    ax = WindroseAxes.from_ax()
    ax.bar(wd, ws, normed=True, opening=0.8, edgecolor="white")
    ax.set_legend()

    # Another stacked histogram representation, not normed, with bins limits
    ax = WindroseAxes.from_ax()
    bins = np.arange(0, 8, 1)
    ax.box(wd, ws, bins=bins)
    ax.set_legend()

    # A windrose in filled representation, with a controled colormap
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.set_legend()

    # Same as above, but with contours over each filled region...
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.contour(wd, ws, bins=bins, colors="black")
    ax.set_legend()

    # ...or without filled regions
    ax = WindroseAxes.from_ax()
    ax.contour(wd, ws, bins=bins, cmap=cm.hot, lw=3)
    ax.set_legend()

    # print ax._info
    # plt.show()

    ax = WindAxes.from_ax()
    bins = np.arange(0, 6 + 1, 0.5)
    bins = bins[1:]
    ax.pdf(ws, bins=bins)
    plt.show()
示例#7
0
def main():
    # Create wind speed and direction variables
    N = 500
    ws = np.random.random(N) * 6
    wd = np.random.random(N) * 360

    ax = WindroseAxes.from_ax()
    ax.scatter(wd, ws, alpha=0.2)
    ax.set_legend()

    # windrose like a stacked histogram with normed (displayed in percent) results
    ax = WindroseAxes.from_ax()
    ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
    ax.set_legend()

    # Another stacked histogram representation, not normed, with bins limits
    ax = WindroseAxes.from_ax()
    bins = np.arange(0, 8, 1)
    ax.box(wd, ws, bins=bins)
    ax.set_legend()

    # A windrose in filled representation, with a controled colormap
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.set_legend()

    # Same as above, but with contours over each filled region...
    ax = WindroseAxes.from_ax()
    ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
    ax.contour(wd, ws, bins=bins, colors='black')
    ax.set_legend()

    # ...or without filled regions
    ax = WindroseAxes.from_ax()
    ax.contour(wd, ws, bins=bins, cmap=cm.hot, lw=3)
    ax.set_legend()

    # print ax._info
    # plt.show()

    ax = WindAxes.from_ax()
    bins = np.arange(0, 6 + 1, 0.5)
    bins = bins[1:]
    ax.pdf(ws, bins=bins)
    plt.show()
示例#8
0
#Another stacked histogram representation, not normed, with bins limits
ax = WindroseAxes.from_ax()
bins = np.arange(0, 8, 1)
ax.box(wd, ws, bins=bins)
ax.set_legend()

#A windrose in filled representation, with a controled colormap
ax = WindroseAxes.from_ax()
ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
ax.set_legend()

#Same as above, but with contours over each filled region...
ax = WindroseAxes.from_ax()
ax.contourf(wd, ws, bins=bins, cmap=cm.hot)
ax.contour(wd, ws, bins=bins, colors='black')
ax.set_legend()

#...or without filled regions
ax = WindroseAxes.from_ax()
ax.contour(wd, ws, bins=bins, cmap=cm.hot, lw=3)
ax.set_legend()

##print ax._info
#plt.show()

ax = WindAxes.from_ax()
bins = np.arange(0, 6 + 1, 0.5)
bins = bins[1:]
ax.pdf(ws, bins=bins)
plt.show()