Ejemplo n.º 1
0
def convergence_plot_layout(figure: go.Figure) -> wcc.Graph:
    return wcc.Graph(
        config={"displayModeBar": False},
        style={"height": "86vh"},
        figure=figure,
    )
Ejemplo n.º 2
0
 wcc.Graph(
     id="example-graph",
     figure={
         "data": [
             {
                 "x": [1, 2, 3],
                 "y": [4, 1, 2],
                 "type": "bar",
                 "name": "a",
             },
             {
                 "x": [1, 2, 3],
                 "y": [2, 4, 5],
                 "type": "bar",
                 "name": "b",
             },
             {
                 "x": [1, 2, 3],
                 "y": [1, 4, 5],
                 "type": "bar",
                 "name": "c",
             },
             {
                 "x": [1, 2, 3],
                 "y": [2, 3, 5],
                 "type": "bar",
                 "name": "d",
             },
             {
                 "x": [1, 2, 3],
                 "y": [2, 2, 5],
                 "type": "bar",
                 "name": "e",
             },
             {
                 "x": [1, 2, 3],
                 "y": [2, 4, 6],
                 "type": "bar",
                 "name": "f",
             },
             {
                 "x": [1, 2, 3],
                 "y": [2, 4, 1],
                 "type": "bar",
                 "name": "g",
             },
         ],
         "layout": {
             "title": "Dash Data Visualization",
             "height": 1200
         },
     },
 ),
        def _render_chart(
            tornado_click_data_str: Union[str, None],
            high_low_storage: dict,
            plot_type: str,
            ensemble: str,
            response: str,
            source: str,
            *filters: Union[str, List[str]],
        ) -> Tuple[Union[wcc.Graph, html.Div], str]:
            if dash.callback_context.triggered is None:
                raise PreventUpdate

            tornado_click: Union[dict, None] = (
                json.loads(tornado_click_data_str) if tornado_click_data_str else None
            )

            ctx = dash.callback_context.triggered[0]["prop_id"].split(".")[0]
            if tornado_click:
                if (
                    high_low_storage is not None
                    and ctx == self.tornadoplot.high_low_storage_id
                ):
                    # Tornado plot is updated without a click in the plot, updating reals:
                    if tornado_click["sens_name"] in high_low_storage:
                        tornado_click["real_low"] = high_low_storage[
                            tornado_click["sens_name"]
                        ].get("real_low")
                        tornado_click["real_high"] = high_low_storage[
                            tornado_click["sens_name"]
                        ].get("real_high")
                    else:
                        # fallback in a case where chosen sens_name does not exist in updated
                        # tornado plot.
                        # (can this ever occur except when sens_name already is None?)
                        tornado_click["sens_name"] = None
                        tornado_click["real_low"] = []
                        tornado_click["real_high"] = []

            # Filter data
            data = filter_dataframe(
                self.volumes, self.selectors, ensemble, source, filters
            )

            # Volume title:
            volume_title = f"{volume_description(response)} [{volume_unit(response)}]"

            # Make Plotly figure
            layout = {}
            layout.update({"height": 600, "margin": {"l": 100, "b": 100}})
            if plot_type == "Per realization":
                # One bar per realization
                layout.update(
                    {
                        "xaxis": {"title": "Realizations"},
                        "yaxis": {"title": volume_title},
                    }
                )
                plot_data = data.groupby("REAL").sum().reset_index()

                if tornado_click:
                    figure_data = [
                        {
                            "y": plot_data[
                                plot_data["REAL"].isin(tornado_click["real_low"])
                            ][response],
                            "x": plot_data[
                                plot_data["REAL"].isin(tornado_click["real_low"])
                            ]["REAL"],
                            "tickformat": ".4s",
                            "type": "bar",
                            "showlegend": False,
                            "name": "",
                        },
                        {
                            "y": plot_data[
                                plot_data["REAL"].isin(tornado_click["real_high"])
                            ][response],
                            "x": plot_data[
                                plot_data["REAL"].isin(tornado_click["real_high"])
                            ]["REAL"],
                            "tickformat": ".4s",
                            "type": "bar",
                            "showlegend": False,
                            "name": "",
                        },
                        {
                            "y": plot_data[
                                ~plot_data["REAL"].isin(
                                    tornado_click["real_low"]
                                    + tornado_click["real_high"]
                                )
                            ][response],
                            "x": plot_data[
                                ~plot_data["REAL"].isin(
                                    tornado_click["real_low"]
                                    + tornado_click["real_high"]
                                )
                            ]["REAL"],
                            "tickformat": ".4s",
                            "type": "bar",
                            "marker": {"color": "grey"},
                            "showlegend": False,
                            "name": "",
                        },
                    ]
                else:
                    figure_data = [
                        {
                            "y": plot_data[response],
                            "x": plot_data["REAL"],
                            "tickformat": ".4s",
                            "type": "bar",
                            "marker": {"color": "grey"},
                        },
                    ]
                figure = wcc.Graph(
                    config={"displayModeBar": False},
                    id=self.uuid("graph"),
                    figure={
                        "data": figure_data,
                        "layout": self.theme.create_themed_layout(layout),
                    },
                )
            elif plot_type == "Per sensitivity case":
                # One box per sensitivity name
                layout.update(
                    {
                        "title": "Distribution for each sensitivity case",
                        "yaxis": {"title": volume_title},
                    }
                )
                figure = wcc.Graph(
                    config={"displayModeBar": False},
                    id=self.uuid("graph"),
                    figure={
                        "data": [
                            {
                                "y": senscase_df.groupby("REAL")
                                .sum()
                                .reset_index()[response],
                                "name": f"{sensname} ({senscase})",
                                "type": "box",
                            }
                            for sensname, sensname_df in data.groupby(["SENSNAME"])
                            for senscase, senscase_df in sensname_df.groupby(
                                ["SENSCASE"]
                            )
                        ],
                        "layout": self.theme.create_themed_layout(layout),
                    },
                )
            elif plot_type == "Per sensitivity name":
                # One box per sensitivity name
                layout.update(
                    {
                        "title": "Distribution for each sensitivity name",
                        "yaxis": {"title": volume_title},
                    }
                )
                figure = wcc.Graph(
                    config={"displayModeBar": False},
                    id=self.uuid("graph"),
                    figure={
                        "data": [
                            {
                                "y": sensname_df.groupby("REAL")
                                .sum()
                                .reset_index()[response],
                                "name": f"{sensname}",
                                "type": "box",
                            }
                            for sensname, sensname_df in data.groupby(["SENSNAME"])
                        ],
                        "layout": self.theme.create_themed_layout(layout),
                    },
                )
            else:
                # Should not occur unless plot_type options are changed
                figure = html.Div("Invalid plot type")

            return figure, volume_title
    def _update_graph(
        ensembles: List[str],
        checklist_values: List[List[str]],
        sumvec: str,
        prod_after_date: Union[str, None],
        chart_selected: str,
        wells_selected: List[str],
        well_attr_selected: List[str],
        checklist_ids: List[Dict[str, str]],
        well_attr_ids: List[Dict[str, str]],
        current_fig_dict: dict,
    ) -> List[wcc.Graph]:
        # pylint: disable=too-many-locals
        # pylint: disable=too-many-arguments
        """Updates the well overview graph with selected input (f.ex chart type)"""
        ctx = callback_context.triggered[0]["prop_id"].split(".")[0]

        settings = {
            checklist_id["charttype"]: checklist_values[i]
            for i, checklist_id in enumerate(checklist_ids)
        }
        well_attributes_selected: Dict[str, List[str]] = {
            well_attr_id["category"]: list(well_attr_selected[i])
            for i, well_attr_id in enumerate(well_attr_ids)
        }

        # Make set of wells that match the well_attributes
        # Well attributes that does not exist in one ensemble will be ignored
        wellattr_filtered_wells: Set[str] = set()
        for _, ens_data_model in data_models.items():
            wellattr_filtered_wells = wellattr_filtered_wells.union(
                ens_data_model.filter_on_well_attributes(
                    well_attributes_selected))
        # Take the intersection with wells_selected.
        # this way preserves the order in wells_selected and will not have duplicates
        filtered_wells = [
            well for well in wells_selected if well in wellattr_filtered_wells
        ]

        # If the event is a plot settings event, then we only update the formatting
        # and not the figure data
        chart_selected_type = ChartType(chart_selected)
        if current_fig_dict is not None and is_plot_settings_event(
                ctx, get_uuid):
            fig_dict = format_well_overview_figure(
                go.Figure(current_fig_dict),
                chart_selected_type,
                settings[chart_selected_type.value],
                sumvec,
                prod_after_date,
            )
        else:
            figure = WellOverviewFigure(
                ensembles,
                data_models,
                sumvec,
                datetime.datetime.strptime(prod_after_date, "%Y-%m-%d")
                if prod_after_date is not None else None,
                chart_selected_type,
                filtered_wells,
                theme,
            )

            fig_dict = format_well_overview_figure(
                figure.figure,
                chart_selected_type,
                settings[chart_selected_type.value],
                sumvec,
                prod_after_date,
            )

        return [
            wcc.Graph(
                id=get_uuid(WellOverviewLayoutElements.GRAPH),
                style={"height": "87vh"},
                figure=fig_dict,
            )
        ]
