diff --git a/resqpy/derived_model/_gather_ensemble.py b/resqpy/derived_model/_gather_ensemble.py index 21bc3418..0910a1fc 100644 --- a/resqpy/derived_model/_gather_ensemble.py +++ b/resqpy/derived_model/_gather_ensemble.py @@ -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) diff --git a/tests/unit_tests/derived_model/test_derived_model.py b/tests/unit_tests/derived_model/test_derived_model.py index c5a59d30..596d6896 100644 --- a/tests/unit_tests/derived_model/test_derived_model.py +++ b/tests/unit_tests/derived_model/test_derived_model.py @@ -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) @@ -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):