Exemplo n.º 1
0
 def __init__(self, eem_stack_cw, datlist_cw, range1, range2, em_range_cw,
              ex_range_cw, timestamps_cw):
     self.eem_stack_cw = eem_stack_cw
     self.datlist_cw = datlist_cw
     self.range1 = range1
     self.range2 = range2
     self.em_range_cw = em_range_cw
     self.ex_range_cw = ex_range_cw
     self.timestamps_cw = timestamps_cw
     self.property_pixel = ipywidgets.Dropdown(
         options=['Timeseries analysis', 'Correlation analysis'],
         description='Property')
     self.em_pixel = ipywidgets.FloatText(value=400, description='Em [nm]')
     self.ex_pixel = ipywidgets.FloatText(value=300, description='Ex [nm]')
     self.caption_pixel_statistics = ipywidgets.Label(
         value='For correlation analysis, please specify the reference '
         'data with either a file path or a manual input')
     self.checkbox_reference_filepath_pixel = ipywidgets.Checkbox(
         value=False)
     self.reference_filepath_pixel = ipywidgets.Text(
         value='reference_example.txt',
         description='File path of input reference data',
         style={'description_width': 'initial'},
         layout=Layout(width='400%'))
     self.checkbox_reference_mannual_input_pixel = ipywidgets.Checkbox(
         value=True)
     self.reference_mannual_input_pixel = ipywidgets.Text(
         description='Type input reference data manually',
         style={'description_width': 'initial'},
         layout=Layout(width='400%'))
     self.button_pixel_statistics = ipywidgets.Button(
         description='Calculate')
Exemplo n.º 2
0
    def __init__(self, net_widget, interactions=None):
        self.key = "PPI"
        self.net = net_widget
        self.interactions = interactions
        self.is_on = w.ToggleButton(description="PPI",
                                    value=False,
                                    layout=w.Layout(width="15%",
                                                    height="40px"))
        self.s1 = w.Dropdown(description="Species 1",
                             options={
                                 "S{}".format(key): key
                                 for key in self.net.types["Complexable"]
                             })
        self.s2 = w.Dropdown(description="Species 2",
                             options={
                                 "S{}".format(key): key
                                 for key in self.net.types["Complexable"]
                             })
        self.custom_p = w.Checkbox(description="custom parameters",
                                   value=False,
                                   layout=w.Layout(width="23%", height="40px"))

        self.kp = w.FloatText(description="k+",
                              value=1,
                              step=0.0001,
                              layout=w.Layout(width="15%", height="40px"))
        self.km = w.FloatText(description="k-",
                              value=1,
                              step=0.0001,
                              layout=w.Layout(width="15%", height="40px"))

        self.update_param_state(False)
        self.update_inter_state(False)
        w.interactive(self.update_inter_state, button=self.is_on)
        w.interactive(self.update_param_state, button=self.custom_p)
Exemplo n.º 3
0
    def __drawWidgets(self):
        nv = self.nv
        vars = self.vars
        steps = self.steps
        self.layout = ipywidgets.GridspecLayout(nv + 1, 3)
        for i, (pname, pstep) in enumerate(zip(vars, steps)):
            self.layout[i, 0] = ipywidgets.FloatText(
                description=pname,
                value=self.parameterobj.parameters.get(pname),
                step=pstep)
            self.layout[i, 0].observe(self.__parCallBack, names='value')
            self.layout[i, 1] = ipywidgets.ToggleButton(
                description="Vary " + pname, value=pname in self.getvars())
            self.layout[i, 1].observe(self.__fixVaryCallBack, names='value')

        self.layout[nv, 0] = ipywidgets.FloatText(
            description='fit_tolerance',
            value=self.parameterobj.parameters.get("fit_tolerance"),
            step=0,
        )
        self.layout[nv, 0].observe(self.__parCallBack, names='value')

        self.layout[nv, 1] = ipywidgets.Button(description="Run Fit (blocks)")
        self.layout[nv, 1].on_click(self.__fitCallBack)

        self.layout[0, 2] = ipywidgets.Button(description="Load parameters")
        self.layout[0, 2].on_click(self.__loadCallBack)

        self.layout[1, 2] = ipywidgets.Button(description="Save to a file")
        self.layout[1, 2].on_click(self.__saveCallBack)
