Exemplo n.º 1
0
def test_plot_map_vels(json):
    track = RKJSON(json)
    vels = track.calculate_vels()

    lllat, lllon = min(track.lat) - 0.01, min(track.lon) - 0.01
    urlat, urlon = max(track.lat) + 0.01, max(track.lon) + 0.01

    print vels.bearing

    # find the centre point
    lat_0 = (urlat - lllat) / 2 + lllat
    lon_0 = (urlon - lllon) / 2 + lllon

    # FIXME: rsphere required because my Proj is screwy
    m = Basemap(projection='cyl',
                llcrnrlon=lllon, llcrnrlat=lllat,
                urcrnrlon=urlon, urcrnrlat=urlat,
                lat_0=lat_0, lon_0=lon_0,
                resolution='h')

    x, y = m(vels.lon, vels.lat)
    plt.annotate("Start", (x[0], y[0]))

    m.barbs(x, y, vels.u, vels.v) #, vels.anom, cmap=plt.get_cmap('RdBu_r'))
    plt.show()
Exemplo n.º 2
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()
Exemplo n.º 3
0
def test_plots(json):
    track = RKJSON(json)

    vels = track.calculate_vels()
    longsmoo = smooth(vels.vel, window_len=len(vels) / 2)
    shortsmoo = smooth(vels.vel)

    fig, (ax1, ax2) = plt.subplots(2)
    ax1.set_title("Speed and smoothed speed")
    ax1.yaxis.set_label_text("km/h")
    ax1.plot(vels.time, shortsmoo, vels.time, longsmoo)

    ax2.set_title("Speed anomaly")
    ax2.yaxis.set_label_text("% anomaly")
    ax2.plot(vels.time, vels.anom * 100)

    fig.autofmt_xdate()
    plt.show()