Пример #1
0
def test_EulerAngleRotation_errors():
    # Bad length of axes_order
    with pytest.raises(TypeError) as err:
        rotations.EulerAngleRotation(mk.MagicMock(),
                                     mk.MagicMock(),
                                     mk.MagicMock(),
                                     axes_order="xyzx")
    assert str(err.value) ==\
        "Expected axes_order to be a character sequence of length 3, got xyzx"

    # Bad axes_order labels
    with pytest.raises(
            ValueError,
            match=r"Unrecognized axis label .* should be one of .*"):
        rotations.EulerAngleRotation(mk.MagicMock(),
                                     mk.MagicMock(),
                                     mk.MagicMock(),
                                     axes_order="abc")

    # Bad units
    message = "All parameters should be of the same type - float or Quantity."
    with pytest.raises(TypeError) as err:
        rotations.EulerAngleRotation(1 * u.m, 2, 3, axes_order="xyz")
    assert str(err.value) == message
    with pytest.raises(TypeError) as err:
        rotations.EulerAngleRotation(1, 2 * u.m, 3, axes_order="xyz")
    assert str(err.value) == message
    with pytest.raises(TypeError) as err:
        rotations.EulerAngleRotation(1, 2, 3 * u.m, axes_order="xyz")
    assert str(err.value) == message
Пример #2
0
def test_EulerAngleRotation_inverse():
    model = rotations.EulerAngleRotation(1, 2, 3, "xyz")

    assert_allclose(model.inverse.phi, -3)
    assert_allclose(model.inverse.theta, -2)
    assert_allclose(model.inverse.psi, -1)
    assert model.inverse.axes_order == "zyx"
Пример #3
0
 def from_tree_transform(self, node):
     if node['direction'] == 'native2celestial':
         return rotations.RotateNative2Celestial(node["phi"], node["theta"],
                                                 node["psi"])
     elif node['direction'] == 'celestial2native':
         return rotations.RotateCelestial2Native(node["phi"], node["theta"],
                                                 node["psi"])
     else:
         return rotations.EulerAngleRotation(node["phi"],
                                             node["theta"],
                                             node["psi"],
                                             axes_order=node["direction"])
Пример #4
0
    def from_yaml_tree_transform(self, node, tag, ctx):
        from astropy.modeling import rotations

        if node["direction"] == "native2celestial":
            return rotations.RotateNative2Celestial(node["phi"], node["theta"],
                                                    node["psi"])
        elif node["direction"] == "celestial2native":
            return rotations.RotateCelestial2Native(node["phi"], node["theta"],
                                                    node["psi"])
        else:
            return rotations.EulerAngleRotation(node["phi"],
                                                node["theta"],
                                                node["psi"],
                                                axes_order=node["direction"])