Skip to content

Commit 83f54d3

Browse files
committed
Update after review of field_statistics.py
1 parent ff6d2f3 commit 83f54d3

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

src/subscript/field_statistics/field_statistics.py

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@
270270
EXAMPLES = """Add a file named e.g. ``ert/bin/workflows/wf_field_statistics`` with the contents::
271271
272272
DEFINE <FIELD_STAT_CONFIG_FILE> ../input/config/field_param_stat.yml
273-
DEFINE <RELATIVE_RESULT_PATH> share/grid_statistics
274273
DEFINE <ENSEMBLE_PATH> <SCRATCH>/<USER>/<CASE_DIR>
275-
DEFINE <LOAD_RESULT_SCRIPT> <SCRATCH>/<USER>/<CASE_DIR>/<RELATIVE_RESULT_PATH>/tmp_import_field_stat.py
276-
FIELD_STATISTICS -c <FIELD_STAT_CONFIG_FILE>
277-
-e <ENSEMBLE_PATH>
278-
-p <CONFIG_PATH>
279-
-r <RELATIVE_RESULT_PATH>
280-
-z <LOAD_RESULT_SCRIPT>
274+
DEFINE <RESULT_FIELD_STAT_PATH> <ENSEMBLE_PATH>/share/grid_statistics
275+
DEFINE <LOAD_TO_RMS_SCRIPT> <RESULT_FIELD_STAT_PATH>/tmp_import_field_stat_into_rms.py
276+
MAKE_DIRECTORY <RESULT_FIELD_STAT_PATH>
277+
FIELD_STATISTICS -c <FIELD_STAT_CONFIG_FILE>
278+
-p <CONFIG_PATH>
279+
-e <ENSEMBLE_PATH>
280+
-z <LOAD_TO_RMS_SCRIPT>
281281
-g
282282
283283
where the config file for FIELD_STATISTICS in this example is located under::
@@ -360,12 +360,7 @@ def field_stat(args):
360360
relative_result_path = Path(args.resultpath)
361361
result_path = ens_path / relative_result_path
362362
if not result_path.exists():
363-
# Create the directory
364-
logger.info(
365-
"Create directory for results for field parameter statistics: "
366-
f"{result_path}"
367-
)
368-
result_path.mkdir()
363+
raise IOError(f"Result directory: {result_path} does not exist.")
369364

370365
rms_load_script = None
371366
if args.generate_rms_load_script:
@@ -1010,13 +1005,13 @@ def get_specifications(input_dict, ertbox_size, ert_config_path):
10101005

10111006
if not ertbox_size:
10121007
# ertbox size does not exist, read it from this scripts config file instead
1013-
print("ERTBOX size is not defined, need to get it from the config file")
1008+
logger.info("ERTBOX size is not defined, need to get it from the config file.")
10141009
key = "ertbox_size"
10151010
if key in input_dict["geogrid_fields"]:
10161011
ertbox_size = input_dict["geogrid_fields"][key]
10171012
else:
10181013
raise KeyError(
1019-
"Missing keyword 'ertbox_size'."
1014+
f"Missing keyword '{key}'."
10201015
"Is required if the ERTBOX.EGRID is not found in the "
10211016
"configuration directory of the FMU project under: "
10221017
f" {ert_config_path / Path('../../rms/output/aps/ERTBOX.EGRID')}"
@@ -1034,10 +1029,9 @@ def get_specifications(input_dict, ertbox_size, ert_config_path):
10341029
zone_code_names = None
10351030
param_name_dict = None
10361031
disc_param_name_dict = None
1037-
key = "geogrid_fields"
1038-
if key in input_dict:
1032+
if "geogrid_fields" in input_dict:
10391033
use_geogrid_fields = True
1040-
geogrid_fields_dict = input_dict[key]
1034+
geogrid_fields_dict = input_dict["geogrid_fields"]
10411035

10421036
key = "zone_code_names"
10431037
if key in geogrid_fields_dict:
@@ -1078,10 +1072,9 @@ def get_specifications(input_dict, ertbox_size, ert_config_path):
10781072
temporary_ertbox_field = None
10791073
init_path = None
10801074
param_list = None
1081-
key = "temporary_ertbox_fields"
1082-
if key in input_dict:
1075+
if "temporary_ertbox_fields" in input_dict:
10831076
use_temporary_fields = True
1084-
temporary_ertbox_field = input_dict[key]
1077+
temporary_ertbox_field = input_dict["temporary_ertbox_fields"]
10851078

10861079
key = "initial_relative_path"
10871080
if key in temporary_ertbox_field:
@@ -1409,22 +1402,17 @@ def calc_stats(
14091402
sum_total_active = np.ma.sum(sum_active) / nreal
14101403
sum_total_code = np.ma.sum(number_of_cells) / nreal
14111404
fraction = sum_total_code / sum_total_active
1412-
txt1 = (
1405+
logger.info(
14131406
f" Average number of active cells: {sum_total_active}"
14141407
)
1415-
logger.info(txt1)
1416-
1417-
txt2 = (
1408+
logger.info(
14181409
f" Average number of cells with facies "
14191410
f"{facies_name} is {sum_total_code}"
14201411
)
1421-
logger.info(txt2)
1422-
1423-
txt3 = (
1412+
logger.info(
14241413
" Average estimated facies probability for facies "
14251414
f"{facies_name}: {fraction}"
14261415
)
1427-
logger.info(txt3)
14281416

14291417
sum_fraction += fraction
14301418

0 commit comments

Comments
 (0)