Exemplo n.º 1
0
    def get_concentric_vdf_images(self,
                                  k_min,
                                  k_max,
                                  k_steps,
                                  normalize=False):
        """Obtain the intensity scattered at each navigation position in an
        ElectronDiffraction Signal by summation over a series of concentric
        in annuli between a specified inner and outer radius in a number of
        steps.

        Parameters
        ----------
        k_min : float
            Minimum radius of the annular integration window in reciprocal
            angstroms.

        k_max : float
            Maximum radius of the annular integration window in reciprocal
            angstroms.

        k_steps : int
            Number of steps within the annular integration window

        Returns
        -------
        vdfs : VDFImage
            VDFImage object containing virtual dark field images for all steps
            within the annulus.
        """
        k_step = (k_max - k_min) / k_steps
        k0s = np.linspace(k_min, k_max - k_step, k_steps)
        k1s = np.linspace(k_min + k_step, k_max, k_steps)

        ks = np.array((k0s, k1s)).T

        vdfs = []
        for k in ks:
            annulus = roi.CircleROI(cx=0, cy=0, r=k[1], r_inner=k[0])
            vdf = annulus(self.signal,
                          axes=self.signal.axes_manager.signal_axes)
            vdfs.append(vdf.sum((2, 3)).as_signal2D((0, 1)).data)

        vdfim = VDFImage(np.asarray(vdfs))

        if normalize == True:
            vdfim.map(normalize_vdf)

        # Set calibration to same as signal
        x = vdfim.axes_manager.signal_axes[0]
        y = vdfim.axes_manager.signal_axes[1]

        x.name = 'x'
        x.scale = self.signal.axes_manager.navigation_axes[0].scale
        x.units = 'nm'

        y.name = 'y'
        y.scale = self.signal.axes_manager.navigation_axes[0].scale
        y.units = 'nm'

        return vdfim
Exemplo n.º 2
0
    def get_vector_vdf_images(self,
                              radius,
                              normalize=False):
        """Obtain the intensity scattered to each diffraction vector at each
        navigation position in an ElectronDiffraction Signal by summation in a
        circular window of specified radius.

        Parameters
        ----------
        radius : float
            Radius of the integration window in reciprocal angstroms.

        normalize : boolean
            If True each VDF image is normalized so that the maximum intensity
            in each VDF is 1.

        Returns
        -------
        vdfs : VDFImage
            VDFImage object containing virtual dark field images for all unique
            vectors.
        """
        if self.vectors:
            vdfs = []
            for v in self.vectors.data:
                disk = roi.CircleROI(cx=v[0], cy=v[1], r=radius, r_inner=0)
                vdf = disk(self.signal,
                           axes=self.signal.axes_manager.signal_axes)
                vdfs.append(vdf.sum((2, 3)).as_signal2D((0, 1)).data)

            vdfim = VDFImage(np.asarray(vdfs))

            if normalize == True:
                vdfim.map(normalize_vdf)

        else:
            raise ValueError("DiffractionVectors non-specified by user. Please "
                             "initialize VDFGenerator with some vectors. ")

        # Set calibration to same as signal
        x = vdfim.axes_manager.signal_axes[0]
        y = vdfim.axes_manager.signal_axes[1]

        x.name = 'x'
        x.scale = self.signal.axes_manager.navigation_axes[0].scale
        x.units = 'nm'

        y.name = 'y'
        y.scale = self.signal.axes_manager.navigation_axes[0].scale
        y.units = 'nm'

        # Assign vectors used to generate images to vdfim attribute.
        vdfim.vectors = self.vectors.data

        return vdfim