Skip to content

Commit

Permalink
ENH: Set table_index explicit in inplace_volume export (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt authored Dec 9, 2024
1 parent f25135e commit aaf3b7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/fmu/dataio/export/rms/inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

_logger: Final = null_logger(__name__)


_TABLE_INDEX_COLUMNS: Final = ("ZONE", "REGION", "FACIES", "LICENCE")

# rename columns to FMU standard
_RENAME_COLUMNS_FROM_RMS: Final = {
"Proj. real.": "REAL",
Expand Down Expand Up @@ -67,6 +70,11 @@ def _classification(self) -> Classification:
"""Get default classification."""
return Classification.restricted

@property
def _table_index(self) -> list[str]:
"""Get index columns present in the dataframe."""
return [col for col in _TABLE_INDEX_COLUMNS if col in self._dataframe]

def _get_rms_volume_job_settings(self) -> dict:
"""Get information out from the RMS job API."""
_logger.debug("RMS VOLJOB settings...")
Expand Down Expand Up @@ -121,6 +129,7 @@ def _export_volume_table(self) -> ExportResult:
classification=self._classification,
name=self.grid_name,
rep_include=False,
table_index=self._table_index,
)
absolute_export_path = edata.export(self._dataframe)
_logger.debug("Volume result to: %s", absolute_export_path)
Expand Down
11 changes: 10 additions & 1 deletion tests/test_export_rms/test_export_rms_volumetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


VOLDATA = (Path("tests/data/drogon/tabular/geogrid--vol.csv")).absolute()
EXPECTED_TABLE_INDEX_COLUMNS = ["ZONE", "REGION", "FACIES"]


@pytest.fixture
Expand All @@ -29,7 +30,10 @@ def test_rms_volumetrics_export_class(
import rmsapi # type: ignore # noqa
import rmsapi.jobs as jobs # type: ignore # noqa

from fmu.dataio.export.rms.inplace_volumes import _ExportVolumetricsRMS
from fmu.dataio.export.rms.inplace_volumes import (
_ExportVolumetricsRMS,
_TABLE_INDEX_COLUMNS,
)

monkeypatch.chdir(rmssetup_with_fmuconfig)

Expand All @@ -54,6 +58,11 @@ def test_rms_volumetrics_export_class(
assert "volumes" in metadata["data"]["content"]
assert metadata["access"]["classification"] == "restricted"

# check that the table index is set correctly
assert len(_TABLE_INDEX_COLUMNS) > len(EXPECTED_TABLE_INDEX_COLUMNS)
assert instance._table_index == EXPECTED_TABLE_INDEX_COLUMNS
assert metadata["data"]["table_index"] == EXPECTED_TABLE_INDEX_COLUMNS


@inside_rms
def test_rms_volumetrics_export_config_missing(
Expand Down

0 comments on commit aaf3b7d

Please sign in to comment.