Skip to content

Commit

Permalink
Avoid assuming inplace units + support descriptions of any column.
Browse files Browse the repository at this point in the history
  • Loading branch information
asnyv committed Jul 15, 2020
1 parent 22644b9 commit 9517136
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 111 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,74 @@
{
"BULK_OIL": {"label": "Bulk volume (oil zone)", "unit": ""},
"BULK_GAS": {"label": "Bulk volume (gas zone)", "unit": ""},
"BULK_TOTAL": {"label": "Bulk volume (total)", "unit": ""},
"NET_OIL": {"label": "Net volume (oil zone)", "unit": ""},
"NET_GAS": {"label": "Net volume (gas zone)", "unit": ""},
"NET_TOTAL": {"label": "Net volume (total)", "unit": ""},
"PORV_OIL": {"label": "Pore volume (oil zone)", "unit": ""},
"PORV_GAS": {"label": "Pore volume (gas zone)", "unit": ""},
"PORV_TOTAL": {"label": "Pore volume (total)", "unit": ""},
"PORE_OIL": {"label": "Pore volume (oil zone)", "unit": ""},
"PORE_GAS": {"label": "Pore volume (gas zone)", "unit": ""},
"PORE_TOTAL": {"label": "Pore volume (total)", "unit": ""},
"HCPV_OIL": {"label": "Hydro carbon pore volume (oil zone)", "unit": ""},
"HCPV_GAS": {"label": "Hydro carbon pore volume (gas zone)", "unit": ""},
"HCPV_TOTAL": {"label": "Hydro carbon pore volume (total zone)", "unit": ""},
"STOIIP_OIL": {"label": "Stock tank oil initially in place (oil zone)", "unit": "Sm³", "eclsum": ["FOIPL", "ROIPL"]},
"STOIIP_GAS": {"label": "Stock tank oil initially in place (gas zone)", "unit": "Sm³", "eclsum": ["FOIPG", "ROIPG"]},
"STOIIP_TOTAL": {"label": "Stock tank oil initially in place (total)", "unit": "Sm³", "eclsum": ["FOIP", "ROIP"]},
"GIIP_OIL": {"label": "Gas initially in place (oil zone)", "unit": "Sm³", "eclsum": ["FGIPL", "RGIPL"]},
"GIIP_GAS": {"label": "Gas initially in place (gas zone)", "unit": "Sm³", "eclsum": ["FGIPG", "RGIPG"]},
"GIIP_TOTAL": {"label": "Gas initially in place (total)", "unit": "Sm³", "eclsum": ["FGIP", "RGIP"]},
"RECOVERABLE_OIL": {"label": "Recoverable volume (oil zone)", "unit": "Sm³"},
"RECOVERABLE_GAS": {"label": "Recoverable volume (gas zone)", "unit": "Sm³"},
"RECOVERABLE_TOTAL": {"label": "Recoverable volume (total)", "unit": "Sm³"}
"BULK_OIL": {
"description": "Bulk volume (oil zone)"
},
"BULK_GAS": {
"description": "Bulk volume (gas zone)"
},
"BULK_TOTAL": {
"description": "Bulk volume (total)"
},
"NET_OIL": {
"description": "Net volume (oil zone)"
},
"NET_GAS": {
"description": "Net volume (gas zone)"
},
"NET_TOTAL": {
"description": "Net volume (total)"
},
"PORV_OIL": {
"description": "Pore volume (oil zone)"
},
"PORV_GAS": {
"description": "Pore volume (gas zone)"
},
"PORV_TOTAL": {
"description": "Pore volume (total)"
},
"PORE_OIL": {
"description": "Pore volume (oil zone)"
},
"PORE_GAS": {
"description": "Pore volume (gas zone)"
},
"PORE_TOTAL": {
"description": "Pore volume (total)"
},
"HCPV_OIL": {
"description": "Hydro carbon pore volume (oil zone)"
},
"HCPV_GAS": {
"description": "Hydro carbon pore volume (gas zone)"
},
"HCPV_TOTAL": {
"description": "Hydro carbon pore volume (total zone)"
},
"STOIIP_OIL": {
"description": "Stock tank oil initially in place (oil zone)"
},
"STOIIP_GAS": {
"description": "Stock tank oil initially in place (gas zone)"
},
"STOIIP_TOTAL": {
"description": "Stock tank oil initially in place (total)"
},
"GIIP_OIL": {
"description": "Gas initially in place (oil zone)"
},
"GIIP_GAS": {
"description": "Gas initially in place (gas zone)"
},
"GIIP_TOTAL": {
"description": "Gas initially in place (total)"
},
"RECOVERABLE_OIL": {
"description": "Recoverable volume (oil zone)"
},
"RECOVERABLE_GAS": {
"description": "Recoverable volume (gas zone)"
},
"RECOVERABLE_TOTAL": {
"description": "Recoverable volume (total)"
}
}

40 changes: 20 additions & 20 deletions webviz_subsurface/_abbreviations/volume_terminology.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import json
import pathlib

from typing import Optional

_DATA_PATH = pathlib.Path(__file__).parent.absolute() / "abbreviation_data"

VOLUME_TERMINOLOGY = json.loads((_DATA_PATH / "volume_terminology.json").read_text())


def volume_description(column: str):
def volume_description(column: str, metadata: Optional[dict] = None):
"""Return description for the column if defined"""
if metadata is not None:
try:
return metadata[column]["description"]
except KeyError:
pass
try:
label = VOLUME_TERMINOLOGY[column]["label"]
description = VOLUME_TERMINOLOGY[column]["description"]
except KeyError:
label = column
return label
description = column
return description


def volume_unit(column: str):
def volume_unit(column: str, metadata: Optional[dict] = None):
"""Return unit for the column if defined"""
try:
unit = VOLUME_TERMINOLOGY[column]["unit"]
except KeyError:
unit = ""
return unit
if metadata is not None:
try:
return metadata[column]["unit"]
except KeyError:
pass
return ""


def volume_simulation_vector_match(column: str):
"""Return a list of simulation vectors that match the column
Useful to verify/propose data to compare.
"""
try:
vectors = VOLUME_TERMINOLOGY[column]["eclsum"]
except KeyError:
vectors = []
return vectors if isinstance(vectors, list) else [vectors]
def column_title(response: str, metadata: dict):
unit = volume_unit(response, metadata)
return f"{volume_description(response, metadata)}" + (f" [{unit}]" if unit else "")
14 changes: 14 additions & 0 deletions webviz_subsurface/_datainput/inplace_volumes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os
from pathlib import Path
from io import BytesIO
import json

import pandas as pd
import fmu.ensemble
Expand Down Expand Up @@ -40,3 +43,14 @@ def extract_volumes(ensemble_paths, volfolder, volfiles) -> pd.DataFrame:
f"Ensure that the files are present in relative folder {volfolder}"
)
return pd.concat(dfs)


@CACHE.memoize(timeout=CACHE.TIMEOUT)
@webvizstore
def get_metadata(metadata: Path) -> BytesIO:
"""Returns a json formatted dict stored in a BytesIO object"""
metadict = json.loads(metadata.read_text())
bytesio = BytesIO()
bytesio.write(json.dumps(metadict).encode())
bytesio.seek(0)
return bytesio
Loading

0 comments on commit 9517136

Please sign in to comment.