示例#1
0
def run():
    """
    <Description>

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    base_dir = RetinalUtil._landscape_base()
    step = Pipeline.Step.REDUCED
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.SANITIZED)
    out_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    force = True
    limit = None
    functor = lambda: to_iwt(in_dir)
    data = CheckpointUtilities.multi_load(cache_dir=out_dir,
                                          load_func=functor,
                                          force=force,
                                          limit=limit,
                                          name_func=FEC_Util.fec_name_func)
    ProcessingUtil.plot_data(base_dir, step, data, xlim=[-50, 150])
    plot_subdir = Pipeline._plot_subdir(base_dir, step)
    out_name = plot_subdir + "heatmap.png"
    ProcessingUtil.heatmap_ensemble_plot(data, out_name=out_name)
示例#2
0
def run():
    """
    <Description>

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    base_input_processing = RetinalUtil._processing_base()
    base_dir = RetinalUtil._landscape_base()
    step = Pipeline.Step.MANUAL
    in_dir = Pipeline._cache_dir(base=base_input_processing,
                                 enum=Pipeline.Step.POLISH)
    out_dir = Pipeline._cache_dir(base=base_dir,enum=step)
    data_input = CheckpointUtilities.lazy_multi_load(in_dir)
    force = True
    functor = lambda : ProcessingUtil.\
        _filter_by_bl(data_input,base_input_processing)
    data = CheckpointUtilities.multi_load(cache_dir=out_dir,load_func=functor,
                                          force=force,
                                          name_func=FEC_Util.fec_name_func)
    # plot each individual
    ProcessingUtil.plot_data(base_dir,step,data,xlim=[-50,150])
    plot_subdir = Pipeline._plot_subdir(base_dir, step)
    out_name = plot_subdir + "heatmap.png"
    ProcessingUtil.heatmap_ensemble_plot(data, out_name=out_name)
示例#3
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.FILTERED
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.READ)
    out_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    force = True
    limit = None
    f_filter_Hz = 5e3
    # filter to X s
    t_filter_s = 1 / f_filter_Hz
    # t_filter -> n_filter_points
    # after filtering, take every N points, where
    # N = f_decimate * n_filter_points
    # in other words, we oversample by 1/f_decimate
    f_decimate = 0.33
    assert f_decimate < 1 and f_decimate > 0
    data = filter_data(in_dir, out_dir, force, t_filter_s, f_decimate)
    ProcessingUtil.plot_data(base_dir, step, data, markevery=1)
示例#4
0
def run():
    """
    <Description>

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    base_dir = RetinalUtil._landscape_base()
    step = Pipeline.Step.POLISH
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.REDUCED)
    out_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    force = True
    limit = None
    functor = lambda: generate_landscape(in_dir)
    energy_obj = CheckpointUtilities.\
        getCheckpoint(filePath=out_dir + "energy.pkl",
                      orCall=functor,force=force)
    data = CheckpointUtilities.lazy_multi_load(in_dir)
    # also load all the data
    fig = PlotUtilities.figure((3, 6))
    PlotUtil.plot_landscapes(data, energy_obj)
    PlotUtilities.savefig(fig, out_dir + "out_G.png")
    pass
示例#5
0
def run():
    """
    <Description>

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    base_dir = RetinalUtil._landscape_base()
    step = Pipeline.Step.SANITIZED
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.MANUAL)
    out_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    force = True
    limit = None
    min_sep = RetinalUtil.min_sep_landscape()
    max_sep = min_sep + 100e-9
    functor = lambda: slice_data(in_dir, min_sep=min_sep, max_sep=max_sep)
    data = CheckpointUtilities.multi_load(cache_dir=out_dir,
                                          load_func=functor,
                                          force=force,
                                          limit=limit,
                                          name_func=FEC_Util.fec_name_func)
    plot_dir = Pipeline._plot_subdir(base=base_dir, enum=step)
    ProcessingUtil.heatmap_ensemble_plot(data,
                                         out_name=plot_dir + "heatmap.png",
                                         xlim=[-20, max_sep * 1e9])
    # plot each individual
    ProcessingUtil.plot_data(base_dir, step, data)
