Esempio n. 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()
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
Esempio n. 3
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()    
Esempio n. 4
0
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()
Esempio n. 5
0
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()
Esempio n. 6
0
def animate_windrose_graph(i):
    all_data_map=data_service.get_all_data_map()
    is_active = data_service.get_active()
    if is_active == "1_3":
        data_service.update_all_data_map(data_service.get_start_date(), data_service.get_end_date())

        ws = my_service.restore_lost_data(all_data_map['FF'])
        wd = my_service.restore_lost_data(all_data_map['dd'])

        ws_scale_1 = tab1_service.map_speed_to_scale_one(ws)
        wd = tab1_service.map_compass_to_degrees(wd)

        # hide axes
        windrose_graph_fig.patch.set_visible(False)
        windrose_graph_ax.axis('off')
        windrose_graph_ax.axis('tight')

        ws_frequency_map = tab1_service.map_ws_by_frequency(ws)
        final_data = [list(ws_frequency_map.keys()), list(ws_frequency_map.values())]
        table = windrose_graph_ax.table(cellText=final_data, loc='top', cellLoc='center',
                                        rowLabels=[" м/с ", " % "], bbox=[0., 0., 0.23, .28])
        windrose_graph_fig.subplots_adjust(bottom=0.6)
        table.auto_set_font_size(False)
        table.set_fontsize(7)
        for (row, col), cell in table.get_celld().items():
            if row == 0:
                cell.set_text_props(fontproperties=FontProperties(weight='normal', size=7))
        for key, cell in table.get_celld().items():
            cell.set_linewidth(0.5)

        # windrose_graph_fig.clear()
        rect = [0.1, 0.1, 0.8, 0.8]
        wa = WindroseAxes(windrose_graph_fig, rect)
        windrose_graph_fig.add_axes(wa)
        windrose_graph_ax.grid()
        wa.bar(wd, ws_scale_1, normed=True, opening=0.8, edgecolor='white')
        # wa.set_legend()
        wa.set_legend(title="інтенсивність", loc="upper right")
Esempio n. 7
0
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import numpy as np
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import numpy as np

kmh_to_ms = 0.277778
# Decembre 2020
ws = [
    5.6 * kmh_to_ms, 6.8 * kmh_to_ms, 6.4 * kmh_to_ms, 4.5 * kmh_to_ms,
    3.5 * kmh_to_ms, 5 * kmh_to_ms, 5.1 * kmh_to_ms
]
wd = [45, 45, 67.5, 67.5, 45, 45, 45]

# Février 2021
# ws = [5.60*kmh_to_ms, 2.90*kmh_to_ms, 2.90*kmh_to_ms, 3.40*kmh_to_ms, 5.00*kmh_to_ms, 6.30*kmh_to_ms, 3.70*kmh_to_ms]
# wd = [135, 45, 90, 90, 90, 112.5, 112.5]

fig = plt.figure()
rect = [0.125, 0.125, 0.75, 0.75]
# rect = [0.5, 0.5, 0.5, 0.5]
wa = WindroseAxes(fig, rect)
fig.add_axes(wa)
wa.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
wa.set_legend(bbox_to_anchor=(1, -0.08), title="WIND SPEED\n(m/s)")

plt.show()
Esempio n. 8
0
mto[wsp].hist(bins=100)
ax1.set_xscale("log")
ax1.set_xlabel("wind speed (m/s)")

right_rectangle = [0.5, 0.1, 0.5, 0.75]  # [left, bottom, width, height]
ax = WindroseAxes(fig, right_rectangle)
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))

######################################################################
# The numbers around the radar plot indicate frequencies for the given
# direction. They look quite ugly, and would benefit from some formatting.
# which is not super trivial:
#

from windrose import WindroseAxes

fig = plt.figure(figsize=(10, 5))

left_rectangle = [
    0, 0.1, 0.4, 0.75
]  # [left, bottom, width, height] as a fraction of total figure size