コード例 #1
0
ファイル: app.py プロジェクト: TimoRoth/glaciers
def get_oggm_panel():
    geo_bounds  = BoundsXY(source=static_geo,  rename={'bounds':  'cenlon__cenlat'})
    elev_bounds = BoundsXY(source=static_elev, rename={'bounds':  'mean_elev__latdeg'})
    temp_bounds = BoundsX(source=static_temp, rename={'boundsx': 'avg_temp_at_mean_elev'})
    prcp_bounds = BoundsX(source=static_prcp, rename={'boundsx': 'avg_prcp'})

    selections  = [geo_bounds, elev_bounds, temp_bounds, prcp_bounds]
    dyn_data    = hv.DynamicMap(select_data, streams=selections)

    dyn_geo   = rasterize(dyn_data.apply(geo),  **geo_kw).options( **geo_opts)
    dyn_elev  = datashade(dyn_data.apply(elev), **elev_kw).options(**elev_opts)
    dyn_temp  =           dyn_data.apply(temp)
    dyn_prcp  =           dyn_data.apply(prcp)
    dyn_count =           dyn_data.apply(count)

    geomap = geo_bg * static_geo  * dyn_geo
    elevation       = static_elev * dyn_elev
    temperature     = static_temp * dyn_temp
    precipitation   = static_prcp * dyn_prcp

    def clear_selections(arg=None):
        geo_bounds.update(bounds=None)
        elev_bounds.update(bounds=None)
        temp_bounds.update(boundsx=None)
        prcp_bounds.update(boundsx=None)
        Stream.trigger(selections)

    clear_button = pn.widgets.Button(name='Clear selection')
    clear_button.param.watch(clear_selections, 'clicks');

    title       = '<div style="font-size:35px">World glaciers explorer</div>'
    instruction = 'Box-select on each plot to subselect; clear selection to reset.<br>' + \
                  'See the <a href="https://github.com/panel-demos/glaciers">Jupyter notebook</a> source code for how to build apps like this!'
    oggm_logo   = '<a href="https://oggm.org"><img src="https://raw.githubusercontent.com/OGGM/oggm/master/docs/_static/logos/oggm_s_alpha.png" width=170></a>'
    pn_logo     = '<a href="https://panel.pyviz.org"><img src="https://panel.pyviz.org/_static/logo_stacked.png" width=140></a>'

    header = pn.Row(pn.Pane(oggm_logo),  pn.layout.Spacer(width=30),
                    pn.Column(pn.Pane(title, width=400), pn.Pane(instruction, width=500)),
                    pn.layout.HSpacer(), pn.Column(pn.Pane(dyn_count), pn.layout.Spacer(height=20), clear_button),
                    pn.Pane(pn_logo, width=140))

    return pn.Column(header, pn.Row(geomap, elevation), pn.Row(temperature, precipitation), width_policy='max', height_policy='max')
コード例 #2
0
    def view(self) -> pn.Column:
        """Returns the view of the application

        Returns:
            pn.Column: The view of the app
        """
        pn.config.sizing_mode = "stretch_width"
        pn.extension("echarts")
        top_app_bar = pn.Row(
            pn.pane.PNG(
                "https://echarts.apache.org/en/images/logo.png",
                sizing_mode="fixed",
                height=40,
                margin=(15, 0, 5, 25),
                embed=False,
            ),
            pn.layout.VSpacer(),
            "",
            background="lightgray",
            height=70,
        )

        settings_pane = pn.Param(
            self,
            show_name=False,
            width=200,
            sizing_mode="fixed",
            background="rgb(245, 247, 250)",
        )

        main = [
            APPLICATION.intro_section(),
            pn.Column(
                top_app_bar,
                pn.layout.HSpacer(height=50),
                pn.Row(self.plot, settings_pane, sizing_mode="stretch_width"),
            ),
        ]
        return pn.template.FastListTemplate(title="Test ECharts",
                                            theme="default",
                                            main=main,
                                            theme_toggle=False)
