Skip to content

Commit

Permalink
Add filtering for History vectors in plotter
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Sep 10, 2024
1 parent 69eada0 commit 00fabd4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ert/gui/tools/plot/data_type_proxy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool:
for meta_key, values in self._metadata_filters.items():
for value, visible in values.items():
if (
not visible
and meta_key in key.metadata
and key.metadata[meta_key] == value
(
not visible
and meta_key in key.metadata
and key.metadata[meta_key] == value
)
or not visible
and key.history_vector
):
show = False

return show

def sourceModel(self) -> DataTypeKeysListModel:
Expand Down
3 changes: 3 additions & 0 deletions src/ert/gui/tools/plot/filter_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def __init__(
for f in filters:
self.addFilterItem(f, f)

if any(k.history_vector for k in key_defs):
self.addFilterItem("History Vector", "History Vector")

frame.setLayout(self.__layout)

self.setLayout(layout)
Expand Down
8 changes: 8 additions & 0 deletions src/ert/gui/tools/plot/plot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ class EnsembleObject:
("dimensionality", int),
("metadata", Dict[Any, Any]),
("log_scale", bool),
("history_vector", bool),
],
)


def _is_history_vector(name: str) -> bool:
key = name.split(":")[0]
return key.endswith("H") and len(key) == 5


class PlotApi:
def __init__(self) -> None:
self._all_ensembles: Optional[List[EnsembleObject]] = None
Expand Down Expand Up @@ -130,6 +136,7 @@ def all_data_type_keys(self) -> List[PlotApiKeyDefinition]:
dimensionality=2,
metadata=value["userdata"],
log_scale=key.startswith("LOG10_"),
history_vector=_is_history_vector(key),
)

response = client.get(
Expand All @@ -145,6 +152,7 @@ def all_data_type_keys(self) -> List[PlotApiKeyDefinition]:
dimensionality=e["dimensionality"],
metadata=e["userdata"],
log_scale=key.startswith("LOG10_"),
history_vector=_is_history_vector(key),
)

return list(all_keys.values())
Expand Down

0 comments on commit 00fabd4

Please sign in to comment.