コード例 #1
0
def test_slow_to_euler_case(random_eulers):
    """
    This function checks that to_Axangle runs with rarer conventions on the eulers
    """
    e = Euler(random_eulers, 'sxyz')
    axangle = e.to_AxAngle()
    assert isinstance(axangle, AxAngle)
コード例 #2
0
def get_grid_around_beam_direction(beam_rotation,
                                   resolution,
                                   angular_range=(0, 360)):
    """
    Creates a rotation list of rotations for which the rotation is about given beam direction

    Parameters
    ----------
    beam_rotation : tuple
        A desired beam direction as a rotation (rzxz eulers), usually found via get_rotation_from_z_to_direction

    resolution : float
        The resolution of the grid (degrees)

    angular_range : tuple
        The minimum (included) and maximum (excluded) rotation around the beam direction to be included

    Returns
    -------
    rotation_list : list of tuples

    Example
    -------
    >>> from diffsims.generators.zap_map_generator import get_rotation_from_z_to_direction
    >>> beam_rotation = get_rotation_from_z_to_direction(structure,[1,1,1])
    >>> grid = get_grid_around_beam_direction(beam_rotation,1)
    """

    beam_rotation = np.deg2rad(beam_rotation)
    axangle = euler2axangle(beam_rotation[0], beam_rotation[1],
                            beam_rotation[2], 'rzxz')
    euler_szxz = axangle2euler(axangle[0], axangle[1],
                               'szxz')  # convert to szxz
    rotation_alpha, rotation_beta = np.rad2deg(euler_szxz[0]), np.rad2deg(
        euler_szxz[1])

    # see _create_advanced_linearly_spaced_array_in_rzxz for details
    steps_gamma = int(
        np.ceil((angular_range[1] - angular_range[0]) / resolution))
    alpha = np.asarray([rotation_alpha])
    beta = np.asarray([rotation_beta])
    gamma = np.linspace(angular_range[0],
                        angular_range[1],
                        num=steps_gamma,
                        endpoint=False)
    z = np.asarray(list(product(alpha, beta, gamma)))
    raw_grid = Euler(
        z, axis_convention='szxz'
    )  # we make use of an uncommon euler angle set here for speed
    grid_rzxz = raw_grid.to_AxAngle().to_Euler(axis_convention='rzxz')
    rotation_list = grid_rzxz.to_rotation_list(round_to=2)
    return rotation_list
コード例 #3
0
def get_grid_around_beam_direction(beam_direction,
                                   resolution,
                                   angular_range=(0, 360),
                                   cubic=False):
    """
    Creates a rotation list of rotations for which the rotation is about given beam direction

    Parameters
    ----------
    beam_direction : [x,y,z]
        A desired beam direction

    resolution : float
        The 'resolution' of the grid (degrees)

    angular_range : tuple
        The minimum (included) and maximum (excluded) rotation around the beam direction to be included

    cubic : bool
        This only works for cubic systems at the present, when False this raises a warning, set to
        True to supress said warning. The default is False

    Returns
    -------
    rotation_list : list of tuples
    """

    if not cubic:
        warnings.warn("This code only works for cubic systems at present")
    rotation_alpha, rotation_beta = _get_rotation_to_beam_direction(
        beam_direction)
    # see _create_advanced_linearly_spaced_array_in_rzxz for details
    steps_gamma = int(
        np.ceil((angular_range[1] - angular_range[0]) / resolution))
    alpha = np.asarray([rotation_alpha])
    beta = np.asarray([rotation_beta])
    gamma = np.linspace(angular_range[0],
                        angular_range[1],
                        num=steps_gamma,
                        endpoint=False)
    z = np.asarray(list(product(alpha, beta, gamma)))
    raw_grid = Euler(
        z, axis_convention='szxz'
    )  #we make use of an uncommon euler angle set here for speed
    grid_rzxz = raw_grid.to_AxAngle().to_Euler(axis_convention='rzxz')
    rotation_list = grid_rzxz.to_rotation_list(round_to=2)
    return rotation_list
コード例 #4
0
def get_grid_streographic(crystal_system, resolution, equal='angle'):
    """
    Creates a rotation list by determining the beam directions within the symmetry reduced
    region of the inverse pole figure, corresponding to the specified crystal system, and
    combining this with rotations about the beam direction at a given resolution.

    Parameters
    ----------
    crytal_system : str
        'cubic','hexagonal','trigonal','tetragonal','orthorhombic','monoclinic' and 'triclinic'

    resolution : float
        The maximum misorientation between rotations in the list, as defined according to
        the parameter 'equal'. Specified as an angle in degrees.
    equal : str
        'angle' or 'area'. If 'angle', the misorientation is calculated between each beam direction
        and its nearest neighbour(s). If 'area', the density of points is as in the equal angle case
        but each point covers an equal area.

    Returns
    -------
    rotation_list : list of tuples
        List of rotations
    """
    beam_directions_rzxz = beam_directions_to_euler_angles(
        get_beam_directions(crystal_system, resolution, equal=equal))
    beam_directions_szxz = beam_directions_rzxz.to_AxAngle().to_Euler(
        axis_convention='szxz')  # convert to high speed convention

    # drop in all the inplane rotations to form z
    alpha = beam_directions_szxz.data[:, 0]
    beta = beam_directions_szxz.data[:, 1]
    in_plane = np.arange(0, 360, resolution)

    ipalpha = np.asarray(list(product(alpha, np.asarray(in_plane))))
    ipbeta = np.asarray(list(product(beta, np.asarray(in_plane))))
    z = np.hstack((ipalpha[:, 0].reshape((-1, 1)), ipbeta))

    raw_grid = Euler(z, axis_convention='szxz')
    grid_rzxz = raw_grid.to_AxAngle().to_Euler(
        axis_convention='rzxz')  # convert back Bunge convention to return
    rotation_list = grid_rzxz.to_rotation_list(round_to=2)
    return rotation_list
コード例 #5
0
 def euler(self, good_array):
     return Euler(good_array)
コード例 #6
0
 def test_to_rotation_list_no_round(self, good_array):
     l = Euler(good_array).to_rotation_list(round_to=None)
     assert isinstance(l, list)
     assert isinstance(l[0], tuple)
コード例 #7
0
 def test_good_array__init__(self, good_array):
     assert isinstance(Euler(good_array), Euler)
コード例 #8
0
 def test_warning_code(self, good_array):
     euler = Euler(good_array)
     euler.data[:, :] = 1e-5
     euler._check_data()