コード例 #3
0
ファイル: dashboard.py プロジェクト: wt12318/epitopepredict
    def update_banner():
        """Update the banner"""

        fullpath = os.path.abspath(path)
        banner = pn.Row(
            pn.pane.Markdown(
                '<h4>epitopepredict: %s</h4> [help](%s) version %s' %
                (fullpath, helppage, __version__),
                css_classes=['divheader'],
                sizing_mode='stretch_width'))
        return banner
コード例 #4
0
ファイル: core.py プロジェクト: vishankkumar/abipy
    def on_edos_plotter_btn(self):
        if self.edos_plotter_btn.clicks == 0: return
        edos_plotter = self.robot.get_edos_plotter()
        plot_mode = self.edos_plotter_mode.value
        plotfunc = getattr(edos_plotter, plot_mode, None)
        if plotfunc is None:
            raise ValueError("Don't know how to handle plot_mode: %s" %
                             plot_mode)

        fig = plotfunc(**self.fig_kwargs)
        return pn.Row(pn.Column(self._mp(fig)), sizing_mode='scale_width')
コード例 #5
0
    def panel(self):
        "view the app"

        return pn.Column(
            pn.Row(
                pn.Spacer(width=30),
                pn.Column(self.view_left_plot, ),
                pn.Column(self.view_right_plot, ),
            ),
            self.date_slider,
        )
コード例 #6
0
 def build_gui(self):
     self.source = ColumnDataSource({"x": self.data[0], "y": self.data[1]})
     p = figure(x_axis_label=self.x_label,
                y_axis_label=self.y_label,
                width=self.width,
                height=self.height,
                tools="lasso_select")
     p.scatter("x", "y", source=self.source)
     p.select_one(LassoSelectTool).select_every_mousemove = False
     self.figure = p
     self.gui = pn.Row(self.figure)
コード例 #7
0
    def widget_plot_module(self):
        if isinstance(self.Aruco, MarkerDetection):
            marker = pn.Column(self.widgets_aruco_visualization(), self.widget_thread_controller())
            widgets = pn.Column(self.cmap_frame.show_widgets(),
                                self.contours.show_widgets())
            rows = pn.Row(widgets, marker)
        else:
            widgets = pn.Column(self.cmap_frame.show_widgets(),
                                self.contours.show_widgets())
            rows = pn.Row(widgets, self.widget_thread_controller())

        panel1 = pn.Column("## Plotting interaction widgets", rows)
        self._update_widget_module_selector()

        panel2 = self.projector.show_widgets_sidepanels()

        panel = pn.Tabs(("Main frame controller", panel1),
                        ("Side panel controller", panel2))

        return panel
コード例 #8
0
ファイル: annutils.py プロジェクト: dwr-psandhu/ann_calsim
def show(df_x, df_y, mlp, xs, ys):
    y = np.ravel(ys.transform(df_y))
    y_pred = mlp.predict(xs.transform(df_x))
    r2 = mlp.score(xs.transform(df_x), y)
    print('Score: ', r2)
    return pn.Column(
        pn.Row(
            hv.Scatter((y, y_pred)).opts(aspect='square'),
            hv.Distribution(y_pred - y).opts(aspect='square')),
        hv.Curve((df_y.index, y_pred), label='prediction') * hv.Curve(
            (df_y.index, y), label='target').opts(width=800))
コード例 #9
0
 def show_widget_legend(self):
     self._create_widgets_legend()
     panel3 = pn.Column("### Legend",
                        self._widgets_show_legend,
                        self._widget_refresh_leg)
     panel4 = pn.Column(self._widget_top_legend,
                        self._widget_left_legend,
                        self._widget_width_legend,
                        self._widget_height_legend,
                        self._widget_leg_background)
     return pn.Row(panel3, panel4)
コード例 #10
0
 def _build_output(self, fig):
     kwargs = {}
     if hasattr(self, 'widgets'):
         kwargs['widgets'] = self.widgets
     buttons = pn.Row(self.plot_button, self.file_download)
     output = pn.Column(pn.Param(self.param, **kwargs), self.select_dataset,
                        self.subsetter, self.purpose, buttons,
                        self.browser_url, fig)
     if self.viewer is not None:
         self.viewer._panels[self.name] = self.browser_url
     return output
