Esempio n. 1
0
        else:
            self.selected = None
        self.fig.canvas.draw_idle()


if __name__ == '__main__':
    from matplotlib.animation import FuncAnimation

    ncf = netcdf_file('KTLX_20100510_22Z.nc')
    data = ncf.variables['Reflectivity']
    lats = ncf.variables['lat']
    lons = ncf.variables['lon']
    stormcells = storm_loader('polygons.shp')

    fig, ax = plt.subplots(1, 1)
    raddisp = RadarDisplay(ax, lats, lons)
    raddisp.update_display(data[0])
    fig.colorbar(raddisp.im)
    polycolls = Stormcells(ax, stormcells)
    linecoll = Tracks(ax)

    # Turn on the first frame's polygons
    polycolls.toggle_polygons(0, True)
    ax.autoscale(True)

    ctrl_sys = ControlSys(fig, raddisp, data, polycolls, linecoll, stormcells)
    #anim = FuncAnimation(fig, lambda _: ctrl_sys.change_frame(1),
    #                     frames=data.shape[0], repeat=False)
    #anim.save('storms_with_tracks.gif', writer='imagemagick')
    plt.show()
Esempio n. 2
0
        self.fig.canvas.draw_idle()

if __name__ == '__main__':
    ncf = netcdf_file('KTLX_20100510_22Z.nc')
    data = ncf.variables['Reflectivity']
    lats = ncf.variables['lat']
    lons = ncf.variables['lon']
    stormcells = storm_loader('polygons.shp')

    app = wx.App()
    win = wx.Frame(None, -1, "Embedding with WX")

    fig = Figure()
    canvas = FigureCanvas(win, -1, fig)
    ax = fig.add_subplot(1, 1, 1)
    raddisp = RadarDisplay(ax, lats, lons)
    raddisp.update_display(data[0])
    fig.colorbar(raddisp.im)
    polycolls = Stormcells(ax, stormcells)
    linecoll = Tracks(ax)

    # Turn on the first frame's polygons
    polycolls.toggle_polygons(0, True)
    ax.autoscale(True)

    ctrl_sys = ControlSys(fig, raddisp, data, polycolls, linecoll, stormcells)

    win.SetInitialSize(wx.Size(int(fig.bbox.width), int(fig.bbox.height)))
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND)
    win.SetSizer(sizer)