How to use the pyxem.signals.transfer_signal_axes function in pyxem

To help you get started, we’ve selected a few pyxem 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 pyxem / pyxem / pyxem / signals / vdf_image.py View on Github external
segments = np.append(segments, vdfsegs[i])
            num_segs = np.shape(vdfsegs[i])[0]
            vectors_of_segments = np.append(
                vectors_of_segments, np.broadcast_to(vector, (num_segs, 2)))

        vectors_of_segments = vectors_of_segments.reshape((-1, 2))
        segments = segments.reshape((np.shape(vectors_of_segments)[0],
                                     vdfs.axes_manager.signal_shape[0],
                                     vdfs.axes_manager.signal_shape[1]))

        # if TraitError is raised, it is likely no segements were found
        segments = Signal2D(segments).transpose(navigation_axes=[0],
                                                signal_axes=[2, 1])
        # Create VDFSegment and transfer axes calibrations
        vdfsegs = VDFSegment(segments, DiffractionVectors(vectors_of_segments))
        vdfsegs.segments = transfer_signal_axes(vdfsegs.segments, vdfs)
        n = vdfsegs.segments.axes_manager.navigation_axes[0]
        n.name = 'n'
        n.units = 'number'
        vdfsegs.vectors_of_segments.axes_manager.set_signal_dimension(1)
        vdfsegs.vectors_of_segments = transfer_signal_axes(
            vdfsegs.vectors_of_segments, self.vectors)
        n = vdfsegs.vectors_of_segments.axes_manager.navigation_axes[0]
        n.name = 'n'
        n.units = 'number'

        return vdfsegs
github pyxem / pyxem / pyxem / generators / variance_generator.py View on Github external
else:
            meansq_dp = Signal2D(np.square(dp.data.astype(set_data_type))).mean((0, 1))

        normvar = (meansq_dp.data / np.square(mean_dp.data)) - 1.
        var_dp = Signal2D(normvar)
        corr_var_array = var_dp.data - (np.divide(dqe, mean_dp.data))
        corr_var_array[np.isinf(corr_var_array)] = 0
        corr_var_array[np.isnan(corr_var_array)] = 0
        corr_var = Signal2D(corr_var_array)
        vardps = stack((mean_dp, meansq_dp, var_dp, corr_var))
        sig_x = vardps.data.shape[1]
        sig_y = vardps.data.shape[2]

        dv = DiffractionVariance2D(vardps.data.reshape((2, 2, sig_x, sig_y)))

        dv = transfer_signal_axes(dv, self.signal)

        return dv
github pyxem / pyxem / pyxem / generators / subpixelrefinement_generator.py View on Github external
def __init__(self, dp, vectors, padding=None):
        if padding:
            dp_padded = np.zeros((dp.data.shape[0], dp.data.shape[1],
                                  dp.data.shape[2] + padding, dp.data.shape[2] + padding))
            dp_padded[:, :, int(padding / 2):dp.data.shape[2] + int(padding / 2), int(padding / 2):dp.data.shape[2] + int(padding / 2)] = dp.data
            dp_padded = pxm.ElectronDiffraction2D(dp_padded)
            transfer_signal_axes(dp_padded, dp)
            transfer_navigation_axes(dp_padded, dp)
            self.dp = dp_padded
        else:
            self.dp = dp
        self.vectors_init = vectors
        self.last_method = None
        sig_ax = dp.axes_manager.signal_axes
        self.calibration = [sig_ax[0].scale, sig_ax[1].scale]
        self.center = [sig_ax[0].size / 2, sig_ax[1].size / 2]

        self.vector_pixels = _get_pixel_vectors(dp,
                                                vectors,
                                                calibration=self.calibration,
                                                center=self.center)
github pyxem / pyxem / pyxem / signals / vdf_image.py View on Github external
vectors_of_segments = vectors_of_segments.reshape((-1, 2))
        segments = segments.reshape((np.shape(vectors_of_segments)[0],
                                     vdfs.axes_manager.signal_shape[0],
                                     vdfs.axes_manager.signal_shape[1]))

        # if TraitError is raised, it is likely no segements were found
        segments = Signal2D(segments).transpose(navigation_axes=[0],
                                                signal_axes=[2, 1])
        # Create VDFSegment and transfer axes calibrations
        vdfsegs = VDFSegment(segments, DiffractionVectors(vectors_of_segments))
        vdfsegs.segments = transfer_signal_axes(vdfsegs.segments, vdfs)
        n = vdfsegs.segments.axes_manager.navigation_axes[0]
        n.name = 'n'
        n.units = 'number'
        vdfsegs.vectors_of_segments.axes_manager.set_signal_dimension(1)
        vdfsegs.vectors_of_segments = transfer_signal_axes(
            vdfsegs.vectors_of_segments, self.vectors)
        n = vdfsegs.vectors_of_segments.axes_manager.navigation_axes[0]
        n.name = 'n'
        n.units = 'number'

        return vdfsegs
github pyxem / pyxem / pyxem / generators / red_intensity_generator1d.py View on Github external
-------
        ri : ReducedIntensity1D
        """

        s_scale = self.signal.axes_manager.signal_axes[0].scale
        s = np.arange(self.signal.axes_manager.signal_axes[0].size,
                      dtype='float64')
        s *= self.signal.axes_manager.signal_axes[0].scale

        reduced_intensity = (2 * np.pi * s *
                             np.divide((self.signal.data - self.background_fit),
                                       self.normalisation))

        ri = ReducedIntensity1D(reduced_intensity)
        ri = transfer_navigation_axes(ri, self.signal)
        ri = transfer_signal_axes(ri, self.signal)

        return ri
github pyxem / pyxem / pyxem / signals / strain_map.py View on Github external
""" Core functionality """

        if self.current_basis_x != [1, 0]:
            # this takes us back to [1,0] if our current map is in a diferent basis
            R = _get_rotation_matrix(self.current_basis_x).T
            strain_map_core = apply_rotation_complete(self, R)
        else:
            strain_map_core = self

        R = _get_rotation_matrix(x_new)
        transposed_to_new_basis = apply_rotation_complete(strain_map_core, R)
        meta_dict = self.metadata.as_dictionary()

        strainmap = StrainMap(transposed_to_new_basis, current_basis_x=x_new, metadata=meta_dict)
        return transfer_signal_axes(strainmap, self)
github pyxem / pyxem / pyxem / signals / segments.py View on Github external
else:
            segment_intensities = np.sum(self.segments.data, axis=(1, 2))
            for i in range(len(correlated_vectors)):
                correlated_vector_intensities[i] = np.zeros(
                    len(correlated_vector_indices[i]))
                for n, index in zip(range(len(correlated_vector_indices[i])),
                                    correlated_vector_indices[i]):
                    correlated_vector_intensities[i][n] = np.sum(
                        segment_intensities[index])

        vdfseg = VDFSegment(Signal2D(correlated_segments),
                            DiffractionVectors(correlated_vectors),
                            correlated_vector_intensities)

        # Transfer axes properties of segments
        vdfseg.segments = transfer_signal_axes(vdfseg.segments, self.segments)
        n = vdfseg.segments.axes_manager.navigation_axes[0]
        n.name = 'n'
        n.units = 'number'

        return vdfseg