equinor / fmu-dataio

FMU data standard and data export with rich metadata in the FMU context
https://fmu-dataio.readthedocs.io/en/latest/
Apache License 2.0
10 stars 15 forks source link

Add `export_fip_mapping()` one liner export #828

Open mferrera opened 1 month ago

mferrera commented 1 month ago

Currently the FIPNUM-Region-Zone mapping is exported in the following way:

  1. Create xtgeo fipnum, region, zone GridPropertys from their respective RMS objects
  2. Create a region table mapping region names to fipnums
  3. Create a zone table mapping zone names to fipnums
  4. Construct this into a Python dict as: {"FIPNUM": {"groups": {"REGION": region_table, "ZONE": zone_table}}}
  5. Export this as a yaml file

This is done on a realization basis.

Simplification

We can compress these steps behind a simple export function.

export_fip_mapping(
    project: Any,
    grid_name: str,  # The RMS grid name, e.g. "Simgrid"
    zone_name: str,  # The RMS zone name, e.g. "Zone"
    region_name: str,  # The RMS region name, e.g. "Region"
    fip_name: str,  # The `FIPxxxxx` keyword, e.g. "FIPNUM"

    config_path: str | Path = "../../fmuconfig/output/global_variables.yml", 
    classification: str | None = None, # Actual default from config
)

This would, without changes, produce a fip.yml file in the following format:

FIPNUM:
  groups:
    REGION:
      CentralHorst:
        - 6
        - ...
      CentralNorth:
        - 3
        - ...
    ZONE:
      Therys:
        - 8
        - ...
      Valysar:
        - 1
        - ...

This format, with the mappings nested into groups, is particular to the format in use for the "old" Webviz:

https://github.com/equinor/fmu-tools/blob/1a30809bca592cf8e6e7e67b3be428a158540d20/src/fmu/tools/fipmapper/fipmapper.py#L509-L526

and we'd like to not nest into groups if possible. See Discussion.

We thought it might be best to store these on a realization level, since every realization generates them. Even if they are in practice the same for every realization, FMU is flexible enough to allow them not to be. Storing them this way is more durable and flexible to this reality.

This means consumers looking to establish this mapping on an ensemble level would need to select from one realization. This could be a reference realization or a random one (i.e. realization 0).

Context

Uses

This produces fip.yml. This file is used for:

Discussion

Dependencies

Relevant issues

Another similar format for this data is used within FMU as well: https://fmu-docs.equinor.com/docs/subscript/scripts/prtvol2csv.html#region-and-zone-support

mferrera commented 1 month ago

Discussion 7 Oct 2024

Actions