コード例 #1
0
ファイル: exp_dep.py プロジェクト: tacaswell/caswell-colloids
def comp_hists_avg(key, frames_a, frames_b, fun, conn):
    """Makes histograms plots comparing the values from various frames
    in the same data set

    not written

    """

    # get file name/comp_num
    (comp_num, fname) = conn.execute(
        "select comp_key,fout from comps\
    where dset_key = ? and function = 'Iden'",
        (key,),
    ).fetchone()

    # open file/group

    F = h5py.File(fname, "r")
    hists_a = np.zeros()
    for fr in frames_a:
        tmp_h, tmp_b = fun(F, "frame%(#)06d" % {"#": fr}, comp_num)
        hists_a += tmp_h

    istatus = lplts.non_i_plot_start()
    (fig, ax) = lplts.set_up_plot()
    hands = [ax.step(r[1][:-1], r[0]) for r in res]
    ax.legend(hands, [str(f) for f in frames])
    lplts.non_i_plot_stop(istatus)

    F.close()
    del F

    return res
コード例 #2
0
ファイル: exp_dep.py プロジェクト: tacaswell/caswell-colloids
def hist_shifts(key, conn, fun, range_bn=None, fig=None):
    """makes histograms of the shift in the x and y directions """

    # get file name/comp_num
    (comp_num, fname) = conn.execute(
        "select comp_key,fout from comps\
    where comp_key = ? and function = 'Iden'",
        (key,),
    ).fetchone()

    # open file/group

    F = h5py.File(fname, "r")

    nbins = 100

    if range_bn is None:
        bin_edges = np.linspace(-2, 2, nbins + 1)
    else:
        bin_edges = np.linspace(*(range_bn + (nbins + 1,)))
    bin_counts = np.zeros(nbins)
    # extract the relevant data
    for fr in F:
        if fr == "parameters":
            continue
        bin_counts += fun(F, fr, comp_num, bin_edges)

    # plot
    istatus = lplts.non_i_plot_start()
    if fig is None:
        (fig, ax) = lplts.set_up_plot()
    else:
        ax = fig.get_axes()[0]

    sh = ax.step(bin_edges[:-1], bin_counts / np.sum(bin_counts))

    if ax.get_legend() is None:
        print "attempt to set leg"
        ax.legend([sh], [F.attrs["Exposure"]], loc=3)
    else:
        # leg =aff  ax.get_legend()
        pass
    lplts.non_i_plot_stop(istatus)
    # clean up
    F.close()
    del F

    return fig
コード例 #3
0
ファイル: exp_dep.py プロジェクト: tacaswell/caswell-colloids
def hist_shifts_frame(key, frame, conn, fun, range_bn=None, fig=None):

    # get file name/comp_num
    (comp_num, fname) = conn.execute(
        "select comp_key,fout from comps\
    where dset_key = ? and function = 'Iden'",
        (key,),
    ).fetchone()

    # open file/group

    F = h5py.File(fname, "r")

    nbins = 1000

    if range_bn is None:
        bin_edges = np.linspace(-2, 2, nbins + 1)
    else:
        bin_edges = np.linspace(*(range_bn + (nbins + 1,)))

    fr = "frame%(#)06d" % {"#": frame}
    bin_counts = fun(F, fr, comp_num, bin_edges)

    # plot
    istatus = lplts.non_i_plot_start()
    if fig is None:
        (fig, ax) = lplts.set_up_plot()
    else:
        ax = fig.get_axes()[0]

    sh = ax.step(bin_edges[:-1], bin_counts / np.sum(bin_counts))

    if ax.get_legend() is None:
        print "attempt to set leg"
        ax.legend([sh], [F.attrs["Exposure"]], loc=3)
    else:
        # leg =aff  ax.get_legend()
        pass
    lplts.non_i_plot_stop(istatus)
    # clean up
    F.close()
    del F

    return fig