Example #1
0
def _load_ensemble_parameters(ensemble, workspace):
    parameters = _utils.load_parameters(workspace)

    ensemble_parameters = {}
    for input_record in ensemble.input:
        record_name = input_record.record
        record_source = input_record.source.split(".")
        assert len(record_source) == 2
        assert record_source[0] == "stochastic"
        parameter_group_name = record_source[1]
        ensemble_parameters[parameter_group_name] = parameters[parameter_group_name]
    return ensemble_parameters
Example #2
0
def sample_record(workspace, parameter_group_name, record_name, ensemble_size):
    parameters = _utils.load_parameters(workspace)

    if parameter_group_name not in parameters:
        raise ValueError(
            f"No parameter group found named: {parameter_group_name}")
    distribution = parameters[parameter_group_name]

    ert3.storage.add_variables(
        workspace,
        record_name,
        [distribution.sample() for _ in range(ensemble_size)],
    )
Example #3
0
def _load_ensemble_parameters(
    ensemble: ert3.config.EnsembleConfig,
    workspace: pathlib.Path,
) -> Mapping[str, ert3.stats.Distribution]:
    parameters = _utils.load_parameters(workspace)

    ensemble_parameters = {}
    for input_record in ensemble.input:
        record_name = input_record.record
        record_source = input_record.source.split(".")
        assert len(record_source) == 2
        assert record_source[0] == "stochastic"
        parameter_group_name = record_source[1]
        ensemble_parameters[record_name] = parameters[parameter_group_name]
    return ensemble_parameters
Example #4
0
def sample_record(
    workspace: Path,
    parameter_group_name: str,
    record_name: str,
    ensemble_size: int,
    experiment_name: Optional[str] = None,
) -> None:
    parameters = _utils.load_parameters(workspace)

    if parameter_group_name not in parameters:
        raise ValueError(f"No parameter group found named: {parameter_group_name}")
    distribution = parameters[parameter_group_name]

    ensrecord = ert3.data.EnsembleRecord(
        records=[distribution.sample() for _ in range(ensemble_size)]
    )
    ert3.storage.add_ensemble_record(
        workspace=workspace,
        record_name=record_name,
        ensemble_record=ensrecord,
        experiment_name=experiment_name,
    )