def test_snapshot_alpha(setup_case, alpha, expected): """ Note that this is now a snapshot test, so there is no guarantee that the snapshots are correct, they are just documenting the current behavior. """ res_config = setup_case("local/snake_oil", "snake_oil.ert") obs_file = Path("observations") / "observations.txt" with obs_file.open(mode="w") as fin: fin.write( """ SUMMARY_OBSERVATION LOW_STD { VALUE = 10; ERROR = 0.1; DATE = 2015-06-23; KEY = FOPR; }; SUMMARY_OBSERVATION HIGH_STD { VALUE = 10; ERROR = 1.0; DATE = 2015-06-23; KEY = FOPR; }; SUMMARY_OBSERVATION EXTREMELY_HIGH_STD { VALUE = 10; ERROR = 10.0; DATE = 2015-06-23; KEY = FOPR; }; """ ) ert = EnKFMain(res_config) es_update = ESUpdate(ert) ert.analysisConfig().selectModule("IES_ENKF") fsm = ert.getEnkfFsManager() sim_fs = fsm.getFileSystem("default_0") target_fs = fsm.getFileSystem("target") run_context = ErtRunContext.ensemble_smoother_update(sim_fs, target_fs) ert.analysisConfig().setEnkfAlpha(alpha) es_update.smootherUpdate(run_context) result_snapshot = ert.update_snapshots[run_context.get_id()] assert result_snapshot.alpha == alpha assert result_snapshot.ministep_snapshots["ALL_ACTIVE"].obs_status == expected
def test_update(setup_case, module, expected_gen_kw): """ Note that this is now a snapshot test, so there is no guarantee that the snapshots are correct, they are just documenting the current behavior. """ res_config = setup_case("local/snake_oil", "snake_oil.ert") ert = EnKFMain(res_config) es_update = ESUpdate(ert) ert.analysisConfig().selectModule(module) fsm = ert.getEnkfFsManager() sim_fs = fsm.getFileSystem("default_0") target_fs = fsm.getFileSystem("target") run_context = ErtRunContext.ensemble_smoother_update(sim_fs, target_fs) es_update.smootherUpdate(run_context) conf = ert.ensembleConfig()["SNAKE_OIL_PARAM"] sim_node = EnkfNode(conf) target_node = EnkfNode(conf) node_id = NodeId(0, 0) sim_node.load(sim_fs, node_id) target_node.load(target_fs, node_id) sim_gen_kw = list(sim_node.asGenKw()) target_gen_kw = list(target_node.asGenKw()) assert sim_gen_kw != target_gen_kw assert sim_gen_kw == pytest.approx( [ -1.3035319087841115, 0.8222709205428339, -1.1400029486153482, 0.7477534046493867, -0.10400064074767973, -1.7223242794585338, 0.0761604027734105, 0.4039137216428462, 0.10001691562080614, 0.09549338450036506, ] ) assert target_gen_kw == pytest.approx(expected_gen_kw)
def test_update_report(setup_case, snapshot): """ Note that this is now a snapshot test, so there is no guarantee that the snapshots are correct, they are just documenting the current behavior. """ res_config = setup_case("local/snake_oil", "snake_oil.ert") ert = EnKFMain(res_config) es_update = ESUpdate(ert) fsm = ert.getEnkfFsManager() sim_fs = fsm.getFileSystem("default_0") target_fs = fsm.getFileSystem("target") run_context = ErtRunContext.ensemble_smoother_update(sim_fs, target_fs) es_update.smootherUpdate(run_context) log_file = Path(ert.analysisConfig().get_log_path()) / "deprecated" snapshot.assert_match(log_file.read_text("utf-8"), "update_log")
def test_ecl_config_creation(self): with TestAreaContext("enkf_library_test") as work_area: work_area.copy_directory(self.case_directory) res_config = ResConfig("simple_config/minimum_config") main = EnKFMain(res_config) self.assertIsInstance(main.analysisConfig(), AnalysisConfig) self.assertIsInstance(main.eclConfig(), EclConfig) with self.assertRaises(AssertionError): # Null pointer! self.assertIsInstance(main.eclConfig().getRefcase(), EclSum) file_system = main.getEnkfFsManager().getCurrentFileSystem() self.assertEqual(file_system.getCaseName(), "default") time_map = file_system.getTimeMap() self.assertIsInstance(time_map, TimeMap)