Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
kvashchuka committed Oct 13, 2023
1 parent b3b51f1 commit ae8953b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
22 changes: 22 additions & 0 deletions test-data/poly_example/poly_loc_1.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 1.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
19 changes: 19 additions & 0 deletions test-data/poly_example/poly_no_loc.ert
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
JOBNAME poly_%d

RANDOM_SEED 1234

QUEUE_SYSTEM LOCAL
QUEUE_OPTION LOCAL MAX_RUNNING 50

RUNPATH runpath/es_no_loc/realization-<IENS>/iter-<ITER>

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
14 changes: 7 additions & 7 deletions tests/unit_tests/analysis/test_adaptive_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def test_that_adaptive_localization_with_cutoff_1_equals_ensemble_prior(copy_cas
lines.insert(2, random_seed_line)
lines.insert(9, set_adaptive_localization_1)

with open("poly_loc_1.ert", "w") as f:
with open("poly_localization_1.ert", "w") as f:
f.writelines(lines)
prior_sample, posterior_sample = run_cli_ES_with_case("poly_loc_1.ert")
prior_sample, posterior_sample = run_cli_ES_with_case("poly_localization_1.ert")

# Check prior and posterior samples are equal
assert np.allclose(posterior_sample, prior_sample)
Expand All @@ -68,7 +68,7 @@ def test_that_adaptive_localization_with_cutoff_1_equals_ensemble_prior(copy_cas
@pytest.mark.integration_test
def test_that_adaptive_localization_with_cutoff_0_equals_ESupdate(copy_case):
"""
Note that "RANDOM_SEED" in poly_loc_0.ert and poly_no_loc.ert needs to be the same to obtain
Note that "RANDOM_SEED" in both ert configs needs to be the same to obtain
the same sample from the prior.
"""
copy_case("poly_example")
Expand All @@ -85,16 +85,16 @@ def test_that_adaptive_localization_with_cutoff_0_equals_ESupdate(copy_case):
lines = f.readlines()
lines.insert(2, random_seed_line)

with open("poly_no_loc.ert", "w") as f:
with open("poly_no_localization.ert", "w") as f:
f.writelines(lines)

lines.insert(9, set_adaptive_localization_0)

with open("poly_loc_0.ert", "w") as f:
with open("poly_localization_0.ert", "w") as f:
f.writelines(lines)

prior_sample_loc0, posterior_sample_loc0 = run_cli_ES_with_case("poly_loc_0.ert")
prior_sample_noloc, posterior_sample_noloc = run_cli_ES_with_case("poly_no_loc.ert")
prior_sample_loc0, posterior_sample_loc0 = run_cli_ES_with_case("poly_localization_0.ert")
prior_sample_noloc, posterior_sample_noloc = run_cli_ES_with_case("poly_no_localization.ert")

# Check posterior sample without adaptive localization and with cut-off 0 are equal
assert np.allclose(posterior_sample_loc0, posterior_sample_noloc)

0 comments on commit ae8953b

Please sign in to comment.