Beispiel #1
0
 def test_make_bivariate_histogram(self):
     x, y = np.ones((100, 100)), np.ones((100, 100))
     make_bivariate_histogram(
         x_position=x,
         y_position=y,
         histogram_range=None,
         masked=None,
         bins=200,
         spatial_std=3,
     )
 def test_single_negative_x(self):
     size = 100
     x, y = -np.ones(size), np.zeros(size)
     s = make_bivariate_histogram(x, y)
     hist_iX = s.axes_manager[0].value2index(-1)
     hist_iY = s.axes_manager[1].value2index(0)
     assert s.data[hist_iY, hist_iX] == size
     s.data[hist_iY, hist_iX] = 0
     assert not s.data.any()
Beispiel #3
0
    def get_bivariate_histogram(self,
                                histogram_range=None,
                                masked=None,
                                bins=200,
                                spatial_std=3):
        """
        Useful for finding the distribution of magnetic vectors(?).

        Parameters
        ----------
        histogram_range : tuple, optional
            Set the minimum and maximum of the histogram range.
            Default is setting it automatically.
        masked : 2-D NumPy bool array, optional
            Mask parts of the data. The array must be the same
            size as the signal. The True values are masked.
            Default is not masking anything.
        bins : integer, default 200
            Number of bins in the histogram
        spatial_std : number, optional
            If histogram_range is not given, this value will be
            used to set the automatic histogram range.
            Default value is 3.

        Returns
        -------
        s_hist : HyperSpy Signal2D

        Examples
        --------
        >>> s = ps.dummy_data.get_stripe_pattern_dpc_signal()
        >>> s_hist = s.get_bivariate_histogram()
        >>> s_hist.plot()

        """
        x_position = self.inav[0].data
        y_position = self.inav[1].data
        s_hist = make_bivariate_histogram(
            x_position,
            y_position,
            histogram_range=histogram_range,
            masked=masked,
            bins=bins,
            spatial_std=spatial_std,
        )
        s_hist.metadata.General.title = "Bivariate histogram of {0}".format(
            self.metadata.General.title)
        return s_hist
Beispiel #4
0
    def get_bivariate_histogram(self,
                                histogram_range=None,
                                masked=None,
                                bins=200,
                                spatial_std=3):
        """
        Useful for finding the distribution of magnetic vectors(?).

        Parameters
        ----------
        histogram_range : tuple, optional
            Set the minimum and maximum of the histogram range.
            Default is setting it automatically.
        masked : 1-D NumPy bool array, optional
            Mask parts of the data. The array must be the same
            size as the signal. The True values are masked.
            Default is not masking anything.
        bins : integer, default 200
            Number of bins in the histogram
        spatial_std : number, optional
            If histogram_range is not given, this value will be
            used to set the automatic histogram range.
            Default value is 3.

        Returns
        -------
        s_hist : Signal2D

        """
        x_position = self.inav[0].data
        y_position = self.inav[1].data
        s_hist = make_bivariate_histogram(
            x_position,
            y_position,
            histogram_range=histogram_range,
            masked=masked,
            bins=bins,
            spatial_std=spatial_std,
        )

        return s_hist