Example #1
0
def loader_rands_grid():
    seed = [123, 234]
    batch_size = [10]
    shuffle = [True, False]
    nworkers = [2]
    extra_ops = [0, 1]
    items = [seed, batch_size, shuffle, nworkers, extra_ops]
    names = ['seed', 'batch_size', 'shuffle', 'nworkers', 'extra_ops']
    mesh = pd.DataFrame(create_named_meshgrid(items, names))
    field_names = ['seed', 'shuffle']
    # field_names = ['shuffle']
    exp_pairs = groupby_fields(field_names, mesh)

    def create_exp_ids(pair, field_names):
        id_str = ""
        for field in field_names:
            id_str += f"{field}:"
            for item in pair:
                id_str += f"{item[field]}+"
            id_str = id_str[:-1]
            id_str += "_"
        id_str = id_str[:-1]
        return id_str

    names = ['seed', 'shuffle']
    for i, pair in enumerate(exp_pairs):
        id_str = create_exp_ids(pair, names)
        print(id_str)
        exp_pairs[i] = pytest.param(pair, id=id_str)
    return exp_pairs
Example #2
0
def create_sfields_mesh(sims, sfields):
    uniques = []
    for sfield in sfields:
        uniques_f = sorted(sims[sfield].unique())
        uniques.append(uniques_f)
    mesh = create_named_meshgrid(uniques, sfields)
    return mesh
Example #3
0
    def get_pair_mlevel(sims, field1, field2, xform=None):

        # -- create field grid --
        f1_unique = sorted(list(sims[field1].unique()))
        f2_unique = sorted(list(sims[field2].unique()))
        uniques = [f1_unique, f2_unique]
        names = ["f1", "f2"]
        fgrid = create_named_meshgrid(uniques, names)

        # -- aggregate over field --
        means = np.zeros((len(f2_unique), len(f1_unique)))
        for point in fgrid:
            filter1 = sims[sims[field1] == point.f1]
            filter2 = filter1[filter1[field2] == point.f2]

            # -- format samples for contour plot --
            est_mean = filter2['est_mean'].mean()
            if np.isnan(est_mean):
                print(len(filter1), point.f1)
                print(len(filter2), point.f2)
                print("est_mean", est_mean)
            f1_index = f1_unique.index(point.f1)
            f2_index = f2_unique.index(point.f2)
            means[f2_index, f1_index] = est_mean

        if not (xform is None): means = xform(means)
        # -- number of contour levels --
        # quants = np.linspace(0.00,1.0,30)
        # mlevels = np.unique(np.quantile(means,quants))
        vmin = means.min()
        mlevels = np.linspace(vmin, 1.0, 30)
        print("mlevels", means.min(), np.min(mlevels), vmin)
        return mlevels
Example #4
0
def get_v1_mesh():

    # -- create grids --
    N = 20
    mu2ave_max = 1e-3
    mu2ave_grid = list(np.linspace(0, mu2ave_max, N) / mu2ave_max)
    std_grid = [25, 50, 75]
    ps_grid = [9, 25]
    t_grid = [3, 7, 15]
    minSN_grid = ['one', 'half', '2/3']

    lists = [mu2ave_grid, std_grid, ps_grid, t_grid, minSN_grid]
    order = ['mu2ave', 'std', 'ps', 'nframes', 'minSN']

    # -- create meshgrid --
    named_mesh = create_named_meshgrid(lists, order)
    filters = [{
        'nframes-minSN': [[3, 'one'], [3, 'half'], [7, 'one'], [7, 'half'],
                          [7, '2/3'], [15, 'one'], [15, 'half'], [15, '2/3']]
    }]
    named_mesh = apply_mesh_filters(named_mesh, filters)
    version = "1"
    return named_mesh, version
