Beispiel #1
0
def vector_selector(get_uuid: Callable, vectormodel: SimulationTimeSeriesModel):
    return wsc.VectorSelector(
        id=get_uuid("vector-selector"),
        maxNumSelectedNodes=1,
        data=vectormodel.vector_selector_data,
        persistence=True,
        persistence_type="session",
        selectedTags=["FOPT"]
        if "FOPT" in vectormodel.vectors
        else vectormodel.vectors[:1],
        numSecondsUntilSuggestionsAreShown=0.5,
        lineBreakAfterTag=True,
    )
def vector_selector(
    get_uuid: Callable,
    vector_model: Union[SimulationTimeSeriesModel,
                        ProviderTimeSeriesDataModel],
) -> wsc.VectorSelector:
    return wsc.VectorSelector(
        id=get_uuid("property-response-vector-select"),
        maxNumSelectedNodes=1,
        data=vector_model.vector_selector_data,
        persistence=True,
        persistence_type="session",
        selectedTags=vector_model.vectors[:1],
        numSecondsUntilSuggestionsAreShown=0.5,
        lineBreakAfterTag=True,
    )
Beispiel #3
0
def __settings_layout(
    get_uuid: Callable,
    ensembles: 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 html.Div(
        children=[
            wcc.Selectors(
                label="Group By",
                id=get_uuid(LayoutElements.TOUR_STEP_GROUP_BY),
                children=[
                    wcc.RadioItems(
                        id=get_uuid(LayoutElements.SUBPLOT_OWNER_OPTIONS_RADIO_ITEMS),
                        options=[
                            {
                                "label": "Time Series",
                                "value": SubplotGroupByOptions.VECTOR.value,
                            },
                            {
                                "label": "Ensemble",
                                "value": SubplotGroupByOptions.ENSEMBLE.value,
                            },
                        ],
                        value=SubplotGroupByOptions.VECTOR.value,
                    ),
                ],
            ),
            wcc.Selectors(
                label="Resampling frequency",
                children=[
                    wcc.Dropdown(
                        id=get_uuid(LayoutElements.RESAMPLING_FREQUENCY_DROPDOWN),
                        clearable=False,
                        disabled=disable_resampling_dropdown,
                        options=[
                            {
                                "label": frequency.value,
                                "value": frequency.value,
                            }
                            for frequency in Frequency
                        ],
                        value=selected_resampling_frequency,
                        style={
                            "margin-bottom": "10px",
                        },
                    ),
                    wcc.Label(
                        "Data relative to date:",
                        style={
                            "font-style": "italic",
                        },
                    ),
                    wcc.Dropdown(
                        clearable=True,
                        disabled=disable_resampling_dropdown,
                        id=get_uuid(LayoutElements.RELATIVE_DATE_DROPDOWN),
                        options=[
                            {
                                "label": datetime_utils.to_str(_date),
                                "value": datetime_utils.to_str(_date),
                            }
                            for _date in sorted(ensembles_dates)
                        ],
                    ),
                    wcc.Label(
                        "NB: Disabled for presampled data",
                        style={"font-style": "italic"}
                        if disable_resampling_dropdown
                        else {"display": "none"},
                    ),
                ],
            ),
            wcc.Selectors(
                label="Ensembles",
                children=[
                    wcc.Dropdown(
                        label="Selected ensembles",
                        id=get_uuid(LayoutElements.ENSEMBLES_DROPDOWN),
                        clearable=False,
                        multi=True,
                        options=[
                            {"label": ensemble, "value": ensemble}
                            for ensemble in ensembles
                        ],
                        value=None if len(ensembles) <= 0 else [ensembles[0]],
                    ),
                    wcc.Selectors(
                        label="Delta Ensembles",
                        id=get_uuid(LayoutElements.TOUR_STEP_DELTA_ENSEMBLE),
                        open_details=False,
                        children=[
                            __delta_ensemble_creator_layout(
                                get_uuid=get_uuid,
                                ensembles=ensembles,
                            )
                        ],
                    ),
                ],
            ),
            wcc.Selectors(
                label="Time Series",
                children=[
                    wsc.VectorSelector(
                        id=get_uuid(LayoutElements.VECTOR_SELECTOR),
                        maxNumSelectedNodes=3,
                        data=vector_selector_data,
                        persistence=True,
                        persistence_type="session",
                        selectedTags=[]
                        if selected_vectors is None
                        else selected_vectors,
                        numSecondsUntilSuggestionsAreShown=0.5,
                        lineBreakAfterTag=True,
                        customVectorDefinitions=custom_vector_definitions,
                    ),
                    html.Button(
                        "Vector Calculator",
                        id=get_uuid(LayoutElements.VECTOR_CALCULATOR_OPEN_BUTTON),
                        style={
                            "margin-top": "5px",
                            "margin-bottom": "5px",
                        },
                    ),
                ],
            ),
            wcc.Selectors(
                label="Visualization",
                children=[
                    wcc.RadioItems(
                        id=get_uuid(LayoutElements.VISUALIZATION_RADIO_ITEMS),
                        options=[
                            {
                                "label": "Individual realizations",
                                "value": VisualizationOptions.REALIZATIONS.value,
                            },
                            {
                                "label": "Statistical lines",
                                "value": VisualizationOptions.STATISTICS.value,
                            },
                            {
                                "label": "Statistical fanchart",
                                "value": VisualizationOptions.FANCHART.value,
                            },
                            {
                                "label": "Statistics + Realizations",
                                "value": VisualizationOptions.STATISTICS_AND_REALIZATIONS,
                            },
                        ],
                        value=selected_visualization.value,
                    ),
                    wcc.Selectors(
                        label="Options",
                        id=get_uuid(LayoutElements.TOUR_STEP_OPTIONS),
                        children=__plot_options_layout(
                            get_uuid=get_uuid,
                            selected_visualization=selected_visualization,
                        ),
                    ),
                ],
            ),
            wcc.Selectors(
                label="Filter Realizations",
                children=__realization_filters(get_uuid, realizations),
            ),
            __vector_calculator_modal_layout(
                get_uuid=get_uuid,
                vector_data=vector_calculator_data,
                predefined_expressions=predefined_expressions,
            ),
            dcc.Store(
                id=get_uuid(LayoutElements.VECTOR_CALCULATOR_EXPRESSIONS),
                data=predefined_expressions,
            ),
            dcc.Store(
                id=get_uuid(LayoutElements.VECTOR_CALCULATOR_EXPRESSIONS_OPEN_MODAL),
                data=predefined_expressions,
            ),
        ]
    )
 def layout(self) -> wcc.FlexBox:
     return wcc.FlexBox(
         id=self.uuid("layout"),
         children=[
             wcc.FlexColumn(children=wcc.Frame(
                 style={"height": "90vh"},
                 children=[
                     wcc.Selectors(label="Ensembles",
                                   children=[self.delta_layout]),
                     wcc.Selectors(
                         label="Time series",
                         children=wsc.VectorSelector(
                             id=self.uuid("vectors"),
                             maxNumSelectedNodes=3,
                             data=self.vector_data,
                             persistence=True,
                             persistence_type="session",
                             selectedTags=self.plot_options.get(
                                 "vectors", [self.smry_cols[0]]),
                             numSecondsUntilSuggestionsAreShown=0.5,
                             lineBreakAfterTag=True,
                         ),
                     ),
                     wcc.Selectors(
                         label="Visualization",
                         id=self.uuid("visualization"),
                         children=[
                             wcc.RadioItems(
                                 id=self.uuid("statistics"),
                                 options=[
                                     {
                                         "label": "Individual realizations",
                                         "value": "realizations",
                                     },
                                     {
                                         "label": "Statistical lines",
                                         "value": "statistics",
                                     },
                                     {
                                         "label": "Statistical fanchart",
                                         "value": "fanchart",
                                     },
                                 ],
                                 value=self.plot_options.get(
                                     "visualization", "statistics"),
                             ),
                         ],
                     ),
                     wcc.Selectors(
                         label="Options",
                         id=self.uuid("options"),
                         children=[
                             wcc.Checklist(
                                 id=self.uuid("trace_options"),
                                 options=[{
                                     "label": val,
                                     "value": val
                                 } for val in ["History", "Histogram"]],
                                 value=["History"],
                             ),
                             html.Div(
                                 id=self.uuid("view_stat_options"),
                                 style={"display": "block"}
                                 if "statistics" in self.plot_options.
                                 get("visualization", ""
                                     ) else {"display": "none"},
                                 children=[
                                     wcc.Checklist(
                                         id=self.uuid("stat_options"),
                                         options=[{
                                             "label": val,
                                             "value": val
                                         } for val in [
                                             "Mean",
                                             "P10 (high)",
                                             "P50 (median)",
                                             "P90 (low)",
                                             "Maximum",
                                             "Minimum",
                                         ]],
                                         value=[
                                             "Mean",
                                             "P10 (high)",
                                             "P90 (low)",
                                         ],
                                     ),
                                 ],
                             ),
                         ],
                     ),
                     wcc.Selectors(
                         label="Calculations",
                         children=[self.from_cumulatives_layout],
                     ),
                 ],
             )),
             wcc.FlexColumn(
                 flex=4,
                 children=[
                     wcc.Frame(
                         style={"height": "90vh"},
                         highlight=False,
                         color="white",
                         children=wcc.Graph(
                             style={"height": "85vh"},
                             id=self.uuid("graph"),
                         ),
                     ),
                     dcc.Store(
                         id=self.uuid("date"),
                         storage_type="session",
                         data=json.dumps(self.plot_options.get(
                             "date", None)),
                     ),
                 ],
             ),
         ],
     )