def test_deepcopy(self, pc1):
     """Yields the expected parameters and an actual deep copy."""
     detector1 = EBSDDetector(pc=pc1)
     detector2 = detector1.deepcopy()
     detector1.pcx += 0.1
     assert np.allclose(detector1.pcx, 0.521)
     assert np.allclose(detector2.pcx, 0.421)
Esempio n. 2
0
    def __init__(
        self,
        detector: EBSDDetector,
        phase: Phase,
        rotations: Rotation,
    ):
        """A generator storing necessary parameters to simulate
        geometrical EBSD patterns.

        Parameters
        ----------
        detector
            Detector describing the detector-sample geometry.
        phase
            A phase container with a crystal structure and a space and
            point group describing the allowed symmetry operations.
        rotations
            Unit cell rotations to simulate patterns for. The
            navigation shape of the resulting simulation is determined
            from the rotations' shape, with a maximum dimension of 2.

        Examples
        --------
        >>> from orix.crystal_map import Phase
        >>> from orix.quaternion import Rotation
        >>> from kikuchipy.detectors import EBSDDetector
        >>> from kikuchipy.generators import EBSDSimulationGenerator
        >>> det = EBSDDetector(
        ...     shape=(60, 60), sample_tilt=70, pc=[0.5,] * 3
        ... )
        >>> p = Phase(name="ni", space_group=225)
        >>> p.structure.lattice.setLatPar(3.52, 3.52, 3.52, 90, 90, 90)
        >>> simgen = EBSDSimulationGenerator(
        ...     detector=det,
        ...     phase=p,
        ...     rotations=Rotation.from_euler([90, 45, 90])
        ... )
        >>> simgen
        EBSDSimulationGenerator (1,)
        EBSDDetector (60, 60), px_size 1 um, binning 1, tilt 0, pc
        (0.5, 0.5, 0.5)
        <name: . space group: None. point group: None. proper point
        group: None. color: tab:blue>
        Rotation (1,)
        """
        self.detector = detector.deepcopy()
        self.phase = phase.deepcopy()
        self.rotations = deepcopy(rotations)