Beispiel #1
0
def _create_initial_convergence_plots(
    criterion_history,
    params_history,
    group_to_param_ids,
    group_to_param_names,
):
    """Create the initial convergence plots.

    Args:
        criterion_history (bokeh ColumnDataSource)
        params_history (bokeh ColumnDataSource)
        group_to_param_ids (dict): Keys are the groups to be plotted. Values are the
            ids of the parameters belonging to the respective group.
        group_to_param_names (dict): Keys are the groups to be plotted. Values are the
            names of the parameters belonging to the respective group.

    Returns:
        convergence_plots (list): List of bokeh Row elements, each containing one
            convergence plot.

    """
    param_plots = []
    for group, param_ids in group_to_param_ids.items():
        param_names = group_to_param_names[group]
        param_group_plot = plot_time_series(
            data=params_history,
            y_keys=param_ids,
            y_names=param_names,
            x_name="iteration",
            title=str(group),
        )
        param_plots.append(param_group_plot)

    arranged_param_plots = [Row(plot) for plot in param_plots]

    linear_criterion_plot = plot_time_series(
        data=criterion_history,
        x_name="iteration",
        y_keys=["criterion"],
        y_names=["criterion"],
        title="Criterion",
        name="linear_criterion_plot",
        logscale=False,
    )
    log_criterion_plot = plot_time_series(
        data=criterion_history,
        x_name="iteration",
        y_keys=["criterion"],
        y_names=["criterion"],
        title="Criterion",
        name="log_criterion_plot",
        logscale=True,
    )
    log_criterion_plot.visible = False

    plot_list = [
        Row(linear_criterion_plot),
        Row(log_criterion_plot),
    ] + arranged_param_plots
    return plot_list
Beispiel #2
0
def _setup_tabs(sec_to_elements):
    """Create tabs for each section in sec_to_elements with titles.

    Args:
        sec_to_elements (dict): A nested dictionary. The first level keys will be the
        sections ("running", "succeeded", "failed", "scheduled"). The second level keys
        are the database names and the second level values a list consisting of the
        link to the dashboard and a button to activate tha dashboard.

    Returns:
        tabs (bokeh.models.Tabs): a tab for every section in sec_to_elements.

    """
    tab_list = []
    for section, name_to_row in sec_to_elements.items():
        text = f"{len(name_to_row.column_names)} optimizations {section}"
        table_rows = [
            Row(Div(text=text, width=400), name=f"{section}_how_many")
        ]
        for name, row in name_to_row.data.items():
            table_rows.append(Row(*row, name=name))
        panel = Panel(
            child=Column(*table_rows, name=f"{section}_col"),
            title=section.capitalize(),
            name=f"{section}_panel",
        )
        tab_list.append(panel)
    tabs = Tabs(tabs=tab_list, name="tabs")
    return tabs
Beispiel #3
0
def create_disp():
    ##### 各画面要素作成
    # テーブル作成
    df_columns = target_data.columns.tolist()
    datatable_source = ColumnDataSource(data=target_data)
    table_columns = create_datatable_columns(df_columns)
    data_table = DataTable(source=datatable_source,
                           selectable=True,
                           columns=table_columns,
                           sortable=True)

    # カラムが変わった時に呼び出す関数リスト
    column_change_functions = []

    # 表示を切り替えるplotリスト
    visible_plots = []

    cm_operation_area, cm_plot_area = create_cm(column_change_functions,
                                                visible_plots,
                                                datatable_source)

    # upload button がクリックされた時の処理
    def upload_button_callback(event):
        global target_data
        global user
        csv_str = base64.b64decode(csv_input.value)
        target_data = pd.read_csv(io.BytesIO(csv_str))
        df_columns = target_data.columns.tolist()
        call_column_change(column_change_functions, df_columns)
        table_columns = create_datatable_columns(df_columns)
        data_table.columns = table_columns
        datatable_source.data = target_data
        data_table.update()
        try:
            user.csv_data = target_data.to_json()
            db.session.commit()
        except Exception as e:
            warn = str(e)

    # csvアップロード実行ボタン
    upload_button = Button(label="Upload", button_type="success")
    upload_button.on_event(ButtonClick, upload_button_callback)

    # ファイル選択ボックス
    csv_input = FileInput()

    scatter_operation_area, scatter_plot_area = create_scatter(
        column_change_functions, visible_plots, datatable_source)

    # サブオペレーションエリア
    sub_operation_area = Row(cm_operation_area, scatter_operation_area)

    operation_area = Column(csv_input, upload_button, sub_operation_area,
                            data_table)
    graph_area = Column(cm_plot_area, scatter_plot_area)
    layout_disp = Row(graph_area, operation_area)

    return layout_disp
def _create_initial_convergence_plots(criterion_history, params_history, start_params):
    """Create the initial convergence plots.

    Args:
        criterion_history (bokeh ColumnDataSource)
        params_history (bokeh ColumnDataSource)
        start_params (pd.DataFrame): params DataFrame that includes the "group" column.

    Returns:
        convergence_plots (list): List of bokeh Row elements, each containing one
            convergence plot.

    """
    criterion_plot = _plot_time_series(
        data=criterion_history,
        x_name="iteration",
        y_keys=["value"],
        y_names=["criterion"],
        title="Criterion",
    )
    convergence_plots = [criterion_plot]

    group_to_params = _map_groups_to_params(start_params)
    for g, group_params in group_to_params.items():
        param_group_plot = _plot_time_series(
            data=params_history, y_keys=group_params, x_name="iteration", title=g,
        )
        convergence_plots.append(Row(param_group_plot))
    return convergence_plots
Beispiel #5
0
def get_plots():
    row = Row()
    plots = [figure(plot_height=400, tools='') for i in range(2)]
    [
        plot.line(x='x', y='y', source=data_sources[index])
        for index, plot in enumerate(plots)
    ]
    [row.children.append(plot) for plot in plots]
    return row