Exemplo n.º 4
0
 def __init__(self, data):
     self.data = data
     self.res = [data.axis1.calibA, data.axis1.calibB, data.axis1.calibC]
     self.A = widgets.FloatText(value=data.axis1.calibA, description="A")
     self.B = widgets.FloatText(value=data.axis1.calibB, description="B")
     self.C = widgets.FloatText(value=data.axis1.calibC, description="C")
     self.bupdate = widgets.Button(
         description="Update",
         button_style=
         'success',  # 'success', 'info', 'warning', 'danger' or ''
         tooltip='set current data-sets to displayed values')
     self.bupdate.on_click(self.update)
     self.bback = widgets.Button(
         description="Restore",
         button_style=
         'success',  # 'success', 'info', 'warning', 'danger' or ''
         tooltip='restore dataset to initial values')
     self.bback.on_click(self.back)
     display(
         VBox([
             HBox([self.A, widgets.Label('Hz/Th')]),
             HBox([self.B, widgets.Label('Hz')]),
             HBox([self.C, widgets.Label('Hz/Th^2')]),
             HBox([self.bupdate, self.bback])
         ]))
 def _set_tab(self):
     ## set titles
     style = {'description_width': 'initial'}
     self.set_title(0,'Field setting')
     self.set_title(1,'Particle setting')
     self.set_title(2,'Simulation setting')
     self.set_title(3,'Output setting')
     self.set_title(4,'Word setting')
     
     ## set widgets
     self._field_setting = widgets.Select(options=['random','vortex','self-defined'],description='Select a field setting: ',\
                                         disabled=False,value='random',style=style)
     self._particle_num = widgets.IntText(description='Number of particles initially: ',disabled=False,value=100,style=style)
     self._particle_mode = widgets.Select(options=['random','middle','self-defined'],description=\
                                 'How particles are distributed initially: ',disables=False,value='random',style=style)
     self._particle_setting = widgets.Accordion(children=[self._particle_num,self._particle_mode])
     self._particle_setting.set_title(0,'Num of particles')
     self._particle_setting.set_title(1,'Distribution mode of particles')
     self._time_length = widgets.IntText(description='Simulation time length: ',disabled=False,value=200,style=style)
     self._time_period = widgets.IntText(description='Simulation time period: ',disabled=False,value=5,style=style)
     self._collision_threshold = widgets.FloatText(description='Particles collision threshold: ',disabled=False,value=0.0001,\
                                                 style=style)
     self._simulation_setting = widgets.Accordion(children=[self._time_length,self._time_period,self._collision_threshold])
     self._simulation_setting.set_title(0,'Time length')
     self._simulation_setting.set_title(1,'Time period')
     self._simulation_setting.set_title(2,'Collision threshold')
     self._output_setting = widgets.Text(description='Save output file to: ',disabled=False,style=style,\
                                         layout=widgets.Layout(width='50%'),value='C:\Users\User\Downloads\example')
     self._decay_rate = widgets.FloatText(description='Decay rate of transformation probability:',\
                                        disabled=False,value=0.001,style=style,layout=widgets.Layout(width='40%'))
     self._mutation_period = widgets.IntText(description='Mutation period of meanings: ',disabled=False,value=5,style=style)
     self._word_setting = widgets.Accordion(children=[self._decay_rate,self._mutation_period])
     self._word_setting.set_title(0,'State transformation probability decay rate')
     self._word_setting.set_title(1,'Mutation period of meanings')
Exemplo n.º 6
0
    def __init__(self, state, **kwargs):
        super(Size, self).__init__(**kwargs)
        self.state = state

        self.widget_size = widgets.FloatSlider(description='size', min=0, max=10, value=self.state.size)
        link((self.state, 'size'), (self.widget_size, 'value'))
        self.widget_scaling = widgets.FloatSlider(description='scale', min=0, max=2, value=self.state.size_scaling)
        link((self.state, 'size_scaling'), (self.widget_scaling, 'value'))

        options = type(self.state).size_mode.get_choice_labels(self.state)
        self.widget_size_mode = widgets.RadioButtons(options=options, description='size mode')
        link((self.state, 'size_mode'), (self.widget_size_mode, 'value'))

        self.widget_size_att = LinkedDropdown(self.state, 'size_att', ui_name='size attribute', label='size attribute')

        self.widget_size_vmin = widgets.FloatText(description='size min')
        self.widget_size_vmax = widgets.FloatText(description='size min')
        self.widget_size_v = widgets.VBox([self.widget_size_vmin, self.widget_size_vmax])
        link((self.state, 'size_vmin'), (self.widget_size_vmin, 'value'), lambda value: value or 0)
        link((self.state, 'size_vmax'), (self.widget_size_vmax, 'value'), lambda value: value or 1)

        dlink((self.widget_size_mode, 'value'), (self.widget_size.layout, 'display'),     lambda value: None if value == options[0] else 'none')
        dlink((self.widget_size_mode, 'value'), (self.widget_size_att.layout, 'display'), lambda value: None if value == options[1] else 'none')
        dlink((self.widget_size_mode, 'value'), (self.widget_size_v.layout, 'display'), lambda value: None if value == options[1] else 'none')

        self.children = (self.widget_size_mode, self.widget_size, self.widget_scaling, self.widget_size_att, self.widget_size_v)
Exemplo n.º 7
0
 def __init__(self, eem_stack, datlist_all, em_range, ex_range,
              eem_preview_parameters):
     self.datlist_all = datlist_all
     self.datlist_filtered = datlist_all.copy()
     self.idx2remove = []
     self.filelist_preview = ipywidgets.Dropdown(
         options=self.datlist_all,
         style={'description_width': 'initial'},
         layout={'width': 'max-content'})
     self.preview_parameter_dict = eem_preview_parameters  # from Widgets2and3
     self.eem_stack = eem_stack
     self.em_range = em_range
     self.ex_range = ex_range
     self.auto_detection_method = ipywidgets.Dropdown(
         options=['Isolation forest', 'One-class-SVM', 'Mixed'],
         description='Artefact detection algorithm')
     self.tf_normalization = ipywidgets.Checkbox(
         value=True, description='Normalize EEM with total fluorescence')
     self.grid_size = ipywidgets.FloatText(
         value=10,
         description='The length and width of each pixel after down-sampling'
     )
     self.contamination = ipywidgets.FloatText(
         value=0.02, description='The proportion of samples with artefacts')
     self.auto_detection_labels = []
Exemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        """Parameters
        ----------
        *args, **kwargs
            Passed to the :py:class:`HBox` constructor after the list of
            children
        """
        self._block_size_sel = ipywidgets.IntText(value=65,
                                                  description="block size")
        self._c_sel = ipywidgets.FloatText(value=-5,
                                           description="const offset")
        self._smoothing_sel = ipywidgets.FloatText(value=1.5,
                                                   description="smooth",
                                                   step=0.1)
        self._method_sel = ipywidgets.Dropdown(options=["mean", "gaussian"],
                                               description="adaptive method")

        self._update_lock = threading.Lock()

        super().__init__([
            self._block_size_sel, self._c_sel, self._smoothing_sel,
            self._method_sel
        ],
                         layout=ipywidgets.Layout(
                             grid_template_columns="repeat(2, max-content)"),
                         *args,
                         **kwargs)

        for w in (self._block_size_sel, self._c_sel, self._smoothing_sel,
                  self._method_sel):
            w.observe(self._options_from_ui, "value")

        self._options_from_ui()
Exemplo n.º 9
0
    def __init__(self, state, **kwargs):
        super(Color, self).__init__(**kwargs)
        self.state = state

        self.widget_color = widgets.ColorPicker(description='color')
        link((self.state, 'color'), (self.widget_color, 'value'), color2hex)

        cmap_mode_options = type(self.state).cmap_mode.get_choice_labels(self.state)
        self.widget_cmap_mode = widgets.RadioButtons(options=cmap_mode_options, description='cmap mode')
        link((self.state, 'cmap_mode'), (self.widget_cmap_mode, 'value'))

        self.widget_cmap_att = LinkedDropdown(self.state, 'cmap_att',
                                              ui_name='color attribute',
                                              label='color attribute')

        self.widget_cmap_vmin = widgets.FloatText(description='color min')
        self.widget_cmap_vmax = widgets.FloatText(description='color max')
        self.widget_cmap_v = widgets.VBox([self.widget_cmap_vmin, self.widget_cmap_vmax])
        link((self.state, 'cmap_vmin'), (self.widget_cmap_vmin, 'value'), lambda value: value or 0)
        link((self.state, 'cmap_vmax'), (self.widget_cmap_vmax, 'value'), lambda value: value or 1)

        self.widget_cmap = widgets.Dropdown(options=colormaps, description='colormap')
        link((self.state, 'cmap'), (self.widget_cmap, 'label'), lambda cmap: colormaps.name_from_cmap(cmap), lambda name: colormaps[name])

        dlink((self.widget_cmap_mode, 'value'), (self.widget_color.layout, 'display'),     lambda value: None if value == cmap_mode_options[0] else 'none')
        dlink((self.widget_cmap_mode, 'value'), (self.widget_cmap.layout, 'display'),     lambda value: None if value == cmap_mode_options[1] else 'none')
        dlink((self.widget_cmap_mode, 'value'), (self.widget_cmap_att.layout, 'display'), lambda value: None if value == cmap_mode_options[1] else 'none')
        dlink((self.widget_cmap_mode, 'value'), (self.widget_cmap_v.layout, 'display'), lambda value: None if value == cmap_mode_options[1] else 'none')
        self.children = (self.widget_cmap_mode, self.widget_color, self.widget_cmap_att, self.widget_cmap_v, self.widget_cmap)
def makesliders(D):
    slider_list = []
    #     ax_list = []
    for label in D.keys():
        slider_list.append(
            ipywidgets.VBox([
                ipywidgets.Label(label),
                #                               ipywidgets.Dropdown(options=list(cbayes.distributions.supported_distributions().keys()))
                #                               ipywidgets.FloatSlider(value=0, min=0, max=10, description='loc'),
                #                               ipywidgets.FloatSlider(value=1, min=0, max=10, description='scale'),
                ipywidgets.FloatText(value=0.0, description='loc'),
                ipywidgets.FloatText(value=1.0, description='scale'),
                ipywidgets.FloatSlider(value=1.0,
                                       min=0,
                                       max=20,
                                       description='a'),
                ipywidgets.FloatSlider(value=1.0,
                                       min=0,
                                       max=20,
                                       description='b'),
                ipywidgets.Dropdown(options=['normal', 'beta', 'uniform'],
                                    value='beta'),
                ipywidgets.widgets.Output(),
                ipywidgets.Button(description='Preview')
            ]))
    return slider_list
Exemplo n.º 11
0
    def __init__(self, net_widget, interactions=None):
        self.key = "TFHill"
        self.net = net_widget
        self.interactions = interactions
        self.is_on = w.ToggleButton(description="TFHill",
                                    value=False,
                                    layout=w.Layout(width="15%",
                                                    height="40px"))
        self.s1 = w.Dropdown(
            description="TF",
            options={"S{}".format(key): key
                     for key in self.net.types["TF"]})
        self.s2 = w.Dropdown(description="Gene",
                             options={
                                 "S{}".format(key): key
                                 for key in self.net.types["Genes"]
                             })
        self.custom_p = w.Checkbox(description="custom parameters",
                                   value=False)

        self.n = w.FloatText(description="n", value=1, step=0.0001)
        self.h = w.FloatText(description="h", value=1, step=0.0001)
        self.activity = w.Dropdown(description="Type",
                                   options={
                                       "activation": 1,
                                       "repression": 0
                                   })
        self.update_param_state(False)
        self.update_inter_state(False)

        w.interactive(self.update_inter_state, button=self.is_on)
        w.interactive(self.update_param_state, button=self.custom_p)
