Skip to content

Commit

Permalink
Allow initialization without field vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Mar 24, 2021
1 parent 0eb21a7 commit 2f8e27e
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 190 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
from typing import Callable

import dash
from dash.dependencies import Input, Output, State
import dash_table
import webviz_core_components as wcc

from ..models import ParametersModel


def parameter_qc_controller(parent, app):
def parameter_qc_controller(
app: dash.Dash, get_uuid: Callable, parametermodel: ParametersModel
):
@app.callback(
Output(parent.uuid("property-qc-wrapper"), "children"),
Input({"id": parent.uuid("ensemble-selector"), "tab": "qc"}, "value"),
Input({"id": parent.uuid("delta-ensemble-selector"), "tab": "qc"}, "value"),
Output(get_uuid("property-qc-wrapper"), "children"),
Input({"id": get_uuid("ensemble-selector"), "tab": "qc"}, "value"),
Input({"id": get_uuid("delta-ensemble-selector"), "tab": "qc"}, "value"),
Input(
{"id": parent.uuid("filter-parameter"), "tab": "qc"},
{"id": get_uuid("filter-parameter"), "tab": "qc"},
"value",
),
Input(parent.uuid("property-qc-plot-type"), "value"),
Input(get_uuid("property-qc-plot-type"), "value"),
)
def _update_bars(ensemble, delta_ensemble, parameters, plot_type):
"""Callback to switch visualization between table and distribution plots"""
parameters = parameters if isinstance(parameters, list) else [parameters]
ensembles = [ensemble, delta_ensemble]

if plot_type == "table":
columns, dframe = parent.pmodel.make_statistics_table(
columns, dframe = parametermodel.make_statistics_table(
ensembles=ensembles, parameters=parameters
)
return dash_table.DataTable(
Expand All @@ -35,10 +42,10 @@ def _update_bars(ensemble, delta_ensemble, parameters, plot_type):
filter_action="native",
)
return wcc.Graph(
id=parent.uuid("property-qc-graph"),
id=get_uuid("property-qc-graph"),
config={"displayModeBar": False},
style={"height": "75vh"},
figure=parent.pmodel.make_grouped_plot(
figure=parametermodel.make_grouped_plot(
ensembles=ensembles,
parameters=parameters,
plot_type=plot_type,
Expand All @@ -47,28 +54,28 @@ def _update_bars(ensemble, delta_ensemble, parameters, plot_type):

@app.callback(
Output(
{"id": parent.uuid("filter-parameter"), "tab": "qc"},
{"id": get_uuid("filter-parameter"), "tab": "qc"},
"options",
),
Output(
{"id": parent.uuid("filter-parameter"), "tab": "qc"},
{"id": get_uuid("filter-parameter"), "tab": "qc"},
"value",
),
Input(parent.uuid("delta-sort"), "value"),
Input({"id": parent.uuid("ensemble-selector"), "tab": "qc"}, "value"),
Input({"id": parent.uuid("delta-ensemble-selector"), "tab": "qc"}, "value"),
Input(get_uuid("delta-sort"), "value"),
Input({"id": get_uuid("ensemble-selector"), "tab": "qc"}, "value"),
Input({"id": get_uuid("delta-ensemble-selector"), "tab": "qc"}, "value"),
State(
{"id": parent.uuid("filter-parameter"), "tab": "qc"},
{"id": get_uuid("filter-parameter"), "tab": "qc"},
"value",
),
)
def _update_parameters(sortby, ensemble, delta_ensemble, current_params):
"""Callback to sort parameters based on selection"""
parent.pmodel.sort_parameters(
parametermodel.sort_parameters(
ensemble=ensemble,
delta_ensemble=delta_ensemble,
sortby=sortby,
)
return [
{"label": i, "value": i} for i in parent.pmodel.parameters
{"label": i, "value": i} for i in parametermodel.parameters
], current_params
Loading

0 comments on commit 2f8e27e

Please sign in to comment.