Пример #1
0
    def test_get_coordinate_at_distance(self):
        bins = np.arange(10)
        G = Geostatistic(self.x, lags=bins)

        with self.assertRaises(ValueError):  # missing center
            lon, lat = G.get_coordinates_at_distance(2.5, dist_threshold=1.)
        G.set_center_position(5., -20.)
        lon, lat = G.get_coordinates_at_distance(2.5, dist_threshold=1.)
Пример #2
0
    def test_init(self):
        with self.assertRaises(ValueError):  # missing range bins
            G = Geostatistic(self.x)

        # 3D is invalid
        y = self.x.copy()
        y.data = np.random.random((10, 20, 30))
        with self.assertRaises(ValueError):  # missing range bins
            G = Geostatistic(self.x, lags=np.random.random(10))

        y = self.x.copy()  # missing 3D
        y.data = np.random.random((10, 20, 30))
        with self.assertRaises(ValueError):
            G = Geostatistic(self.x)

        bins = np.random.random(10)
        with self.assertRaises(ValueError):
            G = Geostatistic(self.x, lags=bins)
        bins = np.arange(10)
        G = Geostatistic(self.x, lags=bins)
Пример #3
0
    def test_get_coordinate_at_distance(self):
        bins = np.arange(10)
        G = Geostatistic(self.x, lags=bins)

        with self.assertRaises(ValueError):  # missing center
            lon, lat = G.get_coordinates_at_distance(2.5, dist_threshold=1.)
        G.set_center_position(5., -20.)
        lon, lat = G.get_coordinates_at_distance(2.5, dist_threshold=1.)
Пример #4
0
    def test_center_pos(self):
        bins = np.arange(10)
        G = Geostatistic(self.x, lags=bins)
        # forgot to set center
        with self.assertRaises(ValueError):
            G._get_center_pos()

        G.set_center_position(-10., -60.)
        i_lat, i_lon = G._get_center_pos()
        self.assertEqual(i_lat, 0)
        self.assertEqual(i_lon, 0)

        G.set_center_position(9., 48.)
        i_lat, i_lon = G._get_center_pos()
        self.assertEqual(i_lat, 54)
        self.assertEqual(i_lon, 19)

        G.set_center_position(-10.1, 48.)
        i_lat, i_lon = G._get_center_pos()
        self.assertEqual(i_lat, 54)
        self.assertEqual(i_lon, 0)
Пример #5
0
 def test_set_center(self):
     bins = np.arange(10)
     G = Geostatistic(self.x, lags=bins)
     G.set_center_position(5., -20.)
     self.assertEqual(G.lon_center, 5.)
     self.assertEqual(G.lat_center, -20.)
Пример #6
0
 def test_percentiles(self):
     bins = np.arange(10)
     G = Geostatistic(self.x, lags=bins)
     G.set_center_position(5., -20.)
     p = [0.05, 0.1, 0.5]
     G.plot_percentiles(p, ax=None, logy=False, ref_lags=None)
Пример #7
0
 def test_plot(self):
     bins = np.arange(3) / 6.
     G = Geostatistic(self.x, lags=bins)
     G.set_center_position(0., 0.)
     G.plot_semivariogram()
Пример #8
0
 def test_invalid_geometry(self):
     x = self.x
     x.data = np.random.random((5, 4, 3))
     with self.assertRaises(ValueError):
         G = Geostatistic(x)
Пример #9
0
    def test_center_pos(self):
        bins = np.arange(10)
        G = Geostatistic(self.x, range_bins=bins)
        # forgot to set center
        with self.assertRaises(ValueError):
            G._get_center_pos()

        G.set_center_position(-10., -60.)
        i_lat, i_lon = G._get_center_pos()
        self.assertEqual(i_lat, 0)
        self.assertEqual(i_lon, 0)

        G.set_center_position(9., 48.)
        i_lat, i_lon = G._get_center_pos()
        self.assertEqual(i_lat, 54)
        self.assertEqual(i_lon, 19)

        G.set_center_position(-10.1, 48.)
        i_lat, i_lon = G._get_center_pos()
        self.assertEqual(i_lat, 54)
        self.assertEqual(i_lon, 0)
Пример #10
0
 def test_set_center(self):
     bins = np.arange(10)
     G = Geostatistic(self.x, range_bins=bins)
     G.set_center_position(5., -20.)
     self.assertEqual(G.lon_center, 5.)
     self.assertEqual(G.lat_center, -20.)
Пример #11
0
 def test_percentiles(self):
     bins = np.arange(10)
     G = Geostatistic(self.x, lags=bins)
     G.set_center_position(5., -20.)
     p = [0.05, 0.1, 0.5]
     G.plot_percentiles(p, ax=None, logy=False, ref_lags=None)
Пример #12
0
 def test_plot(self):
     bins = np.arange(3) / 6.
     G = Geostatistic(self.x, lags=bins)
     G.set_center_position(0., 0.)
     G.plot_semivariogram()