def test_compare_different_jobs(): arguments = {"CALCULATE_KEYS": {"keys": [{"key": "WPR_DIFF_1"}]}} test_data_dir = os.path.join(TEST_DATA_DIR, "local", "snake_oil") shutil.copytree(test_data_dir, "test_data") os.chdir(os.path.join("test_data")) res_config = ResConfig("snake_oil.ert") ert = EnKFMain(res_config) facade = LibresFacade(ert) obs = ert.getObservations() obs_vector = obs["WPR_DIFF_1"] assert_obs_vector(obs_vector, 1.0) job = ert.getWorkflowList().getJob("STD_SCALE_CORRELATED_OBS") job.run(ert, ["WPR_DIFF_1"]) # Result of old job: assert_obs_vector(obs_vector, np.sqrt(4 / 2)) scaling_job.scaling_job(facade, arguments) # Result of new job with no sub-indexing: assert_obs_vector(obs_vector, np.sqrt(4 / 2))
def test_main_entry_point_block_and_summary_data_calc(): arguments = { "CALCULATE_KEYS": { "keys": [{ "key": "FOPT" }, { "key": "RFT3" }] } } test_data_dir = os.path.join(TEST_DATA_DIR, "Equinor", "config", "with_RFT") shutil.copytree(test_data_dir, "test_data") os.chdir(os.path.join("test_data")) res_config = ResConfig("config") ert = EnKFMain(res_config) facade = LibresFacade(ert) obs = ert.getObservations() obs_vector = obs["RFT3"] for index, node in enumerate(obs_vector): assert node.getStdScaling(index) == 1.0 scaling_job.scaling_job(facade, arguments) for index, node in enumerate(obs_vector): assert node.getStdScaling(index) == np.sqrt(64)
def test_main_entry_point_summary_data_update(): arguments = { "CALCULATE_KEYS": { "keys": [{ "key": "WWCT:OP_1" }, { "key": "WWCT:OP_2" }] }, "UPDATE_KEYS": { "keys": [{ "key": "WWCT:OP_2", "index": [1, 2, 3, 4, 5] }] }, } test_data_dir = os.path.join(TEST_DATA_DIR, "Equinor", "config", "obs_testing") shutil.copytree(test_data_dir, "test_data") os.chdir(os.path.join("test_data")) res_config = ResConfig("config") ert = EnKFMain(res_config) facade = LibresFacade(ert) obs = ert.getObservations() obs_vector = obs["WWCT:OP_2"] scaling_job.scaling_job(facade, arguments) for index, node in enumerate(obs_vector): if index in arguments["UPDATE_KEYS"]["keys"][0]["index"]: assert node.getStdScaling(index) == np.sqrt(61.0 * 2.0) else: assert node.getStdScaling(index) == 1.0 obs_vector = obs["WWCT:OP_1"] scaling_job.scaling_job(facade, arguments) for index, node in enumerate(obs_vector): assert node.getStdScaling(index) == 1.0
def test_main_entry_point_gen_data(): arguments = { "CALCULATE_KEYS": { "keys": [{ "key": "WPR_DIFF_1" }] }, "UPDATE_KEYS": { "keys": [{ "key": "WPR_DIFF_1", "index": [400, 800] }] }, } test_data_dir = os.path.join(TEST_DATA_DIR, "local", "snake_oil") shutil.copytree(test_data_dir, "test_data") os.chdir(os.path.join("test_data")) res_config = ResConfig("snake_oil.ert") ert = EnKFMain(res_config) facade = LibresFacade(ert) scaling_job.scaling_job(facade, arguments) obs = ert.getObservations() obs_vector = obs["WPR_DIFF_1"] assert_obs_vector(obs_vector, 1.0, [0, 1], np.sqrt(4 / 2)) arguments["CALCULATE_KEYS"]["keys"][0].update({"index": [400, 800, 1200]}) scaling_job.scaling_job(facade, arguments) assert_obs_vector( obs_vector, 1.0, [0, 1], np.sqrt(3.0 / 2.0), )
def test_main_entry_point_summary_data_calc(): arguments = { "CALCULATE_KEYS": { "keys": [{ "key": "WOPR_OP1_108" }, { "key": "WOPR_OP1_144" }] } } test_data_dir = os.path.join(TEST_DATA_DIR, "local", "snake_oil") shutil.copytree(test_data_dir, "test_data") os.chdir(os.path.join("test_data")) res_config = ResConfig("snake_oil.ert") ert = EnKFMain(res_config) facade = LibresFacade(ert) obs = ert.getObservations() obs_vector = obs["WOPR_OP1_108"] for index, node in enumerate(obs_vector): assert node.getStdScaling(index) == 1.0 scaling_job.scaling_job(facade, arguments) for index, node in enumerate(obs_vector): assert node.getStdScaling(index) == np.sqrt((2.0 * 6.0) / 2.0) arguments["CALCULATE_KEYS"]["keys"][0].update({"index": [1, 2, 3]}) arguments["CALCULATE_KEYS"]["keys"][1].update({"index": [1, 2, 3]}) with pytest.raises(ValueError): # Will give an empty data set scaling_job.scaling_job(facade, arguments) arguments["CALCULATE_KEYS"]["keys"][0].update({"index": [8, 35, 71]}) arguments["CALCULATE_KEYS"]["keys"][1].update({"index": [8, 35, 71]}) scaling_job.scaling_job(facade, arguments) for index, node in enumerate(obs_vector): if index in arguments["CALCULATE_KEYS"]["keys"][0]["index"]: assert node.getStdScaling(index) == np.sqrt((2.0 * 6.0) / 1.0) else: assert node.getStdScaling(index) == np.sqrt((2.0 * 6.0) / 2.0)
def run(self, job_config_file): facade = LibresFacade(self.ert()) user_config = load_yaml(job_config_file) user_config = _insert_default_group(user_config) for job_config in user_config: scaling_job(facade, job_config)
def _run_scaling(facade, job_configs): for job in job_configs: scaling_job(facade, job)