Beispiel #1
0
def test_euler_angle_rotations():
    ydeg = (90 * u.deg, 0 * u.deg)
    y = (90, 0)
    z = (0, 90)

    # rotate y into minus z
    model = models.EulerAngleRotation(0 * u.rad, np.pi / 2 * u.rad, 0 * u.rad,
                                      'zxz')
    assert_allclose(model(*z), y, atol=10**-12)
    model = models.EulerAngleRotation(0 * u.deg, 90 * u.deg, 0 * u.deg, 'zxz')
    assert_quantity_allclose(model(*(z * u.deg)), ydeg, atol=10**-12 * u.deg)
Beispiel #2
0
def test_euler_angle_rotations():
    x = (0, 0)
    y = (90, 0)
    z = (0, 90)
    negx = (180, 0)
    negy = (-90, 0)

    # rotate y into minus z
    model = models.EulerAngleRotation(0, 90, 0, 'zxz')
    assert_allclose(model(*z), y, atol=10**-12)
    # rotate z into minus x
    model = models.EulerAngleRotation(0, 90, 0, 'zyz')
    assert_allclose(model(*z), negx, atol=10**-12)
    # rotate x into minus y
    model = models.EulerAngleRotation(0, 90, 0, 'yzy')
    assert_allclose(model(*x), negy, atol=10**-12)
Beispiel #3
0
def test_euler_angles(axes_order):
    """
    Tests against all Euler sequences.
    The rotation matrices definitions come from Wikipedia.
    """
    phi = np.deg2rad(23.4)
    theta = np.deg2rad(12.2)
    psi = np.deg2rad(34)
    c1 = cos(phi)
    c2 = cos(theta)
    c3 = cos(psi)
    s1 = sin(phi)
    s2 = sin(theta)
    s3 = sin(psi)

    matrices = {
        'zxz':
        np.array([[(c1 * c3 - c2 * s1 * s3), (-c1 * s3 - c2 * c3 * s1),
                   (s1 * s2)],
                  [(c3 * s1 + c1 * c2 * s3), (c1 * c2 * c3 - s1 * s3),
                   (-c1 * s2)], [(s2 * s3), (c3 * s2), (c2)]]),
        'zyz':
        np.array([[(c1 * c2 * c3 - s1 * s3), (-c3 * s1 - c1 * c2 * s3),
                   (c1 * s2)],
                  [(c1 * s3 + c2 * c3 * s1), (c1 * c3 - c2 * s1 * s3),
                   (s1 * s2)], [(-c3 * s2), (s2 * s3), (c2)]]),
        'yzy':
        np.array([[(c1 * c2 * c3 - s1 * s3), (-c1 * s2),
                   (c3 * s1 + c1 * c2 * s3)], [(c3 * s2), (c2), (s2 * s3)],
                  [(-c1 * s3 - c2 * c3 * s1), (s1 * s2),
                   (c1 * c3 - c2 * s1 * s3)]]),
        'yxy':
        np.array([[(c1 * c3 - c2 * s1 * s3), (s1 * s2),
                   (c1 * s3 + c2 * c3 * s1)], [(s2 * s3), (c2), (-c3 * s2)],
                  [(-c3 * s1 - c1 * c2 * s3), (c1 * s2),
                   (c1 * c2 * c3 - s1 * s3)]]),
        'xyx':
        np.array([[(c2), (s2 * s3), (c3 * s2)],
                  [(s1 * s2), (c1 * c3 - c2 * s1 * s3),
                   (-c1 * s3 - c2 * c3 * s1)],
                  [(-c1 * s2), (c3 * s1 + c1 * c2 * s3),
                   (c1 * c2 * c3 - s1 * s3)]]),
        'xzx':
        np.array([[(c2), (-c3 * s2), (s2 * s3)],
                  [(c1 * s2), (c1 * c2 * c3 - s1 * s3),
                   (-c3 * s1 - c1 * c2 * s3)],
                  [(s1 * s2), (c1 * s3 + c2 * c3 * s1),
                   (c1 * c3 - c2 * s1 * s3)]])
    }
    model = models.EulerAngleRotation(23.4, 12.2, 34, axes_order)
    mat = model._create_matrix(phi, theta, psi, axes_order)

    assert_allclose(mat.T,
                    matrices[axes_order])  # get_rotation_matrix(axes_order))
