예제 #1
0
    def test_deprecation_warning_spherical_to_cartesian(self):
        """Test if spherical_to_cartesian in coords is deprecated"""

        with warnings.catch_warnings(record=True) as war:
            coords.spherical_to_cartesian(45.0, 30.0, 1.0)

        assert len(war) >= 1
        assert war[0].category == DeprecationWarning
예제 #2
0
    def test_spherical_to_cartesian_inverse(self):
        """Tests the reversibility of spherical to cartesian conversions"""

        x1 = 3000.0
        y1 = 2000.0
        z1 = 2500.0
        az, el, r = coords.spherical_to_cartesian(x1, y1, z1, inverse=True)
        x2, y2, z2 = coords.spherical_to_cartesian(az, el, r, inverse=False)

        assert abs(x1 - x2) < 1.0e-6
        assert abs(y1 - y2) < 1.0e-6
        assert abs(z1 - z2) < 1.0e-6
예제 #3
0
    def test_spherical_to_cartesian_single(self):
        """Test conversion from spherical to cartesian coordinates"""

        x, y, z = coords.spherical_to_cartesian(45.0, 30.0, 1.0)

        assert abs(x - y) < 1.0e-6
        assert abs(z - 0.5) < 1.0e-6
예제 #4
0
    def test_cartesian_to_spherical_single(self):
        """Test conversion from cartesian to spherical coordinates"""

        x = 0.6123724356957946
        az, el, r = coords.spherical_to_cartesian(x, x, 0.5, inverse=True)

        assert abs(az - 45.0) < 1.0e-6
        assert abs(el - 30.0) < 1.0e-6
        assert abs(r - 1.0) < 1.0e-6
예제 #5
0
    def test_spherical_to_cartesian_mult(self):
        """Test array conversion from spherical to cartesian coordinates"""

        arr = np.ones(shape=(10,), dtype=float)
        x, y, z = coords.spherical_to_cartesian(45.0*arr, 30.0*arr, arr)

        assert x.shape == arr.shape
        assert y.shape == arr.shape
        assert z.shape == arr.shape
        assert abs(x - y).max() < 1.0e-6
        assert abs(z - 0.5).max() < 1.0e-6
예제 #6
0
    def test_cartesian_to_spherical_mult(self):
        """Test array conversion from cartesian to spherical coordinates"""

        arr = np.ones(shape=(10,), dtype=float)
        x = 0.6123724356957946
        az, el, r = coords.spherical_to_cartesian(x*arr, x*arr, 0.5*arr,
                                                  inverse=True)

        assert az.shape == arr.shape
        assert el.shape == arr.shape
        assert r.shape == arr.shape
        assert abs(az - 45.0).max() < 1.0e-6
        assert abs(el - 30.0).max() < 1.0e-6
        assert abs(r - 1.0).max() < 1.0e-6