Beispiel #6
0
    def make_tools(self):
        #ボタンやスライダーを作成
        end = self.make_button(self.exit_hander, "終了")

        self.searchbox = self.make_search_input_textbox()
        self.searchbox.on_change("value", self.celestial_bodies_search_handler)

        self.celestial_text = Div(text="", width=300, height=220)
        self.celestial_text.background = (10, 10, 10, 0.05)

        self.plotting_mode_text = Div(text="投影図法:メルカトル", width=140, height=20)
        self.plotting_mode_text.background = (10, 10, 10, 0.05)
        self.plotting_linkage_button = self.make_button(
            self.switch_plotting_linkage_handler,
            "視等級とズームの連動",
            default_size=100)
        self.plotting_linkage_button.button_type = "primary"

        self.angle_simu_enlarge_slider = self.make_slider(
            self.update_angle_square_enlarge, "焦点距離", 35, 10, 200, 1)
        self.angle_simu_rotate_slider = self.make_slider(
            self.update_angle_square_rotate, "回転角度", 0, -360, 360, 1)
        self.angle_simu_button = self.make_button(
            self.switch_angle_simulator_handler, "撮影シミュレーション")
        angle_simu = Column(self.angle_simu_button,
                            self.angle_simu_enlarge_slider,
                            self.angle_simu_rotate_slider)
        angle_simu.background = (0, 100, 60, 0.2)

        self.star_label_button = self.make_button(self.switch_starlabel_hander,
                                                  "恒星の名前:on/off",
                                                  button_type="primary")
        self.galaxy_button = self.make_button(self.switch_galaxy_handler,
                                              "銀河:off/点のみ/メシエ番号")
        self.star_line_button = self.make_button(self.switch_star_line_handler,
                                                 "星座線:on/off")
        self.constellation_button = self.make_button(
            self.switch_constellation_handler, "星座の名前:on/off")
        switches = Column(self.star_label_button, self.galaxy_button,
                          self.star_line_button, self.constellation_button)
        switches.background = (0, 40, 100, 0.2)

        tools = Column(
            end, self.searchbox, self.celestial_text,
            Row(self.plotting_mode_text, self.plotting_linkage_button),
            angle_simu, switches)

        return tools
 def _make_doc_layout(self):
     """
     Constructs the document layout object.
     
     Note: Row and Column are experimental features. The positions of 
     the widgets could be hardcoded.
     
     Returns:
     --------
     doc_layout : bokeh.layouts.layout object
         Grid layout of bokeh models.
     """
     top_row = Row(self.widgets['add'], Spacer(width=25),
                   self.widgets['clear'])
     right_column = Column(self.widgets['method'],
                           self.widgets['num_train_inst'],
                           self.widgets['color'],
                           self.widgets['change_color'],
                           self.widgets['start'])
     doc_layout = layout([top_row, [self.fig, right_column]])
     return doc_layout
Beispiel #8
0
def update_reviews(attr, old, new):

    data_set = pd.read_csv('Outputs/data_set.csv')
    i = int(star_rating.value)

    #output_review_list = extract_ngrams(str(data_set[(data_set['Star_count'] == i)]['Review'].values),2,3)
    data_set_blob = data_set.copy()
    data_set_blob['Noun_sentences'] = data_set_blob['Review'].apply(lambda x:get_nouns(x))

    n_gram_blob = TextBlob(str(data_set_blob[(data_set_blob['Star_count'] == i)]['Noun_sentences'].values))    

    #Styling the paragraph element
    text1 = Paragraph(style={'font-variant': 'small-caps','font-family': "Tahoma"})
    text1.text=""    

    #review1 = text_cleaner(str(n_gram_blob.ngrams(1)[0]))
    #review2 = text_cleaner(str(n_gram_blob.ngrams(1)[1]))
                
    review1 = text_cleaner(n_gram_blob.ngrams(1)[1][0])
    review2 = text_cleaner(n_gram_blob.ngrams(1)[2][0])

    text1.text = "Top "+str(i)+" star reviews feel: "+review1+", followed by "+review2    
    curdoc().add_root(Row(text1))
Beispiel #9
0
plot_1.title.text = "Circular Layout (NodesAndLinkedEdges inspection policy)"
plot_1.add_tools(HoverTool(tooltips=None))

plot_2 = create_graph(nx.spring_layout,
                      selection_policy=NodesAndLinkedEdges(),
                      scale=2,
                      center=(0, 0))
plot_2.title.text = "Spring Layout (NodesAndLinkedEdges selection policy)"
plot_2.add_tools(TapTool(), BoxSelectTool())

plot_3 = create_graph(nx.random_layout,
                      inspection_policy=EdgesAndLinkedNodes(),
                      center=(0, 0))
plot_3.title.text = "Random Layout (EdgesAndLinkedNodes inspection policy)"
plot_3.add_tools(HoverTool(tooltips=None))

plot_4 = create_graph(nx.fruchterman_reingold_layout,
                      selection_policy=EdgesAndLinkedNodes(),
                      scale=2,
                      center=(0, 0),
                      dim=2)
plot_4.title.text = "FR Layout (EdgesAndLinkedNodes selection policy)"
plot_4.add_tools(TapTool())

layout = Column(Row(plot_1, plot_2), Row(plot_3, plot_4))

doc = curdoc()
doc.add_root(layout)

show(layout)
Beispiel #10
0
def monitoring_app(doc, database_name, session_data):
    """Create plots showing the development of the criterion and parameters.

    Options are loaded from the database. Supported options are:
        - rollover (int): How many iterations to keep before discarding.

    Args:
        doc (bokeh.Document): Argument required by bokeh.
        database_name (str): Short and unique name of the database.
        session_data (dict): Infos to be passed between and within apps.
            Keys of this app's entry are:
            - last_retrieved (int): last iteration currently in the ColumnDataSource.
            - database_path (str or pathlib.Path)
            - callbacks (dict): dictionary to be populated with callbacks.

    """
    database = load_database(session_data["database_path"])
    start_params = read_scalar_field(database, "start_params")
    dash_options = read_scalar_field(database, "dash_options")
    rollover = dash_options["rollover"]

    tables = ["criterion_history", "params_history"]
    criterion_history, params_history = _create_bokeh_data_sources(
        database=database, tables=tables
    )
    session_data["last_retrieved"] = 1

    # create initial bokeh elements without callbacks
    initial_convergence_plots = _create_initial_convergence_plots(
        criterion_history=criterion_history,
        params_history=params_history,
        start_params=start_params,
    )

    activation_button = Toggle(
        active=False,
        label="Start Updating from Database",
        button_type="danger",
        width=50,
        height=30,
        name="activation_button",
    )

    # add elements to bokeh Document
    bokeh_convergence_elements = [Row(activation_button)] + initial_convergence_plots
    convergence_tab = Panel(
        child=Column(*bokeh_convergence_elements), title="Convergence Tab"
    )
    tabs = Tabs(tabs=[convergence_tab])
    doc.add_root(tabs)

    # add callbacks
    activation_callback = partial(
        _activation_callback,
        button=activation_button,
        doc=doc,
        database=database,
        session_data=session_data,
        rollover=rollover,
        tables=tables,
    )
    activation_button.on_change("active", activation_callback)
