Update field_statistics to use individual ertbox per zone#858
Conversation
8777229 to
0512285
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #858 +/- ##
==========================================
- Coverage 84.51% 84.27% -0.25%
==========================================
Files 49 49
Lines 7349 7472 +123
==========================================
+ Hits 6211 6297 +86
- Misses 1138 1175 +37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
c7630cf to
335b994
Compare
4d70873 to
c2443be
Compare
Some model file changes from previous version was required Documentation is updated.
c2443be to
a7fdb52
Compare
alifbe
left a comment
There was a problem hiding this comment.
Not quite sure if the files in ensemble/share/grid_statistics/ are all needed.
In general, we should avoid code repetitions.
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
[nitpick] These extra empty lines are not needed.
| "Valysar": "ertbox_Valysar" | ||
| "Therys": "ertbox_Therys" | ||
| "Volon": "ertbox_Volon" |
There was a problem hiding this comment.
Propose to keep all to lower case.
| "Valysar": "ertbox_Valysar" | |
| "Therys": "ertbox_Therys" | |
| "Volon": "ertbox_Volon" | |
| "Valysar": "ertbox_valysar" | |
| "Therys": "ertbox_therys" | |
| "Volon": "ertbox_volon" |
| # Relative path relative to ERT <RUN_PATH> for localisation of | ||
| # initial ensemble of field parameters | ||
| initial_relative_path: "rms/output/aps" | ||
| initial_field_relative_path: "rms/output/aps" |
There was a problem hiding this comment.
Is this necessary? This will break backward compatibility and personally I think previous naming is ok since it is under temporary_ertbox_fields.
| DEFAULT_RELATIVE_RESULT_PATH = "share/grid_statistics" | ||
| GLOBAL_VARIABLES_FILE = "../../fmuconfig/output/global_variables.yml" | ||
| ERTBOX_GRID_PATH = "../../rms/output/aps/ERTBOX.EGRID" | ||
| # ERTBOX_GRID_PATH = "../../rms/output/aps" |
There was a problem hiding this comment.
Please remove it if it's not relevant anymore
| def get_ertbox_size_per_zone( | ||
| field_stat_dict: dict, | ||
| ert_config_path: str | Path, | ||
| ): |
There was a problem hiding this comment.
It will be nice to specify output type as well here.
| ( | ||
| _use_geogrid_fields, | ||
| _use_temporary_fields, | ||
| _nreal, | ||
| _iter_list, | ||
| _use_population_stdev, | ||
| _relative_path_ertbox_grids, | ||
| _ertbox_per_zone, | ||
| _ertbox_default, | ||
| _zone_code_names, | ||
| geo_zone_names_used, | ||
| geo_zone_conformity, | ||
| geo_facies_per_zone, | ||
| geo_geogrid_name, | ||
| geo_param_name_dict, | ||
| geo_disc_param_name_dict, | ||
| _field_init_path, | ||
| _field_param_per_zone_dict, | ||
| ) = get_specifications( | ||
| input_dict, | ||
| use_facies_per_zone=use_facies_per_zone, | ||
| geo_facies_per_zone=facies_per_zone, | ||
| ) |
There was a problem hiding this comment.
For return variables that are not used, you can just use _ and *_
Or use slicing.
| ( | |
| _use_geogrid_fields, | |
| _use_temporary_fields, | |
| _nreal, | |
| _iter_list, | |
| _use_population_stdev, | |
| _relative_path_ertbox_grids, | |
| _ertbox_per_zone, | |
| _ertbox_default, | |
| _zone_code_names, | |
| geo_zone_names_used, | |
| geo_zone_conformity, | |
| geo_facies_per_zone, | |
| geo_geogrid_name, | |
| geo_param_name_dict, | |
| geo_disc_param_name_dict, | |
| _field_init_path, | |
| _field_param_per_zone_dict, | |
| ) = get_specifications( | |
| input_dict, | |
| use_facies_per_zone=use_facies_per_zone, | |
| geo_facies_per_zone=facies_per_zone, | |
| ) | |
| ( | |
| *_, | |
| geo_zone_names_used, | |
| geo_zone_conformity, | |
| geo_facies_per_zone, | |
| geo_geogrid_name, | |
| geo_param_name_dict, | |
| geo_disc_param_name_dict, | |
| _, | |
| _, | |
| ) = get_specifications( | |
| input_dict, | |
| use_facies_per_zone=use_facies_per_zone, | |
| geo_facies_per_zone=facies_per_zone, | |
| ) |
| ( | ||
| _use_geogrid_fields, | ||
| _use_temporary_fields, | ||
| _nreal, | ||
| _iter_list, | ||
| _use_population_stdev, | ||
| _relative_path_ertbox_grids, | ||
| _ertbox_per_zone, | ||
| _ertbox_default, | ||
| _zone_code_names, | ||
| _geo_zone_names_used, | ||
| _geo_zone_conformity, | ||
| _geo_facies_per_zone, | ||
| _geo_geogrid_name, | ||
| _geo_param_name_dict, | ||
| _geo_disc_param_name_dict, | ||
| field_init_path, | ||
| field_param_per_zone_dict, | ||
| ) = get_specifications( |
There was a problem hiding this comment.
Similar as above:
| ( | |
| _use_geogrid_fields, | |
| _use_temporary_fields, | |
| _nreal, | |
| _iter_list, | |
| _use_population_stdev, | |
| _relative_path_ertbox_grids, | |
| _ertbox_per_zone, | |
| _ertbox_default, | |
| _zone_code_names, | |
| _geo_zone_names_used, | |
| _geo_zone_conformity, | |
| _geo_facies_per_zone, | |
| _geo_geogrid_name, | |
| _geo_param_name_dict, | |
| _geo_disc_param_name_dict, | |
| field_init_path, | |
| field_param_per_zone_dict, | |
| ) = get_specifications( | |
| *_ , field_init_path, field_param_per_zone_dict, = get_specifications( |
| key = "ertbox_default" | ||
| ertbox_default = None | ||
| if key in input_dict: | ||
| ertbox_default = input_dict[key] | ||
|
|
||
| key = "ertbox_per_zone" | ||
| ertbox_per_zone = None | ||
| if key in input_dict: | ||
| ertbox_per_zone = input_dict[key] | ||
|
|
||
| if not ertbox_default and not ertbox_per_zone: | ||
| raise KeyError( | ||
| "Ertbox grid must be specified either as a common " | ||
| "grid for all zones or individual one per zone" | ||
| ) | ||
|
|
||
| key = "zone_code_names" | ||
| if key in input_dict: | ||
| zone_code_names = input_dict[key] | ||
| else: | ||
| raise KeyError(f"Missing keyword: {key} specifying zone codes and zone names.") |
There was a problem hiding this comment.
Similar code with the one in get_ertbox_size_per zone
Please consider create a helper function for it.
| # Default is to use all zones | ||
| key = "use_zones" | ||
| zone_names_used = copy.copy(list(zone_code_names.values())) | ||
| geo_zone_names_used = copy.copy(list(zone_code_names.values())) |
There was a problem hiding this comment.
I think copy.copy is redundant here. list() will automatically create a new list container and since the values are string (immutable)
| # def copy_to_real0_dirs( | ||
| # field_stat: dict, result_path: Path | str, ens_path: Path | str | ||
| # ) -> None: | ||
| # iteration_list = field_stat["iterations"] | ||
| # for iter in iteration_list: | ||
| # source_files = result_path / Path(f"ertbox--*_{iter}.roff") | ||
| # target_dir = ens_path / Path(f"realization-0/iter-{iter}/share/results/grids") | ||
| # print(f"Source_files: {source_files}") | ||
| # print(f"Target dir: {target_dir}") | ||
| # for f in glob.glob(source_files.as_posix()): | ||
| # shutil.copy(f, target_dir.as_posix()) | ||
| # source_file = result_path / Path("ertbox.roff") | ||
| # shutil.copy(source_file.as_posix(), target_dir.as_posix()) |
There was a problem hiding this comment.
Please remove unused code blocks
Closes: #842