Exemplo n.º 12
0
def add_notch_filter(notch_filters, gap_filler):
    """Add a button for a simple square notch filter"""
    new_filter = widgets.HBox([widgets.FloatText(description='Begin', width='150px'),
                               widgets.FloatText(description='End', width='150px'),
                               gap_filler,
                               widgets.Checkbox(description='Use filter', value=True)])
    notch_filters.children += (new_filter,)
Exemplo n.º 13
0
def buneman_widget():
    style = {'description_width': '350px'}
    layout = Layout(width='55%')

    a = ipywidgets.Text(value='buneman.txt',
                        description='Template Input File:',
                        style=style,
                        layout=layout)
    b = ipywidgets.Text(value='case1.txt',
                        description='New Output File:',
                        style=style,
                        layout=layout)
    c = ipywidgets.BoundedFloatText(value=3,
                                    min=0.0,
                                    max=10.0,
                                    description='Electron Drift Velocity:',
                                    style=style,
                                    layout=layout)
    d = ipywidgets.FloatText(value=100.0,
                             description='Mass Ratio (M/m):',
                             style=style,
                             layout=layout)
    e = ipywidgets.FloatText(value=200.0,
                             description='TEND or the Total Simulation Time:',
                             style=style,
                             layout=layout)

    im = interact_calc(buneman_deck_maker,
                       iname=a,
                       oname=b,
                       VX0=c,
                       RMASS=d,
                       tend=e)

    im.widget.manual_button.layout.width = '250px'
Exemplo n.º 14
0
def srs_widget():
    style = {'description_width': '350px'}
    layout = Layout(width='55%')

    a = widgets.Text(value='forslund-sbs.txt',
                     description='Template Input File:',
                     style=style,
                     layout=layout)
    b = widgets.Text(value='case1.txt',
                     description='New Output File:',
                     style=style,
                     layout=layout)
    c = widgets.FloatText(value=0.1,
                          description='a0:',
                          style=style,
                          layout=layout)
    d = widgets.FloatText(value=0.035,
                          description='uth/c:',
                          style=style,
                          layout=layout)
    e = widgets.FloatText(value=0.1,
                          description='n/n_c:',
                          style=style,
                          layout=layout)
    f = widgets.FloatText(value=1800.0,
                          description='tmax:',
                          style=style,
                          layout=layout)

    im = interact_calc(newifile, iname=a, oname=b, a0=c, uth=d, n0=e, tmax=f)
    im.widget.manual_button.layout.width = '250px'
Exemplo n.º 15
0
def Requerimientos():
    Req = widgets.Accordion(children=[
        widgets.FloatText(value=2, disabled=False),
        widgets.FloatText(value=1)
    ])
    Req.set_title(0, 'W')
    Req.set_title(1, 'H')
    return Req
Exemplo n.º 16
0
    def __init__(self, parent, model):
        self.parent = parent
        self.model = model
        
        cell_layout = wg.Layout(width='auto')

        self.Mu = wg.FloatText(value=model.Mu, description=r'$M_{u}$ &nbsp <i>[lb*in]</i>', layout=cell_layout)
        self.Vu = wg.FloatText(value=model.Vu, description=r'$V_{u}$ &nbsp <i>[lb]</i>', layout=cell_layout)
Exemplo n.º 17
0
def create_gif():
    """This function allows the user to select all the parameters to create their own GIFs.
    It saves them directly on their /work directory
    """

    lonmax = widgets.FloatText(value=1.5153795, description='Long max:', disabled=False, step=0.001)
    latmax = widgets.FloatText(value=43.668708, description='Lat max:', disabled=False, step=0.001)
    lonmin = widgets.FloatText(value=1.3503956, description='Long min:', disabled=False, step=0.001)
    latmin = widgets.FloatText(value=43.532654, description='Lat min:', disabled=False, step=0.001)

    bbox_menu = widgets.VBox([lonmax, latmax, lonmin, latmin])

    raw_bbox_menu = widgets.Textarea(
        value='1.5153795,43.668708,1.3503956,43.532654',
        placeholder='BBOX',
        disabled=False,
        layout=widgets.Layout(width='50%')
    )

    cities_menu = widgets.Text(placeholder='Ex: Toulouse, Paris, New-York...')

    children = [bbox_menu,
                widgets.VBox([
                    widgets.Label(value="Enter a city:"),
                    cities_menu
                ]),
                widgets.VBox([
                    widgets.Label(value="Enter a raw BBOX:"),
                    raw_bbox_menu
                ])]

    tab = widgets.Tab()
    tab.children = children
    tab.set_title(0, 'Bounding Box')
    tab.set_title(1, 'Cities')
    tab.set_title(2, 'Raw Bounding Box')

    global_output = widgets.Output()
    out = widgets.Output()
    button = widgets.Button(description='Validate')

    display(tab)
    display(button)
    display(out)
    display(global_output)

    bbox = [1.5153795, 43.668708, 1.3503956, 43.532654]  # default bbox on Toulouse

    # Defines the action when the button is clicked.
    # Here the button validates the bbox, and call the next widget (collection_widget)
    def click_bbox(b):
        global bbox
        bbox = get_bbox(tab, out, lonmax, latmax, lonmin, latmin, cities_menu, raw_bbox_menu)
        with global_output:
            clear_output(wait=True)
            get_collection(bbox)

    button.on_click(click_bbox)