Example #5
0
File: v1.py Project: gauenk/cl_gen
def create_mesh():

    # -- alignment methods  --
    align_fxn = [
        "nn-ransac", "nn-flownet_v2", "c-frame_v_frame", "c-frame_v_mean",
        "c-bootstrap"
    ]

    # -- noise levels --
    noise_type = ['none', 'g-10p0', 'g-25p0', 'g-50p0', 'g-75p0', 'g-100p0']
    noise_type += [
        'qis-40p0-15p0', 'qis-30p0-15p0', 'qis-20p0-15p0', 'qis-4p0-15p0'
    ]
    noise_type += ['p-40p0', 'p-30p0', 'p-20p0', 'p-10p0']

    # -- number of frames --
    nframes = [3, 5, 10, 25]

    # -- datasets --
    datasets = ['voc-gm', 'voc-lm', 'kitti-default']

    # -- number of blocks --
    nblocks = [5, 7, 9, 25]

    # -- patchsize --
    patchsize = [3, 9, 32]

    # -- npatches --
    npatches = [3]

    # -- ppf --
    ppf = [3]

    # -- random seed --
    random_seed = [123, 234, 345, 456, 567]

    # -- batch size --
    batch_size = [10]

    # -- create a list of arrays to mesh --
    lists = [
        align_fxn, noise_type, nframes, datasets, nblocks, patchsize, npatches,
        ppf, random_seed, batch_size
    ]
    order = [
        'align_fxn', 'noise_type', 'nframes', 'datasets', 'nblocks',
        'patchsize', 'npatches', 'ppf', 'random_seed', 'batch_size'
    ]
    named_list = dict(zip(order, lists))

    # -- create mesh --
    named_mesh = create_named_meshgrid(lists, order)

    # -- create filter for nn methods
    non_nn_params = ['nblocks', 'patchsize', 'npatches']
    named_mesh = remove_extra_grid_for_nn_align_fxn(named_mesh, named_list,
                                                    non_nn_params)

    # -- mesh filters --
    filters = [{
        'nframes-nblocks': [[5, 7], [7, 7], [7, 9], [9, 9], [15, 15], [15, 13],
                            [25, 25]]
    }]
    named_mesh = apply_mesh_filters(named_mesh, filters, 'keep')

    return named_mesh, order