Beispiel #11
0
defaultBtn = Button(label="Default", button_type="default")
confirmedBtn = Button(label="Confirmed", button_type="warning")
deceasedBtn = Button(label="Deceased", button_type="danger")
recoveredBtn = Button(label="Recovered", button_type="primary")
menu = [("Item 1", "item_1"), ("Item 2", "item_2"), None, ("Item 3", "item_3")]
dropdown = Dropdown(label="Dropdown button", button_type="success", menu=menu)

# Draw the figures
world_map = create_world_map(confirmed_df)
bar_chart = create_region_impact_bar(confirmed_df, death_df, recovered_df)
vstacked_chart = create_chart(confirmed_df,
                              death_df=death_df,
                              recovered_df=recovered_df)
pie_chart = create_pie_chart(confirmed_df, death_df, recovered_df)

#def confirmedBtn_onclick():
#    create_chart(confirmed_df, "#FF5733")

#confirmedBtn.on_click(confirmedBtn_onclick)
#deceasedBtn.on_click(deceasedBtn_onclick)
#recoveredBtn.on_click(recoveredBtn_onclick)

# Create the Rows
#first_row = Row(defaultBtn, confirmedBtn, deceasedBtn, recoveredBtn)
second_row = Row(world_map, pie_chart)
third_row = Row(bar_chart, vstacked_chart)

# Add to current document
#curdoc().add_root(first_row)
curdoc().add_root(second_row)
curdoc().add_root(third_row)
Beispiel #12
0
matchup_hover_b = HoverTool(tooltips=[('Freq.', '@matchup{0.00%}')],
                            renderers=[matchup_b])

pitches_p.tools = [overall_hover_p, matchup_hover_p, SaveTool()]
pitches_b.tools = [overall_hover_b, matchup_hover_b, SaveTool()]

# tab pitch data
tab1 = Panel(child=pitches_p, title='Pitcher')
tab2 = Panel(child=pitches_b, title='Batter')
pitch_tabs = Tabs(tabs=[tab1, tab2])

# filters for count
balls = Select(title='Balls',
               options=['All', '1', '2', '3'],
               value='All',
               width=60)
strikes = Select(title='Strikes',
                 options=['All', '1', '2'],
                 value='All',
                 width=60)
balls.on_change('value', lambda attr, old, new: filter_data())
strikes.on_change('value', lambda attr, old, new: filter_data())

l = layout([[Row(pfirstname, plastname, psearch)], [pitcherselect],
            [Row(hfirstname, hlastname, hsearch)], [hitterselect],
            [start_date, end_date], [run_button], [balls, strikes],
            [plot, pitch_tabs]],
           sizing_mode='fixed')

curdoc().add_root(l)
Beispiel #13
0
             title='Which buildings use what fuel?',
             tools=['pan', 'reset', 'tap'])

bar.xaxis.axis_label = 'Types of Buildings in NYC'
bar.yaxis.axis_label = 'Total number of Buildings'

bar.xaxis.major_label_orientation = pi / 3

barColor = factor_cmap('btype',
                       palette=Category20c[20],
                       factors=sorted(df['BuildingType'].unique()))

bar.vbar(x='btype', top='count', width=.3, color=barColor, source=cdsbar)

fuelSelect = Select(title='Select the fuel type',
                    options=list(df['PrimaryFuel'].unique()),
                    value='4 (Clean Oil)')

fuelSelect.on_change('value', updateBar)

barHover = HoverTool(
    tooltips=[('Type of building',
               '@btype'), ('Fuel used',
                           '@fuel'), ('Total # of buildings', '@count')])

bar.add_tools(barHover)

curdoc().add_root(
    Column(Column(xSelect, line), Row(scatHigh, scatLow),
           Column(fuelSelect, bar)))
Beispiel #14
0
def main() -> None:
    """メイン処理

    Returns:
        None: None
    """
    # データソースの初期設定
    source = ColumnDataSource(data=dict(length=[], width=[]))
    source.data = {"0": [], "1": []}
    df = pd.DataFrame()

    # CSVファイル設定テキストボックス
    csv_input = TextInput(value="default.csv", title="Input CSV")

    # 可視化手法選択ラジオボタン
    method_group = analysis_method()
    method_radio_group = RadioGroup(labels=list(method_group.keys()), active=0)

    # グラフ初期設定
    p = figure(
        tools=("pan,box_zoom,lasso_select,box_select,poly_select"
               ",tap,wheel_zoom,reset,save,zoom_in"),
        title="Analyze Result",
        plot_width=1000,
        plot_height=800,
    )
    p.circle(x="0", y="1", source=source)

    # データ表示データテーブル
    data_table = DataTable(source=source,
                           columns=[],
                           width=600,
                           height=500,
                           fit_columns=False)

    # 色設定項目用選択セレクトボックス
    def color_select_callback(attr, old, new) -> None:
        mapper = create_mapper(df, new)
        p.circle(x="0", y="1", source=source, line_color=mapper, color=mapper)

    color_select = Select(title="color:", value="0", options=[])
    color_select.on_change("value", color_select_callback)

    # 解析実行ボタン
    def execute_button_callback_inner(evnet):
        nonlocal df
        df = pd.read_csv(csv_input.value, index_col=0)
        result = method_group[method_radio_group.labels[
            method_radio_group.active]](df)
        source.data = to_source_data_from(df, result)
        data_table.columns = to_datatable_columns_from(df)
        mapper = create_mapper(df, df.columns.values[0])
        p.circle(x="0", y="1", source=source, line_color=mapper, color=mapper)
        p.add_tools(create_hover(["ID", df.columns.values[0]]))
        color_select.options = list(df.columns)

    execute_button = Button(label="Execute", button_type="success")
    execute_button.on_event(ButtonClick, execute_button_callback_inner)

    # レイアウト
    operation_area = Column(csv_input, method_radio_group, execute_button,
                            color_select, data_table)
    layout = Row(p, operation_area)
    curdoc().add_root(layout)
