Ejemplo n.º 1
0
    range_arr[:, 0] = -0.5
    range_arr[:, 1] = 0.5
    range_dict[param_type] = range_arr

# dataset
input = InputFile(input_file)
input_params = input.read()
tlen = input_params['tlen']
nspc = input_params['nspc']
dataset, _ = work_parameters.get_dataset_syntest2(tlen=tlen,
                                                  nspc=nspc,
                                                  mode=0,
                                                  add_noise=False,
                                                  noise_normalized_std=2.)

na = NeighbouhoodAlgorithm.from_file(input_file, model_ref, model_params,
                                     range_dict, dataset, comm)

# run
log_path = os.path.join(na.out_dir, 'log_{}'.format(rank))
log = open(log_path, 'w', buffering=1)

result = na.compute(comm, log)

# plot inverted model
if rank == 0:
    fig, ax = plt.subplots(1, 1, figsize=(4, 6))
    result.plot_models(types=types,
                       n_best=1,
                       ax=ax,
                       color='black',
                       label='best model')
Ejemplo n.º 2
0
    if param_type == ParameterType.VSH:
        range_arr[:, 0] = -0.3
        range_arr[:, 1] = 0.3
    range_dict[param_type] = range_arr

# dataset
input = InputFile(input_file)
input_params = input.read()
tlen = input_params['tlen']
nspc = input_params['nspc']
dataset, _ = work_parameters.get_dataset_syntest3(tlen=tlen, nspc=nspc,
                                                  mode=2, add_noise=False,
                                                  noise_normalized_std=1.)

na = NeighbouhoodAlgorithm.from_file(
    input_file, model_ref, model_params, range_dict,
    dataset, comm)

# run
log_path = os.path.join(
    na.out_dir, 'log_{}'.format(rank))
log = open(log_path, 'w', buffering=1)

result = na.compute(comm, log)

# plot inverted model
if rank == 0:
    fig, ax = plt.subplots(1, 1, figsize=(3.5, 6))
    result.plot_models(
        types=types, n_best=1, ax=ax,
        color='black', label='best model')
Ejemplo n.º 3
0
    indices_better = [0]
    for imod in range(1, result.meta['n_mod']):
        i_best = result.get_indices_best_models(n_best=1, n_mod=imod+1)
        if i_best != indices_better[-1]:
            indices_better.append(imod)
    models = [result.models[i] for i in indices_better]
else:
    models = None
outputs = result.compute_models(models)

# plot results
if rank == 0:
    out_dir = 'output_' + utilities.get_temporary_str()
    os.mkdir(out_dir)
    points = NeighbouhoodAlgorithm.get_points_for_voronoi(
                result.perturbations,
                result.meta['range_dict'],
                types)
    points = points[:, free_indices]
    misfits = result.misfit_dict['variance'].mean(axis=1)
    n_r = result.meta['n_r']
    n_s = result.meta['n_s']
    n_mod = points.shape[0]
    i_out = 0
    for imod in range(n_mod):
        figpath = os.path.join(
            out_dir, 'voronoi_{:05d}.png'.format(imod))
        fig = plt.figure(figsize=(13*figscale, 5*figscale))
        gs = gridspec.GridSpec(1, 3, width_ratios=[2,1,1])
        # plot voronoi cells
        ax0 = fig.add_subplot(gs[0])
        _, _, colormap = NeighbouhoodAlgorithm.plot_voronoi_2d(
Ejemplo n.º 4
0
        range_arr[:, 0] = -100
        range_arr[:, 1] = 100
    range_dict[p_type] = range_arr

# dataset
input = InputFile(input_file)
input_params = input.read()
dataset, _ = work_parameters.get_dataset_syntest_vshvsv_4(
    tlen=input_params['tlen'],
    nspc=input_params['nspc'],
    mode=input_params['mode'],
    add_noise=False,
    noise_normalized_std=2.)

na = NeighbouhoodAlgorithm.from_file(
    input_file, model, model_params, range_dict,
    dataset, comm)

# run
log_path = os.path.join(
    na.out_dir, 'log_{}'.format(rank))
log = open(log_path, 'w', buffering=1)

result = na.compute(comm, log)

# plot inverted model
if rank == 0:
    fig, ax = plt.subplots(1, 1, figsize=(4,6))
    result.plot_models(
        types=types, n_best=1, ax=ax,
        color='black', label='best model')