Skip to content

Commit

Permalink
Enable filter on data.content. (#310)
Browse files Browse the repository at this point in the history
* Enable filter on data.content.
  • Loading branch information
perolavsvendsen authored Apr 10, 2024
1 parent 10669d9 commit 467077e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
14 changes: 12 additions & 2 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,7 +249,8 @@ The `SurfaceCollection.filter` method takes the following parameters:

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

* names
* tagnames
* contents
* tagnames
* dataformats
* iterations
* realizations
Expand All @@ -304,6 +312,7 @@ Once we have a `Surface` object we can get surface metadata using properties:
surface = case.surfaces[0]
print(surface.content)
print(surface.uuid)
print(surface.name)
print(surface.tagname)
Expand Down Expand Up @@ -485,6 +494,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
14 changes: 10 additions & 4 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 @@ -136,18 +142,18 @@
" print(\"Format:\", surf.dataformat)\n",
" print(\"Realization:\", surf.realization)\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(\"Format:\", surf.dataformat)\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
5 changes: 5 additions & 0 deletions src/fmu/sumo/explorer/objects/_child.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,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 @@ -238,6 +238,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
non_valid_tagname_surfs = real_surfs.filter(tagname="___not_valid")
assert len(non_valid_tagname_surfs) == 0
Expand Down

0 comments on commit 467077e

Please sign in to comment.