Esempio n. 1
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
Esempio n. 2
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