Example #1
0
            for year in all_spd_data.keys():
                year_spd = np.array(all_spd_data[year])
                year_dir = np.array(all_dir_data[year])
                station_min_max[station_index][year] = {}
                station_min_max[station_index][year]['pts'] = len(year_spd)
                min_spd, max_spd = np.min(year_spd), np.max(year_spd)
                station_min_max[station_index][year]['spd_min'] = min_spd
                station_min_max[station_index][year]['spd_max'] = max_spd
                dir_min, dir_max = np.argmin(year_spd), np.argmax(year_spd)
                yr_dir_min, yr_dir_max = year_dir[dir_min], year_dir[dir_max]
                station_min_max[station_index][year]['dir_at_min'] = yr_dir_min
                station_min_max[station_index][year]['dir_at_max'] = yr_dir_max
            try:
                # A stacked histogram with normed
                # (displayed in percent) results.
                ax = new_axes()
                ax.set_title(station_index.split(":")[-1] +
                             " stacked histogram with normed (displayed in %)"
                             "\nresults (spd in knots), All Time.")
                ax.bar(all_time_dir, all_time_spd, normed=True,
                       opening=0.8, edgecolor='white')
                set_legend(ax)

                fig = plt.gcf()
                fig.set_size_inches(8, 8)
                fname = './images/%s.png' % station_index.split(":")[-1]
                fig.savefig(fname, dpi=100)
            except Exception as e:
                print("Error when plotting %s" % e)
                pass
Example #2
0
# #### Plot wind rose

# <codecell>

# Remove any existing plots...
filelist = [f for f in os.listdir("./images") if f.endswith(".png")]
for f in filelist:
    os.remove("./images/{}".format(f))

# Do work...
for station in st_list.keys():
    if st_list[station]['hasObsData']:
        df = st_list[station]['obsData']
        try:
            # A stacked histogram with normed (displayed in percent) results.
            ax = new_axes()  # Wind rose polar axes
            ax.set_title("Station " + station.split(":")[-1] +
                         "\nstacked histogram with normed (displayed in %)")
            wind_speed = df['wind_speed (m/s)'].values
            wind_direction = df['wind_from_direction (degree)'].values
            ax.bar(wind_direction,
                   wind_speed,
                   normed=True,
                   opening=0.8,
                   edgecolor='white')
            set_legend(ax, 'Wind Speed (m/s)')

            fig = plt.gcf()
            fig.set_size_inches(8, 8)
            fname = './images/%s.png' % station.split(":")[-1]
            fig.savefig(fname, dpi=100)
Example #3
0
# #### Plot wind rose

# <codecell>

# Remove any existing plots...
filelist = [f for f in os.listdir("./images") if f.endswith(".png")]
for f in filelist:
    os.remove("./images/{}".format(f))

# Do work...
for station in st_list.keys():    
    if st_list[station]['hasObsData']:
        df = st_list[station]['obsData']
        try:
            # A stacked histogram with normed (displayed in percent) results.
            ax = new_axes()  # Wind rose polar axes
            ax.set_title("Station " + station.split(":")[-1] +
                         "\nstacked histogram with normed (displayed in %)")
            wind_speed = df['wind_speed (m/s)'].values
            wind_direction = df['wind_from_direction (degree)'].values
            ax.bar(wind_direction, wind_speed, normed=True, opening=0.8, edgecolor='white')
            set_legend(ax, 'Wind Speed (m/s)')

            fig = plt.gcf()
            fig.set_size_inches(8, 8)
            fname = './images/%s.png' % station.split(":")[-1]
            fig.savefig(fname, dpi=100)
        except Exception as e:
            print("Error when plotting %s" % e)

# <markdowncell>
            for year in all_spd_data.keys():
                year_spd = np.array(all_spd_data[year])
                year_dir = np.array(all_dir_data[year])
                station_min_max[station_index][year] = {}
                station_min_max[station_index][year]['pts'] = len(year_spd)
                min_spd, max_spd = np.min(year_spd), np.max(year_spd)
                station_min_max[station_index][year]['spd_min'] = min_spd
                station_min_max[station_index][year]['spd_max'] = max_spd
                dir_min, dir_max = np.argmin(year_spd), np.argmax(year_spd)
                yr_dir_min, yr_dir_max = year_dir[dir_min], year_dir[dir_max]
                station_min_max[station_index][year]['dir_at_min'] = yr_dir_min
                station_min_max[station_index][year]['dir_at_max'] = yr_dir_max
            try:
                # A stacked histogram with normed
                # (displayed in percent) results.
                ax = new_axes()
                ax.set_title(
                    station_index.split(":")[-1] +
                    " stacked histogram with normed (displayed in %)"
                    "\nresults (spd in knots), All Time.")
                ax.bar(all_time_dir,
                       all_time_spd,
                       normed=True,
                       opening=0.8,
                       edgecolor='white')
                set_legend(ax)

                fig = plt.gcf()
                fig.set_size_inches(8, 8)
                fname = './images/%s.png' % station_index.split(":")[-1]
                fig.savefig(fname, dpi=100)