Skip to content

Commit

Permalink
Add test for cut-off 0
Browse files Browse the repository at this point in the history
  • Loading branch information
kvashchuka committed Oct 10, 2023
1 parent a8da6d3 commit 40a21e0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test-data/poly_example/poly_loc_0.ert
Original file line number Diff line number Diff line change
@@ -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-<IENS>/iter-<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
53 changes: 53 additions & 0 deletions tests/unit_tests/analysis/test_adaptive_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
)

0 comments on commit 40a21e0

Please sign in to comment.