コード例 #1
0
def test_all_valid_axes():
    eulers = [10, 20, 30]
    for axes in valid_axes:
        rotation_matrix = euler2matrix(eulers,
                                       axes=axes,
                                       intrinsic=False,
                                       right_handed_rotation=True)

        result_eulers = matrix2euler(rotation_matrix,
                                     axes=axes,
                                     right_handed_rotation=True,
                                     intrinsic=False)
        result_rotation_matrix = euler2matrix(result_eulers,
                                              axes=axes,
                                              intrinsic=False,
                                              right_handed_rotation=True)

        assert_array_almost_equal(eulers, result_eulers)
        assert_array_almost_equal(rotation_matrix, result_rotation_matrix)
コード例 #2
0
ファイル: tbl.py プロジェクト: gutsche-lab/peepingtom
def euler2matrix_dynamo(euler_angles):
    """Convert (n, 3) array of Dynamo euler angles to rotation matrices
    Resulting rotation matrices rotate references into particles
    """
    rotation_matrices = eulerangles.euler2matrix(euler_angles,
                                                 axes='zxz',
                                                 intrinsic=False,
                                                 right_handed_rotation=True)

    rotation_matrices = rotation_matrices.swapaxes(-2, -1)
    return rotation_matrices
コード例 #3
0
def test_euler2matrix_all_combinations():
    eulers = (test_eulers_single, test_eulers_multiple)
    for eulers in eulers:
        for axes in valid_axes:
            for intrinsic in (True, False):
                for right_handed_rotation in (True, False):
                    matrices = euler2matrix(eulers,
                                            axes=axes,
                                            intrinsic=intrinsic,
                                            right_handed_rotation=right_handed_rotation)
                    assert matrices.shape[-1] == 3
                    assert matrices.shape[-2] == 3
コード例 #4
0
def test_euler2matrix_relion():
    relion_eulers = [137.7000, 1.1777, 42.7270]
    relion_matrix = np.array([[-0.99985746, 0.00734648, -0.01520186],
                              [-0.00755692, -0.99987577, 0.01383262],
                              [-0.01509835, 0.01394553, 0.99978876]])
    relion_meta = get_conversion_metadata('relion')

    result_matrix = euler2matrix(relion_eulers,
                                 axes=relion_meta.axes,
                                 intrinsic=relion_meta.intrinsic,
                                 right_handed_rotation=relion_meta.right_handed_rotation)

    assert_array_almost_equal(relion_matrix, result_matrix, decimal=4)
コード例 #5
0
def test_euler2matrix_dynamo():
    dynamo_eulers = np.array([30, 60, 75])
    dynamo_matrix = np.array([[-0.0173, -0.5477, 0.8365],
                              [0.9012, -0.3709, -0.2241],
                              [0.4330, 0.7500, 0.5000]])
    dynamo_meta = get_conversion_metadata('dynamo')

    result_matrix = euler2matrix(dynamo_eulers,
                                 axes=dynamo_meta.axes,
                                 intrinsic=dynamo_meta.intrinsic,
                                 right_handed_rotation=dynamo_meta.right_handed_rotation)

    assert_array_almost_equal(dynamo_matrix, result_matrix, decimal=4)
コード例 #6
0
import numpy as np
from numpy.testing import assert_array_equal
from eulerangles import euler2matrix

from blik.datablocks.simpleblocks.orientationblock import OrientationBlock

# test data for orientationblock
# orientations
rot = np.zeros(50)
tilt = np.linspace(0, 180, 50)
psi = rot
eulers = np.column_stack([rot, tilt, psi])
rotation_matrices = euler2matrix(eulers,
                                 axes='zyz',
                                 intrinsic=True,
                                 right_handed_rotation=True)


def test_orientationblock_instantiation():
    block = OrientationBlock(data=rotation_matrices)
    assert isinstance(block, OrientationBlock)