How to use the hyperspy.gui_ipywidgets.utils.register_ipy_widget function in hyperspy

To help you get started, we’ve selected a few hyperspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperspy / hyperspy / hyperspy / gui_ipywidgets / tools.py View on Github external
@register_ipy_widget(toolkey="Signal1D.smooth_total_variation")
@add_display_arg
def smooth_tv_ipy(obj, **kwargs):
    wdict = {}
    smoothing_parameter = ipywidgets.FloatSlider(min=0.1, max=1000)
    smoothing_parameter_max = ipywidgets.FloatText(
        value=smoothing_parameter.max)
    color = ipywidgets.ColorPicker()
    close = ipywidgets.Button(
        description="Close",
        tooltip="Close widget and remove the smoothed line from the signal figure.")
    apply = ipywidgets.Button(
        description="Apply",
        tooltip="Perform the operation using the selected range.")
    link((obj, "smoothing_parameter"),
         (smoothing_parameter, "value"))
    link((smoothing_parameter_max, "value"),
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / model.py View on Github external
@register_ipy_widget(toolkey="ScalableFixedPattern_Component")
@add_display_arg
def get_scalable_fixed_patter_widget(obj, **kwargs):
    cdict = get_component_widget(obj, display=False)
    wdict = cdict["wdict"]
    container = cdict["widget"]
    interpolate = Checkbox(description='interpolate',
                           value=obj.interpolate)
    wdict["interpolate"] = interpolate
    link((obj, "interpolate"), (interpolate, "value"))
    container.children = (container.children[0], interpolate) + \
        container.children[1:]
    return {
        "widget": container,
        "wdict": wdict,
    }
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / roi.py View on Github external
@register_ipy_widget(toolkey="Point1DROI")
@add_display_arg
def point1d_roi_ipy(obj, **kwargs):
    wdict = {}
    value = ipywidgets.FloatText(description="value")
    wdict["value"] = value
    link((obj, "value"), (value, "value"))
    return {
        "widget": value,
        "wdict": wdict,
    }
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / model.py View on Github external
@register_ipy_widget(toolkey="Model1D.fit_component")
@add_display_arg
def fit_component_ipy(obj, **kwargs):
    wdict = {}
    only_current = Checkbox()
    wdict["only_current"] = only_current
    help = Label(
        "Click on the signal figure and drag to the right to select a"
        "range. Press `Fit` to fit the component in that range. If only "
        "current is unchecked the fit is performed in the whole dataset.",
        layout=ipywidgets.Layout(width="auto"))
    wdict["help"] = only_current
    help = Accordion(children=[help])
    help.set_title(0, "Help")
    link((obj, "only_current"), (only_current, "value"))
    fit = Button(
        description="Fit",
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / roi.py View on Github external
@register_ipy_widget(toolkey="Point2DROI")
@add_display_arg
def point_2d_ipy(obj, **kwargs):
    wdict = {}
    x = ipywidgets.FloatText(description="x")
    y = ipywidgets.FloatText(description="y")
    wdict["x"] = x
    wdict["y"] = y
    link((obj, "x"), (x, "value"))
    link((obj, "y"), (y, "value"))
    container = ipywidgets.HBox([x, y])
    return {
        "widget": container,
        "wdict": wdict,
    }
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / tools.py View on Github external
@register_ipy_widget(toolkey="interactive_range_selector")
@add_display_arg
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 = 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])
    help.set_title(0, "Help")
    close = ipywidgets.Button(
        description="Close",
        tooltip="Close widget and remove span selector from the signal figure.")
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / microscope_parameters.py View on Github external
@register_ipy_widget(toolkey="microscope_parameters_EDS_SEM")
@add_display_arg
def eds_sem_microscope_parameter_ipy(obj, **kwargs):
    return(_set_microscope_parameters(obj=obj, **kwargs))
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / tools.py View on Github external
@register_ipy_widget(toolkey="Signal1D.spikes_removal_tool")
@add_display_arg
def spikes_removal_ipy(obj, **kwargs):
    wdict = {}
    threshold = ipywidgets.FloatText()
    add_noise = ipywidgets.Checkbox()
    default_spike_width = ipywidgets.IntText()
    interpolator_kind = enum2dropdown(obj.traits()["interpolator_kind"])
    spline_order = ipywidgets.IntSlider(min=1, max=10)
    progress_bar = ipywidgets.IntProgress(max=len(obj.coordinates) - 1)
    help = ipywidgets.HTML(
        value=SPIKES_REMOVAL_INSTRUCTIONS.replace('\n', '<br>'))
    help = ipywidgets.Accordion(children=[help])
    help.set_title(0, "Help")

    show_diff = ipywidgets.Button(
        description="Show derivative histogram",
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / axes.py View on Github external
@register_ipy_widget(toolkey="AxesManager")
@add_display_arg
def ipy_axes_gui(obj, **kwargs):
    wdict = {}
    nav_widgets = []
    sig_widgets = []
    i = 0
    for axis in obj.navigation_axes:
        wd = _get_axis_widgets(axis, display=False)
        nav_widgets.append(wd["widget"])
        wdict["axis{}".format(i)] = wd["wdict"]
        i += 1
    for j, axis in enumerate(obj.signal_axes):
        wd = _get_axis_widgets(axis, display=False)
        sig_widgets.append(wd["widget"])
        wdict["axis{}".format(i + j)] = wd["wdict"]
    nav_accordion = ipywidgets.Accordion(nav_widgets)
github hyperspy / hyperspy / hyperspy / gui_ipywidgets / microscope_parameters.py View on Github external
@register_ipy_widget(toolkey="microscope_parameters_EELS")
@add_display_arg
def eels_microscope_parameter_ipy(obj, **kwargs):
    return(_set_microscope_parameters(obj=obj, **kwargs))