Skip to content

Commit

Permalink
Prior-posterior distribution (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer authored Feb 11, 2020
1 parent 8d56bbd commit c807f1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"pillow~=6.1",
"xtgeo~=2.1",
"webviz-config>=0.0.48",
"webviz-subsurface-components>=0.0.20",
"webviz-subsurface-components>=0.0.22",
],
tests_require=TESTS_REQUIRE,
extras_require={"tests": TESTS_REQUIRE},
Expand Down
34 changes: 16 additions & 18 deletions webviz_subsurface/plugins/_parameter_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
from pathlib import Path

import pandas as pd
import plotly.express as px
import dash
from dash.exceptions import PreventUpdate
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc
import webviz_core_components as wcc
import webviz_subsurface_components as wsc
from webviz_config import WebvizPluginABC
from webviz_config.common_cache import CACHE
from webviz_config.webviz_store import webvizstore
Expand Down Expand Up @@ -128,7 +127,7 @@ def layout(self):
self.make_buttons(self.ids("prev-btn"), self.ids("next-btn")),
],
),
wcc.Graph(id=self.ids("graph")),
wsc.PriorPosteriorDistribution(id=self.ids("graph")),
],
)

Expand All @@ -154,25 +153,24 @@ def _set_parameter_from_btn(_prev_click, _next_click, column):
return column

@app.callback(
Output(self.ids("graph"), "figure"), [Input(self.ids("parameter"), "value")]
Output(self.ids("graph"), "data"), [Input(self.ids("parameter"), "value")]
)
def _set_parameter(column):
param = self.parameters[[column, "REAL", "ENSEMBLE"]]

plot = px.histogram(
param,
x=column,
y="REAL",
color="ENSEMBLE",
hover_data=["REAL"],
barmode="overlay",
nbins=10,
range_x=[param[column].min(), param[column].max()],
marginal="box",
template=self.plotly_theme,
).for_each_trace(lambda t: t.update(name=t.name.replace("ENSEMBLE=", "")))

return plot
ensembles = param["ENSEMBLE"].unique().tolist()

iterations = []
values = []
labels = []

for ensemble in ensembles:
df = param[param["ENSEMBLE"] == ensemble]
iterations.append(ensemble)
values.append(df[column].tolist())
labels.append([f"Realization {real}" for real in df["REAL"].tolist()])

return {"iterations": iterations, "values": values, "labels": labels}

def add_webvizstore(self):
return [
Expand Down

0 comments on commit c807f1e

Please sign in to comment.