Skip to content

Commit

Permalink
ensuring local property kind references are handled correctly during …
Browse files Browse the repository at this point in the history
…ensemble gathering
  • Loading branch information
andy-beer committed Feb 5, 2024
1 parent 808debc commit 4a8b131
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions resqpy/derived_model/_gather_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,15 @@ def gather_ensemble(case_epc_list,
case_h5_file_name = case_model.h5_file_name()
for part in grid_relatives:
if 'Property' in part:
prop_root = case_model.root_for_part(part)
forceable = (
shared_time_series and ('Categorical' not in part) and
rqet.find_nested_tags(prop_root, ['PropertyKind', 'LocalPropertyKind']) is None)
composite_model.copy_part_from_other_model(case_model,
part,
realization = r,
consolidate = True,
force = shared_time_series and
'Categorical' not in part,
force = forceable,
self_h5_file_name = composite_h5_file_name,
h5_uuid = composite_h5_uuid,
other_h5_file_name = case_h5_file_name)
Expand Down
27 changes: 27 additions & 0 deletions tests/unit_tests/derived_model/test_derived_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,19 @@ def test_gather_ensemble_time_series_and_string_lookup_consolidation(pair_of_mod
assert m_combo.uuid(uuid = excluded_uuid) is None
sl_combo = rqp.StringLookup(m_combo, uuid = sl_combo_uuid)
assert sl_combo == sl1
# check facies local property kind consolidation
facies_pk_1_uuid = m1.uuid(obj_type = 'PropertyKind', title = 'facies')
facies_pk_2_uuid = m2.uuid(obj_type = 'PropertyKind', title = 'facies')
facies_pk_combo_uuid = m_combo.uuid(obj_type = 'PropertyKind', title = 'facies')
assert facies_pk_1_uuid is not None
assert facies_pk_2_uuid is not None
assert facies_pk_combo_uuid is not None
if bu.matching_uuids(facies_pk_1_uuid, facies_pk_combo_uuid):
excluded_pk_uuid = facies_pk_2_uuid
else:
assert bu.matching_uuids(facies_pk_2_uuid, facies_pk_combo_uuid)
excluded_pk_uuid = facies_pk_1_uuid
assert m_combo.uuid(uuid = excluded_pk_uuid) is None
# check combo categorical properties
p_combo_uuids = m_combo.uuids(obj_type = 'CategoricalProperty')
p_combo_uuids_related = m_combo.uuids(obj_type = 'CategoricalProperty', related_uuid = sl_combo_uuid)
Expand All @@ -1385,6 +1398,20 @@ def test_gather_ensemble_time_series_and_string_lookup_consolidation(pair_of_mod
sl_found = True
break
assert sl_found, f'string lookup reference to combo uuid not found for property uuid: {p_combo_uuid}'
# check locel property kind reference nodes have been set correctly
p_combo_uuids = m_combo.uuids(obj_type = 'CategoricalProperty', related_uuid = facies_pk_combo_uuid)
assert p_combo_uuids is not None and len(p_combo_uuids) > 0
for p_combo_uuid in p_combo_uuids:
root_node = m_combo.root_for_uuid(p_combo_uuid)
assert root_node is not None
ref_nodes = rqet.list_obj_references(root_node)
pk_found = False
for ref_node in ref_nodes:
uuid_node = rqet.find_tag(ref_node, 'UUID')
if bu.matching_uuids(facies_pk_combo_uuid, uuid_node.text):
pk_found = True
break
assert pk_found, f'local property kind reference to combo uuid not found for property uuid: {p_combo_uuid}'


def test_gather_ensemble_unforced_time_series_and_string_lookup_consolidation(pair_of_models_with_prop_ts_rels):
Expand Down

0 comments on commit 4a8b131

Please sign in to comment.