How to use the easyvvuq.analysis.SCAnalysis function in easyvvuq

To help you get started, we’ve selected a few easyvvuq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UCL-CCS / EasyVVUQ / tests / test_anisotropic_order.py View on Github external
# Associate the sampler with the campaign
    my_campaign.set_sampler(my_sampler)

    # Will draw all (of the finite set of samples)
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()

    #   Use this instead to run the samples using EasyVVUQ on the localhost
    my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
        "tests/sc/sc_model.py ade_in.json"))

    my_campaign.collate()

    # Post-processing analysis
    analysis = uq.analysis.SCAnalysis(sampler=my_sampler, qoi_cols=output_columns)

    my_campaign.apply_analysis(analysis)

    #import pickle
    #pickle.dump(analysis, open('analysis.p', 'wb'))

    results = my_campaign.get_last_analysis()

    return results, my_sampler, analysis
github UCL-CCS / EasyVVUQ / tests / sc / test_sobol.py View on Github external
# Associate the sampler with the campaign
my_campaign.set_sampler(my_sampler)

# Will draw all (of the finite set of samples)
my_campaign.draw_samples()
my_campaign.populate_runs_dir()

# Use this instead to run the samples using EasyVVUQ on the localhost
my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
    "tests/sc/sobol_model.py sobol_in.json"))

my_campaign.collate()

# Post-processing analysis
analysis = uq.analysis.SCAnalysis(sampler=my_sampler, qoi_cols=output_columns)

my_campaign.apply_analysis(analysis)

results = my_campaign.get_last_analysis()

print(results['sobols_first'])

print_exact_sobols()

plt.show()
github UCL-CCS / EasyVVUQ / tests / test_hierarchical_sparse_grid_sc.py View on Github external
my_campaign.set_sampler(my_sampler)

    print('Number of samples:', my_sampler._number_of_samples)

    # Will draw all (of the finite set of samples)
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()

    # Use this instead to run the samples using EasyVVUQ on the localhost
    my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
        "tests/sc/poly_model.py poly_in.json"))

    my_campaign.collate()

    # Post-processing analysis
    analysis = uq.analysis.SCAnalysis(sampler=my_sampler, qoi_cols=output_columns)
    my_campaign.apply_analysis(analysis)
    results = my_campaign.get_last_analysis()

    # update the sparse grid to the next level
    my_sampler.next_level_sparse_grid()

    # draw the new samples
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()

    my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
        "tests/sc/poly_model.py poly_in.json"))

    my_campaign.collate()
    my_campaign.apply_analysis(analysis)
    results = my_campaign.get_last_analysis()
github UCL-CCS / EasyVVUQ / tests / test_integration.py View on Github external
output_columns = ["u"]
    encoder = uq.encoders.GenericEncoder(
        template_fname=f'tests/sc/sc.template',
        delimiter='$',
        target_filename='sc_in.json')
    decoder = uq.decoders.SimpleCSV(target_filename=output_filename,
                                    output_columns=output_columns,
                                    header=0)
    collater = uq.collate.AggregateSamples(average=False)
    vary = {
        "Pe": cp.Uniform(100.0, 200.0),
        "f": cp.Normal(1.0, 0.1)
    }
    sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=1)
    actions = uq.actions.ExecuteLocal(f"tests/sc/sc_model.py sc_in.json")
    stats = uq.analysis.SCAnalysis(sampler=sampler, qoi_cols=output_columns)
    campaign(tmpdir, 'sc', 'sc', params, encoder, decoder, sampler,
             collater, actions, stats, vary, 0, 1)
github UCL-CCS / EasyVVUQ / tests / test_vector.py View on Github external
sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=4)
    my_campaign = uq.Campaign(name='gauss_vector', work_dir=tmpdir)
    my_campaign.add_app(name="gauss_vector",
                        params=params,
                        encoder=encoder,
                        decoder=decoder,
                        collater=collater)
    my_campaign.set_sampler(sampler)
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()
    my_campaign.apply_for_each_run_dir(actions)
    my_campaign.collate()

    data = my_campaign.get_collation_result()
    print("===== DATA:\n ", data)
    analysis = uq.analysis.SCAnalysis(sampler=sampler, qoi_cols=["numbers"])
    my_campaign.apply_analysis(analysis)
    results = my_campaign.get_last_analysis()
github UCL-CCS / EasyVVUQ / tests / test_dimension_adaptive_SC.py View on Github external
# Associate the sampler with the campaign
    my_campaign.set_sampler(my_sampler)

    # Will draw all (of the finite set of samples)
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()

    # Run the samples using EasyVVUQ on the localhost
    my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
        "tests/sc/poly_model_anisotropic.py poly_in.json"))

    my_campaign.collate()
    data_frame = my_campaign.get_collation_result()

    # Post-processing analysis
    analysis = uq.analysis.SCAnalysis(sampler=my_sampler, qoi_cols=output_columns)

    my_campaign.apply_analysis(analysis)

    for i in range(number_of_adaptations):
        my_sampler.look_ahead(analysis.l_norm)

        my_campaign.draw_samples()
        my_campaign.populate_runs_dir()
        my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(
            "tests/sc/poly_model_anisotropic.py poly_in.json"))
        my_campaign.collate()
        data_frame = my_campaign.get_collation_result()
        analysis.adapt_dimension('f', data_frame)

        my_campaign.apply_analysis(analysis)