Ejemplo n.º 1
0
def track_len_hists(comp_lst,conn,ax=None,*args,**kwargs):
    """makes histograms of the track lengths for the tracking computations in comp_lst """

    res = [_extract_track_lengths(c,conn) for c in comp_lst]
    hist_res = [np.histogram(r[0],bins=np.max(r[0])) + (r[1],r[2]) for r in res]

    tmps = [d[1] for d in res]
    cm = plots.color_mapper(np.min(tmps),np.max(tmps))
    
    if ax is None:
        ax = plots.set_up_axis('n*dtime [s]','cumsum $n P(n)$','',func = matplotlib.axes.Axes.plot)
        
    for hr in hist_res:
        temp = hr[2]
        ax.plot(np.cumsum((np.diff(hr[1]))+hr[1][0])*hr[3]/1000,np.cumsum(hr[0]*(hr[1][:-1]))/np.sum(hr[0]*(hr[1][:-1]))
                      ,label='%(#)0.1f C'%{'#':temp},color=cm.get_color(temp),*args,**kwargs)
Ejemplo n.º 2
0
def plot_tracks(tracks):
    """
    Takes in a 

    """
    print len(tracks)
    # set up figure
    (fig,ax) = plots.set_up_plot()

    init_frame = np.min([t.start_frame for t in tracks])
    
    ax.set_title(' frame: ' + str(init_frame)
                 + ' dtime: ' + str(tracks.dtime) + 'ms')

    def trk_len_hash(trk):
        return len(trk)
    def trk_disp_hash(trk):
        return np.sqrt((np.sum(np.array(trk[-1]) - np.array(trk[0]))**2))

    trk_hash = trk_len_hash

    t_len = [trk_hash(trk) for trk in tracks]
    cm = plots.color_mapper(min(t_len),max(t_len))
    print (min(t_len),max(t_len))

    # loop over tracks and plot
    [ax.plot(np.array([t[0] for t in trk.positions])*tracks.sp_scale,
             np.array([t[1] for t in trk.positions])*tracks.sp_scale,
             '-',
             color=cm.get_color(trk_hash(trk)))
     for trk in tracks]

    x,y,I = zip(*[trk.positions[0] for trk in tracks])
    # plot the starting points
    ax.plot(np.array(x)*tracks.sp_scale,
            np.array(y)*tracks.sp_scale,'xk')

    ax.set_aspect('equal')
    plt.draw()
Ejemplo n.º 3
0
def plot_msd_old(comp_key, conn, fig=None):
    if fig is None:
        fig = plots.tac_figure("t[s]", "msd", "msd")
        pass

    (fin, dset) = conn.execute("select fout,dset_key from comps where comp_key = ?", (comp_key,)).fetchone()
    (temp,) = conn.execute("select temp from dsets where key = ?", (dset,)).fetchone()

    Fin = h5py.File(fin, "r")
    g_name = _fd("mean_squared_disp", comp_key)
    msd = Fin[g_name]
    msd = Fin[g_name]["data"][:]
    dt = Fin[g_name].attrs["dtime"]
    print
    print "the delta is ", dt, "for comp ", comp_key
    t = (np.arange(len(msd)) + 1) * dt

    cm = plots.color_mapper(27, 33)

    fig.plot(t, msd, label=str(temp), color=cm.get_color(temp))
    Fin.close()
    del Fin
    return fig
Ejemplo n.º 4
0
def plot_msd(comp_key, conn, fig=None):
    if fig is None:
        fig = plots.tac_figure("t[s]", "msd", "msd")
        pass

    (fin,) = conn.execute("select fout from msd where comp_key = ?", (comp_key,)).fetchone()

    Fin = h5py.File(fin, "r")
    g_name = _fd("mean_squared_disp", comp_key)

    msd = Fin[g_name]["msd"][:]
    dt = Fin[g_name].attrs["dtime"]
    temp = Fin[g_name].attrs["temperature"]
    mtl = Fin[g_name].attrs["min_track_length"]
    print
    print "the delta is ", dt, "for comp ", comp_key
    t = (np.arange(len(msd)) + 1) * dt

    cm = plots.color_mapper(27, 33)

    fig.plot(t, msd, label="%(#).2fC, %(!)d" % {"!": mtl, "#": temp}, color=cm.get_color(temp))
    Fin.close()
    del Fin
    return fig