예제 #1
0
파일: roi.py 프로젝트: woozey/hyperspy
    def interactive(self, signal, navigation_signal="same", out=None,
                    color="green", **kwargs):
        """Creates an interactively sliced Signal (sliced by this ROI) via
        hyperspy.interactive.

        Arguments:
        ----------
        signal : Signal
            The source signal to slice
        navigation_signal : Signal, None or "same" (default)
            If not None, it will automatically create a widget on
            navigation_signal. Passing "same" is identical to passing the same
            signal to 'signal' and 'navigation_signal', but is less ambigous,
            and allows "same" to be the default value.
        out : Signal
            If not None, it will use 'out' as the output instead of returning
            a new Signal.
        color : Matplotlib color specifier (default: 'green')
            The color for the widget. Any format that matplotlib uses should be
            ok. This will not change the color fo any widget passed with the
            'widget' argument.
        **kwargs
            All kwargs are passed to the roi __call__ method which is called
            interactivel on any roi attribute change.

        """
        if hasattr(signal, '_plot_kwargs'):
            kwargs.update({'_plot_kwargs': signal._plot_kwargs})
            # in case of complex signal, it is possible to shift the signal
            # during plotting, if so this is currently not supported and we
            # raise a NotImplementedError
            if signal._plot.signal_data_function_kwargs.get(
                    'fft_shift', False):
                raise NotImplementedError('ROIs are not supported when data '
                                          'are shifted during plotting.')
        if isinstance(navigation_signal, str) and navigation_signal == "same":
            navigation_signal = signal
        if navigation_signal is not None:
            if navigation_signal not in self.signal_map:
                self.add_widget(navigation_signal, color=color,
                                axes=kwargs.get("axes", None))
        if (self.update not in
                signal.axes_manager.events.any_axis_changed.connected):
            signal.axes_manager.events.any_axis_changed.connect(
                self.update,
                [])
        if out is None:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal,
                               **kwargs)
        else:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal, out=out, **kwargs)
예제 #2
0
    def interactive(self,
                    signal,
                    navigation_signal="same",
                    out=None,
                    color="green",
                    **kwargs):
        """Creates an interactively sliced Signal (sliced by this ROI) via
        hyperspy.interactive.

        Arguments:
        ----------
        signal : Signal
            The source signal to slice
        navigation_signal : Signal, None or "same" (default)
            If not None, it will automatically create a widget on
            navigation_signal. Passing "same" is identical to passing the same
            signal to 'signal' and 'navigation_signal', but is less ambigous,
            and allows "same" to be the default value.
        out : Signal
            If not None, it will use 'out' as the output instead of returning
            a new Signal.
        color : Matplotlib color specifier (default: 'green')
            The color for the widget. Any format that matplotlib uses should be
            ok. This will not change the color fo any widget passed with the
            'widget' argument.
        **kwargs
            All kwargs are passed to the roi __call__ method which is called
            interactivel on any roi attribute change.

        """
        if isinstance(navigation_signal, str) and navigation_signal == "same":
            navigation_signal = signal
        if navigation_signal is not None:
            if navigation_signal not in self.signal_map:
                self.add_widget(navigation_signal,
                                color=color,
                                axes=kwargs.get("axes", None))
        if (self.update
                not in signal.axes_manager.events.any_axis_changed.connected):
            signal.axes_manager.events.any_axis_changed.connect(
                self.update, [])
        if out is None:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal,
                               **kwargs)
        else:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal,
                               out=out,
                               **kwargs)
