Exemplo n.º 1
0
plt.style.use('ggplot')

interv = (0, 1000)
x = np.linspace(interv[0], interv[1], 1000)
x = x + (100 * np.sin(0.01 * x))
y = np.linspace(interv[0], interv[1], 1000) + np.random.random(len(x)) * 20

tot_gifs = 20

x_plot, y_plot = [], []

axes = plt.gca()
axes.set_ylim([np.min(y), np.max(y)])
axes.set_xlim([np.min(x), np.max(x)])
plot1, = axes.plot(0, 0)

for ii in range(0, tot_gifs):
    x_plot.extend(x[ii * int(len(x) / tot_gifs):(ii + 1) *
                    int(len(x) / tot_gifs)])
    y_plot.extend(y[ii * int(len(x) / tot_gifs):(ii + 1) *
                    int(len(x) / tot_gifs)])
    plot1.set_xdata(x_plot)
    plot1.set_ydata(y_plot)

    gif_maker('straight_line_noise.gif',
              './gif_maker_png/',
              ii,
              tot_gifs,
              dpi=120)
Exemplo n.º 2
0
fig = plt.figure(dpi=dpi)

# set the latitude angle steady, and vary the longitude. You can also reverse this to
# create a rotating globe latitudinally as well
lat_viewing_angle = [20.0, 20.0]
lon_viewing_angle = [-180, 180]
rotation_steps = 360
lat_vec = np.linspace(lat_viewing_angle[0], lat_viewing_angle[0],
                      rotation_steps)
lon_vec = np.linspace(lon_viewing_angle[0], lon_viewing_angle[1],
                      rotation_steps)

# for making the gif animation
gif_indx = 0

# loop through the longitude vector above
for pp in range(0, len(lat_vec)):
    plt.cla()
    m = Basemap(projection='ortho', lat_0=lat_vec[pp], lon_0=lon_vec[pp])
    m.drawcoastlines(linewidth=0.5)
    # m.drawcountries()
    plot_topo(m)

    # iterate to create the GIF animation
    gif_maker('basemap_rotating_globe.gif',
              './png_dir/',
              gif_indx,
              len(lat_vec) - 1,
              dpi=dpi)
    gif_indx += 1
    print("{}/{}".format(pp, len(lat_vec)))
Exemplo n.º 3
0
normalize = matplotlib.colors.Normalize(vmin = cap_min,vmax = cap_max)

loop_size = len(year_sort)
num_gifs = len(np.unique(year_sort))

for pp in range(0,loop_size):
    if year_sort[pp]==curr_year:
        x,y = m(lons_sort[pp],lats_sort[pp])
        x_array.append(x)
        y_array.append(y)
        cap_array.append(np.interp(capacity_sort[pp],[cap_min,cap_max],[30,200]))
        color_array.append(capacity_sort[pp])
        if pp!=loop_size-1:
            continue
    else:
        curr_year = year_sort[pp]

    # recreate figure each loop
    fig = plt.figure(figsize=(12,7))
    m = Basemap(projection='merc',llcrnrlat=bbox[0],urcrnrlat=bbox[1],\
                llcrnrlon=bbox[2],urcrnrlon=bbox[3],lat_ts=10,resolution=None)
    m.bluemarble() # this plots the earth-like contour to the U.S. map

    # scatter new data with the color and size changes
    scat1 = plt.scatter(x_array,y_array,s=cap_array,c = color_array,edgecolors='#444444',alpha=0.5,cmap=colormap,norm=normalize)
    plt.colorbar(scat1,label='Average Power [kW]')
    plt.ylabel(str(year_sort[pp-1])) # updated year

    gif_maker('wind_turbine_yearly_with_colors.gif',png_dir,gif_indx,num_gifs,90)
    gif_indx+=1
Exemplo n.º 4
0
loop_size = len(year_sort)
num_gifs = len(np.unique(year_sort))

for pp in range(0, loop_size):
    if year_sort[pp] == curr_year:
        x, y = m(lons_sort[pp], lats_sort[pp])
        x_array.append(x)
        y_array.append(y)
        if pp != loop_size - 1:
            continue
    else:
        curr_year = year_sort[pp]

    # recreate figure each loop
    fig = plt.figure(figsize=(12, 7))
    m = Basemap(projection='merc',llcrnrlat=bbox[0],urcrnrlat=bbox[1],\
                llcrnrlon=bbox[2],urcrnrlon=bbox[3],lat_ts=10,resolution=None)
    m.bluemarble()  # this plots the earth-like contour to the U.S. map

    # scatter new data
    plt.scatter(x_array,
                y_array,
                s=20,
                c='#D5D8DC',
                linewidths='0.3',
                edgecolors='#34495E',
                alpha=0.8)
    plt.ylabel(str(year_sort[pp - 1]))  # updated year
    gif_maker('function_test.gif', png_dir, gif_indx, num_gifs, 90)
    gif_indx += 1
Exemplo n.º 5
0
map_coords_xy = [m1.llcrnrx, m1.llcrnry, m1.urcrnrx, m1.urcrnry]
map_coords_geo = [m1.llcrnrlat, m1.llcrnrlon, m1.urcrnrlat, m1.urcrnrlon]

#zoom proportion and re-plot map
zoom_prop = 2.0  # use 1.0 for full-scale map

gif_indx = 0
for pp in range(0, len(lat_vec)):

    ax1.clear()
    ax1.set_axis_off()
    m = Basemap(projection='ortho',
                resolution='l',
                lat_0=lat_vec[pp],
                lon_0=lon_vec[pp],
                llcrnrx=-map_coords_xy[2] / zoom_prop,
                llcrnry=-map_coords_xy[3] / zoom_prop,
                urcrnrx=map_coords_xy[2] / zoom_prop,
                urcrnry=map_coords_xy[3] / zoom_prop)

    m.bluemarble(scale=0.5)
    m.drawcoastlines()
    plt.show()
    plt.pause(0.01)
    gif_maker('blue_marble_rotating_globe.gif',
              './png_dir_bluemarble/',
              gif_indx,
              len(lat_vec) - 1,
              dpi=90)
    gif_indx += 1