示例#1
0
def _create_runpath(ert: LibresFacade, iteration: int = 0) -> ErtRunContext:
    """
    Instantiate an ERT runpath. This will create the parameter coefficients.
    """
    enkf_main = ert._enkf_main
    result_fs = ert.get_current_fs()
    target_fs = ert._enkf_main.getEnkfFsManager().getFileSystem("iter")

    model_config = enkf_main.getModelConfig()
    runpath_fmt = model_config.getRunpathFormat()
    jobname_fmt = model_config.getJobnameFormat()
    subst_list = enkf_main.getDataKW()

    run_context = ErtRunContext.ensemble_smoother(
        result_fs,
        target_fs,
        BoolVector(default_value=True, initial_size=ert.get_ensemble_size()),
        runpath_fmt,
        jobname_fmt,
        subst_list,
        iteration,
    )

    enkf_main.getEnkfSimulationRunner().createRunPath(run_context)
    return run_context
示例#2
0
文件: cos.py 项目: kvashchuka/semeio
    def run(self, job_config):
        facade = LibresFacade(self.ert())
        user_config = load_yaml(job_config)
        user_config = _insert_default_group(user_config)

        obs = facade.get_observations()
        obs_keys = [facade.get_observation_key(nr) for nr, _ in enumerate(obs)]
        obs_with_data = keys_with_data(
            obs,
            obs_keys,
            facade.get_ensemble_size(),
            facade.get_current_fs(),
        )
        default_values = _get_default_values(
            facade.get_alpha(), facade.get_std_cutoff()
        )
        for config_dict in user_config:
            config = ObsCorrConfig(config_dict, obs_keys, default_values)
            config.validate(obs_with_data)

            measured_data = _get_measured_data(
                facade,
                config.get_calculation_keys(),
                config.get_index_lists(),
                config.get_alpha(),
                config.get_std_cutoff(),
            )
            job = ObservationScaleFactor(self.reporter, measured_data)
            scale_factor = job.get_scaling_factor(config.get_threshold())
            logging.info(
                "Scaling factor calculated from keys: {}".format(
                    config.get_calculation_keys()
                )
            )
            scale_observations(obs, scale_factor, config.get_update_keys())
示例#3
0
def test_load_inconsistent_time_map_summary(copy_data, caplog):
    """
    Checking that we dont util_abort, we fail the forward model instead
    """
    cwd = os.getcwd()

    # Get rid of GEN_DATA as we are only interested in SUMMARY
    with fileinput.input("snake_oil.ert", inplace=True) as fin:
        for line in fin:
            if line.startswith("GEN_DATA"):
                continue
            print(line, end="")

    res_config = ResConfig("snake_oil.ert")
    ert = EnKFMain(res_config)
    facade = LibresFacade(ert)
    realisation_number = 0
    assert (facade.get_current_fs().getStateMap()[realisation_number].name ==
            "STATE_HAS_DATA")  # Check prior state

    # Create a result that is incompatible with the refcase
    run_path = Path(
        "storage") / "snake_oil" / "runpath" / "realization-0" / "iter-0"
    os.chdir(run_path)
    ecl_sum = run_simulator(1, datetime(2000, 1, 1))
    ecl_sum.fwrite()
    os.chdir(cwd)

    realizations = BoolVector(default_value=False,
                              initial_size=facade.get_ensemble_size())
    realizations[realisation_number] = True
    with caplog.at_level(logging.ERROR):
        loaded = facade.load_from_forward_model("default_0", realizations, 0)
    assert (
        f"""Inconsistency in time_map - loading SUMMARY from: {run_path.absolute()} failed:
Time mismatch for step: 1, new time: 2000-01-10, reference case: 2010-01-10
""" in caplog.messages)
    assert (
        f"Inconsistent time map for summary data from: {run_path.absolute()}"
        f"/SNAKE_OIL_FIELD, realisation failed" in caplog.messages)
    assert loaded == 0
    assert (facade.get_current_fs().getStateMap()[realisation_number].name ==
            "STATE_LOAD_FAILURE")  # Check that status is as expected
    def run(self, job_config):
        facade = LibresFacade(self.ert())
        user_config = load_yaml(job_config)
        user_config = _insert_default_group(user_config)

        obs = facade.get_observations()
        obs_keys = [facade.get_observation_key(nr) for nr, _ in enumerate(obs)]
        obs_with_data = keys_with_data(
            obs,
            obs_keys,
            facade.get_ensemble_size(),
            facade.get_current_fs(),
        )

        for config in user_config:
            job = ScalingJob(obs_keys, obs, obs_with_data, config)
            measured_data = MeasuredData(facade, job.get_calc_keys(),
                                         job.get_index_lists())
            job.scale(measured_data)
示例#5
0
def test_load_forward_model(copy_data):
    """
    Checking that we are able to load from forward model
    """
    # Get rid of GEN_DATA it causes a failure to load from forward model
    with fileinput.input("snake_oil.ert", inplace=True) as fin:
        for line in fin:
            if line.startswith("GEN_DATA"):
                continue
            print(line, end="")

    res_config = ResConfig("snake_oil.ert")
    ert = EnKFMain(res_config)
    facade = LibresFacade(ert)
    realisation_number = 0

    realizations = BoolVector(default_value=False,
                              initial_size=facade.get_ensemble_size())
    realizations[realisation_number] = True
    loaded = facade.load_from_forward_model("default_0", realizations, 0)
    assert loaded == 1
    assert (facade.get_current_fs().getStateMap()[realisation_number].name ==
            "STATE_HAS_DATA")  # Check that status is as expected