Skip to content

Commit 4141c6d

Browse files
committed
ENH: Allow RMS wellbores to share SMDA targets
1 parent 8358e5b commit 4141c6d

2 files changed

Lines changed: 59 additions & 4 deletions

File tree

src/fmu/settings/models/mappings.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,22 @@ def _validate_identifier_mappings_collection(
307307
of a same-system primary. It is also invalid to add two ``rms -> smda``
308308
mappings for the same ``source_id``.
309309
310-
- A cross-system ``target_id`` can be used only once per target system.
310+
- A cross-system ``target_id`` can be used only once per target system, except
311+
for RMS to SMDA wellbore mappings. Different RMS wellbore names can map to
312+
the same SMDA wellbore.
311313
Example valid mappings::
312314
313315
rms -> rms, primary, source_id="TopVolantis", target_id="TopVolantis"
314316
rms -> rms, alias, source_id="TOP_VOLANTIS", target_id="TopVolantis"
315317
rms -> smda, primary, source_id="TopVolantis", target_id="VOLANTIS GP. Top"
316318
319+
Example valid RMS to SMDA wellbore mappings::
320+
321+
rms -> rms, primary, source_id="RFT_30_9-B-21_C", target_id="RFT_30_9-B-21_C"
322+
rms -> rms, primary, source_id="MLW_30_9-B-21_C", target_id="MLW_30_9-B-21_C"
323+
rms -> smda, primary, source_id="RFT_30_9-B-21_C", target_id="NO 30/9-B-21 C"
324+
rms -> smda, primary, source_id="MLW_30_9-B-21_C", target_id="NO 30/9-B-21 C"
325+
317326
Example invalid mappings::
318327
319328
rms -> rms, primary, source_id="TopVolantis", target_id="TopVolantis"
@@ -322,7 +331,9 @@ def _validate_identifier_mappings_collection(
322331
rms -> smda, primary, source_id="Volon", target_id="VOLANTIS GP. Top"
323332
324333
The second cross-system mapping is invalid because one cross-system
325-
``target_id`` cannot be mapped to more than one same-system primary.
334+
``target_id`` cannot be mapped to more than one same-system primary. The
335+
exception permits this relationship only for ``wellbore`` mappings from
336+
``rms`` to ``smda``.
326337
"""
327338
same_system_source_keys: set[tuple[DataSystem, MappingType, str]] = set()
328339
same_system_primary_source_keys: set[tuple[DataSystem, MappingType, str]] = set()
@@ -368,8 +379,14 @@ def _validate_identifier_mappings_collection(
368379
)
369380
cross_system_source_keys.add(cross_system_source_key)
370381

371-
# A cross-system target_id can only belong to one same-system primary.
372-
if mapping.target_id is not None:
382+
# RMS wellbore names can share an SMDA wellbore target. Other
383+
# cross-system target_ids can only belong to one same-system primary.
384+
allows_reused_target_id = (
385+
mapping.mapping_type == MappingType.wellbore
386+
and mapping.source_system == DataSystem.rms
387+
and mapping.target_system == DataSystem.smda
388+
)
389+
if mapping.target_id is not None and not allows_reused_target_id:
373390
cross_system_target_key = (
374391
mapping.mapping_type,
375392
mapping.source_system,

tests/test_mappings_model.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,44 @@ def test_validate_collection_rejects_reused_cross_system_target_id() -> None:
535535
)
536536

537537

538+
def test_wellbore_mappings_allow_reused_rms_to_smda_target_id() -> None:
539+
"""Different RMS wellbore names can map to the same SMDA wellbore."""
540+
rft_primary = create_wellbore_mapping(
541+
source_system=DataSystem.rms,
542+
target_system=DataSystem.rms,
543+
source_id="RFT_30_9-B-21_C",
544+
target_id="RFT_30_9-B-21_C",
545+
)
546+
mlw_primary = create_wellbore_mapping(
547+
source_system=DataSystem.rms,
548+
target_system=DataSystem.rms,
549+
source_id="MLW_30_9-B-21_C",
550+
target_id="MLW_30_9-B-21_C",
551+
)
552+
rft_mapping = create_wellbore_mapping(
553+
source_system=DataSystem.rms,
554+
target_system=DataSystem.smda,
555+
source_id="RFT_30_9-B-21_C",
556+
target_id="NO 30/9-B-21 C",
557+
)
558+
mlw_mapping = create_wellbore_mapping(
559+
source_system=DataSystem.rms,
560+
target_system=DataSystem.smda,
561+
source_id="MLW_30_9-B-21_C",
562+
target_id="NO 30/9-B-21 C",
563+
)
564+
565+
mappings = InternalWellboreMappings(
566+
root=[rft_primary, mlw_primary, rft_mapping, mlw_mapping]
567+
)
568+
569+
converted = mappings.to_wellbore_mappings()
570+
assert [(mapping.source_id, mapping.target_id) for mapping in converted] == [
571+
("RFT_30_9-B-21_C", "NO 30/9-B-21 C"),
572+
("MLW_30_9-B-21_C", "NO 30/9-B-21 C"),
573+
]
574+
575+
538576
def test_validate_collection_rejects_reused_same_system_source_id() -> None:
539577
"""A source_id cannot be both a primary and an alias in the same collection."""
540578
primary = create_stratigraphy_mapping()

0 commit comments

Comments
 (0)