def get_radial_profile(self, mask_array=None, inplace=False, *args, **kwargs): """Return the radial profile of the diffraction pattern. Parameters ---------- mask_array : numpy.array Optional array with the same dimensions as the signal axes. Consists of 0s for excluded pixels and 1s for non-excluded pixels. The 0-pixels are excluded from the radial average. inplace : bool If True (default), this signal is overwritten. Otherwise, returns a new signal. *args: Arguments to be passed to map(). **kwargs: Keyword arguments to be passed to map(). Returns ------- radial_profile: :obj:`pyxem.signals.ElectronDiffraction1D` The radial average profile of each diffraction pattern in the ElectronDiffraction2D signal as an ElectronDiffraction1D. See also -------- :func:`pyxem.utils.expt_utils.radial_average` """ radial_profiles = self.map(radial_average, mask=mask_array, inplace=inplace, *args, **kwargs) radial_profiles.axes_manager.signal_axes[0].offset = 0 signal_axis = radial_profiles.axes_manager.signal_axes[0] rp = ElectronDiffraction1D(radial_profiles.as_signal1D(signal_axis)) ax_old = self.axes_manager.navigation_axes rp.axes_manager.navigation_axes[0].scale = ax_old[0].scale rp.axes_manager.navigation_axes[0].units = ax_old[0].units rp.axes_manager.navigation_axes[0].name = ax_old[0].name if len(ax_old) > 1: rp.axes_manager.navigation_axes[1].scale = ax_old[1].scale rp.axes_manager.navigation_axes[1].units = ax_old[1].units rp.axes_manager.navigation_axes[1].name = ax_old[1].name rp_axis = rp.axes_manager.signal_axes[0] rp_axis.name = 'k' rp_axis.scale = self.axes_manager.signal_axes[0].scale rp_axis.units = '$A^{-1}$' return rp
def electron_diffraction1d(): """A simple, multiuse diffraction profile, with dimensions: ElectronDiffraction1D <2,2|12> """ data = np.array([ [[1.0, 0.25, 0.0, 0.0, 0.0], [1.0, 0.25, 0.0, 0.0, 0.0]], [[1.0, 0.25, 0.0, 0.0, 0.16666667], [1.5, 0.5, 0.0, 0.0, 0.0]], ]) return ElectronDiffraction1D(data)
def test_2d_data_as_lazy(self): data = np.random.random((100, 150)) s = ElectronDiffraction1D(data) scale0, scale1, metadata_string = 0.5, 1.5, "test" s.axes_manager[0].scale = scale0 s.axes_manager[1].scale = scale1 s.metadata.Test = metadata_string s_lazy = s.as_lazy() assert isinstance(s_lazy, LazyElectronDiffraction1D) assert hasattr(s_lazy.data, "compute") assert s_lazy.axes_manager[0].scale == scale0 assert s_lazy.axes_manager[1].scale == scale1 assert s_lazy.metadata.Test == metadata_string assert data.shape == s_lazy.data.shape
def test_2d_data_as_lazy(self): data = np.random.random((100, 150)) s = ElectronDiffraction1D(data) scale0, scale1, metadata_string = 0.5, 1.5, 'test' s.axes_manager[0].scale = scale0 s.axes_manager[1].scale = scale1 s.metadata.Test = metadata_string s_lazy = s.as_lazy() assert s_lazy.__class__ == LazyElectronDiffraction1D assert hasattr(s_lazy.data, 'compute') assert s_lazy.axes_manager[0].scale == scale0 assert s_lazy.axes_manager[1].scale == scale1 assert s_lazy.metadata.Test == metadata_string assert data.shape == s_lazy.data.shape
def red_int_generator(): data = np.arange(10, 0, -1).reshape(1, 10) * np.arange(1, 5).reshape(4, 1) data = data.reshape(2, 2, 10) rp = ElectronDiffraction1D(data) rigen = ReducedIntensityGenerator1D(rp) return rigen
def test_3d_data_as_lazy(self): data = np.random.random((4, 10, 15)) s = ElectronDiffraction1D(data) s_lazy = s.as_lazy() assert isinstance(s_lazy, LazyElectronDiffraction1D) assert data.shape == s_lazy.data.shape
def test_3d_data_as_lazy(self): data = np.random.random((4, 10, 15)) s = ElectronDiffraction1D(data) s_lazy = s.as_lazy() assert s_lazy.__class__ == LazyElectronDiffraction1D assert data.shape == s_lazy.data.shape