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()