Exemplo n.º 18
0
    def init_gui(self):
        stretches = ['linear', 'sqrt', 'log']

        slider_layout = {'min_width': '50%'}
        minmax_layout = {'width': '100px'}
        stretch_layout = {'width': '80px'}

        text_range = ipywidgets.Label(value='', layout={'min_width': '50%'})
        text_min = ipywidgets.Label(value='min.', layout=minmax_layout)
        text_max = ipywidgets.Label(value='max.', layout=minmax_layout)
        text_stretch = ipywidgets.Label(value='stretch', layout=stretch_layout)
        self.box_text = ipywidgets.HBox(
            [text_range, text_min, text_max, text_stretch])

        self.slider_r = ipywidgets.FloatRangeSlider(
            description='<b style="color:#cc3737">Red:</b>',
            min=-9e99,
            max=9e99,
            step=1e98,
            value=(-9e99, 9e99),
            layout=slider_layout)
        self.min_r = ipywidgets.FloatText(value=-9e99, layout=minmax_layout)
        self.max_r = ipywidgets.FloatText(value=9e99, layout=minmax_layout)
        self.stretch_r = ipywidgets.Dropdown(options=stretches,
                                             value='linear',
                                             layout=stretch_layout)
        self.box_r = ipywidgets.HBox(
            [self.slider_r, self.min_r, self.max_r, self.stretch_r])
        self.slider_r.observe(self.scale_red, names='value')
        self.stretch_r.observe(self.scale_red, names='value')
        self.min_r.observe(self.refresh_slider, names='value')
        self.max_r.observe(self.refresh_slider, names='value')

        self.slider_b = ipywidgets.FloatRangeSlider(
            description='<b style="color:#496bd8">Blue:</b>',
            min=-9e99,
            max=9e99,
            step=1e98,
            value=(-9e99, 9e99),
            layout=slider_layout)

        self.min_b = ipywidgets.FloatText(value=-9e99, layout=minmax_layout)
        self.max_b = ipywidgets.FloatText(value=9e99, layout=minmax_layout)
        self.stretch_b = ipywidgets.Dropdown(options=stretches,
                                             value='linear',
                                             layout=stretch_layout)
        self.box_b = ipywidgets.HBox(
            [self.slider_b, self.min_b, self.max_b, self.stretch_b])
        self.slider_b.observe(self.scale_blue, names='value')
        self.stretch_b.observe(self.scale_blue, names='value')
        self.min_b.observe(self.refresh_slider, names='value')
        self.max_b.observe(self.refresh_slider, names='value')

        qlook_shape = self.ctrl.get_qlook_shape()
        self.img = ipywidgets.Image(height=qlook_shape[0],
                                    width=qlook_shape[1],
                                    format='bmp')
        return
Exemplo n.º 19
0
    def setup(self):
        self.var_dropdown = widgets.Dropdown(
            value=self.dataset._widgets.elevation_var,
            options=list(self.color_vars),
        )
        self.var_dropdown.observe(lambda change: self._set_color_var(change['new']), names='value')

        self.colormaps_dropdown = widgets.Dropdown(
            options=self.colormaps, value=self.default_colormap
        )

        da = self.dataset._widgets.color
        self.min_input = widgets.FloatText(
            value=da.min(), layout=widgets.Layout(height='auto', width='auto')
        )
        self.max_input = widgets.FloatText(
            value=da.max(), layout=widgets.Layout(height='auto', width='auto')
        )

        self.rescale_button = widgets.Button(
            description='Rescale',
            tooltip='Rescale to actual data range',
            layout=widgets.Layout(height='auto', width='auto'),
        )
        self.rescale_button.on_click(lambda _: self.reset_color_limits())

        self.rescale_step_button = widgets.Button(
            description='Rescale Step',
            tooltip='Rescale to actual data range (current step)',
            layout=widgets.Layout(height='auto', width='auto'),
        )
        self.rescale_step_button.on_click(lambda _: self.reset_color_limits(step=True))

        self.log_scale_checkbox = widgets.Checkbox(
            value=False, indent=False, layout=widgets.Layout(width='100px'), description='log scale'
        )
        self.log_scale_checkbox.observe(
            lambda change: self._set_color_scale(log=change['new']), names='value'
        )

        range_grid = widgets.GridspecLayout(3, 2)
        range_grid[0, 0] = self.min_input
        range_grid[0, 1] = self.max_input
        range_grid[1, 0] = self.rescale_button
        if self.dataset._widgets.time_dim is not None:
            range_grid[1, 1] = self.rescale_step_button
        range_grid[2, 0] = self.log_scale_checkbox

        return widgets.VBox(
            [
                widgets.Label('Coloring:'),
                self.var_dropdown,
                widgets.Label('Colormap:'),
                self.colormaps_dropdown,
                widgets.Label('Color range / scale:'),
                range_grid,
            ]
        )