Ejemplo n.º 5
0
 def layout(self):
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             html.Div(
                 style={"flex": 1},
                 children=[
                     html.Label(children=[
                         html.Span(
                             "Ensemble:",
                             style={"font-weight": "bold"},
                         ),
                         dcc.Dropdown(
                             id=self.uuid("ensemble"),
                             options=[{
                                 "label": i,
                                 "value": i
                             } for i in self.ensembles],
                             value=self.ensembles[0],
                             multi=False,
                         ),
                     ], ),
                     html.Label(children=[
                         html.Span("Plot type:",
                                   style={"font-weight": "bold"}),
                         dcc.Dropdown(
                             id=self.uuid("plot_type"),
                             options=[{
                                 "label": i,
                                 "value": i
                             } for i in [
                                 "Fan chart",
                                 "Bar chart",
                                 "Line chart",
                             ]],
                             clearable=False,
                             value="Fan chart",
                         ),
                     ], ),
                     html.Label(
                         id=self.uuid("select_stat"),
                         style={"display": "none"},
                         children=[
                             html.Span("Select statistics:",
                                       style={"font-weight": "bold"}),
                             wcc.Select(
                                 id=self.uuid("stat_bars"),
                                 options=[{
                                     "label": key,
                                     "value": value
                                 } for key, value in self.label_map.items()
                                          ],
                                 size=8,
                                 value=["count", "low_p90", "p50"],
                             ),
                         ],
                     ),
                     html.Label(children=[
                         html.Span("Sort by:",
                                   style={"font-weight": "bold"}),
                         dcc.Dropdown(
                             id=self.uuid("sort_by"),
                             options=[{
                                 "label": key,
                                 "value": value
                             } for key, value in self.label_map.items()],
                             clearable=False,
                             value="low_p90",
                         ),
                     ], ),
                     dcc.RadioItems(
                         id=self.uuid("ascending"),
                         options=[
                             {
                                 "label": "Ascending",
                                 "value": True
                             },
                             {
                                 "label": "Descending",
                                 "value": False
                             },
                         ],
                         value=True,
                         labelStyle={"display": "inline-block"},
                     ),
                     html.Label(children=[
                         html.Span(
                             "Max number of wells in plot:",
                             style={"font-weight": "bold"},
                         ),
                         dcc.Slider(
                             id=self.uuid("n_wells"),
                             min=1,
                             max=len(self.wells),
                             value=min(10, len(self.wells)),
                             marks={
                                 1: 1,
                                 len(self.wells): len(self.wells)
                             },
                         ),
                     ]),
                     html.Label(children=[
                         html.Span("Wells:", style={"font-weight": "bold"}),
                         wcc.Select(
                             id=self.uuid("wells"),
                             options=[{
                                 "label": i,
                                 "value": i
                             } for i in self.wells],
                             size=min([len(self.wells), 20]),
                             value=self.wells,
                         ),
                     ], ),
                 ],
             ),
             html.Div(
                 style={"flex": 3},
                 children=[
                     html.Div(
                         # style={"height": "300px"},
                         children=wcc.Graph(id=self.uuid("graph")), ),
                 ],
             ),
         ],
     )
 def grid_layout(self):
     """Layout for color and other settings"""
     return html.Div(children=[
         html.Div(
             style=self.set_grid_layout("3fr 2fr"),
             children=[
                 html.Div(children=[
                     html.Label(
                         style={
                             "font-weight": "bold",
                             "textAlign": "center",
                         },
                         children="Select grid parameter",
                     ),
                     dcc.Dropdown(
                         id=self.ids("gridparameter"),
                         options=[{
                             "label": name,
                             "value": para
                         } for name, para in zip(self.gridparanames,
                                                 self.gridparafiles)],
                         value=self.gridparafiles[0],
                         clearable=False,
                     ),
                 ]),
                 html.Div(
                     style={"zIndex": 2000},
                     children=[
                         html.Label(
                             style={
                                 "font-weight": "bold",
                                 "textAlign": "center",
                             },
                             children="Set colorscale",
                         ),
                         wcc.ColorScales(
                             id=self.ids("color-scale"),
                             colorscale=self.initial_colors,
                             nSwatches=12,
                         ),
                     ],
                 ),
                 html.Div(
                     style={
                         "marginRight": "50px",
                         "marginTop": "20px",
                         "marginLeft": "50px",
                         "marginBottom": "0px",
                     },
                     children=[
                         html.Label(
                             style={
                                 "font-weight": "bold",
                                 "textAlign": "center",
                             },
                             children="Set color range",
                         ),
                         dcc.RangeSlider(
                             id=self.ids("color-values"),
                             tooltip={"always_visible": True},
                         ),
                     ],
                 ),
                 html.Button(id=self.ids("color-range-btn"),
                             children="Reset Range"),
             ],
         ),
         html.Div(
             style={"height": "800px"},
             children=wcc.Graph(config={"displayModeBar": False},
                                id=self.ids("fence-view")),
         ),
     ])
Ejemplo n.º 7
0
 def seismic_layout(self):
     """Layout for color and other settings"""
     return html.Div(children=[
         wcc.FlexBox(children=[
             html.Div(children=[
                 html.Label(
                     style={
                         "font-weight": "bold",
                         "textAlign": "center",
                     },
                     children="Select seismic cube",
                 ),
                 dcc.Dropdown(
                     id=self.ids("cube"),
                     options=[{
                         "label": Path(cube).stem,
                         "value": cube
                     } for cube in self.segyfiles],
                     value=self.segyfiles[0],
                     clearable=False,
                 ),
             ]),
             html.Div(
                 style={"zIndex": 2000},
                 children=[
                     html.Label(
                         style={
                             "font-weight": "bold",
                             "textAlign": "center",
                         },
                         children="Set colorscale",
                     ),
                     wcc.ColorScales(
                         id=self.ids("color-scale"),
                         colorscale=self.initial_colors,
                         nSwatches=12,
                     ),
                 ],
             ),
         ]),
         wcc.FlexBox(children=[
             html.Div(
                 style={
                     "marginRight": "50px",
                     "marginTop": "20px",
                     "marginBottom": "0px",
                     "flex": 1,
                 },
                 children=[
                     html.Label(
                         style={
                             "font-weight": "bold",
                             "textAlign": "center",
                         },
                         children="Set color range",
                     ),
                     dcc.RangeSlider(
                         id=self.ids("color-values"),
                         tooltip={"always_visible": True},
                     ),
                 ],
             ),
             html.Div(
                 style={"flex": 1},
                 children=html.Button(id=self.ids("color-range-btn"),
                                      children="Reset Range"),
             ),
         ], ),
         html.Div(
             style={"height": "800px"},
             children=wcc.Graph(config={"displayModeBar": False},
                                id=self.ids("fence-view")),
         ),
     ])
Ejemplo n.º 8
0
def intersection_and_map_layout(get_uuid: Callable) -> html.Div:
    """Layout for the intersection graph and maps"""
    return html.Div(children=[
        wcc.Frame(
            highlight=False,
            color="white",
            children=[
                wcc.Graph(
                    style={
                        "height": "48vh",
                        "background-color": "white"
                    },
                    id=get_uuid("intersection-graph"),
                ),
            ],
        ),
        wcc.Frame(
            id=get_uuid("maps-and-uncertainty-table-wrapper"),
            highlight=False,
            color="white",
            children=[
                wcc.FlexBox(
                    style={
                        "height": "40vh",
                        "display": "flex"
                    },
                    id=get_uuid("all-maps-wrapper"),
                    children=[
                        html.Div(
                            style={"flex": 1},
                            id=get_uuid("map-wrapper"),
                            children=map_layout(
                                uuid=get_uuid("map"),
                                leaflet_id=get_uuid("leaflet-map1"),
                                synced_uuids=[
                                    get_uuid("leaflet-map2"),
                                    get_uuid("leaflet-map3"),
                                ],
                                draw_polyline=True,
                            ),
                        ),
                        html.Div(
                            style={"flex": 1},
                            children=map_layout(
                                uuid=get_uuid("map2"),
                                leaflet_id=get_uuid("leaflet-map2"),
                                synced_uuids=[
                                    get_uuid("leaflet-map1"),
                                    get_uuid("leaflet-map3"),
                                ],
                            ),
                        ),
                        html.Div(
                            style={"flex": 1},
                            children=map_layout(
                                uuid=get_uuid("map3"),
                                leaflet_id=get_uuid("leaflet-map3"),
                                synced_uuids=[
                                    get_uuid("leaflet-map1"),
                                    get_uuid("leaflet-map2"),
                                ],
                            ),
                        ),
                    ],
                ),
            ],
        ),
    ], )