コード例 #11
0
 def _previous(self, _):
     """Logic for the previous button"""
     index = int(self.current.value)
     if index == 1:
         index = self.num_entries
     else:
         index -= 1
     self.UPDATING = True
     self.current.value = str(index)
     self.UPDATING = False
     self.image = pn.Row(self.get_image_by_index(index - 1), align="center")
コード例 #12
0
def get_title(text, uuid=None):
    """Return pn.Row representation of title.

    Includes provenance link, if uuid is specified.
    """
    title = pn.Row(pn.pane.Markdown('#### ' + text), align='start')

    if uuid is not None:
        title.append(provenance_link(uuid))

    return title
コード例 #13
0
def headline(label, popup_label=None, style=None):
    """Create an HTML headline pane for the given parameter"""
    widget = pn.Row(
        pn.pane.HTML(
            f"<b>{label}</b>", css_classes=["headline"], sizing_mode="stretch_width"
        )
    )
    if popup_label is not None:
        widget.insert(0, pn.pane.HTML(popup(label=popup_label, style=style)))

    return widget
コード例 #14
0
 def show_widget_colorbar(self):
     self._create_widgets_colorbar()
     panel1 = pn.Column("### Colorbar", self._widgets_show_colorbar,
                        self._widget_label, self._widget_refresh_col)
     panel2 = pn.Column(self._widget_colorbar_ori,
                        self._widget_top_colorbar,
                        self._widget_left_colorbar,
                        self._widget_width_colorbar,
                        self._widget_height_colorbar,
                        self._widget_col_background)
     return pn.Row(panel1, panel2)
コード例 #15
0
ファイル: phonons.py プロジェクト: vishankkumar/abipy
    def get_panel(self):
        """Return tabs with widgets to interact with the |PhononBandsPlotter|."""
        tabs = pn.Tabs()
        ws = pn.Column(self.phbands_plotter_mode, self.phbands_plotter_units,
                       self.phbands_plotter_btn)
        tabs.append(("PhbandsPlotter",
                     pn.Row(ws,
                            self.on_phbands_plot_btn,
                            sizing_mode='scale_width')))

        return tabs
コード例 #16
0
 def _options_pane_setup(self):
     self.options_pane.clear()
     self.options_pane.extend([
         pn.pane.Markdown("""### Colormaps"""),
         pn.Column(
             self.colormap,
             pn.Column(
                 pn.Row(self.colormap_min, pn.layout.HSpacer(),
                        self.colormap_max),
                 self.colormap_range_slider,
             ),
             self.colormap_delta,
         ),
         pn.pane.Markdown("""### Change Values"""),
         pn.Column(
             self.spinner,
             self.apply,
             pn.Row(self.undo_button, self.redo_button),
         ),
     ])
コード例 #17
0
 def panel(self):
     return pn.Column(
         pn.Row(
             self.pipeline.title,
             self.pipeline.network,
             self.pipeline.prev_button,
             self.pipeline.next_button,
         ),
         self.pipeline.stage,
         sizing_mode='stretch_width',
     )
