예제 #1
0
    def test_global_to_local_cartesian_inverse(self):
        """Tests the reversibility of the global to loc cartesian transform"""

        x1 = 7000.0
        y1 = 8000.0
        z1 = 9500.0
        lat = 37.5
        lon = 289.0
        rad = 6380.0
        x2, y2, z2 = coords.global_to_local_cartesian(x1,
                                                      y1,
                                                      z1,
                                                      lat,
                                                      lon,
                                                      rad,
                                                      inverse=False)
        x3, y3, z3 = coords.global_to_local_cartesian(x2,
                                                      y2,
                                                      z2,
                                                      lat,
                                                      lon,
                                                      rad,
                                                      inverse=True)
        assert abs(x1 - x3) < 1.0e-6
        assert abs(y1 - y3) < 1.0e-6
        assert abs(z1 - z3) < 1.0e-6
예제 #2
0
    def test_deprecation_warning_global_to_local_cartesian(self):
        """Test if global_to_local_cartesian in coords is deprecated"""

        with warnings.catch_warnings(record=True) as war:
            coords.global_to_local_cartesian(7000.0, 8000.0, 9000.0,
                                             37.5, 289.0, 6380.0)

        assert len(war) >= 1
        assert war[0].category == DeprecationWarning
예제 #3
0
    def test_global_to_local_cartesian_single(self):
        """Test conversion from global to local cartesian coordinates"""

        x, y, z = coords.global_to_local_cartesian(7000.0, 8000.0, 9000.0,
                                                   37.5, 289.0, 6380.0)

        assert abs(x + 9223.175264852474) < 1.0e-6
        assert abs(y + 2239.835278362686) < 1.0e-6
        assert abs(z - 11323.126851088331) < 1.0e-6
예제 #4
0
    def test_local_cartesian_to_global_single(self):
        """Test conversion from local cartesian to global coordinates"""

        x, y, z = coords.global_to_local_cartesian(7000.0, 8000.0, 9000.0,
                                                   37.5, 289.0, 6380.0,
                                                   inverse=True)

        assert abs(x + 5709.804676635975) < 1.0e-6
        assert abs(y + 4918.397556010223) < 1.0e-6
        assert abs(z - 15709.577500484005) < 1.0e-6
예제 #5
0
    def test_global_to_local_cartesian_mult(self):
        """Test array conversion from global to local cartesian coordinates"""

        arr = np.ones(shape=(10,), dtype=float)
        x, y, z = coords.global_to_local_cartesian(7000.0*arr, 8000.0*arr,
                                                   9000.0*arr, 37.5*arr,
                                                   289.0*arr, 6380.0*arr)

        assert x.shape == arr.shape
        assert y.shape == arr.shape
        assert z.shape == arr.shape
        assert abs(x + 9223.175264852474).max() < 1.0e-6
        assert abs(y + 2239.835278362686).max() < 1.0e-6
        assert abs(z - 11323.126851088331).max() < 1.0e-6
예제 #6
0
    def test_local_cartesian_to_global_mult(self):
        """Test array conversion from local cartesian to global coordinates"""

        arr = np.ones(shape=(10,), dtype=float)
        x, y, z = coords.global_to_local_cartesian(7000.0*arr, 8000.0*arr,
                                                   9000.0*arr, 37.5*arr,
                                                   289.0*arr, 6380.0*arr,
                                                   inverse=True)

        assert x.shape == arr.shape
        assert y.shape == arr.shape
        assert z.shape == arr.shape
        assert abs(x + 5709.804676635975).max() < 1.0e-6
        assert abs(y + 4918.397556010223).max() < 1.0e-6
        assert abs(z - 15709.577500484005).max() < 1.0e-6