Exemple #1
0
 def test_symmetric_32_bit(self):
     lats, lons = self._as_bounded_coords([[-90, -89.375],
                                           [89.375, 90]],
                                          [0, 10],
                                          dtype=np.float32)
     area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)
     self.assertArrayAllClose(area, area[::-1])
    def test_area_multiple_lats_and_lons(self):
        lats, lons = self._as_bounded_coords([[-80, -70], [0, 10], [70, 80]],
                                             [[0, 10], [10, 30]])
        area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)

        self.assertArrayAllClose(area, [[3.19251846e+11, 6.38503692e+11],
                                        [1.22880059e+12, 2.45760119e+12],
                                        [3.19251846e+11, 6.38503692e+11]])
    def test_area_multiple_lats(self):
        lats, lons = self._as_bounded_coords([[-80, -70], [0, 10], [70, 80]],
                                             [0, 10])
        area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)

        self.assertArrayAllClose(
            area, [[319251845980.763671875], [1228800593851.443115234375],
                   [319251845980.7646484375]])
    def test_area_multiple_lats_and_lons(self):
        lats, lons = self._as_bounded_coords([[-80, -70], [0, 10], [70, 80]],
                                             [[0, 10], [10, 30]])
        area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)

        self.assertArrayAllClose(area, [[3.19251846e+11, 6.38503692e+11],
                                        [1.22880059e+12, 2.45760119e+12],
                                        [3.19251846e+11, 6.38503692e+11]])
    def test_area_multiple_lats(self):
        lats, lons = self._as_bounded_coords([[-80, -70], [0, 10], [70, 80]],
                                             [0, 10])
        area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)

        self.assertArrayAllClose(area, [[319251845980.763671875],
                                        [1228800593851.443115234375],
                                        [319251845980.7646484375]])
Exemple #6
0
 def test_symmetric_32_bit(self):
     lats, lons = self._as_bounded_coords([[-90, -89.375], [89.375, 90]],
                                          [0, 10],
                                          dtype=np.float32)
     area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)
     self.assertArrayAllClose(area, area[::-1])
Exemple #7
0
 def test_area_in_north_with_reversed_lats(self):
     lats, lons = self._as_bounded_coords([10, 0], [0, 10])
     area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)
     self.assertArrayAllClose(area, [[1228800593851.443115234375]])
Exemple #8
0
 def test_area_in_far_south(self):
     lats, lons = self._as_bounded_coords([-80, -70], [0, 10])
     area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)
     self.assertArrayAllClose(area, [[319251845980.763671875]])
Exemple #9
0
 def _assert_error_on_malformed_bounds(self, lat_bnds, lon_bnds):
     with self.assertRaisesRegex(ValueError,
                                 r"Bounds must be \[n,2\] array"):
         _quadrant_area(np.array(lat_bnds), np.array(lon_bnds), 1.0)
Exemple #10
0
 def test_area_in_north_with_reversed_lats(self):
     lats, lons = self._as_bounded_coords([10, 0], [0, 10])
     area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)
     self.assertArrayAllClose(area, [[1228800593851.443115234375]])
Exemple #11
0
 def test_area_in_far_south(self):
     lats, lons = self._as_bounded_coords([-80, -70], [0, 10])
     area = _quadrant_area(lats, lons, DEFAULT_SPHERICAL_EARTH_RADIUS)
     self.assertArrayAllClose(area, [[319251845980.763671875]])
Exemple #12
0
 def _assert_error_on_malformed_bounds(self, lat_bnds, lon_bnds):
     with self.assertRaisesRegexp(ValueError,
                                  'Bounds must be \[n,2\] array'):
         _quadrant_area(np.array(lat_bnds),
                        np.array(lon_bnds),
                        1.)