コード例 #18
0
    def build_gui(self):
        self.dataset_filter = self.DATASET_FILTER(
            self.base_dataset,
            columns=self.DATASET_FILTER_COLUMNS,
            width=self.width,
            height=self.height - 50)
        self.dataset_filter_create_dataset_button = pnw.Button(name="Create",
                                                               height=50)
        self.dataset_filter_create_dataset_button.on_click(self.create_dataset)
        self.dataset_filter_with_export = pn.Column(
            pn.Row(self.dataset_filter.show(), align="center"),
            pn.Row(self.dataset_filter_create_dataset_button, align="center"))

        if self.with_dataset_overview:
            self.created_datasets_overview = self.MULTI_DATASET_OVERVIEW(
                self.created_datasets,
                with_del_button=True,
                height=150,
                width=self.width)
            self.selected_dataset_overview = self.DATASET_OVERVIEW(
                self.base_dataset, height=self.height - 250,
                width=self.width).gui
        else:
            self.created_datasets_overview = self.MULTI_DATASET_OVERVIEW(
                self.created_datasets,
                with_del_button=True,
                height=self.height - 100,
                width=self.width)
            self.selected_dataset_overview = pn.Spacer(
                sizing_mode="stretch_both")
        self.export_gui = self.create_export_gui()
        self.datasets_overview = pn.Column(
            pn.Row(self.created_datasets_overview.gui, align="center"),
            pn.Row(self.selected_dataset_overview, align="center"),
            pn.Row(self.export_gui, align="center"))
        if self.with_dataset_overview:
            self.created_datasets_overview.overview_table.param.watch(
                self.update_dataset_overview, "selection")

        self.gui = pn.Tabs(("Dataset Filter", self.dataset_filter_with_export),
                           ("Dataset Overview", self.datasets_overview))
コード例 #19
0
    def delete_panel(self):
        if self.show_delete_panel:
            delete_btn = pn.widgets.Button(name='Delete',
                                           button_type='danger',
                                           width=100)
            delete_btn.on_click(self._delete_selected_profile)
            cancel_btn = pn.widgets.Button(name='Cancel',
                                           button_type='primary',
                                           width=100)
            cancel_btn.on_click(lambda e: self.update_delete_panel(False))

            code = 'o.disabled=true; ' \
                   'btn.css_classes.push("pn-loading", "arcs"); btn.properties.css_classes.change.emit();'

            delete_btn.js_on_click(args={
                'btn': delete_btn,
                'o': cancel_btn
            },
                                   code=code)
            cancel_btn.js_on_click(args={
                'btn': cancel_btn,
                'o': delete_btn
            },
                                   code=code)

            return pn.Column(
                self.param.environment_profile_delete,
                pn.pane.Alert(
                    'Are you sure you want to delete the selected profile? This action cannot be undone.',
                    alert_type='danger'),
                pn.Row(delete_btn, cancel_btn, align='end'))
        else:
            delete_btn = pn.widgets.Button(name='Delete Selected Profile',
                                           button_type='danger',
                                           width=200)
            delete_btn.on_click(lambda e: self.update_delete_panel(True))
            code = 'btn.css_classes.push("pn-loading", "arcs"); btn.properties.css_classes.change.emit();'
            delete_btn.js_on_click(args={'btn': delete_btn}, code=code)

            return pn.Column(self.param.environment_profile_delete,
                             pn.Row(delete_btn, align='end'))
コード例 #20
0
    def panel(self):
        load_tab = pn.Column(
            pn.panel(self.param, parameters=['filepath'], show_name=False),
            pn.panel(self.scatter_projection.param, expand_button=False),
            pn.panel(self.param, parameters=['load_data'], show_name=False))

        map_pane = self.view_map

        interp_pane = pn.Column(
            pn.panel(self.param,
                     parameters=['interpolation_option', 'nodal_function'],
                     show_name=False),
            pn.Row(
                pn.panel(self.param,
                         parameters=['truncation', 'truncation_range'],
                         show_name=False), ),
            pn.panel(self.param, parameters=['interp_button'],
                     show_name=False))

        display_tab = pn.Column(
            pn.panel(self.cmap_opts.param,
                     parameters=['colormap'],
                     show_name=False),
            pn.panel(self.display_range.param,
                     parameters=['color_range'],
                     show_name=False),
            pn.panel(self.param,
                     parameters=['scatter_toggle'],
                     show_name=False),
            pn.panel(self.adh_mod.mesh.param,
                     parameters=['elements_toggle', 'elevation_toggle'],
                     show_name=False),
            pn.panel(self.adh_mod.wmts.param,
                     parameters=['source'],
                     expand_button=False,
                     show_name=False))

        tool_panel = pn.Tabs(('Load Data', load_tab), ('Display', display_tab),
                             ('Interpolate', interp_pane))

        return pn.Row(map_pane, tool_panel)
