Esempio n. 1
0
def plot_dists(day='Fri'):
    df = data.read_data(day, grouped=True)
    dists = data.read_group_distances(day)

    # y, x = np.histogram(dists, 100)
    # plt.figure()
    # plt.bar(x[:-1], y, x[1]-x[0])
    #
    # plt.figure()
    # plt.pcolormesh(dists)
    #
    # plt.figure()
    # ix = np.indices(dists.shape)
    # plt.scatter(dists.flat, ix[0], s=2, lw=0)

    close_dists = np.unique(dists)
    for dist in close_dists[1:10]:
        matches = np.where(dists == dist)
        n_matches = len(matches)
        if n_matches > 2:
            print('More than 2 matches ({})'.format(n_matches))
        ids = np.where(dists == dist)[0]
        fig, ax = plt.subplots(subplot_kw={'projection': '3d'})
        tc.plot_trajectories(ax=ax, df=df[df['group_id'].isin(ids)], id_str='group_id')
        ax.set_title('group {} & {}\ndistance = {}'.format(ids[0], ids[1], dist))
def plot_group(day=None, group_id=0, ax=None, df=None):
    if df is None:
        df = data.read_data(day)
    groups = data.read_groups(day)
    ids = groups.loc[groups['group_id'] == group_id, 'id']
    if ax is None:
        fig, ax = plt.subplots(subplot_kw={'projection': '3d'})
    tc.plot_trajectories(ax=ax, df=df[df['id'].isin(ids)])
    return ax
Esempio n. 3
0
def on_click(event):
    if event.inaxes is not ax:
        return
    cutoff = event.ydata
    ax.lines.clear()
    ax.plot([0, 1], [cutoff, cutoff], color='red', lw=2)
    ids_below = [id for i, id in enumerate(td.all_ids) if dists[i] <= cutoff]
    ax3d.clear()
    tc.plot_trajectories(ax=ax3d, df=td.df[td.df['id'].isin(ids_below)])
    ax3d.set_title('{0} trajectories.\nCutoff = {1:.2f}'.format(
        len(ids_below), cutoff))
    fig.canvas.draw()
Esempio n. 4
0
"""
Little script that draws two trajectories at a time.

Used to quickly find matching trajectories.
"""

import data
import matplotlib.pyplot as plt
import script.plot.timecube as tc
import itertools

df = data.read_data('Fri', 'subset-100')
ids = df['id'].unique()

for id1, id2 in itertools.combinations(ids, 2):
    fig, ax = plt.subplots(1, 1, subplot_kw={'projection': '3d'})
    df2 = df[df['id'].isin([id1, id2])]

    tc.plot_trajectories(ax=ax, df=df2)
    plt.title('id {} and id {}'.format(id1, id2))
    plt.show()
Esempio n. 5
0
import data
import script.plot.timecube as tc
import matplotlib.pyplot as plt

with open('C:/Users/zchen4/Desktop/data/outputlab.csv') as f1:
    data1 = f1.read()

data1 = data1.split('\n')
x1 = [row for row in data1]

x1 = x1[:len(x1) - 1]

print(x1)

x1 = map(int, x1)

df = data.read_data('Fri')

tc.plot_trajectories(df[df['id'].isin(x1)])

plt.show()