Skip to content

Commit

Permalink
Merge branch 'master' into fix_polygon_options3
Browse files Browse the repository at this point in the history
  • Loading branch information
AudunSektnanNR authored Oct 12, 2023
2 parents 3e3c2ee + 58be779 commit ccd017b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
9 changes: 5 additions & 4 deletions webviz_subsurface/plugins/_simulation_time_series/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(
"is not supported by plugin yet!"
)
self._sampling = Frequency(sampling)
self._presampled_frequency = None
self._has_presampled_providers = False

# TODO: Update functionality when allowing raw data and csv file input
# NOTE: If csv is implemented-> handle/disable statistics, PER_INTVL_, PER_DAY_, delta
Expand All @@ -135,10 +135,11 @@ def __init__(
for ensemble_name in ensembles
}
if perform_presampling:
self._presampled_frequency = self._sampling
presampled_frequency = self._sampling
self._has_presampled_providers = True
self._input_provider_set = (
create_presampled_ensemble_summary_provider_set_from_paths(
ensemble_paths, rel_file_pattern, self._presampled_frequency
ensemble_paths, rel_file_pattern, presampled_frequency
)
)
else:
Expand Down Expand Up @@ -324,7 +325,7 @@ def __init__(
SubplotView(
custom_vector_definitions=self._custom_vector_definitions,
custom_vector_definitions_base=self._custom_vector_definitions_base,
disable_resampling_dropdown=self._presampled_frequency is not None,
has_presampled_providers=self._has_presampled_providers,
initial_selected_vectors=self._initial_vectors,
initial_vector_selector_data=self._initial_vector_selector_data,
initial_visualization=self._initial_visualization_selection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,31 @@ class Ids(StrEnum):

def __init__(
self,
disable_resampling_dropdown: bool,
disable_dropdowns: bool,
selected_resampling_frequency: Frequency,
ensembles_dates: List[datetime.datetime],
input_provider_set: EnsembleSummaryProviderSet,
) -> None:
super().__init__("Resampling frequency")
self._disable_resampling_dropdown = disable_resampling_dropdown
self._disable_dropdowns = disable_dropdowns
self._selected_resampling_frequency = selected_resampling_frequency
self._ensembles_dates = ensembles_dates
self._input_provider_set = input_provider_set

def layout(self) -> List[Component]:
return [
wcc.Label(
"NB: Disabled for pre-sampled data",
style={"font-style": "italic", "font-weight": "bold"}
if self._disable_dropdowns
else {"display": "none"},
),
wcc.Dropdown(
id=self.register_component_unique_id(
ResamplingFrequencySettings.Ids.RESAMPLING_FREQUENCY_DROPDOWN
),
clearable=False,
disabled=self._disable_resampling_dropdown,
disabled=self._disable_dropdowns,
options=[
{
"label": frequency.value,
Expand All @@ -59,11 +65,11 @@ def layout(self) -> List[Component]:
},
),
wcc.Dropdown(
clearable=True,
disabled=self._disable_resampling_dropdown,
id=self.register_component_unique_id(
ResamplingFrequencySettings.Ids.RELATIVE_DATE_DROPDOWN
),
clearable=True,
disabled=self._disable_dropdowns,
options=[
{
"label": datetime_utils.to_str(_date),
Expand All @@ -72,10 +78,4 @@ def layout(self) -> List[Component]:
for _date in sorted(self._ensembles_dates)
],
),
wcc.Label(
"NB: Disabled for pre-sampled data",
style={"font-style": "italic"}
if self._disable_resampling_dropdown
else {"display": "none"},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
self,
custom_vector_definitions: dict,
custom_vector_definitions_base: dict,
disable_resampling_dropdown: bool,
has_presampled_providers: bool,
initial_selected_vectors: List[str],
initial_vector_selector_data: list,
initial_visualization: VisualizationOptions,
Expand All @@ -90,15 +90,20 @@ def __init__(
column = self.add_column()
column.add_view_element(SubplotGraph(), SubplotView.Ids.SUBPLOT)

# Do not request resampling frequency for pre-sampled providers
ensemble_dates = (
[]
if has_presampled_providers
else input_provider_set.all_dates(selected_resampling_frequency)
)

self.add_settings_groups(
{
SubplotView.Ids.GROUP_BY_SETTINGS: GroupBySettings(),
SubplotView.Ids.RESAMPLING_FREQUENCY_SETTINGS: ResamplingFrequencySettings(
disable_resampling_dropdown=disable_resampling_dropdown,
disable_dropdowns=has_presampled_providers,
selected_resampling_frequency=selected_resampling_frequency,
ensembles_dates=input_provider_set.all_dates(
selected_resampling_frequency
),
ensembles_dates=ensemble_dates,
input_provider_set=input_provider_set,
),
SubplotView.Ids.ENSEMBLE_SETTINGS: EnsemblesSettings(
Expand Down Expand Up @@ -129,6 +134,7 @@ def __init__(
self._line_shape_fallback = line_shape_fallback
self._user_defined_vector_definitions = user_defined_vector_definitions
self._observations = observations
self._has_presampled_providers = has_presampled_providers

# pylint: disable=too-many-statements
def set_callbacks(self) -> None:
Expand Down Expand Up @@ -305,7 +311,7 @@ def _update_graph(

relative_date: Optional[datetime.datetime] = (
None
if relative_date_value is None
if relative_date_value is None or self._has_presampled_providers
else datetime_utils.from_str(relative_date_value)
)

Expand Down Expand Up @@ -682,7 +688,7 @@ def _user_download_data(
)
relative_date: Optional[datetime.datetime] = (
None
if relative_date_value is None
if relative_date_value is None or self._has_presampled_providers
else datetime_utils.from_str(relative_date_value)
)

Expand Down Expand Up @@ -912,6 +918,10 @@ def _update_relative_date_dropdown_and_trace_options_style(
If dates are not existing for a provider, the data accessor must handle invalid
relative date selection!
"""
# Early return when providers are pre-sampled
if self._has_presampled_providers:
return ([], None, {"display": "block"})

resampling_frequency = Frequency.from_string_value(
resampling_frequency_value
)
Expand Down

0 comments on commit ccd017b

Please sign in to comment.