コード例 #21
0
 def update_sorting(self, event):
     """Calculates the new index order for sorting."""
     sort_ascending = False if "Desc." in self.sort_order.value else True
     data = getattr(self.data, self.gallery_desciptor).sort_values(
         self.sorter.value, ascending=sort_ascending)
     if "Drop duplicates" in self.sort_order.value:
         data = data.drop_duplicates(self.img_id_col)
     self.num_entries = data.shape[0]
     self.image_count = pn.Row("/" + str(self.num_entries),
                               width=int(self.width / 6))
     self.gui_image_selection_controlls[2] = self.image_count
     self.index_mapping = data.reset_index(drop=True)
コード例 #22
0
    def create_export_gui(self):
        self.export_path = pnw.TextInput(name="Export path", value="datasets", height=50)
        self.export_button = pnw.Button(name="Export", align="end", height=50)
        self.export_button.on_click(self.export_datasets)

        export_dataset_name = "" if len(self.created_datasets) == 0 else self.created_datasets[self.export_dataset_overview.selection[0]].name
        export_description_name = "" if len(self.created_datasets) == 0 else self.created_datasets[self.export_dataset_overview.selection[0]].description
        self.export_name_input = pnw.TextInput(name="Dataset name", value=export_dataset_name, height=50)
        self.export_name_input.param.watch(self.change_dataset_name, "value")
        self.export_description_input = pnw.TextAreaInput(name="Description", value=export_description_name, height=50)
        self.export_description_input.param.watch(self.change_dataset_description, "value")
        return pn.Column(pn.Row(self.export_name_input, self.export_description_input), pn.Row(self.export_path, self.export_button))
コード例 #23
0
ファイル: viewer.py プロジェクト: penikune/abinit
    def view_fort_file(self):
        dirpath = self.dirname2path[self.dir_select.value]
        fort_file = self._find_fort_file(dirpath)

        # Update widgets.
        self.pubproc_select.options = list(fort_file.all_public_procedures.keys())
        self.datatype_select.options = list(fort_file.all_datatypes.keys())
        if hasattr(self, "tabs"): self.tabs.active = 1

        return pn.Row(_df(fort_file.get_stats()),
                      fort_file.get_graphviz(engine=self.engine.value),
                      sizing_mode="scale_width")
コード例 #24
0
 def _create_view(self):
     self.settings_panel = pn.Param(
         self, parameters=["value_a", "value_b", "value_c"])
     self.plot_panel = pn.pane.HoloViews(sizing_mode="stretch_width")
     self.progress = pn.widgets.Progress(sizing_mode="stretch_width",
                                         bar_color="primary")
     self.view = pn.Column(
         self.progress,
         pn.Row(pn.WidgetBox(self.settings_panel),
                self.plot_panel,
                sizing_mode="stretch_width"),
     )
コード例 #25
0
ファイル: gui.py プロジェクト: zillow/intake
 def __init__(self, cats=None):
     self.source = SourceGUI()
     self.cat = CatGUI(cats=cats, done_callback=self.done_callback)
     self.panel = pn.Column(pn.Row(pn.panel(ICONS['logo']),
                                   pn.Column(self.cat.select.panel,
                                             self.cat.control_panel,
                                             margin=0,
                                             width_policy='max'),
                                   pn.Column(self.source.select.panel,
                                             self.source.control_panel,
                                             margin=0,
                                             width_policy='max'),
                                   self.source.description.panel,
                                   margin=0,
                                   width_policy='max'),
                            pn.Row(self.cat.search.panel,
                                   self.cat.add.panel,
                                   self.source.plot.panel,
                                   width_policy='max'),
                            width_policy='max')
     super(GUI, self).__init__()
