Average Maps from Grid Properties

Python script
 1"""Export maps that holds certain average gridmodel properties.
 2
 3The files on disk are:
 4
 5facies_fraction_channels_volon.gri
 6klogh_average_valysar.gri
 7phit_average_therys.gri
 8
 9We want to use the file names here to extract some data (like name of formation, e.g.
10Therys).
11"""
12
13from pathlib import Path
14
15import xtgeo
16from fmu.config import utilities as ut
17
18from fmu.dataio import ExportData
19
20CFG = ut.yaml_load("../../fmuconfig/output/global_variables.yml")
21
22# Property attributes. This maps a property name (key) to an attribute name (value).
23PROP_ATTRIBUTE_MAP = {
24    "facies_fraction": "facies_fraction",
25    "phit": "porosity",
26    "klog": "permeability",
27}
28
29# Name attributes. This maps a name in the map (key) to a name used for export (value).
30NAME_MAP = {
31    "valysar": "Valysar",
32    "therys": "Therys",
33    "volon": "Volon",
34}
35
36MAPS_DIR = Path("../output/maps/grid_averages")
37
38
39def export_property_maps():
40    """Re-export maps with metadata."""
41
42    map_files = MAPS_DIR.glob("*.gri")
43    for file in map_files:
44        surf = xtgeo.surface_from_file(file)
45
46        attribute = "unset"
47        for from_prop, to_attribute in PROP_ATTRIBUTE_MAP.items():
48            if from_prop in str(file).lower():
49                attribute = to_attribute
50
51        name = "unset"
52        for from_name, to_name in NAME_MAP.items():
53            if from_name in str(file).lower():
54                name = to_name
55
56        export_data = ExportData(
57            config=CFG,
58            name=name,
59            unit="fraction",
60            content="property",
61            content_metadata={"attribute": attribute, "is_discrete": False},
62            tagname=f"average_{attribute}",
63            workflow="rms property model",
64        )
65
66        out_path = export_data.export(surf)
67        print(f"Exported property map to file {out_path}")
68
69
70def main():
71    print("\nExporting property maps and metadata...")
72    export_property_maps()
73    print("Done exporting property maps and metadata.")
74
75
76if __name__ == "__main__":
77    main()

Press + to see generated YAML file.

class: surface
masterdata:
  smda:
    coordinate_system:
      identifier: ST_WGS84_UTM37N_P32637
      uuid: ad214d85-dac7-19da-e053-c918a4889309
    country:
    - identifier: Norway
      uuid: ad214d85-8a1d-19da-e053-c918a4889309
    discovery:
    - short_identifier: DROGON
      uuid: ad214d85-8a1d-19da-e053-c918a4889309
    field:
    - identifier: DROGON
      uuid: 00000000-0000-0000-0000-000000000000
    stratigraphic_column:
      identifier: DROGON_2020
      uuid: ad214d85-8a1d-19da-e053-c918a4889310
tracklog:
- datetime: '2026-06-03T13:22:32.260698Z'
  event: created
  user:
    id: docs
  sysinfo:
    fmu-dataio:
      version: 2.29.1
    operating_system:
      hostname: build-32973030-project-703197-fmu-dataio
      operating_system: Linux-7.0.0-1004-aws-x86_64-with-glibc2.35
      release: 7.0.0-1004-aws
      system: Linux
      version: '#4-Ubuntu SMP PREEMPT Mon Apr 13 13:14:24 UTC 2026'
source: fmu
version: 0.22.0
$schema: https://main-fmu-schemas-prod.radix.equinor.com/schemas/0.22.0/fmu_results.json
fmu:
  case:
    name: MyCase
    user:
      id: docs
    uuid: 6b92bfd4-b6e8-42c5-948d-7c49a1376d51
  model:
    name: ff
    revision: 21.1.0.dev
  context:
    stage: realization
  ensemble:
    name: iter-0
    uuid: 80339c1d-31e0-b289-0fdb-8bfe7a02bf84
    id: 0
  iteration:
    name: iter-0
    uuid: 80339c1d-31e0-b289-0fdb-8bfe7a02bf84
    id: 0
  workflow:
    reference: rms property model
  realization:
    id: 0
    name: example_exports
    uuid: 65ea7846-2c12-aec6-42d1-6d84cac948c5
  entity:
    uuid: 5a40d722-8600-71bd-89ed-6eafb9a83e40
  ert:
    experiment:
      id: 00000000-0000-0000-0000-000000000000
    simulation_mode: test_run
    ensemble:
      name: iter-0
      uuid: b027f225-c45d-477d-8f33-73695217ba14
      id: 0
access:
  asset:
    name: Drogon
  classification: internal
  ssdl:
    access_level: internal
    rep_include: false
data:
  content: property
  name: Therys Fm.
  alias:
  - Therys
  tagname: average_porosity
  stratigraphic: true
  smda_entity:
    identifier: Therys Fm.
  bbox:
    xmin: 456012.5
    xmax: 467540.52719139645
    ymin: 5926500.0
    ymax: 5939492.128806534
    zmin: 0.0
    zmax: 0.38215649127960205
  format: irap_binary
  is_observation: false
  is_prediction: true
  layout: regular
  offset: 0.0
  spec:
    nrow: 440
    ncol: 280
    rotation: 30.0
    undef: 1.0e+30
    xinc: 25.0
    yinc: 25.0
    xori: 461500.0
    yflip: 1
    yori: 5926500.0
    value_statistics:
      min: 0.0
      max: 0.38215649127960205
      mean: 0.2262042955107155
      std: 0.08046811630282148
  undef_is_zero: false
  unit: fraction
  vertical_domain: depth
  domain_reference: msl
  property:
    attribute: porosity
    is_discrete: false
file:
  absolute_path: /home/docs/checkouts/readthedocs.org/user_builds/fmu-dataio/checkouts/stable/examples/example_exports/share/results/maps/therys--average_porosity.gri
  relative_path: example_exports/share/results/maps/therys--average_porosity.gri
  runpath_relative_path: share/results/maps/therys--average_porosity.gri
  checksum_md5: 7b8d677044c2701d88f1a95e85aec142
  size_bytes: 496420
display:
  name: Therys Fm.
_preprocessed: false