Ejemplo n.º 9
0
 def layout(self) -> wcc.FlexBox:
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             html.Div(
                 id=self.uuid("filters"),
                 style={"flex": "1"},
                 children=[
                     html.Label(
                         id=self.uuid("color_by_selector"),
                         children=[
                             html.Span("Color by:",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("color_by"),
                                 clearable=False,
                                 options=[{
                                     "label": i.lower().capitalize(),
                                     "value": i,
                                 } for i in self.color_options],
                                 value=self.color_options[0],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("ensemble_selector"),
                         children=[
                             html.Span("Ensembles:",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("ensemble"),
                                 clearable=False,
                                 multi=True,
                                 options=[{
                                     "label": i,
                                     "value": i
                                 } for i in self.ensembles],
                                 value=self.ensembles,
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("phase_selector"),
                         children=[
                             html.Span(
                                 "Phase:",
                                 style={"font-weight": "bold"},
                             ),
                             dcc.Dropdown(
                                 id=self.uuid("phase"),
                                 clearable=False,
                                 options=[{
                                     "label":
                                     f"{value.lower().capitalize()} ({info})",
                                     "value": value,
                                 } for value, info in self.phases.items()],
                                 multi=False,
                                 value=list(self.phases.keys())[0],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("pvtnum_selector"),
                         children=[
                             html.Span("Pvtnum:",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("pvtnum"),
                                 clearable=False,
                                 multi=False,
                                 options=[{
                                     "label": i,
                                     "value": i
                                 } for i in self.pvtnums],
                                 value=self.pvtnums[0],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                 ],
             ),
             html.Div(
                 id=self.uuid("graphs"),
                 style={"flex": "4"},
                 children=wcc.Graph(id=self.uuid("graph")),
             ),
             dcc.Store(id=self.uuid("init_callback"),
                       storage_type="session",
                       data=True),
         ],
     )
Ejemplo n.º 10
0
def parameter_response_view(
    get_uuid: Callable,
    parametermodel: ParametersModel,
    vectormodel: SimulationTimeSeriesModel,
    theme: WebvizConfigTheme,
) -> wcc.FlexBox:
    df = parametermodel.dataframe
    parameter_filter = ParameterFilter(
        uuid=get_uuid("parameter-filter"),
        dframe=df[df["ENSEMBLE"].isin(parametermodel.mc_ensembles)].copy(),
        reset_on_ensemble_update=True,
    )
    return wcc.FlexBox(
        children=[
            wcc.FlexColumn(
                flex=1,
                children=selector_view(
                    get_uuid=get_uuid,
                    parametermodel=parametermodel,
                    vectormodel=vectormodel,
                    theme=theme,
                ),
            ),
            wcc.FlexColumn(
                flex=4,
                children=wcc.FlexBox(
                    children=[
                        wcc.FlexColumn(
                            flex=2,
                            children=[
                                wcc.Frame(
                                    style={"height": "38.5vh"},
                                    color="white",
                                    highlight=False,
                                    children=timeseries_view(get_uuid=get_uuid),
                                ),
                                wcc.Frame(
                                    style={"height": "38.5vh"},
                                    color="white",
                                    highlight=False,
                                    children=[
                                        wcc.Graph(
                                            id=get_uuid("vector-vs-param-scatter"),
                                            config={"displayModeBar": False},
                                            style={"height": "38vh"},
                                        )
                                    ],
                                ),
                            ],
                        ),
                        wcc.FlexColumn(
                            flex=2,
                            children=[
                                wcc.Frame(
                                    color="white",
                                    highlight=False,
                                    style={"height": "38.5vh"},
                                    children=[
                                        wcc.Graph(
                                            config={"displayModeBar": False},
                                            style={"height": "38vh"},
                                            id=get_uuid("vector-corr-graph"),
                                        ),
                                    ],
                                ),
                                wcc.Frame(
                                    color="white",
                                    highlight=False,
                                    style={"height": "38.5vh"},
                                    children=[
                                        wcc.Graph(
                                            config={"displayModeBar": False},
                                            style={"height": "38vh"},
                                            id=get_uuid("param-corr-graph"),
                                        ),
                                    ],
                                ),
                            ],
                        ),
                        wcc.FlexColumn(
                            id=get_uuid("param-filter-wrapper"),
                            style={"display": "none"},
                            flex=1,
                            children=wcc.Frame(
                                style={"height": "80vh"},
                                children=parameter_filter.layout,
                            ),
                        ),
                    ],
                ),
            ),
        ],
    )
Ejemplo n.º 11
0
 def layout(self):
     return wcc.FlexBox(
         id=self.ids("layout"),
         children=[
             wcc.Frame(
                 style={"flex": 1},
                 children=[
                     wcc.Selectors(
                         label="Map settings",
                         children=[
                             wcc.Dropdown(
                                 id=self.ids("surface"),
                                 label="Select surface",
                                 options=[{
                                     "label": name,
                                     "value": path
                                 } for name, path in zip(
                                     self.surfacenames, self.surfacefiles)],
                                 value=self.surfacefiles[0],
                                 clearable=False,
                             ),
                             wcc.RadioItems(
                                 id=self.ids("surface-type"),
                                 options=[
                                     {
                                         "label": "Display surface z-value",
                                         "value": "surface",
                                     },
                                     {
                                         "label":
                                         "Display seismic attribute as z-value",
                                         "value": "attribute",
                                     },
                                 ],
                                 value="surface",
                             ),
                         ],
                     ),
                     wcc.Selectors(
                         label="Intersection settings",
                         children=[
                             wcc.Dropdown(
                                 label="Select grid parameter",
                                 id=self.ids("gridparameter"),
                                 options=[{
                                     "label": name,
                                     "value": para
                                 } for name, para in zip(
                                     self.gridparanames, self.gridparafiles)
                                          ],
                                 value=self.gridparafiles[0],
                                 clearable=False,
                             ),
                             wcc.Label(children="Set colorscale", ),
                             wcc.ColorScales(
                                 id=self.ids("color-scale"),
                                 colorscale=self.initial_colors,
                                 nSwatches=12,
                             ),
                             wcc.RangeSlider(
                                 label="Set color range",
                                 id=self.ids("color-values"),
                                 tooltip={"always_visible": False},
                             ),
                             html.Button(
                                 id=self.ids("color-range-btn"),
                                 children="Reset Range",
                             ),
                         ],
                     ),
                 ],
             ),
             wcc.Frame(
                 highlight=False,
                 style={
                     "height": "800px",
                     "flex": 3,
                 },
                 children=[
                     LeafletMap(
                         id=self.ids("map-view"),
                         autoScaleMap=True,
                         minZoom=-19,
                         updateMode="update",
                         layers=[],
                         drawTools={
                             "drawMarker": False,
                             "drawPolygon": False,
                             "drawPolyline": True,
                             "position": "topright",
                         },
                         mouseCoords={"position": "bottomright"},
                         colorBar={"position": "bottomleft"},
                         switch={
                             "value": False,
                             "disabled": False,
                             "label": "Hillshading",
                         },
                     ),
                 ],
             ),
             html.Div(
                 style={
                     "flex": 3,
                     "height": "800px"
                 },
                 children=[
                     wcc.Graph(config={"displayModeBar": False},
                               id=self.ids("fence-view")),
                 ],
             ),
         ],
     )
Ejemplo n.º 12
0
 def layout(self) -> html.Div:
     return html.Div(
         style={
             "marginLeft": "10px",
             "height": "90vh"
         },
         children=[
             html.Div(children=[
                 html.Label(
                     "Tornado Plot",
                     style={
                         "textAlign": "center",
                         "font-weight": "bold",
                     },
                 ),
                 wcc.RadioItems(
                     vertical=False,
                     id=self.ids("plot-or-table"),
                     options=[
                         {
                             "label": "Show bars",
                             "value": "bars"
                         },
                         {
                             "label": "Show table",
                             "value": "table",
                         },
                     ],
                     value="bars",
                 ),
             ], ),
             html.Div(
                 style={
                     "overflowY": "auto",
                     "height": "60vh"
                 },
                 children=[
                     html.Div(
                         id=self.ids("graph-wrapper"),
                         style={},
                         children=wcc.Graph(
                             id=self.ids("tornado-graph"),
                             config={"displayModeBar": False},
                         ),
                     ),
                     html.Div(
                         id=self.ids("table-wrapper"),
                         style={"display": "none"},
                         children=dash_table.DataTable(
                             id=self.ids("tornado-table"),
                             style_cell={
                                 "whiteSpace": "normal",
                                 "height": "auto",
                             },
                         ),
                     ),
                 ],
             ),
             html.Hr(style={"marginTop": "10px"}),
             self.settings_layout,
             dcc.Store(id=self.ids("storage"), storage_type="session"),
             dcc.Store(id=self.ids("click-store"), storage_type="session"),
             dcc.Store(id=self.ids("high-low-storage"),
                       storage_type="session"),
             dcc.Store(id=self.ids("client-height-pixels"),
                       storage_type="session"),
         ],
     )
 def layout(self):
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             # Hidden object
             dcc.Store(id=self.uuid("reset_flag")),
             # Control
             html.Div(
                 id=self.uuid("control"),
                 style={"flex": "1"},
                 children=[
                     html.Label(
                         id=self.uuid("x_axis_selector"),
                         style={
                             "display":
                             "block" if self.plot_profile else "none"
                         },
                         children=[
                             html.Span("X-axis",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("x_axis"),
                                 clearable=False,
                                 options=self.keywords_options,
                                 value=self.x_axis,
                                 optionHeight=60,
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("y_axis_selector"),
                         style={
                             "display":
                             "block" if self.plot_profile else "none"
                         },
                         children=[
                             html.Span("Y-axis",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("y_axis"),
                                 multi=True,
                                 options=self.keywords_options,
                                 value=self.y_axis,
                                 optionHeight=60,
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("satnum_selector"),
                         style={
                             "display":
                             "block" if self.plot_krpc else "none"
                         },
                         children=[
                             html.Span("SATNUM",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("satnum"),
                                 clearable=False,
                                 options=[{
                                     "label": f"{val}",
                                     "value": val
                                 } for val in self.satnum_list],
                                 value=self.satnum_list[0],
                                 disabled=len(self.satnum_list) == 1,
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("fluid_selector"),
                         style={
                             "display":
                             "block" if self.plot_krpc else "none"
                         },
                         children=[
                             html.Span("Type",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("type"),
                                 options=[{
                                     "label": val,
                                     "value": val
                                 } for val in self.table_type],
                                 value=self.table_type[0],
                                 clearable=False,
                                 disabled=len(self.table_type) == 1,
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("visc1_input"),
                         style={
                             "display":
                             "block" if self.plot_krpc else "none"
                         },
                         children=[
                             html.Span("Water/Gas Viscosity",
                                       style={"font-weight": "bold"}),
                             dcc.Input(
                                 id=self.uuid("visc1"),
                                 style={"width": "97%"},
                                 value=1.0,
                                 type="number",
                                 debounce=True,
                                 placeholder="Water/Gas viscosity",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("visc2_input"),
                         style={
                             "display":
                             "block" if self.plot_krpc else "none"
                         },
                         children=[
                             html.Span("Oil Viscosity",
                                       style={"font-weight": "bold"}),
                             dcc.Input(
                                 id=self.uuid("visc2"),
                                 style={"width": "97%"},
                                 value=1.0,
                                 type="number",
                                 debounce=True,
                                 placeholder="Oil Viscosity",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("axis_selector"),
                         style={
                             "display":
                             "block" if self.plot_krpc else "none"
                         },
                         children=[
                             html.Span("Rel. Perm Plot",
                                       style={"font-weight": "bold"}),
                             dcc.RadioItems(
                                 id=self.uuid("axis"),
                                 options=[
                                     {
                                         "label": "Linear",
                                         "value": "linear",
                                     },
                                     {
                                         "label": "Semi-Log",
                                         "value": "log",
                                     },
                                 ],
                                 value="linear",
                                 labelStyle={"display": "inline-block"},
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("opacity_selector"),
                         style={
                             "display":
                             "block" if self.plot_ensembles else "none"
                         },
                         children=[
                             html.Span("Opacity",
                                       style={"font-weight": "bold"}),
                             dcc.Slider(
                                 id=self.uuid("opacity"),
                                 min=0.0,
                                 max=1.0,
                                 value=0.3,
                                 step=0.1,
                                 marks={
                                     val: {
                                         "label": f"{val:.1f}"
                                     }
                                     for val in [x * 0.2 for x in range(6)]
                                 },
                             ),
                         ],
                     ),
                     html.Button("Clear selected", id=self.uuid("reset")),
                 ],
             ),
             # Figures
             html.Div(
                 id=self.uuid("plot"),
                 style={"flex": "4"},
                 children=[wcc.Graph(id=self.uuid("figure"))],
             ),
         ],
     )
Ejemplo n.º 14
0
def property_delta_view(parent: "PropertyStatistics") -> wcc.FlexBox:
    table_surf_options = [{"label": "Table view", "value": "table"}]
    if parent.surface_folders is not None:
        table_surf_options.append({
            "label": "Surface view (click on bar in chart)",
            "value": "surface"
        })
    return wcc.FlexBox(
        style={"margin": "20px"},
        children=[
            html.Div(style={"flex": 1}, children=selector_view(parent=parent)),
            html.Div(
                style={
                    "flex": 4,
                    "height": "80vh"
                },
                className="framed",
                children=[
                    dcc.RadioItems(
                        id=parent.uuid("delta-sort"),
                        options=[
                            {
                                "label": "Sort by Average",
                                "value": "Avg"
                            },
                            {
                                "label": "Sort by Standard Deviation",
                                "value": "Stddev"
                            },
                        ],
                        value="Avg",
                        labelStyle={
                            "display": "inline-block",
                            "margin": "5px",
                        },
                        persistence=True,
                        persistence_type="session",
                    ),
                    wcc.Graph(
                        id=parent.uuid("delta-bar-graph"),
                        config={"displayModeBar": False},
                        style={"height": "75vh"},
                    ),
                ],
            ),
            html.Div(
                style={
                    "flex": 4,
                    "height": "80vh"
                },
                className="framed",
                children=[
                    dcc.RadioItems(
                        id=parent.uuid("delta-switch-table-surface"),
                        options=table_surf_options,
                        value="table",
                        labelStyle={
                            "display": "inline-block",
                            "margin": "5px",
                        },
                        persistence=True,
                        persistence_type="session",
                    ),
                    html.Div(id=parent.uuid("delta-table-surface-wrapper")),
                ],
            ),
        ],
    )
Ejemplo n.º 15
0
 def cross_section_graph_layout(self) -> html.Div:
     return html.Div(children=[wcc.Graph(id=self.ids("xsec-view"), )])
Ejemplo n.º 16
0
def create_graph(
    data_frame: pd.DataFrame,
    color_by: str,
    colors: Dict[str, List[str]],
    phase: str,
    plot: str,
    plot_title: str,
    theme: dict,
) -> html.Div:
    return html.Div(
        style={
            "min-width": "500px",
            "min-height": "400px",
            "text-align": "center",
            "padding": "2%",
            "flex": "1 1 46%",
        },
        children=([
            html.Span(plot_title, style={"font-weight": "bold"}),
            wcc.Graph(
                figure={
                    "layout":
                    plot_layout(
                        color_by,
                        theme,
                        fr"Pressure [{data_frame['PRESSURE_UNIT'].iloc[0]}]",
                        fr"[{data_frame['VOLUMEFACTOR_UNIT'].iloc[0]}]",
                    ),
                    "data":
                    create_traces(
                        data_frame,
                        color_by,
                        colors,
                        phase,
                        "VOLUMEFACTOR",
                        True,
                        True,
                    ),
                }),
        ] if plot == "fvf" else [
            html.Span(plot_title, style={"font-weight": "bold"}),
            wcc.Graph(
                figure={
                    "layout":
                    plot_layout(
                        color_by,
                        theme,
                        fr"Pressure [{data_frame['PRESSURE_UNIT'].iloc[0]}]",
                        fr"[{data_frame['VISCOSITY_UNIT'].iloc[0]}]",
                    ),
                    "data":
                    create_traces(
                        data_frame,
                        color_by,
                        colors,
                        phase,
                        "VISCOSITY",
                        True,
                        True,
                    ),
                }),
        ] if plot == "viscosity" else [
            html.Span(plot_title, style={"font-weight": "bold"}),
            wcc.Graph(
                figure={
                    "layout":
                    plot_layout(
                        color_by,
                        theme,
                        fr"Pressure [{data_frame['PRESSURE_UNIT'].iloc[0]}]",
                        fr"[{data_frame['DENSITY_UNIT'].iloc[0]}]",
                    ),
                    "data":
                    create_traces(
                        data_frame,
                        color_by,
                        colors,
                        phase,
                        "DENSITY",
                        True,
                        True,
                    ),
                }),
        ] if plot == "density" else [
            html.Span(plot_title, style={"font-weight": "bold"}),
            wcc.Graph(
                figure={
                    "layout":
                    plot_layout(
                        color_by,
                        theme,
                        fr"Pressure [{data_frame['PRESSURE_UNIT'].iloc[0]}]",
                        fr"[{data_frame['RATIO_UNIT'].iloc[0]}]",
                    ),
                    "data":
                    create_traces(
                        data_frame,
                        color_by,
                        colors,
                        phase,
                        "RATIO",
                        False,
                        True,
                        True,
                    ),
                }),
        ] if plot == "ratio" else []),
    )
Ejemplo n.º 17
0
def main_layout(
    get_uuid: Callable,
    ensemble_names: List[str],
    vector_selector_data: list,
    vector_calculator_data: list,
    predefined_expressions: List[ExpressionInfo],
    custom_vector_definitions: dict,
    realizations: List[int],
    disable_resampling_dropdown: bool,
    selected_resampling_frequency: Frequency,
    selected_visualization: VisualizationOptions,
    ensembles_dates: List[datetime.datetime],
    selected_vectors: Optional[List[str]] = None,
) -> html.Div:
    return wcc.FlexBox(
        id=get_uuid(LayoutElements.TOUR_STEP_MAIN_LAYOUT),
        children=[
            # Settings layout
            wcc.FlexColumn(
                id=get_uuid(LayoutElements.TOUR_STEP_SETTINGS_LAYOUT),
                children=wcc.Frame(
                    style={"height": "90vh"},
                    children=__settings_layout(
                        get_uuid=get_uuid,
                        ensembles=ensemble_names,
                        vector_selector_data=vector_selector_data,
                        vector_calculator_data=vector_calculator_data,
                        predefined_expressions=predefined_expressions,
                        custom_vector_definitions=custom_vector_definitions,
                        realizations=realizations,
                        disable_resampling_dropdown=disable_resampling_dropdown,
                        selected_resampling_frequency=selected_resampling_frequency,
                        selected_visualization=selected_visualization,
                        selected_vectors=selected_vectors,
                        ensembles_dates=ensembles_dates,
                    ),
                ),
            ),
            # Graph layout
            wcc.FlexColumn(
                flex=4,
                children=[
                    wcc.Frame(
                        style={"height": "90vh"},
                        highlight=False,
                        color="white",
                        children=[
                            wcc.Graph(
                                style={"height": "85vh"},
                                id=get_uuid(LayoutElements.GRAPH),
                            ),
                            dcc.Store(
                                # NOTE:Used to trigger graph update callback if data has
                                # changed, i.e. no change of regular INPUT html-elements
                                id=get_uuid(
                                    LayoutElements.GRAPH_DATA_HAS_CHANGED_TRIGGER
                                ),
                                data=0,
                            ),
                        ],
                    )
                ],
            ),
        ],
    )
Ejemplo n.º 18
0
 def layout(self) -> wcc.FlexBox:
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             wcc.Frame(
                 style={
                     "flex": 1,
                     "height": "45vh"
                 },
                 children=[
                     wcc.Dropdown(
                         label="Ensemble",
                         id=self.uuid("ensemble"),
                         options=[{
                             "label": i,
                             "value": i
                         } for i in self.ensembles],
                         value=self.ensembles[0],
                         clearable=False,
                         multi=False,
                     ),
                     wcc.Dropdown(
                         label="Plot type",
                         id=self.uuid("plot_type"),
                         options=[{
                             "label": i,
                             "value": i
                         } for i in [
                             "Fan chart",
                             "Bar chart",
                             "Line chart",
                         ]],
                         clearable=False,
                         value="Fan chart",
                     ),
                     html.Div(
                         id=self.uuid("select_stat"),
                         style={"display": "none"},
                         children=[
                             wcc.SelectWithLabel(
                                 label="Select statistics",
                                 id=self.uuid("stat_bars"),
                                 options=[{
                                     "label": key,
                                     "value": value
                                 } for key, value in self.label_map.items()
                                          ],
                                 size=8,
                                 value=["count", "low_p90", "p50"],
                             ),
                         ],
                     ),
                     wcc.Dropdown(
                         label="Sort by",
                         id=self.uuid("sort_by"),
                         options=[{
                             "label": key,
                             "value": value
                         } for key, value in self.label_map.items()],
                         clearable=False,
                         value="low_p90",
                     ),
                     wcc.RadioItems(
                         vertical=False,
                         id=self.uuid("ascending"),
                         options=[
                             {
                                 "label": "Ascending",
                                 "value": True
                             },
                             {
                                 "label": "Descending",
                                 "value": False
                             },
                         ],
                         value=True,
                         labelStyle={"display": "inline-block"},
                     ),
                     wcc.Slider(
                         label="Max number of wells in plot",
                         id=self.uuid("n_wells"),
                         min=1,
                         max=len(self.wells),
                         step=1,
                         value=min(10, len(self.wells)),
                         marks={
                             1: 1,
                             len(self.wells): len(self.wells)
                         },
                     ),
                     wcc.SelectWithLabel(
                         label="Wells",
                         id=self.uuid("wells"),
                         options=[{
                             "label": i,
                             "value": i
                         } for i in self.wells],
                         size=min([len(self.wells), 20]),
                         value=self.wells,
                     ),
                 ],
             ),
             wcc.Frame(
                 color="white",
                 highlight=False,
                 style={
                     "flex": 6,
                     "height": "45vh"
                 },
                 children=[
                     wcc.Graph(id=self.uuid("graph")),
                 ],
             ),
         ],
     )
 def layout(self):
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             html.Div(
                 id=self.uuid("filters"),
                 style={"flex": "1"},
                 children=[
                     html.Label(
                         id=self.uuid("sataxis_selector"),
                         children=[
                             html.Span(
                                 "Saturation axis:",
                                 style={"font-weight": "bold"},
                             ),
                             dcc.Dropdown(
                                 id=self.uuid("sataxis"),
                                 clearable=False,
                                 options=[
                                     {
                                         "label": i.lower().capitalize(),
                                         "value": i,
                                     }
                                     for i in self.sat_axes
                                 ],
                                 value=self.sat_axes[0],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("color_by_selector"),
                         children=[
                             html.Span("Color by:", style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("color_by"),
                                 clearable=False,
                                 options=[
                                     {
                                         "label": i.lower().capitalize(),
                                         "value": i,
                                     }
                                     for i in self.color_options
                                 ],
                                 value=self.color_options[0],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("ensemble_selector"),
                         children=[
                             dcc.Store(
                                 id=self.uuid("stored_ensemble"),
                                 storage_type="session",
                                 data={},
                             ),
                             html.Span("Ensembles:", style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("ensemble"),
                                 clearable=False,
                                 multi=True,
                                 options=[
                                     {"label": i, "value": i} for i in self.ensembles
                                 ],
                                 value=self.ensembles[0],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("curve_selector"),
                         children=[
                             html.Span("Curves:", style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("curve"),
                                 clearable=False,
                                 multi=True,
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     dcc.Store(
                         id=self.uuid("stored_satnum"),
                         storage_type="session",
                         data={},
                     ),
                     html.Label(
                         id=self.uuid("satnum_selector"),
                         children=[
                             html.Span("Satnum:", style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 id=self.uuid("satnum"),
                                 clearable=False,
                                 multi=True,
                                 options=[
                                     {"label": i, "value": i} for i in self.satnums
                                 ],
                                 value=self.satnums[0],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("visualization_selector"),
                         children=[
                             html.Span(
                                 "Visualization:", style={"font-weight": "bold"}
                             ),
                             dcc.RadioItems(
                                 id=self.uuid("visualization"),
                                 options=[
                                     {
                                         "label": "Individual realizations",
                                         "value": "realizations",
                                     },
                                     {
                                         "label": "Statistical fanchart",
                                         "value": "statistics",
                                     },
                                 ],
                                 value="statistics",
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         id=self.uuid("linlog_selector"),
                         children=[
                             html.Span("Y-axis:", style={"font-weight": "bold"}),
                             dcc.RadioItems(
                                 id=self.uuid("linlog"),
                                 options=[
                                     {
                                         "label": "Linear",
                                         "value": "linear",
                                     },
                                     {
                                         "label": "Log",
                                         "value": "log",
                                     },
                                 ],
                                 value="linear",
                                 labelStyle={"display": "inline-block"},
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                     html.Label(
                         style={"display": "block"}
                         if self.scal is not None
                         else {"display": "none"},
                         id=self.uuid("scal_selector"),
                         children=[
                             html.Span(
                                 "SCAL recommendation:",
                                 style={"font-weight": "bold"},
                             ),
                             dcc.Checklist(
                                 id=self.uuid("scal"),
                                 options=[
                                     {
                                         "label": "Show SCAL",
                                         "value": "show_scal",
                                     },
                                 ],
                                 value=["show_scal"]
                                 if self.scal is not None
                                 else [],
                                 persistence=True,
                                 persistence_type="session",
                             ),
                         ],
                     ),
                 ],
             ),
             html.Div(
                 style={"flex": "4"}, children=wcc.Graph(id=self.uuid("graph"))
             ),
         ],
     )
Ejemplo n.º 20
0
        def _update_graph(input_filter_obs, input_filter_param, choiceplot):
            """Renders KS matrix (how much a parameter is changed from prior to posterior"""
            active_info = read_csv(
                get_path(self.input_dir / "active_obs_info.csv"), index_col=0
            )
            joint_ks = read_csv(
                get_path(self.input_dir / "ks.csv"), index_col=0
            ).replace(np.nan, 0.0)
            input_filter_obs = _set_inputfilter(input_filter_obs)
            input_filter_param = _set_inputfilter(input_filter_param)

            listtoplot = _get_listtoplot(joint_ks, choiceplot)
            joint_ks_sorted = joint_ks.filter(items=listtoplot).sort_index(axis=1)
            xx_data = list(
                joint_ks_sorted.filter(like=input_filter_obs, axis=1).columns
            )
            yy_data = list(
                joint_ks_sorted.filter(like=input_filter_param, axis=0).index
            )
            zz_data = _get_zzdata(joint_ks_sorted, yy_data, xx_data, active_info)

            if not xx_data or not yy_data:
                raise PreventUpdate

            yall_obs_data = list(
                joint_ks_sorted.filter(like=input_filter_param, axis=0).index
            )
            zall_obs_data = joint_ks.loc[yall_obs_data, ["All_obs"]].to_numpy()

            return wcc.Graph(
                id=self.uuid("heatmap_id"),
                figure={
                    "data": [
                        go.Heatmap(
                            x=xx_data,
                            y=yy_data,
                            z=zz_data,
                            type="heatmap",
                            colorscale="YlGnBu",
                            zmin=0,
                            zmax=1,
                            hoverinfo="text",
                            text=_hovertext_list(
                                xx_data, yy_data, zz_data, active_info
                            ),
                        ),
                        go.Heatmap(
                            x=["All_obs"],
                            y=yall_obs_data,
                            z=zall_obs_data,
                            type="heatmap",
                            colorscale="YlGnBu",
                            zmin=0,
                            zmax=1,
                            hoverinfo="text",
                            text=_hovertext_list(
                                ["All_obs"], yall_obs_data, zall_obs_data, active_info
                            ),
                            xaxis="x2",
                        ),
                    ],
                    "layout": self.theme.create_themed_layout(
                        {
                            "title": "KS Matrix (degree of parameter change prior to posterior)",
                            "xaxis": {
                                "title": "Observations",
                                "ticks": "",
                                "domain": [0.0, 0.9],
                                "showticklabels": True,
                                "tickangle": 30,
                                "automargin": True,
                            },
                            "yaxis": {
                                "title": "Parameters",
                                "ticks": "",
                                "showticklabels": True,
                                "tickangle": -30,
                                "automargin": True,
                            },
                            "xaxis2": {"ticks": "", "domain": [0.95, 1.0]},
                            "plot_bgcolor": "grey",
                        }
                    ),
                },
                style={"height": 750},
                clickData={"points": [{"x": xx_data[0], "y": yy_data[0]}]},
            )
 def layout(self):
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             html.Div(
                 style={"flex": 1},
                 children=[
                     self.delta_layout,
                     html.Div(
                         id=self.uuid("vectors"),
                         style={"marginTop": "25px"},
                         children=[
                             html.Span("Time series:",
                                       style={"font-weight": "bold"}),
                             dcc.Dropdown(
                                 style={
                                     "marginTop": "5px",
                                     "marginBottom": "5px",
                                     "fontSize": ".95em",
                                 },
                                 optionHeight=55,
                                 id=self.uuid("vector1"),
                                 clearable=False,
                                 multi=False,
                                 options=self.dropdown_options,
                                 value=self.plot_options.get(
                                     "vector1", self.smry_cols[0]),
                             ),
                             dcc.Dropdown(
                                 style={
                                     "marginBottom": "5px",
                                     "fontSize": ".95em"
                                 },
                                 optionHeight=55,
                                 id=self.uuid("vector2"),
                                 clearable=True,
                                 multi=False,
                                 placeholder="Add additional series",
                                 options=self.dropdown_options,
                                 value=self.plot_options.get(
                                     "vector2", None),
                             ),
                             dcc.Dropdown(
                                 style={"fontSize": ".95em"},
                                 optionHeight=55,
                                 id=self.uuid("vector3"),
                                 clearable=True,
                                 multi=False,
                                 placeholder="Add additional series",
                                 options=self.dropdown_options,
                                 value=self.plot_options.get(
                                     "vector3", None),
                             ),
                         ],
                     ),
                     html.Div(
                         id=self.uuid("visualization"),
                         style={"marginTop": "25px"},
                         children=[
                             html.Span("Visualization:",
                                       style={"font-weight": "bold"}),
                             dcc.RadioItems(
                                 id=self.uuid("statistics"),
                                 options=[
                                     {
                                         "label": "Individual realizations",
                                         "value": "realizations",
                                     },
                                     {
                                         "label": "Statistical fanchart",
                                         "value": "statistics",
                                     },
                                     {
                                         "label":
                                         "Statistical fanchart and histogram",
                                         "value": "statistics_hist",
                                     },
                                 ],
                                 value=self.plot_options.get(
                                     "visualization", "statistics"),
                             ),
                         ],
                     ),
                 ],
             ),
             html.Div(
                 style={"flex": 3},
                 children=[
                     html.Div(
                         style={"height": "300px"},
                         children=wcc.Graph(id=self.uuid("graph"), ),
                     ),
                     dcc.Store(
                         id=self.uuid("date"),
                         data=json.dumps(self.plot_options.get(
                             "date", None)),
                     ),
                 ],
             ),
         ],
     )
Ejemplo n.º 22
0
        def _display_click_data(celldata, hist_display):
            """render a histogram of parameters distribution prior/posterior or
            an average delta map prior-posterior."""
            obs = celldata["points"][0]["x"]
            param = celldata["points"][0]["y"]
            active_info = read_csv(
                get_path(self.input_dir / "active_obs_info.csv"), index_col=0
            )
            if "FIELD" in param:
                fieldparam = param.replace("FIELD_", "")
                mygrid_ok_short = read_csv(
                    get_path(
                        Path(str(self.input_dir).replace("scalar_", "field_"))
                        / f"delta_field{fieldparam}.csv"
                    )
                )
                maxinput = mygrid_ok_short.filter(like="Mean_").max(axis=1)
                deltadata = "Mean_D_" + obs
                return wcc.Graph(
                    id="2Dmap_avgdelta",
                    figure=px.scatter(
                        mygrid_ok_short,
                        x="X_UTME",
                        y="Y_UTMN",
                        color=deltadata,
                        range_color=[0, maxinput.max()],
                        color_continuous_scale="Rainbow",
                        opacity=0.9,
                        title=f"Mean_delta_posterior-prior {obs}, {param}",
                        hover_data=[
                            "X_UTME",
                            "Y_UTMN",
                            "Z_TVDSS",
                            "IX",
                            "JY",
                            deltadata,
                        ],
                        height=750,
                    ),
                )
            post_df = read_csv(get_path(self.input_dir / f"{obs}.csv"))
            prior_df = read_csv(get_path(self.input_dir / "prior.csv"))
            if "TRANS" in hist_display:
                paraml = [ele for ele in prior_df.keys() if f"_{param}" in ele]
                if paraml != []:
                    param = paraml[0]
            fig = go.Figure()
            fig.add_trace(go.Histogram(x=prior_df[param], name="prior", nbinsx=10))
            fig.add_trace(go.Histogram(x=post_df[param], name="update", nbinsx=10))
            fig.update_layout(
                self.theme.create_themed_layout(
                    {
                        "title": (
                            "Parameter distribution for observation "
                            f"{obs} ({active_info.at['ratio', obs]})"
                        ),
                        "bargap": 0.2,
                        "bargroupgap": 0.1,
                        "xaxis": {"title": param},
                    }
                )
            )

            return wcc.Graph(id="lineplots", style={"height": 750}, figure=fig)
Ejemplo n.º 23
0
def update_crossplot(df: pd.DataFrame, sizeby: str, colorby: str) -> List[wcc.Graph]:

    sim_range = find_sim_range(df)
    sizeref, cmin, cmax = size_color_settings(df, sizeby, colorby)

    figures = []

    for _ens, ensdf in df.groupby("ENSEMBLE"):

        dframe = (
            ensdf.groupby(["WELL", "DATE", "ZONE", "TVD"]).mean().reset_index().copy()
        )
        trace = {
            "x": dframe["OBSERVED"],
            "y": dframe["SIMULATED"],
            "type": "scatter",
            "mode": "markers",
            "hovertext": [
                f"Well: {well}"
                f"<br>Zone: {zone}"
                f"<br>Pressure observation: {obs:.2f}"
                f"<br>Mean simulated pressure: {pressure:.2f}"
                f"<br>Mean misfit: {misfit:.2f}"
                f"<br>Stddev pressure: {stddev:.2f}"
                for well, zone, obs, stddev, misfit, pressure in zip(
                    dframe["WELL"],
                    dframe["ZONE"],
                    dframe["OBSERVED"],
                    dframe["STDDEV"],
                    dframe["DIFF"],
                    dframe["SIMULATED"],
                )
            ],
            "hoverinfo": "text",
            "marker": {
                "size": dframe[sizeby],
                "sizeref": 2.0 * sizeref / (30.0**2),
                "sizemode": "area",
                "sizemin": 6,
                "color": dframe[colorby],
                "cmin": cmin,
                "cmax": cmax,
                "colorscale": [[0, "#2584DE"], [1, "#E50000"]],
                "colorbar": {"x": 1.05},
                "showscale": True,
            },
        }

        layout = {
            "height": 400,
            "title": {
                "text": _ens,
                "y": 0.95,
                "x": 0.15,
                "xanchor": "center",
                "yanchor": "top",
            },
            "margin": {"l": 100, "r": 0, "b": 50, "t": 30},
            "showlegend": False,
            "xaxis": {
                "range": sim_range,
                "title": "Pressure Observation",
                "showticklabels": True,
            },
            "yaxis": {"range": sim_range, "title": "Simulated mean pressure"},
            "shapes": [
                {
                    "type": "line",
                    "x0": sim_range[0],
                    "y0": sim_range[0],
                    "x1": sim_range[1],
                    "y1": sim_range[1],
                    "line": {
                        "color": "#007079",
                        "width": 2,
                    },
                }
            ],
        }

        figures.append(wcc.Graph(figure={"data": [trace], "layout": layout}))
    return figures
Ejemplo n.º 24
0
 def layout(self):
     return html.Div([
         html.Div(
             style={"marginLeft": "10px"},
             children=[
                 html.Label(
                     "Tornado Plot",
                     style={
                         "textAlign": "center",
                         "font-weight": "bold"
                     },
                 ),
                 html.Div(
                     style=self.set_grid_layout("1fr 1fr"),
                     children=[
                         html.Label("Reference:"),
                         html.Label("Scale:"),
                     ],
                 ),
                 html.Div(
                     style=self.set_grid_layout("1fr 1fr"),
                     children=[
                         dcc.Dropdown(
                             id=self.ids("reference"),
                             options=[{
                                 "label": r,
                                 "value": r
                             } for r in self.sensnames],
                             value=self.initial_reference,
                             clearable=False,
                             persistence=True,
                             persistence_type="session",
                         ),
                         dcc.Dropdown(
                             id=self.ids("scale"),
                             options=[{
                                 "label": r,
                                 "value": r
                             } for r in ["Percentage", "Absolute"]],
                             value="Percentage",
                             clearable=False,
                             persistence=True,
                             persistence_type="session",
                         ),
                     ],
                 ),
                 dcc.Checklist(
                     id=self.ids("cut-by-ref"),
                     options=[
                         {
                             "label": "Cut by reference",
                             "value": "Cut by reference",
                         },
                     ],
                     value=[],
                     persistence=True,
                     persistence_type="session",
                 ),
                 html.Details(
                     open=False,
                     children=[
                         html.Summary("Filter"),
                         wcc.Select(
                             id=self.ids("sens_filter"),
                             options=[{
                                 "label": i,
                                 "value": i
                             } for i in self.sensnames],
                             value=self.sensnames,
                             multi=True,
                             size=min(10, len(self.sensnames)),
                             persistence=True,
                             persistence_type="session",
                         ),
                     ],
                 ),
                 html.Button(
                     style={
                         "position": "relative",
                         "top": "-50%",
                         "fontSize": "10px",
                     },
                     id=self.ids("reset"),
                     children="Clear selected",
                 ),
                 wcc.Graph(
                     id=self.ids("tornado-graph"),
                     config={"displayModeBar": False},
                 ),
                 dcc.Store(id=self.ids("storage"), storage_type="session"),
                 dcc.Store(id=self.ids("click-store"),
                           storage_type="session"),
                 dcc.Store(id=self.ids("high-low-storage"),
                           storage_type="session"),
             ],
         )
     ])
def parameter_response_view(
    get_uuid: Callable,
    parametermodel: ParametersModel,
    parameterfilter_layout: html.Div,
    vectormodel: SimulationTimeSeriesModel,
    theme: WebvizConfigTheme,
) -> wcc.FlexBox:
    return wcc.FlexBox(children=[
        wcc.FlexColumn(
            flex=1,
            children=selector_view(
                get_uuid=get_uuid,
                parametermodel=parametermodel,
                vectormodel=vectormodel,
                theme=theme,
            ),
        ),
        wcc.FlexColumn(
            flex=4,
            children=wcc.FlexBox(children=[
                wcc.FlexColumn(
                    flex=2,
                    children=[
                        wcc.Frame(
                            style={"height": "38.5vh"},
                            color="white",
                            highlight=False,
                            children=timeseries_view(get_uuid=get_uuid),
                        ),
                        wcc.Frame(
                            style={"height": "38.5vh"},
                            color="white",
                            highlight=False,
                            children=[
                                wcc.Graph(
                                    id=get_uuid("vector-vs-param-scatter"),
                                    config={"displayModeBar": False},
                                    style={"height": "38vh"},
                                )
                            ],
                        ),
                    ],
                ),
                wcc.FlexColumn(
                    flex=2,
                    children=[
                        wcc.Frame(
                            color="white",
                            highlight=False,
                            style={"height": "38.5vh"},
                            children=[
                                wcc.Graph(
                                    config={"displayModeBar": False},
                                    style={"height": "38vh"},
                                    id=get_uuid("vector-corr-graph"),
                                ),
                            ],
                        ),
                        wcc.Frame(
                            color="white",
                            highlight=False,
                            style={"height": "38.5vh"},
                            children=[
                                wcc.Graph(
                                    config={"displayModeBar": False},
                                    style={"height": "38vh"},
                                    id=get_uuid("param-corr-graph"),
                                ),
                            ],
                        ),
                    ],
                ),
                wcc.FlexColumn(
                    id=get_uuid("param-filter-wrapper"),
                    style={"display": "none"},
                    flex=1,
                    children=wcc.Frame(
                        style={"height": "80vh"},
                        children=parameterfilter_layout,
                    ),
                ),
            ], ),
        ),
    ], )
Ejemplo n.º 26
0
    def layout(self):

        tabs_styles = {"height": "44px", "width": "100%"}
        tab_style = {
            "borderBottom": "1px solid #d6d6d6",
            "padding": "6px",
            "fontWeight": "bold",
        }

        tab_selected_style = {
            "borderTop": "1px solid #d6d6d6",
            "borderBottom": "1px solid #d6d6d6",
            "backgroundColor": "#007079",
            "color": "white",
            "padding": "6px",
        }

        return dcc.Tabs(
            style=tabs_styles,
            children=[
                dcc.Tab(
                    label="RFT Map",
                    style=tab_style,
                    selected_style=tab_selected_style,
                    children=[
                        html.Div(children=[
                            wcc.FlexBox(children=[
                                html.Div(
                                    style={"flex": 1},
                                    children=self.map_plot_selectors,
                                ),
                                html.Div(
                                    style={"flex": 1},
                                    children=self.formation_plot_selectors,
                                ),
                            ]),
                            wcc.FlexBox(children=[
                                wcc.Graph(
                                    style={"flex": 1},
                                    id=self.uuid("map"),
                                ),
                                wcc.Graph(
                                    style={"flex": 1},
                                    id=self.uuid("graph"),
                                    figure={
                                        "layout": {
                                            "height": 800,
                                            "margin": {
                                                "t": 50
                                            },
                                            "xaxis": {
                                                "showgrid": False
                                            },
                                            "yaxis": {
                                                "showgrid": False
                                            },
                                        }
                                    },
                                ),
                            ]),
                        ])
                    ],
                ),
                dcc.Tab(
                    label="RFT misfit per real",
                    style=tab_style,
                    selected_style=tab_selected_style,
                    children=[
                        wcc.FlexBox(children=[
                            html.Div(
                                style={"flex": 1},
                                children=self.filter_layout("misfitplot"),
                            ),
                            html.Div(
                                style={"flex": 4},
                                id=self.uuid("misfit-graph-wrapper"),
                            ),
                        ])
                    ],
                ),
                dcc.Tab(
                    label="RFT crossplot - sim vs obs",
                    style=tab_style,
                    selected_style=tab_selected_style,
                    children=[
                        wcc.FlexBox(children=[
                            html.Div(
                                style={"flex": 1},
                                children=self.filter_layout("crossplot") +
                                self.size_color_layout(),
                            ),
                            html.Div(
                                style={"flex": 4},
                                children=[
                                    html.Div(id=self.uuid(
                                        "crossplot-graph-wrapper")),
                                ],
                            ),
                        ], ),
                    ],
                ),
                dcc.Tab(
                    label="RFT misfit per observation",
                    style=tab_style,
                    selected_style=tab_selected_style,
                    children=[
                        wcc.FlexBox(children=[
                            html.Div(
                                style={"flex": 1},
                                children=self.filter_layout("errorplot"),
                            ),
                            html.Div(
                                style={"flex": 4},
                                children=wcc.Graph(
                                    id=self.uuid("errorplot-graph")),
                            ),
                        ], ),
                    ],
                ),
            ],
        )
def correlation_view(get_uuid: Callable) -> wcc.Graph:
    return wcc.Graph(
        style={"height": "78vh"},
        id=get_uuid("property-response-correlation-graph"),
    )
Ejemplo n.º 28
0
 def layout(self):
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             wcc.Frame(
                 id=self.uuid("filters"),
                 style={
                     "flex": "1",
                     "height": "90vh"
                 },
                 children=[
                     wcc.Selectors(
                         label="Selectors",
                         children=[
                             wcc.Dropdown(
                                 label="Saturation axis",
                                 id=self.uuid("sataxis"),
                                 clearable=False,
                                 options=[{
                                     "label": i.lower().capitalize(),
                                     "value": i,
                                 } for i in self.sat_axes],
                                 value=self.sat_axes[0],
                             ),
                             wcc.Dropdown(
                                 label="Color by",
                                 id=self.uuid("color_by"),
                                 clearable=False,
                                 options=[{
                                     "label": i.lower().capitalize(),
                                     "value": i,
                                 } for i in self.color_options],
                                 value=self.color_options[0],
                             ),
                             dcc.Store(
                                 id=self.uuid("stored_ensemble"),
                                 storage_type="session",
                                 data={},
                             ),
                             wcc.Dropdown(
                                 label="Ensembles",
                                 id=self.uuid("ensemble"),
                                 clearable=False,
                                 multi=True,
                                 options=[{
                                     "label": i,
                                     "value": i
                                 } for i in self.ensembles],
                                 value=self.ensembles[0],
                             ),
                             wcc.Dropdown(
                                 label="Curves",
                                 id=self.uuid("curve"),
                                 clearable=False,
                                 multi=True,
                             ),
                             dcc.Store(
                                 id=self.uuid("stored_satnum"),
                                 storage_type="session",
                                 data={},
                             ),
                             wcc.Dropdown(
                                 label="Satnum",
                                 id=self.uuid("satnum"),
                                 clearable=False,
                                 multi=True,
                                 options=[{
                                     "label": i,
                                     "value": i
                                 } for i in self.satnums],
                                 value=self.satnums[0],
                             ),
                         ],
                     ),
                     wcc.Selectors(
                         label="Visualization",
                         children=[
                             wcc.RadioItems(
                                 label="Line traces",
                                 id=self.uuid("visualization"),
                                 className="block-options",
                                 options=[
                                     {
                                         "label": "Individual realizations",
                                         "value": "realizations",
                                     },
                                     {
                                         "label": "Statistical fanchart",
                                         "value": "statistics",
                                     },
                                 ],
                                 value="statistics",
                             ),
                             wcc.RadioItems(
                                 label="Y-axis",
                                 id=self.uuid("linlog"),
                                 className="block-options",
                                 options=[
                                     {
                                         "label": "Linear",
                                         "value": "linear",
                                     },
                                     {
                                         "label": "Log",
                                         "value": "log",
                                     },
                                 ],
                                 value="linear",
                             ),
                         ],
                     ),
                     wcc.Selectors(
                         style={"display": "block"}
                         if self.scal is not None else {"display": "none"},
                         id=self.uuid("scal_selector"),
                         label="SCAL recommendation",
                         children=[
                             wcc.Checklist(
                                 id=self.uuid("scal"),
                                 options=[
                                     {
                                         "label": "Show SCAL",
                                         "value": "show_scal",
                                     },
                                 ],
                                 value=["show_scal"]
                                 if self.scal is not None else [],
                             ),
                         ],
                     ),
                 ],
             ),
             wcc.Frame(
                 color="white",
                 highlight=False,
                 style={
                     "flex": "4",
                     "height": "90vh"
                 },
                 children=wcc.Graph(style={"height": "88vh"},
                                    id=self.uuid("graph")),
             ),
         ],
     )
Ejemplo n.º 29
0
 def layout(self):
     return html.Div([
         html.Div(
             style=Intersect.LAYOUT_STYLE,
             children=[
                 html.Div([
                     html.P("Well:", style={"font-weight": "bold"}),
                     dcc.Dropdown(
                         id=self.well_list_id,
                         options=[{
                             "label": PurePath(well).stem,
                             "value": well
                         } for well in self.well_names],
                         value=self.well_names[0],
                         clearable=False,
                     ),
                     html.P("Realization:", style={"font-weight": "bold"}),
                     dcc.Dropdown(
                         id=self.real_list_id,
                         options=[{
                             "label": r,
                             "value": p
                         } for p, r in self.realizations.items()],
                         value=list(self.realizations.keys())[0],
                         multi=True,
                         placeholder="All realizations",
                     ),
                     html.P("Surfaces:", style={"font-weight": "bold"}),
                     dcc.Dropdown(
                         id=self.surf_list_id,
                         options=[{
                             "label": r,
                             "value": r
                         } for r in self.surface_names],
                         value=self.surface_names[0],
                         multi=True,
                         placeholder="All surfaces",
                     ),
                     html.Div(
                         style=Intersect.TABLE_STYLE,
                         children=[
                             DataTable(
                                 id=self.table_id,
                                 columns=[{
                                     "name": i,
                                     "id": i
                                 } for i in [
                                     "Name",
                                     "TVDmin",
                                     "TVDmean",
                                     "TVDmax",
                                     "TVDstddev",
                                 ]],
                             )
                         ],
                     ),
                 ]),
                 html.Div(
                     style={"height": "80vh"},
                     children=[
                         wcc.Graph(style={"height": "80vh"},
                                   id=self.intersection_id),
                         html.Div(
                             style=Intersect.FENCE_OPTION_STYLE,
                             children=[
                                 html.P(
                                     "Start depth:",
                                     style={"font-weight": "bold"},
                                 ),
                                 html.P(
                                     "Graph zoom level:",
                                     style={"font-weight": "bold"},
                                 ),
                                 dcc.Input(
                                     style={"overflow": "auto"},
                                     id=self.well_tvd_id,
                                     type="number",
                                     value=0,
                                 ),
                                 dcc.RadioItems(
                                     id=self.zoom_state_id,
                                     options=[{
                                         "label": k,
                                         "value": v
                                     } for k, v in {
                                         "Keep on new data": True,
                                         "Reset on new data": False,
                                     }.items()],
                                     value=True,
                                 ),
                             ],
                         ),
                     ],
                 ),
             ],
         )
     ])
Ejemplo n.º 30
0
    def layout(self) -> wcc.Tabs:

        return wcc.Tabs(children=[
            wcc.Tab(
                label="RFT Map",
                children=[
                    wcc.FlexBox(children=[
                        wcc.Frame(
                            style={
                                "flex": 1,
                                "height": "87vh"
                            },
                            children=[
                                self.map_plot_selectors,
                                self.formation_plot_selectors,
                            ],
                        ),
                        wcc.Frame(
                            style={
                                "flex": 3,
                                "height": "87vh"
                            },
                            color="white",
                            highlight=False,
                            children=wcc.Graph(id=self.uuid("map"), ),
                        ),
                        wcc.Frame(
                            style={
                                "flex": 3,
                                "height": "87vh"
                            },
                            color="white",
                            highlight=False,
                            children=wcc.Graph(
                                id=self.uuid("graph"),
                                figure={
                                    "layout": {
                                        "height": 800,
                                        "margin": {
                                            "t": 50
                                        },
                                        "xaxis": {
                                            "showgrid": False
                                        },
                                        "yaxis": {
                                            "showgrid": False
                                        },
                                    }
                                },
                            ),
                        ),
                    ])
                ],
            ),
            wcc.Tab(
                label="RFT misfit per real",
                children=[
                    wcc.FlexBox(children=[
                        wcc.Frame(
                            style={
                                "flex": 1,
                                "height": "87vh"
                            },
                            children=self.filter_layout("misfitplot"),
                        ),
                        wcc.Frame(
                            style={
                                "flex": 6,
                                "height": "87vh"
                            },
                            color="white",
                            highlight=False,
                            id=self.uuid("misfit-graph-wrapper"),
                            children=[],
                        ),
                    ])
                ],
            ),
            wcc.Tab(
                label="RFT crossplot - sim vs obs",
                children=[
                    wcc.FlexBox(children=[
                        wcc.Frame(
                            style={
                                "flex": 1,
                                "height": "87vh"
                            },
                            children=[
                                self.filter_layout("crossplot"),
                                self.size_color_layout(),
                            ],
                        ),
                        wcc.Frame(
                            style={
                                "flex": 6,
                                "height": "87vh"
                            },
                            color="white",
                            highlight=False,
                            children=[
                                html.Div(
                                    id=self.uuid("crossplot-graph-wrapper")),
                            ],
                        ),
                    ], ),
                ],
            ),
            wcc.Tab(
                label="RFT misfit per observation",
                children=[
                    wcc.FlexBox(children=[
                        wcc.Frame(
                            style={
                                "flex": 1,
                                "height": "87vh"
                            },
                            children=self.filter_layout("errorplot"),
                        ),
                        wcc.Frame(
                            color="white",
                            highlight=False,
                            style={
                                "flex": 6,
                                "height": "87vh"
                            },
                            children=wcc.Graph(
                                style={"height": "84vh"},
                                id=self.uuid("errorplot-graph"),
                            ),
                        ),
                    ], ),
                ],
            ),
        ], )