How to use the easyvvuq.decoders.SimpleCSV 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_dask.py View on Github external
"type": "float",
            "min": 0.0001,
            "max": 1000.0,
            "default": 1.0},
        "velocity": {
            "type": "float",
            "min": 0.0,
            "max": 1000.0,
            "default": 10.0}}

    # Create an encoder and decoder for the cannonsim app
    encoder = uq.encoders.GenericEncoder(
        template_fname='tests/cannonsim/test_input/cannonsim.template',
        delimiter='#',
        target_filename='in.cannon')
    decoder = uq.decoders.SimpleCSV(
        target_filename='output.csv', output_columns=[
            'Dist', 'lastvx', 'lastvy'], header=0)
    # Create a collation element for this campaign
    collater = uq.collate.AggregateSamples(average=False)
    actions = uq.actions.ExecuteLocal("/home/hpc/pn69ju/di73kuj2/cannonsim/bin/cannonsim in.cannon output.csv")
    campaign.add_app(name='cannonsim',
                     params=params,
                     encoder=encoder,
                     decoder=decoder,
                     collater=collater)
    stats = uq.analysis.BasicStats(qoi_cols=['Dist', 'lastvx', 'lastvy'])
    # Make a random sampler
    vary = {
        "angle": cp.Uniform(0.0, 1.0),
        "height": cp.Uniform(2.0, 10.0),
        "velocity": cp.Normal(10.0, 1.0),
github UCL-CCS / EasyVVUQ / tests / test_jinja_encoder.py View on Github external
# "Rigc": cp.Uniform(0.1, 0.4),
        # "Prandtl": cp.Uniform(0.2, 0.4),
        # "z0": cp.Uniform(1e-4, 2e-4),
        "l_sb": cp.DiscreteUniform(0, 1),
        # "Nh": cp.DiscreteUniform(10, 20),
        # "extent": cp.Uniform(1000, 2000),
        "seed": cp.Uniform(1, 2000),
    }

    output_columns = ['cfrac', 'lwp', 'rwp', 'zb', 'zi', 'prec', 'wq', 'wtheta', 'we', 'walltime']
    my_sampler = uq.sampling.SCSampler(vary=vary, polynomial_order=2,
                                       quadrature_rule="C")
    my_campaign = uq.Campaign(name='dales', work_dir=tmpdir, db_location='sqlite:///')
    encoder = JinjaEncoder(template_fname='tests/jinjaencoder/namoptions.template',
                           target_filename='namoptions.001')
    decoder = uq.decoders.SimpleCSV(
        target_filename='results.csv',
        output_columns=output_columns,
        header=0)
    collater = uq.collate.AggregateSamples(average=False)
    my_campaign.add_app(name="dales",
                        params=params,
                        encoder=encoder,
                        decoder=decoder,
                        collater=collater)
    my_campaign.verify_all_runs = False  # to prevent errors on integer quantities
    my_campaign.set_sampler(my_sampler)
    my_campaign.draw_samples()
    my_campaign.populate_runs_dir()
github UCL-CCS / EasyVVUQ / tests / test_cannonsim_csv_jsondb.py View on Github external
"type": "float",
            "min": 0.0001,
            "max": 1000.0,
            "default": 1.0},
        "velocity": {
            "type": "float",
            "min": 0.0,
            "max": 1000.0,
            "default": 10.0}}

    # Create an encoder and decoder for the cannonsim app
    encoder = uq.encoders.GenericEncoder(
        template_fname='tests/cannonsim/test_input/cannonsim.template',
        delimiter='#',
        target_filename='in.cannon')
    decoder = uq.decoders.SimpleCSV(
        target_filename='output.csv', output_columns=[
            'Dist', 'lastvx', 'lastvy'], header=0)

    print("Serialized encoder:", encoder.serialize())
    print("Serialized decoder:", decoder.serialize())

    # Add the cannonsim app
    my_campaign.add_app(name="cannonsim",
                        params=params,
                        encoder=encoder,
                        decoder=decoder)

    # Set the active app to be cannonsim (this is redundant when only one app
    # has been added)
    my_campaign.set_app("cannonsim")
