Beispiel #1
0
    def test_bandwidth(self):
        DV = DirectionalVariogram(self.c, self.v, bandwidth=12, normalize=True)

        for x, y in zip([
                DV.describe()[name]
                for name in ("normalized_effective_range", "normalized_sill",
                             "normalized_nugget")
        ], [435.733, 2715.865, 0]):
            self.assertAlmostEqual(x, y, places=3)
Beispiel #2
0
    def test_binning_change_nlags(self):
        DV = DirectionalVariogram(self.c, self.v, n_lags=5)

        self.assertEqual(DV.n_lags, 5)

        # go through the n_lags chaning procedure
        DV.bin_func = 'scott'

        # with scott, there are 6 classes now
        self.assertEqual(DV.n_lags, 6)
Beispiel #3
0
    def test_standard_settings(self):
        DV = DirectionalVariogram(self.c, self.v, normalize=True)

        assert_array_almost_equal(DV.describe()["normalized_effective_range"],
                                  436.,
                                  decimal=0)
        assert_array_almost_equal(DV.describe()["normalized_sill"],
                                  2706.,
                                  decimal=0)
        assert_array_almost_equal(DV.describe()["normalized_nugget"],
                                  0.,
                                  decimal=0)
Beispiel #4
0
    def test_azimuth(self):
        DV = DirectionalVariogram(self.c, self.v, azimuth=-45, normalize=True)

        assert_array_almost_equal(DV.describe()["normalized_effective_range"],
                                  23.438,
                                  decimal=3)
        assert_array_almost_equal(DV.describe()["normalized_sill"],
                                  219.406,
                                  decimal=3)
        assert_array_almost_equal(DV.describe()["normalized_nugget"],
                                  0.,
                                  decimal=3)
Beispiel #5
0
    def test_tolerance(self):
        DV = DirectionalVariogram(self.c, self.v, tolerance=15, normalize=True)

        assert_array_almost_equal(DV.describe()["normalized_effective_range"],
                                  435.7,
                                  decimal=1)
        assert_array_almost_equal(DV.describe()["normalized_sill"],
                                  2722.1,
                                  decimal=1)
        assert_array_almost_equal(DV.describe()["normalized_nugget"],
                                  0.,
                                  decimal=1)
Beispiel #6
0
 def test_invalid_model_type(self):
     with self.assertRaises(ValueError) as e:
         DirectionalVariogram(self.c, self.v, directional_model=5)
         self.assertEqual(
             str(e), 'The directional model has to be identified by a '
             'model name, or it has to be the search area '
             'itself')
Beispiel #7
0
 def test_invalid_model(self):
     with self.assertRaises(ValueError) as e:
         DirectionalVariogram(self.c, self.v, directional_model='NotAModel')
         self.assertEqual(
             str(e),
             'NotAModel is not a valid model.'
         )
Beispiel #8
0
 def test_invalid_azimuth(self):
     with self.assertRaises(ValueError) as e:
         DirectionalVariogram(self.c, self.v, azimuth=360)
         self.assertEqual(
             str(e),
             'The azimuth is an angle in degree and has '
             'to meet -180 <= angle <= 180'
         )
Beispiel #9
0
 def test_invalid_tolerance(self):
     with self.assertRaises(ValueError) as e:
         DirectionalVariogram(self.c, self.v, tolerance=-1)
         self.assertEqual(
             str(e),
             'The tolerance is an angle in degree and has to '
             'meet 0 <= angle <= 360'
         )
Beispiel #10
0
    def test_bin_func(self):
        DV = DirectionalVariogram(self.c, self.v, n_lags=4)
        V = Variogram(self.c, self.v, n_lags=4)

        for x, y in zip(DV.bins, V.bins):
            self.assertNotEqual(x, y)

        assert_array_almost_equal(np.array([12.3, 24.7, 37., 49.4]),
                                  DV.bins,
                                  decimal=1)
Beispiel #11
0
def dirVar(coords, response, azi, tolerance=15, maxlag=200, n_lags=20):
    time_ = TIME.time()
    print("Fitting Variogram for Azimuth {}\n".format(azi))
    DV = DirectionalVariogram(coords,
                              response,
                              azimuth=azi,
                              tolerance=tolerance,
                              maxlag=maxlag,
                              n_lags=n_lags,
                              fit_method='lm')
    print("Fit Time: {} Minutes".format((TIME.time() - time_) / 60))
    return DV
Beispiel #12
0
    def getRange(self, mat):
        # fits an anisotropic variogram model and returns the effective range for a given azimuth
        mat = np.squeeze(mat)

        m, n = mat.shape
        coords = []
        for i in range(m):
            for j in range(n):
                coords.append((i, j))
        coords = np.array(coords)
        response = np.ndarray.flatten(mat)
        azi_r = []
        for azi in self.azis:
            DV = DirectionalVariogram(coords,
                                      response,
                                      azimuth=45,
                                      tolerance=15,
                                      maxlag=int(m / 2),
                                      n_lags=int(m / 10) + 1)
            azi_r.append(DV.cof[0])

        return azi_r
    def test_standard_settings(self):
        DV = DirectionalVariogram(self.c, self.v, normalize=True)

        assert_array_almost_equal(DV.parameters, [436., 2706., 0], decimal=0)
    def test_tolerance(self):
        DV = DirectionalVariogram(self.c, self.v, tolerance=15, normalize=True)

        assert_array_almost_equal(DV.parameters, [435.7, 2722.1, 0], decimal=1)
Beispiel #15
0
    def test_standard_settings(self):
        DV = DirectionalVariogram(self.c, self.v, normalize=True)

        for x, y in zip(DV.parameters, [407.467, 2138.098, 0]):
            self.assertAlmostEqual(x, y, places=0)
Beispiel #16
0
    def test_azimuth(self):
        DV = DirectionalVariogram(self.c, self.v, azimuth=-45, normalize=True)

        for x, y in zip(DV.parameters, [27.288, 131.644, 0]):
            self.assertAlmostEqual(x, y, places=3)
Beispiel #17
0
    def test_tolerance(self):
        DV = DirectionalVariogram(self.c, self.v, tolerance=15, normalize=True)

        for x, y in zip(DV.parameters, [26.342, 1880.015, 0]):
            self.assertAlmostEqual(x, y, places=3)
Beispiel #18
0
    def test_bandwidth(self):
        DV = DirectionalVariogram(self.c, self.v, bandwidth=12, normalize=True)

        for x, y in zip(DV.parameters, [435.733, 2715.865, 0]):
            self.assertAlmostEqual(x, y, places=3)
    def test_azimuth(self):
        DV = DirectionalVariogram(self.c, self.v, azimuth=-45, normalize=True)

        assert_array_almost_equal(DV.parameters, [23.438, 219.406, 0],
                                  decimal=3)