Beispiel #15
0
import pandas as pd
from bokeh.io import curdoc
from scatter_plot import create_scatter_plot
from population_per_region import create_bar_chart
from child_mortality_plot import create_mortality_bar_plot
from bokeh.layouts import Row, Column

main_df = pd.read_csv('gapminder_tidy.csv', index_col='Year')

scatter_plot = create_scatter_plot(main_df)
pop_per_region_bar = create_bar_chart(main_df)
child_mortality_bar = create_mortality_bar_plot(main_df)

column = Column(pop_per_region_bar, child_mortality_bar)
first_row = Row(scatter_plot)
second_row = Row(child_mortality_bar, pop_per_region_bar)

curdoc().add_root(first_row)
curdoc().add_root(second_row)
Beispiel #16
0
def _create_button_row(
    doc,
    database,
    session_data,
    start_params,
    updating_options,
):
    """Create a row with two buttons, one for (re)starting and one for scale switching.

    Args:
        doc (bokeh.Document)
        database (sqlalchemy.MetaData): Bound metadata object.
        session_data (dict): dictionary with the last retrieved rowid
        start_params (pd.DataFrame): See :ref:`params`
        updating_options (dict): Specification how to update the plotting data.
            It contains rollover, update_frequency, update_chunk, jump and stride.

    Returns:
        bokeh.layouts.Row

    """
    # (Re)start convergence plot button
    activation_button = Toggle(
        active=False,
        label="Start Updating",
        button_type="danger",
        width=200,
        height=30,
        name="activation_button",
    )
    partialed_activation_callback = partial(
        activation_callback,
        button=activation_button,
        doc=doc,
        database=database,
        session_data=session_data,
        tables=["criterion_history", "params_history"],
        start_params=start_params,
        updating_options=updating_options,
    )
    activation_button.on_change("active", partialed_activation_callback)

    # switch between linear and logscale button
    logscale_button = Toggle(
        active=False,
        label="Show criterion plot on a logarithmic scale",
        button_type="default",
        width=200,
        height=30,
        name="logscale_button",
    )
    partialed_logscale_callback = partial(
        logscale_callback,
        button=logscale_button,
        doc=doc,
    )
    logscale_button.on_change("active", partialed_logscale_callback)

    button_row = Row(children=[activation_button, logscale_button],
                     name="button_row")
    return button_row
def tab_visualize(csv):

    csv_original = csv.copy()
    csv_modified = csv.copy()

    target_csv = {'csv': csv_original}

    source_length = target_csv['csv'].shape[0]

    table_source = ColumnDataSource(target_csv['csv'])
    table_columns = [
        TableColumn(field=col, title=col)
        for col in list(target_csv['csv'].columns)
    ]

    table_original = DataTable(source=table_source,
                               columns=table_columns,
                               width=1550,
                               height=250,
                               fit_columns=False,
                               name="Original")

    g = target_csv['csv'].columns.to_series().groupby(
        target_csv['csv'].dtypes).groups
    g_list = list(g.keys())

    float_list = []
    rest_list = []
    for l in g_list:
        if ('float' or 'int' in str(l)):
            float_list += list(g[l])
        else:
            rest_list += list(g[l])
    print(float_list)
    print(rest_list)

    def make_dataset(col_list, range_start, range_end):

        xs = []
        ys = []
        labels = []
        colors = []

        target_length = target_csv['csv'].shape[0]
        end = range_end if (range_end < target_length) else target_length

        target_data = target_csv['csv'][col_list +
                                        rest_list].iloc[range_start:end]
        target_x = list(np.arange(target_data.shape[0]) + range_start)

        for col, i in zip(col_list, range(len(col_list))):
            y = list(target_data[col].values)

            xs.append(target_x)
            ys.append(y)
            labels.append(col)
            colors.append(line_colors[i])

        new_src = ColumnDataSource(data={
            'x': xs,
            'y': ys,
            'label': labels,
            'colors': colors
        })

        return new_src

    def make_plot(src):
        p = figure(plot_width=1300,
                   plot_height=400,
                   title='Raw data',
                   x_axis_label='Index',
                   y_axis_label='Sensor value')

        p.multi_line('x',
                     'y',
                     legend='label',
                     color='colors',
                     line_width=1,
                     source=src)

        tools = HoverTool()
        TOOLTIPS = [("", ""), ("", "")]

        return p

    def update(attr, old, new):

        column_to_plot = select_column.value

        new_src = make_dataset(column_to_plot, range_select.value[0],
                               range_select.value[1])
        src.data.update(new_src.data)

    line_colors = Category20_16
    line_colors.sort()

    select_column = MultiSelect(title="Column visualization",
                                value=float_list,
                                options=float_list)
    select_column.on_change("value", update)

    range_select = RangeSlider(start=0,
                               end=source_length,
                               value=(0, int(source_length / 100)),
                               step=1,
                               title='Sensor range')
    range_select.on_change('value', update)

    src = make_dataset([float_list[0]], range_select.value[0],
                       range_select.value[1])

    p = make_plot(src)

    select_normalize = Select(title="Select normalize transformation",
                              options=["-", "Min-Max", "Z normalize", "Raw"])
    button_get_normal = Button(label="Transform")

    def normal_handler():
        print("Normalize")
        # cols_to_normalize = float_list
        cols_to_normalize = select_transform.value

        if (select_normalize.value == "Min-Max"):
            scaler = preprocessing.MinMaxScaler()
            csv_modified[cols_to_normalize] = scaler.fit_transform(
                X=csv_original[cols_to_normalize].values)

            target_csv['csv'] = csv_modified
            table_source.data = ColumnDataSource(target_csv['csv']).data

            csv[cols_to_normalize] = target_csv['csv'][cols_to_normalize]
            print("Min Max Mormalize")

        elif (select_normalize.value == "Z normalize"):
            scaler = preprocessing.StandardScaler()
            csv_modified[cols_to_normalize] = scaler.fit_transform(
                X=csv_original[cols_to_normalize].values)

            target_csv['csv'] = csv_modified
            table_source.data = ColumnDataSource(target_csv['csv']).data

            csv[cols_to_normalize] = target_csv['csv'][cols_to_normalize]
            print("Z normalize")

        elif (select_normalize.value == "Raw"):

            csv_modified[cols_to_normalize] = csv_original[cols_to_normalize]

            target_csv['csv'] = csv_modified
            table_source.data = ColumnDataSource(target_csv['csv']).data

            csv[cols_to_normalize] = target_csv['csv'][cols_to_normalize]
            print("Raw")

    button_get_normal.on_click(normal_handler)

    select_transform = MultiSelect(title="Select columns for transformation",
                                   value=list(target_csv['csv'].columns),
                                   options=list(target_csv['csv'].columns))

    controls = WidgetBox(select_normalize, select_transform, button_get_normal,
                         select_column, range_select)

    layout = Column(Row(table_original), Row(controls, p))

    tab = Panel(child=layout, title='Visualization')

    return tab