Example #6
0
def create_standard_parameter_grid():
    pgrid = edict()

    start,end,size,base = 1,4,15,10
    D_exp = np.linspace(start,end,size)
    D = np.power([base],D_exp).astype(np.long) # np.linspace(3,128,10)**2
    D_tickmarks = np.linspace(start,end,end-start+1)
    D_tickmarks = skip_with_endpoints(D_tickmarks,1)
    D_ticks = np.power([base],D_tickmarks)
    D_tickmarks_str = ["%d" % x for x in D_tickmarks]

    start,end,size,base = -1,2,5,10
    mu2_exp = np.linspace(start,end,size)
    mu2 = np.power([base],mu2_exp) # [0,1e-6,1e-3,1e-1,1,1e1]
    mu2_tickmarks = np.linspace(start,end,end - start + 1)
    mu2_tickmarks = skip_with_endpoints(mu2_tickmarks,3)
    mu2_ticks = np.power([base],mu2_tickmarks)
    mu2_tickmarks_str = ["%d" % x for x in mu2_tickmarks]

    # start,end,size,base = -5,2,50,10
    start,end,size,base = 0,100,21,10
    #std_exp = np.linspace(start,end,size).astype(np.int)
    #std = np.power([base],std_exp) # [1e-6,1e-3,1e-1,1,1e1]
    std_exp = np.linspace(start,end,end - start + 1)
    std_exp = skip_with_endpoints(std_exp,len(std_exp)//size)
    std = std_exp
    std_tickmarks = np.linspace(start,end,end - start + 1)
    std_tickmarks = skip_with_endpoints(std_tickmarks,50)
    #std_ticks = np.power([base],std_tickmarks)
    std_ticks = std_tickmarks
    std_tickmarks_str = ["%d" % x for x in std_tickmarks]

    start,end = 3,50
    int_spacing = (end - start + 1)
    num = 5
    nframes = [3,10,50]
    #nframes = np.linspace(start,end,num).astype(np.long)
    # nframes = [3,18,34,50]
    #nframes_tickmarks = np.linspace(start,end,num)
    nframes_tickmarks = nframes
    nframes_ticks = np_log(nframes_tickmarks)/ np_log([10])
    nframes_tickmarks_str = ["%d" % x for x in nframes_tickmarks]

    size = [5000]

    params = [D,mu2,std,nframes,size]
    names = ['D','mu2','std','T','size']
    pgrid = create_named_meshgrid(params,names)
    print(f"Mesh grid created of size [{len(pgrid)}]")

    ticks = edict({'D':D_ticks,'mu2':mu2_ticks,
                   'std':std_ticks,'T':nframes_ticks})
    tickmarks = edict({'D':D_tickmarks,'mu2':mu2_tickmarks,
                       'std':std_tickmarks,'T':nframes_tickmarks})
    tickmarks_str = edict({'D':D_tickmarks_str,'mu2':mu2_tickmarks_str,
                           'std':std_tickmarks_str,
                           'T':nframes_tickmarks_str})
    logs = {'D':True,'mu2':True,'std':False,'T':False}
    # log_tickmarks = edict({'D':np_log(D_ticks),
    #                        'mu2':np_log(mu2_ticks),
    #                        'std':np_log(std_ticks)})
    lgrid = edict({'ticks':ticks,'tickmarks':tickmarks,
                   'tickmarks_str':tickmarks_str,'logs':logs})
                   #'log_tickmarks':log_tickmarks})

    return pgrid,lgrid
Example #7
0
def plot_sim_test_pairs_old(ax,sims,lgrids,mlevels,title,fname,field1,field2,
                        add_legend_bool=True):
    
    MAX_LEN_TICKS = 30
    shrink_perc = 0.8

    # -- create field grid --
    f1_unique = list(sims[field1].unique())
    f2_unique = list(sims[field2].unique())
    uniques = [f1_unique,f2_unique]
    names = ["f1","f2"]
    fgrid = create_named_meshgrid(uniques,names)
    
    # -- aggregate over field --
    means = np.zeros((len(f2_unique),len(f1_unique)))
    stds = np.zeros((len(f2_unique),len(f1_unique)))
    aggs = []
    for point in fgrid:
        filter1 = sims[sims[field1] == point.f1]
        filter2 = filter1[filter1[field2] == point.f2]

        # -- create dict --
        agg = edict()
        agg.est_mean = filter2['est_mean'].mean()
        agg.est_std = filter2['est_std'].std()
        agg.f1 = point.f1
        agg.f2 = point.f2

        # -- format samples for contour plot --
        f1_index = f1_unique.index(point.f1)
        f2_index = f2_unique.index(point.f2)
        means[f2_index,f1_index] = agg.est_mean
        stds[f2_index,f1_index] = agg.est_std

        aggs.append(agg)
    
    # -- number of contour levels --
    if mlevels is None:
        vmin = means.min()
        quants = np.linspace(vmin,1.0,30)
        mlevels = np.unique(np.quantile(means,quants))
        # slevels = np.unique(np.quantile(stds,quants))
    
    # -- log axis --
    fields = [field1,field2]
    xgrid,ygrid = f1_unique,f2_unique
    grids = [xgrid,ygrid]
    for idx,field in enumerate(fields):
        if field in ["D","mu2","std"]:
            grids[idx] = np_log(grids[idx])/np_log([10])

    # -- figure size depends on legend inclusion --
    figsize = [6,4]
    if add_legend_bool and (ax is None): figsize[0] = figsize[0]/shrink_perc

    # -- plot contours --
    title = f"Approx. Probability of Correct Alignment [Standard]"
    if ax is None:
        fig,axes = plt.subplots(figsize=figsize)
        axes = [axes]
        axes[0].set_title(title,fontsize=FONTSIZE)
    else:
        axes = [ax]
    cs = axes[0].contourf(grids[0],grids[1],means,levels=mlevels,cmap="plasma")
    

    def translate_axis_labels(labels):
        def translate_label(name):
            if name == "D": return "Patchsize, $D$ [Log-scale]"
            elif name == "std": return "Noise Level, $\sigma^2$ [Log-scale]"
            elif name == "mu2": return r"MSE($I_t$,$I_0$), $\Delta I_t$ [Log-scale]"
            else: raise ValueError(f"Uknown name [{name}]")
        new = edict({'x':None,'y':None})
        new.x = translate_label(labels.x)
        new.y = translate_label(labels.y)
        return new

    axis_labels = edict({'x':field1,'y':field2})
    axis_labels = translate_axis_labels(axis_labels)
    axes[0].set_xlabel(axis_labels.x,fontsize=FONTSIZE)
    axes[0].set_ylabel(axis_labels.y,fontsize=FONTSIZE)

    # -- filter ticks --
    N = np.min([len(grids[0]),MAX_LEN_TICKS])
    if N > MAX_LEN_TICKS//2: skip = 2
    else: skip = 1
    xlocs = grids[0][::skip]
    xlabels = ["%1.1e" % x for x in f1_unique[::skip]]
    N = np.min([len(grids[1]),MAX_LEN_TICKS])
    if N > MAX_LEN_TICKS//2: skip = 2
    else: skip = 1
    ylocs = grids[1][::skip]
    ylabels = ["%1.1e" % x for x in f2_unique[::skip]]

    # -- x and y ticks --
    axes[0].set_xticks(lgrids.tickmarks[field1])
    axes[0].set_xticklabels(lgrids.tickmarks_str[field1],fontsize=FONTSIZE)

    axes[0].set_yticks(lgrids.tickmarks[field2])
    axes[0].set_yticklabels(lgrids.tickmarks_str[field2],fontsize=FONTSIZE)

    # axes[0].set_xticks(xlocs)
    # axes[0].set_xticklabels(xlabels,rotation=45,ha="right")
    # axes[0].set_yticks(ylocs)
    # axes[0].set_yticklabels(ylabels,rotation=45,ha="right")

    # -- legend --
    if add_legend_bool and (ax is None):
        proxy = [plt.Rectangle((0,0),1,1,fc = pc.get_facecolor()[0]) 
                 for pc in cs.collections]
        mlevels_fmt = ["%0.3f" % x for x in mlevels]
        N,skip = len(proxy),8
        skim_proxy = proxy[::N//skip]
        skim_fmt = mlevels_fmt[1::N//skip] # skip 1st element; return max of interval
        if skim_fmt[-1] != mlevels_fmt[-1]: #N % skip != 0:
            skim_proxy += [proxy[-1]]
            skim_fmt += [mlevels_fmt[-1]]
        add_legend(axes[0],"Approx. Prob.",skim_fmt,skim_proxy,
                   framealpha=0.,shrink_perc=shrink_perc)

    # -- save/file io --
    # axes[1].contourf(f1_unique,f2_unique,stds.T,levels=slevels)
    # axes[1].set_title(f"Vars",fontsize=FONTSIZE)
    # axes[1].set_xlabel(f"Field [{field1}]",fontsize=FONTSIZE)
    
    if ax is None:
        DIR = Path("./output/pretty_plots")
        if not DIR.exists(): DIR.mkdir()
        fn =  DIR / f"./stat_test_properties_{fname}_contours-{field1}-{field2}.png"
        plt.savefig(fn,transparent=True,bbox_inches='tight',dpi=300)
        plt.close('all')
        print(f"Wrote plot to [{fn}]")

    return cs
Example #8
0
def plot_p1boundary(ax,
                    sims,
                    lgrids,
                    title,
                    fname,
                    field1,
                    field2,
                    zinfo=None):

    MAX_LEN_TICKS = 30
    shrink_perc = 0.8

    # -- order field pairs for consistency --
    field1, field2 = order_field_pairs(field1, field2)
    fields = [field1, field2]

    # -- default z info --
    zinfo = get_default_zinfo(zinfo, fname)

    # -- create field grid --
    f1_unique = sorted(list(sims[field1].unique()))
    f2_unique = sorted(list(sims[field2].unique()))
    grids = [f1_unique, f2_unique]
    names = ["f1", "f2"]
    fgrid = create_named_meshgrid(grids, names)

    # -- compute contour map --
    means, stds = compute_stat_contour(sims, fgrid, grids, fields, zinfo)
    if not (zinfo.xform is None): means = zinfo.xform(means)

    # -- log axis --
    grids = compute_log_lists(grids, fields, lgrids.logs)

    # -- compute the boundary --
    rows, cols = compute_max_yval_boundary(means, grids)
    # rc_tuple = compute_log_lists([rows,cols],fields,lgrids.logs)
    # rows,cols = rc_tuple[0],rc_tuple[1]

    # -- figure size depends on legend inclusion --
    figsize, title = [6, 4], zinfo.title
    # if add_legend_bool and (ax is None): figsize[0] = figsize[0]/shrink_perc
    axes = get_default_axis(ax, figsize, title)

    # -- create the plot --
    cs = axes[0].plot(rows, cols, ls=zinfo.ls, color=zinfo.color)

    # -- axis labels --
    axis_labels = edict({'x': field1, 'y': field2})
    axis_logs = edict({'x': lgrids.logs[field1], 'y': lgrids.logs[field1]})
    axis_labels = translate_axis_labels(axis_labels, axis_logs)
    axes[0].set_xlabel(axis_labels.x, fontsize=FONTSIZE)
    axes[0].set_ylabel(axis_labels.y, fontsize=FONTSIZE)

    # -- filter ticks --
    # xticklabels,yticklabels = filter_ticks(MAX_LEN_TICKS,grids)

    # -- x and y ticks --
    axes[0].set_xticks(lgrids.tickmarks[field1])
    axes[0].set_xticklabels(lgrids.tickmarks_str[field1], fontsize=FONTSIZE)

    axes[0].set_yticks(lgrids.tickmarks[field2])
    axes[0].set_yticklabels(lgrids.tickmarks_str[field2], fontsize=FONTSIZE)

    # -- legend --
    # add_contour_legend(axes,ax,cs,add_legend_bool,mlevels,zinfo,shrink_perc)

    # -- save/file io --
    # axes[1].contourf(f1_unique,f2_unique,stds.T,levels=slevels)
    # axes[1].set_title(f"Vars",fontsize=FONTSIZE)
    # axes[1].set_xlabel(f"Field [{field1}]",fontsize=FONTSIZE)

    if ax is None:
        DIR = Path(f"./output/pretty_plots/stat_test_properties/{fname}/")
        if not DIR.exists(): DIR.mkdir()
        fn = DIR / f"./stat_test_properties_{fname}_p1boundary-{field1}-{field2}-{zinfo.mean}.png"
        plt.savefig(fn, transparent=True, bbox_inches='tight', dpi=300)
        plt.close('all')
        print(f"Wrote plot to [{fn}]")

    return cs
Example #9
0
def plot_sim_test_pairs(ax,
                        sims,
                        lgrids,
                        mlevels,
                        title,
                        fname,
                        field1,
                        field2,
                        add_legend_bool=True,
                        zinfo=None,
                        vmin=None,
                        vmax=None):

    MAX_LEN_TICKS = 30
    shrink_perc = 0.8

    # -- order field pairs for consistency --
    field1, field2 = order_field_pairs(field1, field2)
    fields = [field1, field2]

    # -- default z info --
    zinfo = get_default_zinfo(zinfo, fname)

    # -- create field grid --
    f1_unique = sorted(list(sims[field1].unique()))
    f2_unique = sorted(list(sims[field2].unique()))
    grids = [f1_unique, f2_unique]
    names = ["f1", "f2"]
    fgrid = create_named_meshgrid(grids, names)

    # -- compute contour map --
    means, stds = compute_stat_contour(sims, fgrid, grids, fields, zinfo)
    if not (zinfo.xform is None): means = zinfo.xform(means)

    # -- number of contour levels --
    if mlevels is None:
        quants = np.linspace(0.00, 1.0, 30)
        mlevels = np.linspace(means.min(), means.max(), 30)
        # mlevels = np.unique(np.quantile(means,quants))

    # -- log axis --
    grids = compute_log_lists(grids, fields, lgrids.logs)

    # -- figure size depends on legend inclusion --
    figsize = [6, 4]
    # if add_legend_bool and (ax is None): figsize[0] = figsize[0]/shrink_perc

    # -- plot contours --
    title = zinfo.title
    if ax is None:
        fig, axes = plt.subplots(figsize=figsize)
        axes = [axes]
        axes[0].set_title(title, fontsize=FONTSIZE)
    else:
        axes = [ax]

    # -- color range --
    vmin, vmax = get_color_range(mlevels, means, vmin, vmax)
    # print("means",np.min(means),np.min(mlevels),np.max(means))

    # -- create the plot --
    cs = axes[0].contourf(grids[0],
                          grids[1],
                          means,
                          levels=mlevels,
                          cmap="plasma",
                          vmin=vmin,
                          vmax=vmax)

    # -- axis labels --
    axis_labels = edict({'x': field1, 'y': field2})
    axis_logs = edict({'x': lgrids.logs[field1], 'y': lgrids.logs[field2]})
    axis_labels = translate_axis_labels(axis_labels, axis_logs)
    axes[0].set_xlabel(axis_labels.x, fontsize=FONTSIZE)
    axes[0].set_ylabel(axis_labels.y, fontsize=FONTSIZE)

    # -- filter ticks --
    # xticklabels,yticklabels = filter_ticks(MAX_LEN_TICKS,grids)

    # -- x and y ticks --
    axes[0].set_xticks(lgrids.tickmarks[field1])
    axes[0].set_xticklabels(lgrids.tickmarks_str[field1], fontsize=FONTSIZE)

    axes[0].set_yticks(lgrids.tickmarks[field2])
    axes[0].set_yticklabels(lgrids.tickmarks_str[field2], fontsize=FONTSIZE)

    # -- legend --
    add_contour_legend(axes, ax, cs, add_legend_bool, mlevels, zinfo,
                       shrink_perc)

    # -- save/file io --
    # axes[1].contourf(f1_unique,f2_unique,stds.T,levels=slevels)
    # axes[1].set_title(f"Vars",fontsize=FONTSIZE)
    # axes[1].set_xlabel(f"Field [{field1}]",fontsize=FONTSIZE)

    if ax is None:
        DIR = Path(f"./output/pretty_plots/stat_test_properties/{fname}/")
        if not DIR.exists(): DIR.mkdir()
        fn = DIR / f"./contours-{field1}-{field2}-{zinfo.mean}.png"
        plt.savefig(fn, transparent=True, bbox_inches='tight', dpi=300)
        plt.close('all')
        print(f"Wrote plot to [{fn}]")

    return cs
Example #10
0
def create_proposed_parameter_grid():
    pgrid = edict()

    start, end, size, base = 1, 4, 10, 10
    # [10000,1778,316,56,10]
    D_exp = np.linspace(start, end, size)
    D = np.power([base], D_exp).astype(np.long)  # np.linspace(3,128,10)**2
    D_tickmarks = np.linspace(start, end, end - start + 1)
    D_tickmarks = skip_with_endpoints(D_tickmarks, 1)
    D_ticks = np.power([base], D_tickmarks)
    D_tickmarks_str = ["%d" % x for x in D_tickmarks]
    D = D[::-1]

    start, end, size, base = 0, 100, 21, 10
    std_exp = np.linspace(start, end, size).astype(np.int)
    std = std_exp
    std_tickmarks = np.linspace(start, end, end - start + 1)
    std_tickmarks = skip_with_endpoints(std_tickmarks, 50)
    std_ticks = std_tickmarks
    std_tickmarks_str = ["%d" % x for x in std_tickmarks]

    start, end, size, base = -3, 1, 4, 10
    ub_exp = np.linspace(start, end, size)
    ub = np.power([base], ub_exp)  # [0,1e-6,1e-3,1e-1,1,1e1]
    ub_tickmarks = np.linspace(start, end, end - start + 1)
    ub_tickmarks = skip_with_endpoints(ub_tickmarks, 3)
    ub_ticks = np.power([base], ub_tickmarks)
    ub_tickmarks_str = ["%d" % x for x in ub_tickmarks]

    start, end = 35, 95
    int_spacing = (end - start + 1)
    num = 3  # int_spacing
    pmis = np.linspace(start, end, num)  # to percent
    pmis_tickmarks = np.linspace(start, end, num)
    pmis_ticks = pmis_tickmarks
    pmis_tickmarks_str = ["%d" % x for x in pmis_tickmarks]

    start, end = 3, 50
    int_spacing = (end - start + 1)
    num = 5
    nframes = [3, 10, 50]
    #nframes = np.linspace(start,end,num).astype(np.long)
    # nframes = [3,18,34,50]
    #nframes_tickmarks = np.linspace(start,end,num)
    nframes_tickmarks = nframes
    nframes_ticks = np_log(nframes_tickmarks) / np_log([10])
    nframes_tickmarks_str = ["%d" % x for x in nframes_tickmarks]

    start, end = 1000, 1200
    int_spacing = (end - start + 1)
    num = 1
    B = np.linspace(start, end, num).astype(np.long)
    B_tickmarks = np.linspace(start, end, num)
    B_ticks = B_tickmarks
    B_tickmarks_str = ["%d" % x for x in B_tickmarks]

    size = [50]

    params = [D, ub, std, pmis, nframes, B, size]
    names = ['D', 'ub', 'std', 'pmis', 'T', 'B', 'size']
    named_params = {key: val for key, val in zip(names, params)}
    print("About to create mesh.")
    for n, p in zip(names, params):
        print(f"# of [{n}] terms is [{len(p)}]: {p}")
    pgrid = create_named_meshgrid(params, names)
    print(f"Mesh grid created of size [{len(pgrid)}]")

    logs = {
        'D': True,
        'ub': True,
        'std': False,
        'pmis': False,
        'T': False,
        'B': False,
        'size': False
    }
    ticks = edict({
        'D': D_ticks,
        'ub': ub_ticks,
        'std': std_ticks,
        'pmis': pmis_ticks,
        'T': nframes_ticks,
        'B': B_ticks
    })
    tickmarks = edict({
        'D': D_tickmarks,
        'ub': ub_tickmarks,
        'std': std_tickmarks,
        'pmis': pmis_tickmarks,
        'T': nframes_tickmarks,
        'B': B_tickmarks
    })
    tickmarks_str = edict({
        'D': D_tickmarks_str,
        'ub': ub_tickmarks_str,
        'std': std_tickmarks_str,
        'pmis': pmis_tickmarks_str,
        'T': nframes_tickmarks_str,
        'B': B_tickmarks_str
    })
    lgrid = edict({
        'ticks': ticks,
        'tickmarks': tickmarks,
        'tickmarks_str': tickmarks_str,
        'logs': logs,
        'grids': named_params
    })
    #'log_tickmarks':log_tickmarks})

    return pgrid, lgrid
Example #11
0
def get_grid():
    
    # -- PATCHSIZE --
    start,end,size,base = 1,2,5,10
    D_exp = np.linspace(start,end,size)
    D = np.power([base],D_exp).astype(np.long) # np.linspace(3,128,10)**2
    D_tickmarks = np.linspace(start,end,end-start+1)
    D_tickmarks = skip_with_endpoints(D_tickmarks,1)
    D_ticks = np.power([base],D_tickmarks)
    D_tickmarks_str = ["%d" % x for x in D_tickmarks]
    D = D[::-1]

    # -- NUM OF FRAMES --
    start,end = 3,50
    int_spacing = (end - start + 1)
    num = 5
    nframes = [3,10,20,35,45,50]
    nframes_tickmarks = nframes
    nframes_ticks = np_log(nframes_tickmarks)/ np_log([10])
    nframes_tickmarks_str = ["%d" % x for x in nframes_tickmarks]

    # -- NOISE LEVEL --
    start,end,size,base = 0,100,21,10
    std_exp = np.linspace(start,end,size).astype(np.int)
    std = std_exp
    std_tickmarks = np.linspace(start,end,end - start + 1)
    std_tickmarks = skip_with_endpoints(std_tickmarks,50)
    std_ticks = std_tickmarks
    std_tickmarks_str = ["%d" % x for x in std_tickmarks]

    # -- ERROR VAR --
    start,end,size,base = 0,100,21,10
    eps_exp = np.linspace(start,end,size)
    #eps = np.power([base],eps_exp) # [0,1e-6,1e-3,1e-1,1,1e1]
    eps = eps_exp
    eps_tickmarks = np.linspace(start,end,end - start + 1)
    eps_tickmarks = skip_with_endpoints(eps_tickmarks,3)
    eps_ticks = np.power([base],eps_tickmarks)
    eps_tickmarks_str = ["%d" % x for x in eps_tickmarks]

    # -- NUM OF BOOTSTRAP REPS --
    start,end = 1000,1200
    int_spacing = (end - start + 1)
    num = 1
    B = np.linspace(start,end,num).astype(np.long)
    B_tickmarks = np.linspace(start,end,num)
    B_ticks = B_tickmarks
    B_tickmarks_str = ["%d" % x for x in B_tickmarks]

    # -- NUM OF REPEAT EXPERIMENT --
    size = [50]

    # -- CREATE GRID --
    params = [D,eps,std,nframes,B,size]
    names = ['D','eps','std','T','B','size']
    named_params = {key:val for key,val in zip(names,params)}
    print("About to create mesh.")
    for n,p in zip(names,params): print(f"# of [{n}] terms is [{len(p)}]: {p}")
    grid = create_named_meshgrid(params,names)
    print(f"Mesh grid created of size [{len(grid)}]")

    logs = {'D':True,'eps':False,'std':False,'T':False,'B':False,'size':False}
    ticks = edict({'D':D_ticks,'eps':eps_ticks,'std':std_ticks,
                   'T':nframes_ticks,'B':B_ticks})
    tickmarks = edict({'D':D_tickmarks,'eps':eps_tickmarks,
                       'std':std_tickmarks,
                       'T':nframes_tickmarks,'B':B_tickmarks})
    tickmarks_str = edict({'D':D_tickmarks_str,'eps':eps_tickmarks_str,
                           'std':std_tickmarks_str,
                           'T':nframes_tickmarks_str,'B':B_tickmarks_str})
    lgrid = edict({'ticks':ticks,'tickmarks':tickmarks,
                   'tickmarks_str':tickmarks_str,'logs':logs,
                   'grids':named_params})

    return grid,lgrid