From 40a21e0546d65722534387bfadb2bcb4a17d010a Mon Sep 17 00:00:00 2001 From: Anna Kvashchuk Date: Tue, 10 Oct 2023 15:53:51 +0200 Subject: [PATCH] Add test for cut-off 0 --- test-data/poly_example/poly_loc_0.ert | 22 ++++++++ .../analysis/test_adaptive_localization.py | 53 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test-data/poly_example/poly_loc_0.ert diff --git a/test-data/poly_example/poly_loc_0.ert b/test-data/poly_example/poly_loc_0.ert new file mode 100644 index 00000000000..f668f1698a5 --- /dev/null +++ b/test-data/poly_example/poly_loc_0.ert @@ -0,0 +1,22 @@ +JOBNAME poly_%d + +RANDOM_SEED 1234 + +QUEUE_SYSTEM LOCAL +QUEUE_OPTION LOCAL MAX_RUNNING 50 + +RUNPATH runpath/es_loc_1/realization-/iter- + +ANALYSIS_SET_VAR STD_ENKF LOCALIZATION True +ANALYSIS_SET_VAR STD_ENKF LOCALIZATION_CORRELATION_THRESHOLD 0.0 + +OBS_CONFIG observations + +NUM_REALIZATIONS 100 +MIN_REALIZATIONS 1 + +GEN_KW COEFFS coeff.tmpl coeffs.json coeff_priors +GEN_DATA POLY_RES RESULT_FILE:poly.out + +INSTALL_JOB poly_eval POLY_EVAL +SIMULATION_JOB poly_eval diff --git a/tests/unit_tests/analysis/test_adaptive_localization.py b/tests/unit_tests/analysis/test_adaptive_localization.py index 212d05b31f1..d5d9f2c804a 100644 --- a/tests/unit_tests/analysis/test_adaptive_localization.py +++ b/tests/unit_tests/analysis/test_adaptive_localization.py @@ -43,3 +43,56 @@ def test_that_adaptive_localization_with_cutoff_1_equals_ensemble_prior(copy_cas ) +def test_that_adaptive_localization_with_cutoff_0_equals_ESupdate(copy_case): + copy_case("poly_example") + + parser = ArgumentParser(prog="test_main_0") + parsed_loc0 = ert_parser( + parser, + [ + ENSEMBLE_SMOOTHER_MODE, + "--current-case", + "default_loc0", + "--target-case", + "target_loc0", + "--realizations", + "1-50", + "poly_loc_0.ert", + "--port-range", + "1024-65535", + ], + ) + + run_cli(parsed_loc0) + facade_loc0 = LibresFacade.from_config_file("poly_loc_0.ert") + with open_storage(facade_loc0.enspath) as storage_loc0: + target_fs_loc0 = storage_loc0.get_ensemble_by_name("target_loc0") + posterior_loc0 = facade_loc0.load_all_gen_kw_data(target_fs_loc0) + + parser_noloc = ArgumentParser(prog="test_main") + parsed_noloc = ert_parser( + parser_noloc, + [ + ENSEMBLE_SMOOTHER_MODE, + "--current-case", + "default_noloc", + "--target-case", + "target_noloc", + "--realizations", + "1-50", + "poly_no_loc.ert", + "--port-range", + "1024-65535", + ], + ) + + run_cli(parsed_noloc) + facade_noloc = LibresFacade.from_config_file("poly.ert") + with open_storage(facade_noloc.enspath) as storage_noloc: + target_fs_noloc = storage_noloc.get_ensemble_by_name("target_noloc") + posterior_noloc = facade_noloc.load_all_gen_kw_data(target_fs_noloc) + + # We expect that when cut-off is 0, the posterior is equal to ES + assert ( + np.linalg.det(posterior_loc0.cov().to_numpy()) == np.linalg.det(posterior_noloc.cov().to_numpy()) + )