Beispiel #18
0
# Use the filter in a view
long_filter = Filter([item == 'long' for item in data['type']])
long_view = CDSView(source=source, filters=[long_filter, js_filter])
short_filter = Filter([item == 'short' for item in data['type']])
short_view = CDSView(source=source, filters=[short_filter, js_filter])

fig = figure(toolbar_location=None)
fig.axis.visible = False
fig.xgrid.visible = False
fig.ygrid.visible = False
fig.outline_line_color = None
fig.rect(x='x',
         y='y',
         source=source,
         view=long_view,
         width=size - .05,
         height=0.6,
         color='red')
fig.rect(x='x',
         y='y',
         source=source,
         view=short_view,
         width=0.95,
         height=0.6,
         color='navy')




save(Row(slider, fig,text))
Beispiel #19
0
    Figure(y_range=r1_ps[0].y_range, plot_height=ROW_HEIGHT, **pargs),
    Figure(y_range=r2_ps[0].y_range,
           plot_height=ROW_HEIGHT + axargs['plot_height'],
           **pargs)
]
for i, y_ax in enumerate(y_axes):
    y_ax.xgrid.visible = False
    y_ax.ygrid.visible = False
    y_ax.xaxis.visible = False
    y_ax.min_border = 0
    y_ax.toolbar.active_scroll = y_ax.tools[1]
    # for some reason the following line totally breaks the profiler
    y_ax.yaxis[0].formatter = PrintfTickFormatter(format="%4d")
    y_ax.yaxis.axis_label = rnames[i]
    y_ax.line(x='zeroes',
              y='avg_wh_y' + str(i + 1),
              line_width=0.5,
              alpha=0.3,
              line_cap='round',
              source=source)

left_column = Column([Div(height=73, width=25)] + y_axes)

profile = Row([left_column] + [
    Column(ti, inp, r1, r2, x_ax, width=COL_WIDTH)
    for ti, inp, r1, r2, x_ax in zip(t0_ps, textrow, r1_ps, r2_ps, x_axes)
])
surftab = Tabs(tabs=[tab1, tab2], width=COL_WIDTH * 5)

curdoc().add_root(Column(profile, surftab))
                                  active=True)

radius_slider = Slider(start=0,
                       end=0.2,
                       value=0.01,
                       step=0.0001,
                       title="Radius for visual classifier",
                       format="0[.]0000")
radius_source = ColumnDataSource({'x': [], 'y': [], 'rad': []})

color_from_dropdown = Select(
    title="Color by:",
    value='Categories',
    options=['Categories', 'cats_ae_pred', 'original_pred'])

global_plot = Row(children=[])


def add_renderers():
    color_attribute, label_mapping = {
        'Categories': ('cat_str', categories),
        'cats_ae_pred': ('cats_ae_pred_str', binary),
        'original_pred': ('original_pred_str', binary),
    }[color_from_dropdown.value]
    plot = figure(x_range=(0, 1),
                  y_range=(0, 1),
                  width=800,
                  height=400,
                  tools=[hover_tool])
    plot.add_tools(TapTool(behavior='select'))
Beispiel #21
0
    print(old, new)
    #update CDS
    cdsAuto.data = dict(xVal=dfAuto[xSelect.value], yVal=dfAuto['City_MPG'])
    scatChart.xaxis.axis_label = xSelect.value


dfAuto = pd.read_excel('data/Auto_Insu.xlsx')

cdsAuto = ColumnDataSource(
    data=dict(xVal=dfAuto['HP'], yVal=dfAuto['City_MPG']))

xSelect = Select(title="Select the X variable from the list",
                 options=['HP', 'Length', 'Width'],
                 value='HP')
# Figure
scatChart = figure(height=500,
                   width=500,
                   title="Using Widgets",
                   x_axis_label="HP",
                   y_axis_label="City MPG")

scatChart.square(x='xVal', y='yVal', source=cdsAuto)

xSelect.on_change('value', updateScatter)

#output_file('Scat1.html')
#show(Row(xSelect,scatChart))

curdoc().add_root(Row(xSelect, scatChart))