Beispiel #4
0
def test_euler_rotations_with_units(params):
    x = 1 * u.deg
    y = 1 * u.deg
    phi, theta, psi = params

    urot = models.EulerAngleRotation(phi, theta, psi, axes_order='xyz')
    a, b = urot(x.value, y.value)
    assert_allclose((a, b), (-23.614457631192547, 9.631254579686113))
    a, b = urot(x, y)
    assert_quantity_allclose(
        (a, b), (-23.614457631192547 * u.deg, 9.631254579686113 * u.deg))
    a, b = urot(x.to(u.rad), y.to(u.rad))
    assert_quantity_allclose(
        (a, b), (-23.614457631192547 * u.deg, 9.631254579686113 * u.deg))
Beispiel #5
0
    astmodels.Identity(2),
    astmodels.Polynomial1D(2, c0=1, c1=2, c2=3),
    astmodels.Polynomial2D(1, c0_0=1, c0_1=2, c1_0=3),
    astmodels.Shift(2.),
    astmodels.Hermite1D(2, c0=2, c1=3, c2=0.5),
    astmodels.Legendre1D(2, c0=2, c1=3, c2=0.5),
    astmodels.Chebyshev1D(2, c0=2, c1=3, c2=0.5),
    astmodels.Chebyshev2D(1, 1, c0_0=1, c0_1=2, c1_0=3),
    astmodels.Legendre2D(1, 1, c0_0=1, c0_1=2, c1_0=3),
    astmodels.Hermite2D(1, 1, c0_0=1, c0_1=2, c1_0=3),
    astmodels.Scale(3.4),
    astmodels.RotateNative2Celestial(5.63, -72.5, 180),
    astmodels.Multiply(3),
    astmodels.Multiply(10 * u.m),
    astmodels.RotateCelestial2Native(5.63, -72.5, 180),
    astmodels.EulerAngleRotation(23, 14, 2.3, axes_order='xzx'),
    astmodels.Mapping((0, 1), n_inputs=3),
    astmodels.Shift(2. * u.deg),
    astmodels.Scale(3.4 * u.deg),
    astmodels.RotateNative2Celestial(5.63 * u.deg, -72.5 * u.deg, 180 * u.deg),
    astmodels.RotateCelestial2Native(5.63 * u.deg, -72.5 * u.deg, 180 * u.deg),
    astmodels.RotationSequence3D([1.2, 2.3, 3.4, .3], 'xyzx'),
    astmodels.SphericalRotationSequence([1.2, 2.3, 3.4, .3], 'xyzy'),
    custom_and_analytical_inverse(),
]

math_models = []

for kl in astmodels.math.__all__:
    klass = getattr(astmodels.math, kl)
    math_models.append(klass())
Beispiel #6
0
    astropy_models.Sky2Pix_SlantZenithalPerspective(mu=1.5,
                                                    phi0=15.0,
                                                    theta0=80.0),
    astropy_models.Pix2Sky_Stereographic(),
    astropy_models.Sky2Pix_Stereographic(),
    astropy_models.Pix2Sky_TangentialSphericalCube(),
    astropy_models.Sky2Pix_TangentialSphericalCube(),
    astropy_models.Pix2Sky_ZenithalEqualArea(),
    astropy_models.Sky2Pix_ZenithalEqualArea(),
    astropy_models.Pix2Sky_ZenithalEquidistant(),
    astropy_models.Sky2Pix_ZenithalEquidistant(),
    astropy_models.Pix2Sky_ZenithalPerspective(mu=1.5, gamma=15.0),
    astropy_models.Sky2Pix_ZenithalPerspective(mu=1.5, gamma=15.0),

    # astropy.modeling.rotations
    astropy_models.EulerAngleRotation(23, 14, 2.3, axes_order="xzx"),
    astropy_models.RotateCelestial2Native(5.63, -72.5, 180),
    astropy_models.RotateCelestial2Native(5.63 * u.deg, -72.5 * u.deg,
                                          180 * u.deg),
    astropy_models.RotateNative2Celestial(5.63, -72.5, 180),
    astropy_models.RotateNative2Celestial(5.63 * u.deg, -72.5 * u.deg,
                                          180 * u.deg),
    astropy_models.Rotation2D(angle=1.51),
    astropy_models.RotationSequence3D([1.2, 2.3, 3.4, .3], "xyzx"),
    astropy_models.SphericalRotationSequence([1.2, 2.3, 3.4, .3], "xyzy"),

    # astropy.modeling.tabular
    astropy_models.Tabular1D(points=np.arange(0, 5),
                             lookup_table=[1., 10, 2, 45, -3]),
    astropy_models.Tabular1D(points=np.arange(0, 5) * u.pix,
                             lookup_table=[1., 10, 2, 45, -3] * u.nm),