How to use the pyxem.signals.transfer_navigation_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 / diffraction2d.py View on Github external
**kwargs_for_map)

        if len(azimuthal_integrals.data.shape) == 3:
            ap = Diffraction1D(azimuthal_integrals.data[:, 1, :])
            tth = azimuthal_integrals.data[0, 0, :]  # tth is the signal axis
        else:
            ap = Diffraction1D(azimuthal_integrals.data[:, :, 1, :])
            tth = azimuthal_integrals.data[0, 0, 0, :]  # tth is the signal axis
        scale = (tth[1] - tth[0]) * scaling_factor
        offset = tth[0] * scaling_factor
        ap.axes_manager.signal_axes[0].scale = scale
        ap.axes_manager.signal_axes[0].offset = offset
        ap.axes_manager.signal_axes[0].name = 'scattering'
        ap.axes_manager.signal_axes[0].units = unit

        transfer_navigation_axes(ap, self)
        push_metadata_through(ap, self)

        return ap
github pyxem / pyxem / pyxem / generators / indexation_generator.py View on Github external
library=library,
                                        mag_tol=mag_tol,
                                        angle_tol=np.deg2rad(angle_tol),
                                        index_error_tol=index_error_tol,
                                        n_peaks_to_index=n_peaks_to_index,
                                        n_best=n_best,
                                        inplace=False,
                                        *args,
                                        **kwargs)
        indexation = matched.isig[0]
        rhkls = matched.isig[1].data

        indexation_results = VectorMatchingResults(indexation)
        indexation_results.vectors = vectors
        indexation_results.hkls = rhkls
        indexation_results = transfer_navigation_axes(indexation_results,
                                                      vectors.cartesian)

        vectors.hkls = rhkls

        return indexation_results
github pyxem / pyxem / pyxem / signals / diffraction_vectors.py View on Github external
----------
        accelerating_voltage : float
            The acceleration voltage with which the data was acquired.
        camera_length : float
            The camera length in meters.
        """
        # Imported here to avoid circular dependency
        from diffsims.utils.sim_utils import get_electron_wavelength
        wavelength = get_electron_wavelength(accelerating_voltage)
        self.cartesian = self.map(detector_to_fourier,
                                  wavelength=wavelength,
                                  camera_length=camera_length * 1e10,
                                  inplace=False,
                                  parallel=False,  # TODO: For testing
                                  *args, **kwargs)
        transfer_navigation_axes(self.cartesian, self)
github pyxem / pyxem / pyxem / signals / diffraction_variance2d.py View on Github external
:func:`pyxem.utils.expt_utils.radial_average`

        Examples
        --------
        .. code-block:: python
            profiles = ed.get_radial_profile()
            profiles.plot()
        """
        radial_profiles = self.map(radial_average,
                                   inplace=inplace, **kwargs)

        radial_profiles.axes_manager.signal_axes[0].offset = 0
        signal_axis = radial_profiles.axes_manager.signal_axes[0]

        rp = DiffractionVariance1D(radial_profiles.as_signal1D(signal_axis))
        rp = transfer_navigation_axes(rp, self)
        rp_axis = rp.axes_manager.signal_axes[0]
        rp_axis.name = 'q'
        rp_axis.scale = self.axes_manager.signal_axes[0].scale
        rp_axis.units = '$A^{-1}$'

        return rp
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 / generators / pdf_generator1d.py View on Github external
s_values = np.arange(s_limits[0], s_limits[1], 1) * s_scale
        s_values = s_values.reshape(s_values.size, 1)  # column vector

        limited_red_int = self.signal.isig[s_limits[0]:s_limits[1]].data

        pdf_sine = np.sin(2 * np.pi * np.matmul(s_values, r_values))
        # creates a vector of the pdf
        rpdf = PairDistributionFunction1D(8 * np.pi * s_scale
                                          * np.matmul(limited_red_int, pdf_sine))

        signal_axis = rpdf.axes_manager.signal_axes[0]
        pdf_scaling = r_increment
        signal_axis.scale = pdf_scaling
        signal_axis.name = 'Radius r'
        signal_axis.units = '$Å$'
        rpdf = transfer_navigation_axes(rpdf, self.signal)

        return rpdf
github pyxem / pyxem / pyxem / generators / indexation_generator.py View on Github external
cropped_library[phase_name] = {
                'orientations': phase_entry['orientations'],
                'pixel_coords': pixel_coords.astype('int'),
                'intensities': intensities,
                'pattern_norms': np.linalg.norm(intensities, axis=1),
            }

        matches = signal.map(correlate_library,
                             library=cropped_library,
                             n_largest=n_largest,
                             mask=mask,
                             inplace=False,
                             **kwargs)

        matching_results = TemplateMatchingResults(matches)
        matching_results = transfer_navigation_axes(matching_results, signal)

        return matching_results
github pyxem / pyxem / pyxem / generators / indexation_generator.py View on Github external
n_best=n_best,
                                   rank=rank,
                                   method="leastsq",
                                   verbose=False,
                                   vary_angles=vary_angles,
                                   vary_center=vary_center,
                                   vary_scale=vary_scale,
                                   inplace=False, parallel=False)

        indexation = matched.isig[0]
        rhkls = matched.isig[1].data

        indexation_results = VectorMatchingResults(indexation)
        indexation_results.vectors = vectors
        indexation_results.hkls = rhkls
        indexation_results = transfer_navigation_axes(indexation_results,
                                                      vectors.cartesian)

        return indexation_results
github pyxem / pyxem / pyxem / signals / indexation_results.py View on Github external
which defines the phase, orientation as Euler angles in the zxz
            convention and metrics associated with the matching.

            Metrics for template matching results are
                'match_rate'
                'total_error'
                'orientation_reliability'
                'phase_reliability'
        """
        crystal_map = self.map(crystal_from_vector_matching,
                               inplace=False,
                               *args, **kwargs)

        cryst_map = CrystallographicMap(crystal_map)
        cryst_map = transfer_navigation_axes(cryst_map, self)
        cryst_map.method = 'vector_matching'

        return cryst_map
github pyxem / pyxem / pyxem / signals / indexation_results.py View on Github external
which defines the phase, orientation as Euler angles in the zxz
            convention and metrics associated with the matching.

            Metrics for template matching results are
                'correlation'
                'orientation_reliability'
                'phase_reliability'

        """
        # TODO: Add alternative methods beyond highest correlation score.
        crystal_map = self.map(crystal_from_template_matching,
                               inplace=False,
                               *args, **kwargs)

        cryst_map = CrystallographicMap(crystal_map)
        cryst_map = transfer_navigation_axes(cryst_map, self)
        cryst_map.method = 'template_matching'

        return cryst_map