Exemple #1
0
def polish_plot(ax1,ax2,d_unpolish,d_polish,xlim,ylim,f_x,plot_components_1,i):
    plt.sca(ax1)
    kw_plot = dict(f_x=f_x,xlim=xlim,ylim=ylim,use_shift=True,i=i)
    ProcessingUtil._aligned_plot(d_unpolish, plot_components=plot_components_1,
                                 **kw_plot)
    PlotUtilities.xlabel("")
    PlotUtilities.no_x_label(ax1)
    plt.sca(ax2)
    ProcessingUtil._aligned_plot(d_polish, plot_components=False,
                                 **kw_plot)
Exemple #2
0
def fix_axes(ax_list):
    # loop through all the axes and toss them.
    xlims = get_ranges(ax_list, get_x=True)
    ylims = get_ranges(ax_list, get_x=False)
    for i, axs in enumerate(ax_list):
        for j, ax in enumerate(axs):
            if (i > 0):
                # columns after the first lose their labels
                PlotUtilities.no_y_label(ax)
                PlotUtilities.ylabel("", ax=ax)
            ax.set_ylim(ylims[j])
            if (j != 0):
                PlotUtilities.no_x_label(ax)
                PlotUtilities.xlabel("", ax=ax)
Exemple #3
0
def _make_plots(galleries_labels):
    alignments = [
        FigureUtil._alignment_pipeline(gallery_tmp[0])
        for gallery_tmp in galleries_labels
    ]
    for i, (_, label) in enumerate(galleries_labels):
        # make the standard aligning plot
        alignment = alignments[i]
        _make_algned_plot(alignment, label)
    # plot the final curves on the same plot
    xlim, ylim = FigureUtil._limits(alignment._all_fecs)
    colors = ['rebeccapurple', 'g']
    fig = PlotUtilities.figure((5, 3))
    gs = gridspec.GridSpec(2, 2)
    # reverse everything, so PEG600 is on top
    galleries_labels = galleries_labels[::-1]
    alignments = alignments[::-1]
    for i, (_, l) in enumerate(galleries_labels):
        ax = plt.subplot(gs[i, 0])
        a = alignments[i]
        FigureUtil._plot_fec_list(a.blacklisted.fec_list,
                                  xlim,
                                  ylim,
                                  label=l,
                                  color=colors[i])
        if (i == 0):
            PlotUtilities.no_x_label(ax)
            PlotUtilities.xlabel("", ax=ax)
    # plot them both on the last column
    plt.subplot(gs[:, 1])
    kw = [dict(), dict(linewidth=0.6)]
    for i, (_, l) in enumerate(galleries_labels):
        a = alignments[i]
        FigureUtil._plot_fec_list(a.blacklisted.fec_list,
                                  xlim,
                                  ylim,
                                  label=l,
                                  color=colors[i],
                                  **kw[i])
    PlotUtilities.savefig(fig, "FigureS_3400vs600.png")
Exemple #4
0
def _plot_fmt(ax,
              xlim,
              ylim,
              is_bottom=False,
              color=False,
              is_left=True,
              ylabel="$F$ (pN)",
              xlabel="Extension (nm)"):
    PlotUtilities.tickAxisFont(ax=ax)
    ax.set_xlim(xlim)
    ax.set_ylim(ylim)
    PlotUtilities.title("", ax=ax)
    PlotUtilities.ylabel(ylabel, ax=ax)
    PlotUtilities.xlabel(xlabel, ax=ax)
    if (not is_bottom):
        PlotUtilities.no_x_label(ax=ax)
        PlotUtilities.xlabel("", ax=ax)
    if (not is_left):
        PlotUtilities.no_y_label(ax=ax)
        PlotUtilities.ylabel("", ax=ax)
    if color:
        color_kw = dict(ax=ax, color='w', label_color='k')
        PlotUtilities.color_x(**color_kw)
        PlotUtilities.color_y(**color_kw)
Exemple #5
0
def run():
    """
    <Description>

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    default_base = "../../../Data/170321FEC/"
    base_dir = Pipeline._base_dir_from_cmd(default=default_base)
    step = Pipeline.Step.POLISH
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.ALIGNED)
    out_dir = Pipeline._cache_dir(base=base_dir,enum=step)
    plot_dir = Pipeline._plot_subdir(base=base_dir, enum=step)
    force = True
    limit = None
    functor = lambda : polish_data(in_dir)
    data =CheckpointUtilities.multi_load(cache_dir=out_dir,load_func=functor,
                                         force=force,
                                         limit=limit,
                                         name_func=FEC_Util.fec_name_func)
    sizes = [d.Force.size for d in data]
    min_s = min(sizes)
    sliced_data = [d._slice(slice(0,min_s,1)) for d in data]
    for d in sliced_data:
        d.Offset = d.ZSnsr[0]
        d.Extension = d.Separation
        d.kT = 4.1e-21
    data_wham = UtilWHAM.to_wham_input(objs=sliced_data, n_ext_bins=75)
    data_wham.z = np.array([d.ZSnsr for d in sliced_data])
    obj_wham = WeightedHistogram.wham(data_wham)
    data_unpolished = CheckpointUtilities.lazy_multi_load(in_dir)
    f_x_zsnsr = lambda x: x.ZSnsr
    xlim = [-40,150]
    ProcessingUtil.heatmap_ensemble_plot(data,out_name=plot_dir + "heatmap.png",
                                         xlim=xlim)
    ProcessingUtil.heatmap_ensemble_plot(data,f_x=f_x_zsnsr,
                                         out_name=plot_dir + "heatmap_Z.png",
                                         kw_map=dict(x_func=f_x_zsnsr),
                                         xlim=xlim)
    # plot each individual
    f_x = lambda x_tmp : x_tmp.Separation
    plot_subdir = Pipeline._plot_subdir(base_dir, step)
    name_func = FEC_Util.fec_name_func
    _, ylim = ProcessingUtil.nm_and_pN_limits(data,f_x)
    for i,(d_unpolish,d_polish) in enumerate(zip(data_unpolished,data)):
        kw_plot = dict(d_unpolish=d_unpolish,
                       d_polish=d_polish,
                       xlim=xlim,ylim=ylim,i=i)
        fig = PlotUtilities.figure((6,6))
        # make the Separation column
        ax1,ax2 = plt.subplot(2,2,1), plt.subplot(2,2,3)
        polish_plot(ax1, ax2, f_x = lambda x: x.Separation,
                    plot_components_1=True,**kw_plot)
        # make the ZSnsr column
        ax3,ax4 = plt.subplot(2,2,2), plt.subplot(2,2,4)
        polish_plot(ax3, ax4, f_x = lambda x: x.ZSnsr,plot_components_1=False,
                    **kw_plot)
        PlotUtilities.xlabel("Stage Position (nm)", ax=ax4)
        for a in [ax3,ax4]:
            PlotUtilities.no_y_label(ax=a)
            PlotUtilities.ylabel("",ax=a)
        name = plot_subdir + name_func(0, d_polish) + ".png"
        PlotUtilities.savefig(fig,name)