示例#6
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)
示例#7
0
def make_aligned_plot(base_dir, step, data, xlim=None, post="", **kw):
    plot_subdir = Pipeline._plot_subdir(base_dir, step)
    f_x = lambda x: x.Separation
    xlim_tmp, ylim = nm_and_pN_limits(data, f_x)
    xlim = [xlim[0], 200] if xlim is None else xlim
    name_func = FEC_Util.fec_name_func
    for i, d in enumerate(data):
        f = PlotUtilities.figure()
        _aligned_plot(d, f_x, xlim, ylim, i=i, **kw)
        PlotUtilities.savefig(f, plot_subdir + name_func(0, d) + post + ".png")
示例#8
0
def read_dir(base_dir,enum):
    in_dir = Pipeline._cache_dir(base=base_dir,
                                 enum=enum)
    dir_exists = os.path.exists(in_dir)
    if (dir_exists and \
            len(GenUtilities.getAllFiles(in_dir, ext=".pkl")) > 0):
        data = CheckpointUtilities.lazy_multi_load(in_dir)
    else:
        data = []
    return data
示例#9
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.CORRECTED
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.FILTERED)
    out_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    force = True
    n_filter = 10
    data = filter_data(in_dir, out_dir, force, n_filter)
    ProcessingUtil.plot_data(base_dir, step, data, markevery=1)
示例#10
0
def read_energy_lists(subdirs):
    """
    :param subdirs: which directories to look in (e.g. BR+Retinal/)
    :return: list, elements are all the landscapes in the subdirs
    """
    energy_list_arr = []
    # get all the energy objects
    for base in subdirs:
        in_dir = Pipeline._cache_dir(base=base, enum=Pipeline.Step.CORRECTED)
        in_file = in_dir + "energy.pkl"
        e = CheckpointUtilities.lazy_load(in_file)
        energy_list_arr.append(e)
    return energy_list_arr
示例#11
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.READ
    cache_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    force = True
    limit = None
    functor = lambda: read_all_data(base_dir)
    data = CheckpointUtilities.multi_load(cache_dir=cache_dir,
                                          load_func=functor,
                                          force=force,
                                          limit=limit,
                                          name_func=FEC_Util.fec_name_func)
    ProcessingUtil.plot_data(base_dir, step, data, markevery=100)
示例#12
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.SANITIZED
    in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.CORRECTED)
    out_dir = Pipeline._cache_dir(base=base_dir,enum=step)
    force = True
    max_n_pool = 6
    n_pool = max_n_pool
    kw_feather = RetinalUtil._def_kw_FEATHER()
    data = align_data(in_dir,out_dir,force=force,n_pool=n_pool,
                      **kw_feather)
    # plot all of the FEATHER information
    plot_subdir = Pipeline._plot_subdir(base_dir, step)
    PlotUtil._feather_plot(data,plot_subdir)
示例#13
0
def read_in_energy(base_dir):
    """
    :param base_dir: where the landscape lives; should be a series of FECs of
    about the same spring constant (e.g.  /BR+Retinal/300/170321FEC/)
    :return: RetinalUtil.EnergyWithMeta
    """
    landscape_base = _landscape_dir(base_dir)
    cache_tmp = \
        Pipeline._cache_dir(base=landscape_base,
                            enum=Pipeline.Step.POLISH)
    file_load = cache_tmp + "energy.pkl"
    energy_obj = CheckpointUtilities.lazy_load(file_load)
    obj = EnergyWithMeta(file_load,landscape_base, energy_obj)
    # read in the data, determine how many curves there are
    data_tmp = read_fecs(obj)
    n_data = len(data_tmp)
    obj.set_n_fecs(n_data)
    return obj
def run():
    """
    <Description>

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    base_dir_analysis = RetinalUtil._analysis_base()
    out_dir = Pipeline._cache_dir(base=base_dir_analysis,
                                  enum=Pipeline.Step.CORRECTED)
    force = True
    GenUtilities.ensureDirExists(out_dir)
    energy_list = CheckpointUtilities.getCheckpoint(out_dir + \
                                                    "energy.pkl",
                                                    get_energy_list,force,
                                                    base_dir_analysis)
    _fec_demo_plot(energy_list, out_dir)
示例#15
0
def _processing_base(default_base="../../../Data/BR+Retinal/170321FEC/",**kw):
    return Pipeline._base_dir_from_cmd(default=default_base,**kw)
示例#16
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)
示例#17
0
def _snapsnot(base_dir, step):
    corrected_dir = Pipeline._cache_dir(base=base_dir, enum=step)
    data = CheckpointUtilities.lazy_multi_load(corrected_dir)
    return SnapshotFEC(step, data)