Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split settings groups in RftPlotter #1180

Merged
merged 6 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def __init__(self, datamodel: RftPlotterDataModel) -> None:
self._well_names = datamodel.well_names

def layout(self) -> List[Component]:
ensemble = self._ensembles[0] if len(self._ensembles) > 0 else None
well = self._well_names[0] if len(self._well_names) > 0 else None
ensemble = self._ensembles[0] if self._ensembles else None
well = self._well_names[0] if self._well_names else None
dates_in_well = self._datamodel.date_in_well(well) if well is not None else []
return [
wcc.Dropdown(
Expand All @@ -49,7 +49,7 @@ def layout(self) -> List[Component]:
id=self.register_component_unique_id(self.Ids.DATE),
options=[{"label": date, "value": date} for date in dates_in_well],
clearable=False,
value=dates_in_well[0] if len(dates_in_well) > 0 else None,
value=dates_in_well[0] if dates_in_well else None,
),
wcc.RadioItems(
label="Plot simulations as",
Expand Down Expand Up @@ -154,7 +154,7 @@ def _update_date(
well: str, current_date: str
) -> Tuple[List[Dict[str, str]], Optional[str]]:
dates = self._datamodel.date_in_well(well)
first_date = dates[0] if len(dates) > 0 else None
first_date = dates[0] if dates else None
available_dates = [{"label": date, "value": date} for date in dates]
date = current_date if current_date in dates else first_date
return available_dates, date
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def layout(self) -> List[Component]:
label="Ensembles",
id=self.register_component_unique_id(self.Ids.ENSEMBLES),
options=[{"label": ens, "value": ens} for ens in self._ensembles],
value=[self._ensembles[0] if len(self._ensembles) > 0 else None],
value=[self._ensembles[0] if self._ensembles else None],
clearable=False,
multi=True,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def _update_selections_from_clickdata(

clickdata = corr_vector_clickdata.get("points", [{}])[0].get("y")
ls_clickdata = clickdata.split()
print("click dat ais: ", ls_clickdata)
return ls_clickdata[0]

@callback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from ._selections import PlotType, Selections
from ._ensembles import Ensembles
from ._plot_type import PlotType, PlotTypeSettings
from ._size_color_settings import SizeColorSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import List

import webviz_core_components as wcc
from dash.development.base_component import Component
from webviz_config.utils import StrEnum
from webviz_config.webviz_plugin_subclasses import SettingsGroupABC


class Ensembles(SettingsGroupABC):
class Ids(StrEnum):
ENSEMBLES = "ensembles"

def __init__(self, ensembles: List[str]) -> None:
super().__init__("Ensembles")
self._ensembles = ensembles

def layout(self) -> List[Component]:
return [
wcc.Dropdown(
id=self.register_component_unique_id(self.Ids.ENSEMBLES),
options=[{"label": ens, "value": ens} for ens in self._ensembles],
value=[self._ensembles[0] if self._ensembles else None],
clearable=False,
multi=True,
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ class PlotType(StrEnum):
ERROR_BOXPLOT = "error-boxplot"


class Selections(SettingsGroupABC):
class PlotTypeSettings(SettingsGroupABC):
class Ids(StrEnum):
PLOT_TYPE = "plot-type"
ENSEMBLES = "ensembles"

def __init__(self, ensembles: List[str]) -> None:
super().__init__("Selections")
self._ensembles = ensembles
def __init__(self) -> None:
super().__init__("Plot Type")

def layout(self) -> List[Component]:
return [
wcc.RadioItems(
label="Plot Type",
id=self.register_component_unique_id(self.Ids.PLOT_TYPE),
options=[
{
Expand All @@ -37,12 +34,4 @@ def layout(self) -> List[Component]:
],
value=PlotType.CROSSPLOT,
),
wcc.Dropdown(
label="Ensembles",
id=self.register_component_unique_id(self.Ids.ENSEMBLES),
options=[{"label": ens, "value": ens} for ens in self._ensembles],
value=[self._ensembles[0] if len(self._ensembles) > 0 else None],
clearable=False,
multi=True,
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
from ..._reusable_view_element import GeneralViewElement
from ..._types import ColorAndSizeByType
from ..._utils import RftPlotterDataModel, filter_frame
from ._settings import PlotType, Selections, SizeColorSettings
from ._settings import Ensembles, PlotType, PlotTypeSettings, SizeColorSettings
from ._utils import update_crossplot, update_errorplot


class SimVsObsView(ViewABC):
class Ids(StrEnum):
SELECTIONS = "selections"
PLOT_TYPE = "plot-type"
ENSEMBLES = "ensembles"
FILTERS = "filters"
SIZE_COLOR_SETTINGS = "size-color-settings"
VIEW_ELEMENT = "view-element"
Expand All @@ -26,7 +27,8 @@ def __init__(self, datamodel: RftPlotterDataModel) -> None:

self.add_settings_groups(
{
self.Ids.SELECTIONS: Selections(self._datamodel.ensembles),
self.Ids.PLOT_TYPE: PlotTypeSettings(),
self.Ids.ENSEMBLES: Ensembles(self._datamodel.ensembles),
self.Ids.FILTERS: FilterLayout(
wells=self._datamodel.well_names,
zones=self._datamodel.zone_names,
Expand All @@ -47,14 +49,14 @@ def set_callbacks(self) -> None:
"children",
),
Input(
self.settings_group(self.Ids.SELECTIONS)
.component_unique_id(Selections.Ids.PLOT_TYPE)
self.settings_group(self.Ids.PLOT_TYPE)
.component_unique_id(PlotTypeSettings.Ids.PLOT_TYPE)
.to_string(),
"value",
),
Input(
self.settings_group(self.Ids.SELECTIONS)
.component_unique_id(Selections.Ids.ENSEMBLES)
self.settings_group(self.Ids.ENSEMBLES)
.component_unique_id(Ensembles.Ids.ENSEMBLES)
.to_string(),
"value",
),
Expand Down