Exemple #1
0
    def test_ExternalDriftKriging_3(self):
        """testing the basic behaviour of the ExternalDriftKriging class
        with missing drift terms"""
        ip = ipol.ExternalDriftKriging(self.src, self.trg, '1.0 Lin(2.0)',
                                       src_drift=None,
                                       trg_drift=None)

        self.assertRaises(ValueError, ip, self.vals)
Exemple #2
0
 def test_nnearest_warning(self):
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         ipol.Idw(self.src, self.trg, nnearest=len(self.src) + 1)
         ipol.OrdinaryKriging(self.src, self.trg, nnearest=len(self.src) + 1)
         ipol.ExternalDriftKriging(self.src, self.trg, nnearest=len(self.src) + 1)
         for item in w:
             assert issubclass(item.category, UserWarning)
             assert "nnearest" in str(item.message)
Exemple #3
0
    def test_ExternalDriftKriging_3(self):
        """testing the basic behaviour of the ExternalDriftKriging class
        with missing drift terms"""
        ip = ipol.ExternalDriftKriging(
            self.src, self.trg, "1.0 Lin(2.0)", src_drift=None, trg_drift=None
        )

        with pytest.raises(ValueError):
            ip(self.vals)
Exemple #4
0
 def test_MissingErrors(self):
     with pytest.raises(ipol.MissingSourcesError):
         ipol.Nearest(np.array([]), self.trg)
     with pytest.raises(ipol.MissingTargetsError):
         ipol.Nearest(self.src, np.array([]))
     with pytest.raises(ipol.MissingSourcesError):
         ipol.Idw(np.array([]), self.trg)
     with pytest.raises(ipol.MissingTargetsError):
         ipol.Idw(self.src, np.array([]))
     with pytest.raises(ipol.MissingSourcesError):
         ipol.Linear(np.array([]), self.trg)
     with pytest.raises(ipol.MissingTargetsError):
         ipol.Linear(self.src, np.array([]))
     with pytest.raises(ipol.MissingSourcesError):
         ipol.OrdinaryKriging(np.array([]), self.trg)
     with pytest.raises(ipol.MissingTargetsError):
         ipol.OrdinaryKriging(self.src, np.array([]))
     with pytest.raises(ipol.MissingSourcesError):
         ipol.ExternalDriftKriging(np.array([]), self.trg)
     with pytest.raises(ipol.MissingTargetsError):
         ipol.ExternalDriftKriging(self.src, np.array([]))
Exemple #5
0
    def test_ExternalDriftKriging_1(self):
        """testing the basic behaviour of the ExternalDriftKriging class
        with drift terms constant over multiple fields"""

        ip = ipol.ExternalDriftKriging(self.src, self.trg, '1.0 Lin(2.0)',
                                       src_drift=self.src_d,
                                       trg_drift=self.trg_d)

        res = ip(self.vals)
        self.assertTrue(np.all(res == np.array([[1., 2., 3.],
                                                [3., 2., 1.],
                                                [5., 2., -1.],
                                                [7., 2., -3.]])))
    def test_ExternalDriftKriging_1(self):
        """testing the basic behaviour of the ExternalDriftKriging class
        with drift terms constant over multiple fields"""

        ip = ipol.ExternalDriftKriging(self.src, self.trg, '1.0 Lin(2.0)',
                                       src_drift=self.src_d,
                                       trg_drift=self.trg_d)

        # input more than one dataset
        res = ip(self.vals)
        self.assertTrue(np.all(res == np.array([[1., 2., 3.],
                                                [3., 2., 1.],
                                                [5., 2., -1.],
                                                [7., 2., -3.]])))
        # input only one flat array
        res = ip(self.vals[:, 2])
        self.assertTrue(np.allclose(res, np.array([3., 1., -1., -3.])))
Exemple #7
0
    def test_ExternalDriftKriging_2(self):
        """testing the basic behaviour of the ExternalDriftKriging class
        with drift terms varying over multiple fields"""
        src_d = np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0]])
        trg_d = np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [2.0, 2.0, 2.0],
                          [3.0, 3.0, 3.0]])

        ip = ipol.ExternalDriftKriging(self.src,
                                       self.trg,
                                       "1.0 Lin(2.0)",
                                       src_drift=src_d,
                                       trg_drift=trg_d)

        res = ip(self.vals)
        assert np.all(res == np.array([[1.0, 2.0, 3.0], [3.0, 2.0, 1.0],
                                       [5.0, 2.0, -1.0], [7.0, 2.0, -3.0]]))
        # input only one flat array
        res = ip(self.vals[:, 2], src_drift=src_d[:, 2], trg_drift=trg_d[:, 2])
        assert np.allclose(res, np.array([3.0, 1.0, -1.0, -3.0]))