# Glyph
Beispiel #22
0
            s2.change.emit();
            s3.change.emit();
            s4.change.emit();
        """.replace("{code}", sleep_scatter_code)))

#########################################################################################################
# Dashboard
#########################################################################################################


def space(width, height=0):
    return Div(text=htmltext.div_space.format(width=width, height=height))


dash = Column(
    Row(space('20'), Div(text=htmltext.div_social)),
    Column(Row(space('40'), date_slider), Row(space('40'), pcal)),
    Row(
        space(2),
        Div(text=htmltext.div_intro),
        Div(text=htmltext.div_conclusion),
    ),
    #Div(text=htmltext.div_squatchek),
    Tabs(
        tabs=[
            Panel(child=Row(
                Column(
                    Div(text=htmltext.div_sleep),
                    Row(
                        space('30'),
                        Column(
Beispiel #23
0

p.js_on_event(events.PanEnd, CustomJS.from_py_func(pan_end))

#def mouse_move(ld = tweet_data_controller.lod_dummy):
#    print("Mouse Move:")

#p.js_on_event(events.MouseMove, CustomJS.from_py_func(mouse_move))

#def mouse_wheel(ld = tweet_data_controller.lod_dummy):
#    print("Mouse Wheel:")

#p.js_on_event(events.MouseWheel, CustomJS.from_py_func(mouse_wheel))

lhs = Column(map_widgets.radio_button_data_type,
             Row(map_widgets.toggle_data,
                 map_widgets.button_clear), map_widgets.text_selection_details,
             map_widgets.toggle_sde_ellipse,
             map_widgets.toggle_sibling_ellipses, map_widgets.toggle_dissolve,
             map_widgets.toggle_blend, map_widgets.slider_blend,
             map_widgets.text_input, map_widgets.button_find,
             map_widgets.toggle_legend)

filter_sliders \
    = Column(   Row(    Column(map_widgets.button_count_start_minus, map_widgets.button_count_start_plus, width=50),
                        map_widgets.range_slider_count,
                        Column(map_widgets.button_count_end_minus, map_widgets.button_count_end_plus)),
                Row(    Column(map_widgets.button_area_start_minus, map_widgets.button_area_start_plus, width=50),
                        map_widgets.range_slider_area,
                        Column(map_widgets.button_area_end_minus, map_widgets.button_area_end_plus)),
                Row(    Column(map_widgets.button_distance_start_minus, map_widgets.button_distance_start_plus, width=50),
                        map_widgets.range_slider_distance,
                   y_axis_label="City MPG")

# Adding the square glyph to the scatterplot
scatChart.square(x='xVal', y='yVal',source=cdsAuto)

# Getting dataset ready for viewing mean MPG values by Body_style.
# reset_index() converts the groupby object back to the dataframe.
meanCity = dfAuto.groupby(['Body_Style'])['City_MPG'].mean().reset_index()

# Preparing CDS object ready to populate the bar chart
cdsMean = ColumnDataSource(data=dict(xVal = meanCity['Body_Style'],
                                      yVal = meanCity['City_MPG']))

# Bar chart and its vbar glyph
# Again remember that for bar charts, you need to specify x_range when you create 
# the figure. List passed here should be unique values of type 'string'.
barChart = figure(height=400, width=700,
                  title="Summarizing City_MPG mean values",
                  x_range=meanCity['Body_Style'])

barChart.vbar(x='xVal', top='yVal', source=cdsMean, width=.3)

# Capturing the event of change of value
xSelect.on_change('value', updateScatter)
barSelect.on_change('value', updateBar)
weightSlider.on_change('value', updateScatter)

# Equivalent of show()... Curdoc() allows your charts to be rendered with server.
curdoc().add_root(Row(Column(xSelect, weightSlider, scatChart), 
                      Column(barSelect, barChart)))
Beispiel #25
0
    animate_start = animate_start + 2000
    p_trade_feed.x_range.start = animate_start
    p_trade_feed.x_range.end = animate_start + 600000


callback_id = None


def animate():
    global callback_id, start, end
    if button.label == '► Play':
        button.label = '❚❚ Pause'
        callback_id = curdoc().add_periodic_callback(animate_update, 1)
    else:
        button.label = '► Play'
        start = datetime(2019, 3, 3, 14, 0, 0,
                         tzinfo=timezone.utc).timestamp() * 1000
        end = datetime(2019, 3, 3, 15, 0, 0,
                       tzinfo=timezone.utc).timestamp() * 1000
        curdoc().remove_periodic_callback(callback_id)


button = Button(label='► Play', width=60)
button.on_click(animate)

left = Column(p_trade_feed, p_candlestick, p_trade_feed_hist,
              WidgetBox(button))
right = Column(p_order_book, p_trade_feed_distribution, p_buy_sell_pie)

curdoc().add_root(Row(left, right))
Beispiel #26
0
# mass_finder_range_text = Div(text= " Range mz:", width= 150, height=30 )
mass_finder_range_slider = RangeSlider(start=1.0, end=500.0, value=(1.0,50.0), title='Charge range:',name='mass_finder_range_slider', step=1, width= 250, height=30)
# mass_finder_mass_text = Div(text= " Mass of Complex (kDa):", width= 150, height=30 )
mass_finder_mass = Slider(value=100, start=0.0, end=1000.0, step=10.0, title='Mass of Complex (kDa)',name='gau_sigma', width=250, height=30)

mass_finder_exact_mass_text = Div(text= "Enter exact Mass (Da)", width= 150, height=30 )
mass_finder_exact_mass_sele = TextInput(value=str(mass_finder_mass.value*1000), disabled=False, width=100, height=30)

mass_finder_line_text = Div(text= "Show mz prediction", width= 150, height=30 )
mass_finder_line_sele = Toggle(label='off', active=False, width=100, height=30, callback=toggle_cb)

mass_finder_cb =CustomJS(args=dict(mass_finder_line_sele=mass_finder_line_sele, raw_mz=raw_mz, mass_finder_data=mass_finder_data, mass_finder_exact_mass_sele=mass_finder_exact_mass_sele, mass_finder_mass=mass_finder_mass, mass_finder_range_slider=mass_finder_range_slider, mfl=mfl), code=open(os.path.join(os.getcwd(), 'JS_Functions', "mass_finder_cb.js")).read())
mass_finder_exact_cb =CustomJS(args=dict(mass_finder_line_sele=mass_finder_line_sele, mass_finder_exact_mass_sele=mass_finder_exact_mass_sele, mass_finder_mass=mass_finder_mass), code=open(os.path.join(os.getcwd(), 'JS_Functions', "mass_finder_exact_cb.js")).read())
mass_finder_exact_mass_sele.js_on_change('value', mass_finder_exact_cb)

mass_finder_column=Column(mass_finder_header,mass_finder_mass, mass_finder_range_slider, Row(mass_finder_exact_mass_text,mass_finder_exact_mass_sele), Row(mass_finder_line_text, mass_finder_line_sele), visible=False)
mass_finder.js_link('active', mass_finder_column, 'visible')
mass_finder_line_sele.js_link('active', mfl, 'visible')
mass_finder_mass.js_on_change('value', mass_finder_cb)
mass_finder_line_sele.js_on_change('active', mass_finder_cb)
mass_finder_range_slider.js_on_change('value',mass_finder_cb)
### DATA PROCESSING ###

cropping = Div(text= " Range mz:", width= 150, height=30 )
# crop_max = Div(text= " ", width= 150, height=30 )
gau_name = Div(text= " Gaussian Smoothing:", width= 150, height=30 )
n_smooth_name = Div(text= " Repeats of Smoothing:", width= 150, height=30 )
# bin_name = Div(text= " Bin Every:", width= 150, height=30 )
int_name = Div(text= " Intensity Threshold (%)", width= 150, height=30 )
sub_name = Select(options=['Substract Minimum', 'Substract Line', 'Substract Curved'], name='sub_mode', value='Substract Minimum', width= 150, height=30 )
# add_name = Div(text= " Adduct Mass (Da)", width= 150, height=30 )
    def dead_dropdown_callback(self, attr, old, new):
        color_choice = dead_color_dropdown.value
        dead_data_source.data['color'] = [color_choice] * len(dead_data_source.data['color'])

    def speed_slider_callback(self, attr, old, new):
        self.speed = speed_slider.value

    def start_button_callback(self):
        for generation_num in range(self.starting_gen_num, generations + 1):
            plot.title.text = 'Generation ' + str(generation_num)
            self.adjust_data(alive_data_source, dead_data_source, output_dict, generation_num)
            sleep(1/(2*self.speed))

    def adjust_data(self, alive_data_source, dead_data_source, output_dict, gen_num):
        output_dict[gen_num][0].data['color'] = [alive_data_source.data['color'][0]] * len(output_dict[gen_num][0].data['x'])
        output_dict[gen_num][1].data['color'] = [dead_data_source.data['color'][0]] * len(output_dict[gen_num][1].data['x'])

        alive_data_source.data = output_dict[gen_num][0].data
        dead_data_source.data = output_dict[gen_num][1].data

callbacks = Callbacks()

generations_slider.on_change('value', callbacks.generations_slider_callback)
speed_slider.on_change('value', callbacks.speed_slider_callback)
alive_color_dropdown.on_change('value', callbacks.alive_dropdown_callback)
dead_color_dropdown.on_change('value', callbacks.dead_dropdown_callback)
start_button.on_click(callbacks.start_button_callback)

layout = Row(Column(generations_slider, alive_color_dropdown, dead_color_dropdown, speed_slider, start_button), plot)
curdoc().add_root(layout)
def tab_testing():
    data_list = glob.glob('./np/Regression/*.npy')
    data_list = sorted(data_list)
    select_data = Select(title="Data:", value="", options=data_list)

    model_list = os.listdir('./model/Regression/')
    model_list = sorted(model_list)
    select_model = Select(title="Trained Model:", value="", options=model_list)

    notifier = Paragraph(text=""" Notification """, width=200, height=100)

    def refresh_handler():
        data_list_new = glob.glob('./np/Regression/*.npy')
        data_list_new = sorted(data_list_new)
        select_data.options = data_list_new

        model_list_new = os.listdir('./model/Regression/')
        model_list_new = sorted(model_list_new)
        select_model.options = model_list_new

    button_refresh = Button(label="Refresh list")
    button_refresh.on_click(refresh_handler)

    button_test = Button(label="Test model")

    select_result = MultiSelect(title="Key(result):")

    src = ColumnDataSource()
    df = pd.DataFrame(columns=['key', 'y', 'y_hat'])

    table_src = ColumnDataSource(pd.DataFrame(columns=['Key', 'MSE', 'R^2']))
    table_columns = [
        TableColumn(field=col, title=col) for col in ['Key', 'MSE', 'R^2']
    ]
    table_acc = DataTable(source=table_src,
                          columns=table_columns,
                          width=350,
                          height=400,
                          fit_columns=True,
                          name="Accuracy per Key")

    def test_handler():
        df.drop(df.index, inplace=True)
        print("Start test")
        tf.reset_default_graph()
        K.clear_session()

        notifier.text = """ Start testing """

        if (select_data.value == ""):
            data = np.load(select_data.options[0])
        else:
            data = np.load(select_data.value)
        data = data.item()
        notifier.text = """ Import data """

        data_x = data.get('x')
        if (data_x.shape[-1] == 1 and not 'cnn' in select_model.value):
            data_x = np.squeeze(data_x, -1)
        data_y = data.get('y')
        data_key = data.get('key1')

        print(data_x.shape)
        print(data_y.shape)

        df['key'] = data_key
        df['y'] = data_y[:, 0]

        op_list = []
        for i in df['key'].unique():
            op_list.append(str(i))
        select_result.options = op_list

        print(data_x.shape)
        print(data_y.shape)
        print(data.get('key1'))

        if (select_model.value == ""):
            model_name = select_model.options[0]
        else:
            model_name = select_model.value
        model_save_dir = './model/Regression/' + model_name + '/'

        model_dl = glob.glob(model_save_dir + '*.h5')
        model_ml = glob.glob(model_save_dir + '*.sav')

        print(model_save_dir + '*.h5')
        print(model_dl)
        print(model_ml)

        if (len(model_dl) > len(model_ml)):
            model = keras.models.load_model(model_save_dir + model_name +
                                            '.h5')
            target_hat = model.predict(data_x)
            DL = True

        elif (len(model_dl) < len(model_ml)):
            model = pickle.load(
                open(model_save_dir + model_name + '.sav', 'rb'))
            data_x = data_x.reshape([data_x.shape[0], -1])
            target_hat = model.predict(data_x)
            target_hat = np.expand_dims(target_hat, -1)
            DL = False

        notifier.text = """ Model restored """
        print("Model restored.")

        xs = []
        ys = []
        keys = []
        color = ['blue', 'red']

        xs.append([i for i in range(data_y.shape[0])])
        xs.append([i for i in range(data_y.shape[0])])
        ys.append(data_y)
        keys.append(data_key)

        print(target_hat.shape)
        K.clear_session()

        ys.append(target_hat)
        keys.append(data_key)

        print(target_hat[:, 0])
        df['y_hat'] = target_hat[:, 0]

        src.data = ColumnDataSource(
            data=dict(xs=xs, ys=ys, color=color, keys=keys)).data

        figure_trend.multi_line('xs', 'ys', source=src, color='color')

        line_mse = []
        line_r_2 = []
        for unit in df['key'].unique():
            target = df[df['key'] == unit]

            y = target['y'].values
            y_hat = target['y_hat'].values

            unit_mse = np.sum((y - y_hat)**2) / target.shape[0]
            unit_r_2 = np.max([r2_score(y, y_hat), 0])

            line_mse.append(unit_mse)
            line_r_2.append(unit_r_2)

        acc = pd.DataFrame(columns=['Key', 'MSE', 'R^2'])
        acc['Key'] = df['key'].unique()

        mse_mean = np.mean(line_mse)
        r_2_mean = np.mean(line_r_2)

        line_mse = list(map(lambda x: format(x, '.2f'), line_mse))
        acc['MSE'] = line_mse
        line_r_2 = list(map(lambda x: format(x, '.2f'), line_r_2))
        acc['R^2'] = line_r_2

        acc_append = pd.DataFrame(columns=acc.columns)
        acc_append['Key'] = ['MSE average', 'R^2 average']
        acc_append['MSE'] = [mse_mean, r_2_mean]

        acc = pd.concat([acc, acc_append])

        table_src.data = ColumnDataSource(acc).data

        notifier.text = """ Drawing complete """
        history.text = history.text + "\n\t" + model_name + "'s R^2 score: " + format(
            np.mean(r_2_mean), '.2f')

    def update(attr, old, new):

        key_to_plot = select_result.value

        xs = []
        ys = []
        keys = []

        y = []
        y_hat = []
        key = []

        key_type = type(df['key'].values[0])
        for k in key_to_plot:

            y += list(df[df['key'] == key_type(k)]['y'].values)
            y_hat += list(df[df['key'] == key_type(k)]['y_hat'].values)
            key += [k for _ in range(df[df['key'] == key_type(k)].shape[0])]

        ys.append(y)
        ys.append(y_hat)

        xs.append([i for i in range(len(y))])
        xs.append([i for i in range(len(y))])

        keys.append(key)
        keys.append(key)

        color = ['blue', 'red']

        src.data = ColumnDataSource(
            data=dict(xs=xs, ys=ys, color=color, keys=keys)).data

    select_result.on_change("value", update)

    button_test.on_click(test_handler)

    button_export = Button(label="Export result")

    def handler_export():
        df.to_csv('./Export/result.csv', index=False)

    button_export.on_click(handler_export)

    figure_trend = figure(title="Prediction result", width=800, height=460)
    history = PreText(text="", width=300, height=460)

    layout = Column(
        Row(button_refresh),
        Row(select_data, select_model, button_test, select_result, notifier),
        Row(table_acc, figure_trend, history, button_export))

    tab = Panel(child=layout, title='Regression Test')

    return tab
Beispiel #29
0
def qso_updater(attr, old, new):
    indexes = np.array(new['1d']['indices'],
                       dtype='int')  # the indices of the selected QSOs.
    mags = [qso_catalog.data['fuvmag'][i] for i in indexes]
    print(mags)
    hist_source.data['cos'] = [np.size(mags) * 20.]
    hist_source.data['lumos'] = [np.size(mags) * 2.]
    if (np.size(mags) * 20. > 250.): hist_source.data['coscolor'] = ['red']
    if (np.size(mags) * 2. > 250.): hist_source.data['coscolor'] = ['red']
    print("DONE WITH QSO_UPDATER")


aperture = Slider(title="Aperture (meters)",
                  value=15.,
                  start=3.,
                  end=15.0,
                  step=3.0,
                  callback_policy='mouseup',
                  width=550)
aperture.on_change('value', update_image)

#qso_syms.data_source.on_change('selected', qso_updater)

#plot1_tab = Panel(child=[p1], title='CenA', width=550, height=800)
#plot2_tab = Panel(child=[p2], title=galaxy['name'], width=550, height=800)
#info_tab = Panel(child=Div(text=h.help(),width=450, height=300), title='Info', width=550, height=300)
#tabs = Tabs(tabs=[plot2_tab], width=550)
#adf = gridplot([aperture],[tabs])
curdoc().add_root(Column(aperture, Row(p2, hist_plot)))
Beispiel #30
0
def fpe_fpa_plots(conn, start, end):
    '''Combines plots to a tab
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : tab object
        used by dashboard.py to set up dashboard
    '''
    descr = Div(text=
    """
    <style>
    table, th, td {
      border: 1px solid black;
      background-color: #efefef;
      border-collapse: collapse;
      padding: 5px
    }
    table {
      border-spacing: 15px;
    }
    </style>

    <body>
    <table style="width:100%">
      <tr>
        <th><h6>Plotname</h6></th>
        <th><h6>Mnemonic</h6></th>
        <th><h6>Description</h6></th>
      </tr>
      <tr>
        <td>ASIC (1,2) Voltages</td>
        <td>IGDP_NRSD_ALG_A(1,2)_VDDA<br>
            IGDP_NRSD_ALG_A(1,2)GND4VDA<br>
            IGDP_NRSD_ALG_A(1,2)GND5VRF<br>
            INRSD_ALG_A(1,2)_VDD3P3<br>
            INRSD_ALG_A(1,2)_VDD<br>
            INRSD_ALG_A(1,2)_REF<br>
            INRSD_A(1,2)_DSUB_V<br>
            INRSD_A(1,2)_VRESET_V<br>
            INRSD_A(1,2)_CELLDRN_V<br>
            INRSD_A(1,2)_DRAIN_V<br>
            INRSD_A(1,2)_VBIASGATE_V<br>
            INRSD_A(1,2)_VBIASPWR_V<br>
        </td>
        <td>
            ASIC (1,2) VDDA Voltage<br>
            ASIC (1,2) VDDA/Ground Voltage<br>
            ASIC (1,2) Ref/Ground Voltage<br>
            ASIC (1,2) VDD 3.3 Supply Voltage<br>
            ASIC (1,2) VDD Voltage<br>
            ASIC (1,2) Reference Voltage<br>
            ASIC (1,2) Dsub Voltage<br>
            ASIC (1,2) Reset Voltage<br>
            ASIC (1,2) Cell Drain Voltage<br>
            ASIC (1,2) Drain Voltage<br>
            ASIC (1,2) Bias Gate Voltage<br>
            ASIC (1,2) Bias Power Voltage<br>
        </td>
      </tr>

      <tr>
        <td>ASIC (1,2) Currents</td>
        <td>IGDP_NRSD_ALG_A(1,2)_VDD_C<br>
            IGDP_NRSD_ALG_A(1,2)VDAP12C<br>
            IGDP_NRSD_ALG_A(1,2)VDAN12C<br>
            INRSD_A(1,2)_VDDA_I<br>
        </td>
        <td>ASIC (1,2) VDD Current<br>
            ASIC (1,2) VDDA +12V Current<br>
            ASIC (1,2) VDDA -12V Current<br>
            ASIC (1,2) VDDA Current<br>
        </td>
      </tr>
      
    </table>
    </body>
    """, width=1100)

    plot1 = asic_1_voltages(conn, start, end)
    plot2 = asic_2_voltages(conn, start, end)
    plot3 = asic_1_currents(conn, start, end)
    plot4 = asic_2_currents(conn, start, end)

    currents = Row(plot3, plot4)
    layout = Column(descr, plot1, plot2, currents)

    tab = Panel(child = layout, title = "FPE/FPA")

    return tab