From 8479f505e40fec8bbdc270e7417ba06727f699ed Mon Sep 17 00:00:00 2001 From: "Oddvar Lia (ST MSU GEO)" Date: Tue, 1 Oct 2024 14:24:15 +0200 Subject: [PATCH 1/4] Fixed input file paths in template for rms script to be generated --- src/subscript/field_statistics/field_statistics.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/subscript/field_statistics/field_statistics.py b/src/subscript/field_statistics/field_statistics.py index 1d4952517..1025d54e2 100644 --- a/src/subscript/field_statistics/field_statistics.py +++ b/src/subscript/field_statistics/field_statistics.py @@ -952,11 +952,11 @@ def generate_script( ERT_CONFIG_PATH = "{ert_config_path}" GLOBAL_VARIABLES_FILE = \ - ERT_CONFIG_PATH / Path("../../fmuconfig/output/global_variables.yml") + Path(ERT_CONFIG_PATH) / Path("../../fmuconfig/output/global_variables.yml") -FIELD_STAT_CONFIG_FILE = "{field_stat_config_file}" +FIELD_STAT_CONFIG_FILE = Path(ERT_CONFIG_PATH) / Path("{field_stat_config_file}") -RESULT_PATH = "{result_path}" +RESULT_PATH = Path("{result_path}") LABEL = "drogon" From 260ce1dbd13376ddc79efc37f1c904d81070f1b7 Mon Sep 17 00:00:00 2001 From: "Oddvar Lia (ST MSU GEO)" Date: Wed, 2 Oct 2024 08:42:37 +0200 Subject: [PATCH 2/4] Modified input to subprocess by calling field_statistics.py --- tests/test_field_statistics.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/test_field_statistics.py b/tests/test_field_statistics.py index d073b2fae..ca825c327 100644 --- a/tests/test_field_statistics.py +++ b/tests/test_field_statistics.py @@ -881,7 +881,6 @@ def test_get_specification( ) def test_main(tmp_path, config_file, config_dict, print_info=True): import subprocess - import sys # First make an ensemble to be used as testdata. This is based on the config_dict _, ens_path, result_path, ert_config_path, _ = make_test_case(tmp_path, config_dict) @@ -892,18 +891,15 @@ def test_main(tmp_path, config_file, config_dict, print_info=True): result_path = ens_path / RESULT_PATH rms_load_script = result_path / RMS_LOAD_SCRIPT_NAME - # Run the main script as a subprocess - script_name = Path(__file__).absolute().parent.parent / Path( - "src/subscript/field_statistics/field_statistics.py" - ) - if print_info: - print(f"\nRun script: {script_name}") + + # Run the main script as a subprocess,but first clean up + # result directory to be sure this test does not re-use + # previous results from previous tests remove_file_path = result_path / Path("ertbox--*.roff") subprocess.run(["rm", "-f", remove_file_path]) subprocess.run( [ - sys.executable, - script_name.as_posix(), + "field_statistics", "-c", config_path.as_posix(), "-p", From 1b0c82b729ca15aa1c57b026ce0459740cd2ad40 Mon Sep 17 00:00:00 2001 From: "Oddvar Lia (ST MSU GEO)" Date: Wed, 2 Oct 2024 09:02:34 +0200 Subject: [PATCH 3/4] Removed unnecessary code --- tests/test_field_statistics.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test_field_statistics.py b/tests/test_field_statistics.py index ca825c327..91a14d181 100644 --- a/tests/test_field_statistics.py +++ b/tests/test_field_statistics.py @@ -892,11 +892,7 @@ def test_main(tmp_path, config_file, config_dict, print_info=True): rms_load_script = result_path / RMS_LOAD_SCRIPT_NAME - # Run the main script as a subprocess,but first clean up - # result directory to be sure this test does not re-use - # previous results from previous tests - remove_file_path = result_path / Path("ertbox--*.roff") - subprocess.run(["rm", "-f", remove_file_path]) + # Run the main script as a subprocess subprocess.run( [ "field_statistics", From 6f44cfca56af58d53068f4004f278934bad98be0 Mon Sep 17 00:00:00 2001 From: "Oddvar Lia (ST MSU GEO)" Date: Wed, 2 Oct 2024 09:40:46 +0200 Subject: [PATCH 4/4] Updated template for rms script generated by field_statistics.py --- src/subscript/field_statistics/field_statistics.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/subscript/field_statistics/field_statistics.py b/src/subscript/field_statistics/field_statistics.py index 1025d54e2..5b6bfa324 100644 --- a/src/subscript/field_statistics/field_statistics.py +++ b/src/subscript/field_statistics/field_statistics.py @@ -981,7 +981,10 @@ def main(): zone_code_names = field_stat["zone_code_names"] facies_per_zone = get_facies_per_zone(GLOBAL_VARIABLES_FILE) result_path = RESULT_PATH - zone_list= list(zone_code_names.values()) + if "use_zones" in field_stat: + zone_list= field_stat["use_zones"] + else: + zone_list= list(zone_code_names.values()) stat_list= ["mean", "stdev"] iter_list = field_stat["iterations"]