コード例 #26
0
    def widget_boreholes(self):
        self._widget_show_boreholes = pn.widgets.Button(
            name="Show Boreholes panel", button_type="success")
        self._widget_show_boreholes.param.watch(self._callback_show_boreholes,
                                                'clicks',
                                                onlychanged=False)

        self._widget_show_boreholes_pyvista = pn.widgets.Button(
            name="Show Boreholes pyvista", button_type="warning")
        self._widget_show_boreholes_pyvista.param.watch(
            self._callback_show_boreholes_pyvista, 'clicks', onlychanged=False)
        self._w_borehole_name = pn.widgets.TextInput(name='Borehole name',
                                                     value='BH_1')
        self._w_x = pn.widgets.TextInput(name='x:', value='10.0', width=60)
        self._w_y = pn.widgets.TextInput(name='y:', value='20.0', width=60)

        self._widget_add_bh = pn.widgets.Button(name="Add borehole",
                                                button_type="success")
        self._widget_add_bh.param.watch(self._callback_add_bh,
                                        'clicks',
                                        onlychanged=False)

        self._w_remove_borehole_name = pn.widgets.AutocompleteInput(
            name='Remove borehole name',
            options=list(self.borehole_dict.keys()))
        self._widget_remove_bh = pn.widgets.Button(name="Remove borehole",
                                                   button_type="success")
        self._widget_remove_bh.param.watch(self._callback_remove_bh,
                                           'clicks',
                                           onlychanged=False)

        self._widget_boreholes_available = pn.widgets.RadioBoxGroup(
            name='Available boreholes',
            options=list(self.borehole_dict.keys()),
            inline=False,
            disabled=True)

        widgets = pn.Column(
            '### Creation of boreholes',
            self._widget_show_boreholes,
            self._widget_show_boreholes_pyvista,
            '<b>add new borehole </b>',
            pn.WidgetBox(self._w_borehole_name, pn.Row(self._w_x, self._w_y)),
            self._widget_add_bh,
            '<b>Remove borehole</b>',
            self._w_remove_borehole_name,
            self._widget_remove_bh,
            '<b>Loaded boreholes</b>',
            self._widget_boreholes_available,
        )
        # TODO: add method to include more boreholes

        return widgets
コード例 #27
0
ファイル: resource.py プロジェクト: jmosbacher/eve-panel
 def gui_progress(self):
     if self._progress is None:
         self._progress = pn.indicators.Progress(value=0,
                                                 active=self._active,
                                                 align="center")
     npages = 0
     if self.page_number:
         npages = len(self.page_numbers)
         if npages:
             self._progress.value = int(100 * self.page_number / npages)
     return pn.Row(self._progress,
                   f"[{self.page_number or 'NA'} / {npages or 'NA'}]")
コード例 #28
0
    def panel(self):

        return pn.Row(
            pn.Column(
                pn.pane.Markdown(f'##{self.param.name_of_page.default}'),
                self.options_page,
            ),
            pn.Column(
                pn.Spacer(height=52),
                self.df_pane,
                self.continue_button_pane,
            ))
コード例 #29
0
ファイル: defined_plots.py プロジェクト: leifdenby/intake
    def setup(self):
        self.instructions = pn.pane.Markdown(self.instructions_contents,
                                             align='center',
                                             width_policy='max')
        self.select = pn.widgets.Select(options=self.options,
                                        height=30,
                                        align='center',
                                        min_width=200)
        self.pane = pn.pane.HoloViews(self._plot_object(self.selected),
                                      name="Plot")

        self.watchers = [
            self.select.param.watch(self.callback, ['options', 'value']),
            self.custom.param.watch(self.interact, ['clicks'])
        ]
        self.out = pn.Row(self.pane, name="Plot")

        self.children = [
            pn.Row(self.instructions, self.select, self.custom),
            self.out,
        ]
コード例 #30
0
    def setup(self):
        self.watchers = [
            self.plot_widget.param.watch(self.on_click_plot_widget, 'value'),
            self.select.widget.link(self.description, value='source'),
        ]

        self.children = [
            pn.Row(pn.Column(self.select.panel, self.control_panel, margin=0),
                   self.description.panel,
                   margin=0),
            self.plot.panel,
        ]