コード例 #1
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.ALIGNED
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.SANITIZED)
    out_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    force = True
    max_n_pool = multiprocessing.cpu_count() - 1
    n_pool = 6
    N_fit_pts = 20
    min_F_N = 175e-12 if "+Retinal" in base_dir else 90e-12
    data = RetinalUtil.align_data(in_dir,
                                  out_dir,
                                  force=force,
                                  n_pool=n_pool,
                                  min_F_N=min_F_N,
                                  N_fit_pts=N_fit_pts)
    plot_subdir = Pipeline._plot_subdir(base_dir, step)
    xlim_heatmap_nm = [-40, 100]
    ProcessingUtil.heatmap_ensemble_plot(data,
                                         xlim=xlim_heatmap_nm,
                                         out_name=plot_subdir + "heatmap.png")
    # get the post-blacklist heapmap, too..
    data_filtered = ProcessingUtil._filter_by_bl(data, in_dir)
    # align the data...
    data_aligned = [RetinalUtil._polish_helper(d) for d in data_filtered]
    out_name = plot_subdir + "heatmap_bl.png"
    ProcessingUtil.heatmap_ensemble_plot(data_aligned,
                                         xlim=xlim_heatmap_nm,
                                         out_name=out_name)
    # make individual plots
    ProcessingUtil.make_aligned_plot(base_dir,
                                     step,
                                     data,
                                     xlim=[-30, 150],
                                     use_shift=True)
コード例 #2
0
def make_plot(dir_in, out_name):
    dir_aligned = dir_in + "cache_8_aligned/"
    dir_polished = dir_in + "cache_10_polish/"
    data_unaligned = CheckpointUtilities.lazy_multi_load(dir_aligned)
    data_polished = CheckpointUtilities.lazy_multi_load(dir_polished)
    data_unaligned = ProcessingUtil._filter_by_bl(data_unaligned, dir_in)
    data_polished = ProcessingUtil._filter_by_bl(data_polished, dir_in)
    # scootch the data over slightly
    for d in data_polished:
        d.Separation -= 20e-9
    to_x = lambda _x: _x * 1e9
    to_y = lambda _y: _y * 1e12
    xlim = [-10, 100]
    ylim = [-20, 350]
    plt.close()
    fig = PlotUtilities.figure(figsize=(3.5, 4.5))
    kw_plot = dict(linewidth=0.75)
    ax1 = plt.subplot(2, 2, 1)
    for d in data_unaligned:
        plt.plot(to_x(d.Separation), to_y(d.Force), **kw_plot)
    ax2 = plt.subplot(2, 2, 2)
    for d in data_polished:
        plt.plot(to_x(d.Separation), to_y(d.Force), **kw_plot)
    for a in [ax1, ax2]:
        a.set_ylim(ylim)
        a.set_xlim(xlim)
        PlotUtilities.lazyLabel("Extension (nm)", "$F$ (pN)", "", ax=a)
    PlotUtilities.ylabel("", ax=ax2)
    height_pN = 100
    min_y, max_y, delta_y = Scalebar.offsets_zero_tick(
        limits=ylim, range_scalebar=height_pN)
    kw_scale = dict(offset_x=0.7,
                    offset_y=max_y,
                    x_kwargs=dict(width=20, unit="nm"),
                    y_kwargs=dict(height=height_pN, unit="pN"))
    for a in [ax1, ax2]:
        Scalebar.crossed_x_and_y_relative(ax=a, **kw_scale)
        PlotUtilities.no_y_label(ax=a)
        PlotUtilities.no_x_label(ax=a)
        PlotUtilities.x_label_on_top(ax=a)
    num = 200
    bins_x = np.linspace(xlim[0], xlim[-1], endpoint=True, num=num)
    bins_y = np.linspace(ylim[0], ylim[-1], endpoint=True, num=num)
    kw = dict(color='w', use_colorbar=False, bins=(bins_x, bins_y), title="")
    kw_scale_heat = dict(**kw_scale)
    line_kw_def = dict(color='w', linewidth=2)
    font_x, font_y = Scalebar.font_kwargs_modified(x_kwargs=dict(color='w'),
                                                   y_kwargs=dict(color='w'))
    kw_scale_heat['x_kwargs']['line_kwargs'] = line_kw_def
    kw_scale_heat['x_kwargs']['font_kwargs'] = font_x
    kw_scale_heat['y_kwargs']['line_kwargs'] = line_kw_def
    kw_scale_heat['y_kwargs']['font_kwargs'] = font_y
    ax3 = plt.subplot(2, 2, 3)
    Plotting.formatted_heatmap(data=data_unaligned, **kw)
    Scalebar.crossed_x_and_y_relative(ax=ax3, **kw_scale_heat)
    ax4 = plt.subplot(2, 2, 4)
    Plotting.formatted_heatmap(data=data_polished, **kw)
    Scalebar.crossed_x_and_y_relative(ax=ax4, **kw_scale_heat)
    for a in [ax3, ax4]:
        PlotUtilities.no_y_label(ax=a)
        PlotUtilities.no_x_label(ax=a)
        a.set_xlim(xlim)
        a.set_ylim(ylim)
        PlotUtilities.xlabel("", ax=a)
    PlotUtilities.ylabel("", ax=ax4)
    PlotUtilities.ylabel("$F$ (pN)", ax=ax3)
    PlotUtilities.savefig(fig, out_name)
    pass