Exemplo n.º 20
0
def _get_axis_widgets(obj):
    widgets = []
    wd = {}
    name = ipywidgets.Text()
    widgets.append(labelme(ipywidgets.Label("Name"), name))
    link((obj, "name"), (name, "value"))
    wd["name"] = name

    size = ipywidgets.IntText(disabled=True)
    widgets.append(labelme("Size", size))
    link((obj, "size"), (size, "value"))
    wd["size"] = size

    index_in_array = ipywidgets.IntText(disabled=True)
    widgets.append(labelme("Index in array", index_in_array))
    link((obj, "index_in_array"), (index_in_array, "value"))
    wd["index_in_array"] = index_in_array
    if obj.navigate:
        index = ipywidgets.IntSlider(min=0, max=obj.size - 1)
        widgets.append(labelme("Index", index))
        link((obj, "index"), (index, "value"))
        wd["index"] = index

        value = ipywidgets.FloatSlider(
            min=obj.low_value,
            max=obj.high_value,
        )
        wd["value"] = value
        widgets.append(labelme("Value", value))
        link((obj, "value"), (value, "value"))
        link((obj, "high_value"), (value, "max"))
        link((obj, "low_value"), (value, "min"))
        link((obj, "scale"), (value, "step"))

    units = ipywidgets.Text()
    widgets.append(labelme("Units", units))
    link((obj, "units"), (units, "value"))
    wd["units"] = units

    if hasattr(obj, "scale"):
        scale = ipywidgets.FloatText()
        widgets.append(labelme("Scale", scale))
        link((obj, "scale"), (scale, "value"))
        wd["scale"] = scale

    if hasattr(obj, "offset"):
        offset = ipywidgets.FloatText()
        widgets.append(labelme("Offset", offset))
        link((obj, "offset"), (offset, "value"))
        wd["offset"] = offset

    if "_expression" in obj.__dict__.keys():
        expression = ipywidgets.Text(disabled=True)
        widgets.append(labelme("Expression", expression))
        link((obj, "_expression"), (expression, "value"))
        wd["expression"] = expression

    return {"widget": ipywidgets.VBox(widgets), "wdict": wd}
Exemplo n.º 21
0
 def __init__(self, *args, **kwd):
     super(ToggleMinMax, self).__init__(*args, **kwd)
     style = {'description_width': 'initial'}
     self._min_box = widgets.FloatText(description="Low threshold",
                                       style=style)
     self._max_box = widgets.FloatText(description="High threshold",
                                       style=style)
     self.add_child(self._min_box)
     self.add_child(self._max_box)
Exemplo n.º 22
0
    def __init__(self, parent, model):
        self.parent = parent
        self.model = model
        
        cell_layout = wg.Layout(width='auto')

        self.fc_prime = wg.FloatText(value=model.fc_prime, description=r'$f^{\prime}_{c}$ &nbsp <i>[psi]</i>', layout=cell_layout)
        self.strain_ult = wg.FloatText(value=model.strain_ult, description=r'$\epsilon_{u}$ &nbsp <i>[in/in]</i>', layout=cell_layout)
        self.Ec = wg.FloatText(value=model.Ec, description=r'$E_c$ &nbsp <i>[psi]</i>', layout=cell_layout)
Exemplo n.º 23
0
def createControlRow(row_index, parameter_options):
    parameter_dropdown = widgets.Dropdown(options=parameter_options,
                                          value=no_selection)
    parameter_dropdown.rowIndex = row_index

    ft_LB = widgets.FloatText(disabled=True)
    ft_UB = widgets.FloatText(disabled=True)

    return [parameter_dropdown, ft_LB, ft_UB]
Exemplo n.º 24
0
def image_constast_editor_ipy(obj, **kwargs):
    wdict = {}
    left = ipywidgets.FloatText(disabled=True)
    right = ipywidgets.FloatText(disabled=True)
    help = ipywidgets.HTML(
        "Click on the histogram figure and drag to the right to select a"
        "range. Press `Apply` to set the new contrast limits, `Reset` to reset "
        "them or `Close` to cancel.", )
    wdict["help"] = help
    help = ipywidgets.Accordion(children=[help])
    help.set_title(0, "Help")
    close = ipywidgets.Button(
        description="Close",
        tooltip="Close widget and remove span selector from the signal figure."
    )
    apply = ipywidgets.Button(
        description="Apply",
        tooltip="Perform the operation using the selected range.")
    reset = ipywidgets.Button(
        description="Reset",
        tooltip="Reset the contrast to the previous value.")
    wdict["left"] = left
    wdict["right"] = right
    wdict["close_button"] = close
    wdict["apply_button"] = apply
    wdict["reset_button"] = reset

    # Connect
    link((obj, "ss_left_value"), (left, "value"))
    link((obj, "ss_right_value"), (right, "value"))

    def on_apply_clicked(b):
        obj.apply()

    apply.on_click(on_apply_clicked)

    def on_reset_clicked(b):
        obj.reset()

    reset.on_click(on_reset_clicked)

    box = ipywidgets.VBox([
        labelme("vmin", left),
        labelme("vmax", right), help,
        ipywidgets.HBox((apply, reset, close))
    ])

    def on_close_clicked(b):
        obj.close()
        box.close()

    close.on_click(on_close_clicked)
    return {
        "widget": box,
        "wdict": wdict,
    }
