From 83f54d368fba03cc9e8d9e5f7f39759d21fd330f Mon Sep 17 00:00:00 2001 From: "Oddvar Lia (ST MSU GEO)" Date: Tue, 29 Oct 2024 10:23:18 +0100 Subject: [PATCH] Update after review of field_statistics.py --- .../field_statistics/field_statistics.py | 46 +++++++------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/src/subscript/field_statistics/field_statistics.py b/src/subscript/field_statistics/field_statistics.py index 2ee89f918..dba9063ec 100644 --- a/src/subscript/field_statistics/field_statistics.py +++ b/src/subscript/field_statistics/field_statistics.py @@ -270,14 +270,14 @@ EXAMPLES = """Add a file named e.g. ``ert/bin/workflows/wf_field_statistics`` with the contents:: DEFINE ../input/config/field_param_stat.yml - DEFINE share/grid_statistics DEFINE // - DEFINE ////tmp_import_field_stat.py - FIELD_STATISTICS -c - -e - -p - -r - -z + DEFINE /share/grid_statistics + DEFINE /tmp_import_field_stat_into_rms.py + MAKE_DIRECTORY + FIELD_STATISTICS -c + -p + -e + -z -g where the config file for FIELD_STATISTICS in this example is located under:: @@ -360,12 +360,7 @@ def field_stat(args): relative_result_path = Path(args.resultpath) result_path = ens_path / relative_result_path if not result_path.exists(): - # Create the directory - logger.info( - "Create directory for results for field parameter statistics: " - f"{result_path}" - ) - result_path.mkdir() + raise IOError(f"Result directory: {result_path} does not exist.") rms_load_script = None if args.generate_rms_load_script: @@ -1010,13 +1005,13 @@ def get_specifications(input_dict, ertbox_size, ert_config_path): if not ertbox_size: # ertbox size does not exist, read it from this scripts config file instead - print("ERTBOX size is not defined, need to get it from the config file") + logger.info("ERTBOX size is not defined, need to get it from the config file.") key = "ertbox_size" if key in input_dict["geogrid_fields"]: ertbox_size = input_dict["geogrid_fields"][key] else: raise KeyError( - "Missing keyword 'ertbox_size'." + f"Missing keyword '{key}'." "Is required if the ERTBOX.EGRID is not found in the " "configuration directory of the FMU project under: " f" {ert_config_path / Path('../../rms/output/aps/ERTBOX.EGRID')}" @@ -1034,10 +1029,9 @@ def get_specifications(input_dict, ertbox_size, ert_config_path): zone_code_names = None param_name_dict = None disc_param_name_dict = None - key = "geogrid_fields" - if key in input_dict: + if "geogrid_fields" in input_dict: use_geogrid_fields = True - geogrid_fields_dict = input_dict[key] + geogrid_fields_dict = input_dict["geogrid_fields"] key = "zone_code_names" if key in geogrid_fields_dict: @@ -1078,10 +1072,9 @@ def get_specifications(input_dict, ertbox_size, ert_config_path): temporary_ertbox_field = None init_path = None param_list = None - key = "temporary_ertbox_fields" - if key in input_dict: + if "temporary_ertbox_fields" in input_dict: use_temporary_fields = True - temporary_ertbox_field = input_dict[key] + temporary_ertbox_field = input_dict["temporary_ertbox_fields"] key = "initial_relative_path" if key in temporary_ertbox_field: @@ -1409,22 +1402,17 @@ def calc_stats( sum_total_active = np.ma.sum(sum_active) / nreal sum_total_code = np.ma.sum(number_of_cells) / nreal fraction = sum_total_code / sum_total_active - txt1 = ( + logger.info( f" Average number of active cells: {sum_total_active}" ) - logger.info(txt1) - - txt2 = ( + logger.info( f" Average number of cells with facies " f"{facies_name} is {sum_total_code}" ) - logger.info(txt2) - - txt3 = ( + logger.info( " Average estimated facies probability for facies " f"{facies_name}: {fraction}" ) - logger.info(txt3) sum_fraction += fraction