예제 #3
0
파일: roi.py 프로젝트: jhemmelg/hyperspy
    def interactive(self, signal, navigation_signal="same", out=None,
                    color="green", **kwargs):
        """Creates an interactively sliced Signal (sliced by this ROI) via
        hyperspy.interactive.

        Arguments:
        ----------
        signal : Signal
            The source signal to slice
        navigation_signal : Signal, None or "same" (default)
            If not None, it will automatically create a widget on
            navigation_signal. Passing "same" is identical to passing the same
            signal to 'signal' and 'navigation_signal', but is less ambigous,
            and allows "same" to be the default value.
        out : Signal
            If not None, it will use 'out' as the output instead of returning
            a new Signal.
        color : Matplotlib color specifier (default: 'green')
            The color for the widget. Any format that matplotlib uses should be
            ok. This will not change the color fo any widget passed with the
            'widget' argument.
        **kwargs
            All kwargs are passed to the roi __call__ method which is called
            interactivel on any roi attribute change.

        """
        if isinstance(navigation_signal, str) and navigation_signal == "same":
            navigation_signal = signal
        if navigation_signal is not None:
            if navigation_signal not in self.signal_map:
                self.add_widget(navigation_signal, color=color)
        if (self.update not in
                signal.axes_manager.events.any_axis_changed.connected):
            signal.axes_manager.events.any_axis_changed.connect(
                self.update,
                [])
        if out is None:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal,
                               **kwargs)
        else:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal, out=out, **kwargs)
예제 #4
0
파일: roi.py 프로젝트: AakashV/hyperspy
    def interactive(self, signal, navigation_signal="same", out=None,
                    **kwargs):
        """Creates an interactively sliced Signal (sliced by this ROI) via
        hyperspy.interactive.

        Arguments:
        ----------
        signal : Signal
            The source signal to slice
        navigation_signal : Signal, None or "same" (default)
            If not None, it will automatically create a widget on
            navigation_signal. Passing "same" is identical to passing the same
            signal to 'signal' and 'navigation_signal', but is less ambigous,
            and allows "same" to be the default value.
        out : Signal
            If not None, it will use 'out' as the output instead of returning
            a new Signal.
        """
        if isinstance(navigation_signal, str) and navigation_signal == "same":
            navigation_signal = signal
        if navigation_signal is not None:
            if navigation_signal not in self.signal_map:
                self.add_widget(navigation_signal)
        if (self.update not in
                signal.axes_manager.events.any_axis_changed.connected):
            signal.axes_manager.events.any_axis_changed.connect(
                self.update,
                [])
        if out is None:
            return hsi.interactive(self.__call__,
                                   event=self.events.changed,
                                   signal=signal,
                                   **kwargs)
        else:
            return hsi.interactive(self.__call__,
                                   event=self.events.changed,
                                   signal=signal, out=out, **kwargs)
예제 #5
0
파일: roi.py 프로젝트: askorikov/hyperspy
    def interactive(self,
                    signal,
                    navigation_signal="same",
                    out=None,
                    color="green",
                    **kwargs):
        """Creates an interactively sliced Signal (sliced by this ROI) via
        hyperspy.interactive.

        Arguments:
        ----------
        signal : Signal
            The source signal to slice
        navigation_signal : Signal, None or "same" (default)
            If not None, it will automatically create a widget on
            navigation_signal. Passing "same" is identical to passing the same
            signal to 'signal' and 'navigation_signal', but is less ambigous,
            and allows "same" to be the default value.
        out : Signal
            If not None, it will use 'out' as the output instead of returning
            a new Signal.
        color : Matplotlib color specifier (default: 'green')
            The color for the widget. Any format that matplotlib uses should be
            ok. This will not change the color fo any widget passed with the
            'widget' argument.
        **kwargs
            All kwargs are passed to the roi __call__ method which is called
            interactively on any roi attribute change.

        """
        if hasattr(signal, '_plot_kwargs'):
            kwargs.update({'_plot_kwargs': signal._plot_kwargs})
            # in case of complex signal, it is possible to shift the signal
            # during plotting, if so this is currently not supported and we
            # raise a NotImplementedError
            if signal._plot.signal_data_function_kwargs.get(
                    'fft_shift', False):
                raise NotImplementedError('ROIs are not supported when data '
                                          'are shifted during plotting.')
        if isinstance(navigation_signal, str) and navigation_signal == "same":
            navigation_signal = signal
        if navigation_signal is not None:
            if navigation_signal not in self.signal_map:
                self.add_widget(navigation_signal,
                                color=color,
                                axes=kwargs.get("axes", None))
        if (self.update
                not in signal.axes_manager.events.any_axis_changed.connected):
            signal.axes_manager.events.any_axis_changed.connect(
                self.update, [])
        if out is None:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal,
                               **kwargs)
        else:
            return interactive(self.__call__,
                               event=self.events.changed,
                               signal=signal,
                               out=out,
                               **kwargs)