Exemplo n.º 25
0
def interactive_range_ipy(obj, **kwargs):
    # Define widgets
    wdict = {}
    axis = obj.axis
    left = ipywidgets.FloatText(disabled=True)
    right = ipywidgets.FloatText(disabled=True)
    units = ipywidgets.Label()
    help_text = ipywidgets.HTML(
        "Click on the signal figure and drag to the right to select a signal "
        "range. Press `Apply` to perform the operation or `Close` to cancel.",
    )
    help = ipywidgets.Accordion(children=[help_text], selected_index=None)
    set_title_container(help, ["Help"])
    close = ipywidgets.Button(
        description="Close",
        tooltip="Close widget and remove span selector from the signal figure."
    )
    apply = ipywidgets.Button(
        description="Apply",
        tooltip="Perform the operation using the selected range.")
    wdict["left"] = left
    wdict["right"] = right
    wdict["units"] = units
    wdict["help_text"] = help_text
    wdict["close_button"] = close
    wdict["apply_button"] = apply

    # Connect
    link((obj, "ss_left_value"), (left, "value"))
    link((obj, "ss_right_value"), (right, "value"))
    link((axis, "units"), (units, "value"))

    def on_apply_clicked(b):
        if obj.ss_left_value != obj.ss_right_value:
            obj.span_selector_switch(False)
            for method, cls in obj.on_close:
                method(cls, obj.ss_left_value, obj.ss_right_value)
            obj.span_selector_switch(True)

    apply.on_click(on_apply_clicked)

    box = ipywidgets.VBox([
        ipywidgets.HBox([left, units,
                         ipywidgets.Label("-"), right, units]), help,
        ipywidgets.HBox((apply, close))
    ])

    def on_close_clicked(b):
        obj.span_selector_switch(False)
        box.close()

    close.on_click(on_close_clicked)
    return {
        "widget": box,
        "wdict": wdict,
    }
Exemplo n.º 26
0
def create_settings(box):
    "Creates a widget Container for settings and info of a particular slider."
    _, slider, sl_units = box.children

    enable = widgets.Checkbox(value=box.visible, width="3ex")
    link((box, 'visible'), (enable, 'value'))

    def slider_link(obj, attr):
        "Function to link one object to an attr of the slider."

        # pylint: disable=unused-argument
        def link_fn(name, new_value):
            "How to update the object's value given min/max on the slider. "
            if new_value >= slider.max:
                slider.max = new_value
            # if any value is greater than the max, the max slides up
            # however, this is not held true for the minimum, because
            # during typing the max or value will grow, and we don't want
            # to permanently anchor the minimum to unfinished typing
            if attr == "max" and new_value <= slider.value:
                if slider.max >= slider.min:
                    slider.value = new_value
                else:
                    pass  # bounds nonsensical, probably because we picked up
                    # a small value during user typing.
            elif attr == "min" and new_value >= slider.value:
                slider.value = new_value
            setattr(slider, attr, new_value)
            slider.step = (slider.max - slider.min) / 24.0

        obj.on_trait_change(link_fn, "value")
        link((slider, attr), (obj, "value"))

    text_html = "<span class='form-control' style='width: auto;'>"
    setvalue = widgets.FloatText(value=slider.value,
                                 description=slider.description)
    slider_link(setvalue, "value")
    fromlabel = widgets.HTML(text_html + "from")
    setmin = widgets.FloatText(value=slider.min, width="10ex")
    slider_link(setmin, "min")
    tolabel = widgets.HTML(text_html + "to")
    setmax = widgets.FloatText(value=slider.max, width="10ex")
    slider_link(setmax, "max")

    units = widgets.Label()
    units.width = "6ex"
    units.font_size = "1.165em"
    link((sl_units, 'value'), (units, 'value'))
    descr = widgets.HTML(text_html + slider.varkey.descr.get("label", ""))
    descr.width = "40ex"

    return widgets.HBox(children=[
        enable, setvalue, units, descr, fromlabel, setmin, tolabel, setmax
    ],
                        width="105ex")
Exemplo n.º 27
0
    def __init__(self, show_header=True):
        def el_ly(w):
            return dict(width='{}px'.format(w), margin='0px')

        # minimum block
        self.nomin = ipyw.Checkbox(value=True, layout=el_ly(125))
        self.min = ipyw.FloatText(value=-float('inf'), layout=el_ly(165))
        box_ly = dict(border='1px solid black',
                      display='flex',
                      margin='0px',
                      flex_flow='row',
                      width='290px')
        self.minbox = ipyw.Box([self.nomin, self.min], layout=box_ly)

        # value element
        self.value = ipyw.FloatText(value=0, layout=el_ly(170))

        # maximum block
        self.nomax = ipyw.Checkbox(value=True, layout=el_ly(125))
        self.max = ipyw.FloatText(value=float('inf'), layout=el_ly(165))
        self.maxbox = ipyw.Box([self.nomax, self.max], layout=box_ly)

        # constraints block
        self.vary = ipyw.Checkbox(value=True, layout=el_ly(125))
        self.expr = ipyw.Text(value='',
                              continuous_update=False,
                              layout=el_ly(275))

        # array elements in an horizontal block
        self.elements = [
            self.minbox, self.value, self.maxbox, self.vary, self.expr
        ]

        # Header labels
        self.header = None
        if show_header is True:
            d_lbs = (('-inf', 125), ('min', 165), ('value', 170), ('inf', 125),
                     ('max', 165), ('vary', 125), ('expression', 275))
            l_lbs = [ipyw.Label(k, layout=el_ly(v)) for (k, v) in d_lbs]
            box_ly = dict(display='flex', margin='0px', border='solid')
            self.header = ipyw.HBox(l_lbs, layout=box_ly)

        # Layout
        if self.header is None:
            box_ly = dict(display='flex',
                          margin='0px',
                          border='solid',
                          flex_flow='row')
            super(ParameterWidget, self).__init__(self.elements, layout=box_ly)
        else:
            box_ly = dict(display='flex', margin='0px', border='solid')
            b_els = ipyw.HBox(self.elements, layout=box_ly)
            box_ly.update({'flex_flow': 'column'})
            super(ParameterWidget, self).__init__([self.header, b_els],
                                                  layout=box_ly)
