Skip to content

Commit

Permalink
add is_observation and is_prediction to metadata (#178)
Browse files Browse the repository at this point in the history
* add is_observation and is_prediction to metadata

* do not expose isobservation and isprediction as explicit properties
  • Loading branch information
equinor-ruaj authored Jun 9, 2023
1 parent 722f523 commit e897043
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions examples/explorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
"print(\"Tagname:\", cube.tagname)\n",
"print(\"Iteration:\", cube.iteration)\n",
"print(\"Realization:\", cube.realization)\n",
"print(\"is_observation:\", cube[\"data\"][\"is_observation\"])\n",
"print(\"is_prediction:\", cube[\"data\"][\"is_prediction\"])\n",
"\n",
"print(\"\\nOpenVDS data:\")\n",
"openvds_handle = cube.openvds_handle\n",
Expand Down
4 changes: 2 additions & 2 deletions src/fmu/sumo/explorer/objects/_child.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def name(self) -> str:
def tagname(self) -> str:
"""Object tagname"""
return self._get_property(["data", "tagname"])

@property
def stratigraphic(self) -> str:
"""Object stratigraphic"""
return self._get_property(["data", "stratigraphic"])

@property
def vertical_domain(self) -> str:
"""Object vertical_domain"""
Expand Down
11 changes: 8 additions & 3 deletions src/fmu/sumo/explorer/objects/_child_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"access.asset",
"masterdata.smda.field",
"file.relative_path",
"data.is_observation",
"data.is_prediction"
]


Expand Down Expand Up @@ -71,18 +73,17 @@ def aggregations(self) -> List[str]:
def stages(self) -> List[str]:
"""List of unique stages"""
return self._get_field_values("fmu.context.stage.keyword")

@property
def stratigraphic(self) -> List[str]:
"""List of unqiue object stratigraphic"""
return self._get_field_values("data.stratigraphic")

@property
def vertical_domain(self) -> List[str]:
"""List of unqiue object vertical domain"""
return self._get_field_values("data.vertical_domain")


def _init_query(self, doc_type: str, query: Dict = None) -> Dict:
new_query = super()._init_query(doc_type, query)
case_filter = {
Expand All @@ -108,6 +109,8 @@ def _add_filter(
uuid: Union[str, List[str], bool] = None,
stratigraphic: Union[str, List[str], bool] = None,
vertical_domain: Union[str, List[str], bool] = None,
is_observation: bool = None,
is_prediction: bool = None
):
must = []
must_not = []
Expand All @@ -123,6 +126,8 @@ def _add_filter(
"_id": uuid,
"data.stratigraphic.keyword": stratigraphic,
"data.vertical_domain.keyword": vertical_domain,
"data.is_observation.keyword": is_observation,
"data.is_prediction.keyword": is_prediction
}

for prop, value in prop_map.items():
Expand Down
2 changes: 0 additions & 2 deletions src/fmu/sumo/explorer/objects/cube.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Module containing class for cube object"""
import json
import openvds
from typing import Dict
from sumo.wrapper import SumoClient
Expand Down Expand Up @@ -62,4 +61,3 @@ def interval(self) -> str:
return (t0, t1)

return None

6 changes: 6 additions & 0 deletions src/fmu/sumo/explorer/objects/cube_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def filter(
stage: Union[str, List[str], bool] = None,
time: TimeFilter = None,
uuid: Union[str, List[str], bool] = None,
is_observation: bool = None,
is_prediction: bool = None
) -> "CubeCollection":
"""Filter cubes
Expand All @@ -98,6 +100,8 @@ def filter(
stage (Union[str, List[str], bool]): context/stage
time (TimeFilter): time filter
uuid (Union[str, List[str], bool]): cube object uuid
is_observation (bool): cube is_observation
is_prediction (bool): cube is_prediction
Returns:
CubeCollection: A filtered CubeCollection
Expand All @@ -110,6 +114,8 @@ def filter(
stage=stage,
time=time,
uuid=uuid,
is_observation=is_observation,
is_prediction=is_prediction
)

return CubeCollection(self._sumo, self._case_uuid, query, self._pit)

0 comments on commit e897043

Please sign in to comment.