Example #1
0
def test_bin_direction():
    filename = glob('json/*.json')[4]

    with open(filename) as f:
        track = RKJSON(f)
        vels = track.calculate_vels()
        grid = Grid([track])

        fig, ax = plt.subplots(1)
        ax.set_title("Direction Sorting (red inbound, blue outbound)")
        ax.set_xlabel("Longitude")
        ax.set_ylabel("Latitude")
        ax.set_aspect('equal')
        ax.annotate("Brunswick", (144.960, -37.767))
        ax.annotate("MELBOURNE", (MELBOURNE.lon, MELBOURNE.lat))
        ax.scatter(MELBOURNE.lon, MELBOURNE.lat)

        for v in vels:
            d = grid.bin_direction(v)
            if d == Direction.INBOUND:
                color='r'
            else:
                color='b'

            ax.barbs(v.lon, v.lat, v.u, v.v, color=color)


        plt.show()
Example #2
0
def test_plot_all_map_vels():
    def gen_tracks():
        for fn in glob('tracks/*.json'):
            with open(fn, 'rb') as fp:
                try:
                    yield RKJSON(fp)
                except BadInputException:
                    pass

    tracks = list(gen_tracks())

    print "Considering {} tracks".format(len(tracks))

    lllat, urlat, lllon, urlon = Grid.calculate_bounds(tracks)

    m = Basemap(projection='cyl',
                llcrnrlon=lllon, llcrnrlat=lllat,
                urcrnrlon=urlon, urcrnrlat=urlat,
                resolution='h')
    m.drawcoastlines()

    for t in tracks:
        vels = t.calculate_vels()
        x, y = m(vels.lon, vels.lat)
        m.barbs(x, y, vels.u, vels.v)

    plt.annotate("Docklands", (144.948, -37.815))
    plt.annotate("Brunswick", (144.960, -37.767))
    plt.annotate("Brunswick East", (144.979, -37.769))
    plt.annotate("Richmond", (144.999, -37.819))
    plt.annotate("Fitzroy", (144.978, -37.800))

    plt.show()