Skip to content

Commit

Permalink
Enable filter on data.content.
Browse files Browse the repository at this point in the history
  • Loading branch information
perolavsvendsen committed Mar 23, 2024
1 parent 7b7416c commit 3bdd493
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
10 changes: 10 additions & 0 deletions docs/explorer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ The `SurfaceCollection` object has a filter method and properties for getting fi
surfaces = case.surfaces.filter(iteration="iter-0")
contents = surfaces.contents
surfaces = surfaces.filter(
content=contents[0]
)
names = surfaces.names
surfaces = surfaces.filter(
Expand All @@ -243,6 +249,7 @@ The `SurfaceCollection.filter` method takes the following parameters:

* uuid
* name
* content
* tagname
* iteration
* realization
Expand Down Expand Up @@ -280,6 +287,7 @@ We can get list of filter values for the following properties:

* names
* tagnames
* contents
* iterations
* realizations
* aggregations
Expand All @@ -304,6 +312,7 @@ Once we have a `Surface` object we can get surface metadata using properties:
print(surfaces.uuid)
print(surfaces.name)
print(surface.content)
print(surfaces.tagname)
print(surface.stratigraphic)
print(surface.vertical_domain)
Expand Down Expand Up @@ -482,6 +491,7 @@ The `SurfaceCollection` class can be used to do on-demand surface aggregations.
surfaces = case.surfaces.filter(
stage="realization",
content="depth",
iteration="iter-0",
name="Valysar Fm.",
tagname="FACIES_Fraction_Channel"
Expand Down
23 changes: 15 additions & 8 deletions examples/explorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
"# Filter on iteration\n",
"surfs = surfs.filter(iteration=\"iter-0\")\n",
"\n",
"# Get available contents\n",
"print(\"Contents:\", surfs.contents)\n",
"\n",
"# Filter on content\n",
"surfs = surfs.filter(content=\"depth\")\n",
"\n",
"# Get available names\n",
"print(\"Names:\", surfs.names)\n",
"\n",
Expand All @@ -127,22 +133,23 @@
"# Iterate over results\n",
"print(\"\\nResults:\", len(surfs))\n",
"\n",
"for surf in surfs:\n",
" print(\"\\n\")\n",
" print(\"ID:\", surf.uuid)\n",
" print(\"Realization:\", surf.realization)\n",
"# Sort by realization\n",
"sorted_surfs = sorted(surfs, key=lambda x:x.realization)\n",
"\n",
"for surf in sorted_surfs:\n",
" print(f\"\\n Realization {surf.realization}: {surf.name} ({surf.content}) ({surf.uuid})\")\n",
"\n",
"# Select surface instance\n",
"# Select one surface instance\n",
"surf = surfs[0]\n",
"\n",
"print(\"\\nSelected surface:\")\n",
"print(\"ID:\", surf.uuid)\n",
"print(\"Uuid:\", surf.uuid)\n",
"print(\"Name:\", surf.name)\n",
"print(\"Content:\", surf.content)\n",
"print(\"Tagname:\", surf.tagname)\n",
"print(\"Iteration:\", surf.iteration)\n",
"print(\"Realization:\", surf.realization)\n",
"print(\"stratigraphic\", surf.stratigraphic)\n",
"print(\"vertical domain\", surf.vertical_domain)\n",
"print(\"vertical domain:\", surf.vertical_domain)\n",
"\n",
"# xtgeo.RegularSurface\n",
"reg_surf = surf.to_regular_surface()\n",
Expand Down
6 changes: 6 additions & 0 deletions src/fmu/sumo/explorer/objects/_child.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""module containing class for child object"""

from typing import Dict
from io import BytesIO
from sumo.wrapper import SumoClient
Expand All @@ -23,6 +24,11 @@ def name(self) -> str:
"""Object name"""
return self._get_property(["data", "name"])

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

@property
def tagname(self) -> str:
"""Object tagname"""
Expand Down
7 changes: 7 additions & 0 deletions tests/test_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ def test_case_surfaces_filter(test_case: Case):
assert surf.iteration == "iter-0"
assert surf.name == "Valysar Fm."

# filter on content
non_valid_content_surfs = real_surfs.filter(content="___not_valid")
assert len(non_valid_content_surfs) == 0

real_surfs = real_surfs.filter(content="depth")
assert len(real_surfs) == 56

# filter on tagname
real_surfs = real_surfs.filter(tagname="FACIES_Fraction_Channel")
assert len(real_surfs) == 4
Expand Down

0 comments on commit 3bdd493

Please sign in to comment.