github UCL-CCS / EasyVVUQ / tests / test_multiencoder.py View on Github external
# Create two encoders
    encoder1 = uq.encoders.GenericEncoder(
        template_fname='tests/cannonsim/test_input/cannonsim.template',
        delimiter='#',
        target_filename='in.cannon')
    encoder2 = uq.encoders.GenericEncoder(
        template_fname='tests/cannonsim/test_input/cannonsim.template',
        delimiter='#',
        target_filename='in.cannon.2')

    # Combine both encoders into a single encoder
    multiencoder = uq.encoders.MultiEncoder(encoder1, encoder2)

    # Create decoder and collater for the cannonsim app
    decoder = uq.decoders.SimpleCSV(
        target_filename='output.csv', output_columns=[
            'Dist', 'lastvx', 'lastvy'], header=0)
    collater = uq.collate.AggregateSamples(average=False)

    # Add the cannonsim app
    my_campaign.add_app(name="cannonsim",
                        params=params,
                        encoder=multiencoder,
                        decoder=decoder,
                        collater=collater)

    # Set the active app to be cannonsim (this is redundant when only one app
    # has been added)
    my_campaign.set_app("cannonsim")

    # Set up sampler
github UCL-CCS / EasyVVUQ / tests / test_vector.py View on Github external
"default": 10
        },
        "out_file": {
            "type": "string",
            "default": "output.csv"
        },
    }

    vary = {
        "mu": cp.Uniform(1.0, 100.0),
    }

    encoder = uq.encoders.GenericEncoder(template_fname='tests/gauss/gauss.template',
                                         target_filename='gauss_in.json')
   # decoder = JSONDecoder(target_filename='output.csv.json', output_columns=['numbers'])
    decoder = uq.decoders.SimpleCSV(target_filename="output.csv",
                                    output_columns=["numbers"],
                                    header=0)
    collater = uq.collate.AggregateSamples(average=False)
    actions = uq.actions.ExecuteLocal("tests/gauss/gauss_json.py gauss_in.json")
    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()
github UCL-CCS / EasyVVUQ / tests / test_db.py View on Github external
"min": 0.0,
            "max": 0.1,
            "default": 0.025},
        "t_env": {
            "type": "float",
            "min": 0.0,
            "max": 40.0,
            "default": 15.0},
        "out_file": {
            "type": "string",
            "default": "output.csv"}}),
        uq.encoders.GenericEncoder(
            template_fname='tests/cooling/cooling.template',
            delimiter='$',
            target_filename='cooling_in.json'),
        uq.decoders.SimpleCSV(
            target_filename='output.csv',
            output_columns=["te"],
            header=0),
        uq.collate.AggregateSamples(average=False))

    return app_info
github UCL-CCS / EasyVVUQ / tests / test_multiapp.py View on Github external
"mass": {
            "type": "float",
            "min": 0.0001,
            "max": 1000.0,
            "default": 1.0},
        "velocity": {
            "type": "float",
            "min": 0.0,
            "max": 1000.0,
            "default": 10.0}}

    encoder = uq.encoders.GenericEncoder(
        template_fname='tests/cannonsim/test_input/cannonsim.template',
        delimiter='#',
        target_filename='in.cannon')
    decoder = uq.decoders.SimpleCSV(
        target_filename='output.csv', output_columns=[
            'Dist', 'lastvx', 'lastvy'], header=0)
    collater = uq.collate.AggregateSamples(average=False)

    vary = {
        "gravity": cp.Uniform(9.8, 1.0),
        "mass": cp.Uniform(2.0, 10.0),
    }
    cannon_sampler = uq.sampling.RandomSampler(vary=vary, max_num=5)
    cannon_action = uq.actions.ExecuteLocal("tests/cannonsim/bin/cannonsim in.cannon output.csv")
    cannon_stats = uq.analysis.BasicStats(qoi_cols=['Dist', 'lastvx', 'lastvy'])

    return params, encoder, decoder, collater, cannon_sampler, cannon_action, cannon_stats
github UCL-CCS / EasyVVUQ / docs / tutorial_files / easyvvuq_restart_campaign_tutorial.py View on Github external
"max": 100000,
        "default": 10
    },
    "out_file": {
        "type": "string",
        "default": "output.csv"
    }
}

# 3. Wrap Application
#    - Define a new application (we'll call it 'gauss'), and the encoding/decoding elements it needs
#    - Also requires a collation element - his will be responsible for aggregating the results
encoder = uq.encoders.GenericEncoder(template_fname=template,
                                     target_filename=input_filename)

decoder = uq.decoders.SimpleCSV(
            target_filename=out_file,
            output_columns=['Step', 'Value'],
            header=0)

collater = uq.collate.AggregateSamples(average=True)

my_campaign.add_app(name="gauss",
                    params=params,
                    encoder=encoder,
                    decoder=decoder,
                    collater=collater
                    )

# 4. Specify Sampler
#    -  vary the `mu` parameter only
vary = {