How to use the pyxem.ElectronDiffraction2D 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 / utils / big_data_utils.py View on Github external
def _load_and_cast(filepath,x,y,chunk_size):
    """ Loads a chunk of a larger diffraction pattern"""
    s = hs.load(filepath,lazy=True)
    s = s.inav[x:x+chunk_size,y:y+chunk_size]
    s.compute()
    return pxm.ElectronDiffraction2D(s)
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 / utils / expt_utils.py View on Github external
--------
    subtract_background_dog : The background subtraction method used.
    np.arange : Produces suitable objects for std_dev_maxs

    """
    gauss_processed = np.empty((
        len(std_dev_maxs),
        len(std_dev_mins),
        *sample_dp.axes_manager.signal_shape))

    for i, std_dev_max in enumerate(tqdm(std_dev_maxs, leave=False)):
        for j, std_dev_min in enumerate(std_dev_mins):
            gauss_processed[i, j] = sample_dp.remove_background('gaussian_difference',
                                                                sigma_min=std_dev_min, sigma_max=std_dev_max,
                                                                show_progressbar=False)
    dp_gaussian = pxm.ElectronDiffraction2D(gauss_processed)
    dp_gaussian.metadata.General.title = 'Gaussian preprocessed'
    dp_gaussian.axes_manager.navigation_axes[0].name = r'$\sigma_{\mathrm{min}}$'
    dp_gaussian.axes_manager.navigation_axes[1].name = r'$\sigma_{\mathrm{max}}$'
    for axes_number, axes_value_list in [(0, std_dev_mins), (1, std_dev_maxs)]:
        dp_gaussian.axes_manager.navigation_axes[axes_number].offset = axes_value_list[0]
        dp_gaussian.axes_manager.navigation_axes[axes_number].scale = axes_value_list[1] - axes_value_list[0]
        dp_gaussian.axes_manager.navigation_axes[axes_number].units = ''

    dp_gaussian.plot(cmap='viridis')
    return None