Beispiel #1
0
    def plot_corrected_diffraction_pattern(self, reference_circle=True):
        """Plot the distortion corrected diffraction pattern with an optional
        reference circle.

        Parameters
        ----------
        reference_circle : bool
            If True a CircleROI widget is added to the plot for reference.

        """
        # Check all required parameters are defined as attributes
        if self.calibration_data.au_x_grating_dp is None:
            raise ValueError("This method requires an Au X-grating diffraction "
                             "pattern to be provided. Please update the "
                             "CalibrationDataLibrary.")
        if self.affine_matrix is None:
            raise ValueError("This method requires a distortion matrix to have "
                             "been determined. Use get_elliptical_distortion "
                             "to determine this matrix.")
        # Set name for experimental data pattern
        dpeg = self.calibration_data.au_x_grating_dp
        # Apply distortion corrections to experimental data
        size = dpeg.data.shape[0]
        dpegs = stack_method([dpeg, dpeg, dpeg, dpeg])
        dpegs = ElectronDiffraction2D(dpegs.data.reshape((2, 2, size, size)))
        dpegs.apply_affine_transformation(self.affine_matrix,
                                          preserve_range=True,
                                          inplace=True)
        dpegm = dpegs.mean((0, 1))
        # Plot distortion corrected data
        dpegm.plot(cmap='magma', vmax=0.1)
        # add reference circle if specified
        if reference_circle is True:
            circ = CircleROI(cx=128, cy=128, r=53.5, r_inner=0)
            circ.add_widget(dpegm)