Exemplo n.º 28
0
def circle_and_the_line():
    m, b = get_m_b_sliders()

    out = widgets.interactive_output(
        lambda m, b: plot_proba(class_inner, class_outer, linear, m, b), {
            'm': m,
            'b': b
        })
    loss_plot(None, None, reset=True)
    loss_display = widgets.interactive_output(
        lambda m, b: loss_plot(np.mean([
            binary_crossentropy(
                0, linear_sigmoid(class_inner_x, class_inner_y, m, b)),
            binary_crossentropy(
                1, linear_sigmoid(class_outer_x, class_outer_y, m, b))
        ]),
                               loss_name='b. c. e.'), {
                                   'm': m,
                                   'b': b
                               })

    acc_text = widgets.interactive_output(
        lambda m, b: display(
            widgets.FloatText(value=round(
                np.mean([
                    1 - accuracy(class_inner[1], linear(class_inner[0], m, b)),
                    accuracy(class_outer[1], linear(class_outer[0], m, b))
                ]), 3),
                              description='accuracy:',
                              disabled=False,
                              layout={'width': '100%'})), {
                                  'm': m,
                                  'b': b
                              })
    bce_text = widgets.interactive_output(
        lambda m, b: display(
            widgets.FloatText(value=round(
                np.mean([
                    binary_crossentropy(
                        0, linear_sigmoid(class_inner_x, class_inner_y, m, b)),
                    binary_crossentropy(
                        1, linear_sigmoid(class_outer_x, class_outer_y, m, b))
                ]), 3),
                              description='b. c. e. loss:',
                              disabled=False,
                              layout={'width': '100%'})), {
                                  'm': m,
                                  'b': b
                              })
    display(
        widgets.VBox([
            widgets.HBox([out, loss_display]),
            widgets.VBox([m, b, acc_text, bce_text])
        ],
                     layout=widgets.Layout(align_items='center')))
Exemplo n.º 29
0
def options(X):
    style = {'description_width': 'initial'} #general style settings

    ### Define sample properties ###
    fn = X['fn']
    prop_title = widgets.HTML(value='<h3>Sample preprocessing options</h3>')
    mass_title = widgets.HTML(value='To disable mass normalization use a value of -1')

    sample, unit, mass = ut.sample_details(X)

    sample_widge = widgets.Text(value=sample,description='Sample name:',style=style)
    
    if mass == "N/A":
        mass_widge = widgets.FloatText(value=-1, description = 'Sample mass (g):',style=style)
    else:
        mass_widge = widgets.FloatText(value=mass, description = 'Sample mass (g):',style=style)

    mass_widge1 = HBox([mass_widge,mass_title])
    
    ### Define measurement corrections ###
    correct_title = widgets.HTML(value='<h3>Select preprocessing options:</h3>')
    
    slope_widge = widgets.FloatSlider(
        value=70,
        min=1,
        max=100.0,
        step=1,
        description='Slope correction [%]:',
        style=style,
        readout_format='.0f',
    )
    
    slope_title = widgets.HTML(value='To disable high-field slope correction use a value of 100%')
    slope_widge1 = HBox([slope_widge,slope_title])
    
    drift_widge = widgets.Checkbox(value=False, description='Measurement drift correction')
    fpa_widge = widgets.Checkbox(value=False, description='Remove first point artifact')
    lpa_widge = widgets.Checkbox(value=False, description='Remove last point artifact')
    correct_widge = VBox([correct_title,sample_widge,mass_widge1,slope_widge1,drift_widge,fpa_widge,lpa_widge])

    preprocess_nest = widgets.Tab()
    preprocess_nest.children = [correct_widge]
    preprocess_nest.set_title(0, 'PREPROCESSING')
    display(preprocess_nest)

    X["sample"] = sample_widge
    X["mass"] = mass_widge
    X["unit"] = unit
    X["drift"] = drift_widge
    X["slope"] = slope_widge
    X["fpa"] = fpa_widge
    X["lpa"] = lpa_widge
    
    return X
Exemplo n.º 30
0
def data_input(mode):
  if mode == 'чтение из файла':
    display_file_input(lambda path: load_file(path),
                       description='Загрузить:',
                       placeholder='Путь к файлу с a, b, Δ, разделенными пробелом',
                       button_text="Открыть")
  else:
    int_start = widgets.FloatText(description='a', value=0.0, step=0.1)
    int_end = widgets.FloatText(description='b', value=0.0, step=0.1)
    delta = widgets.FloatText(description='Δ', value=0.01, step=0.000001)
    widgets.interact(find_root, int_start=int_start, int_end=int_end, delta=delta)