From 81d14e4db60df04e74f88d99b0b329ed892f262a Mon Sep 17 00:00:00 2001 From: MuellerSeb Date: Mon, 30 Dec 2019 01:49:58 +0100 Subject: [PATCH] Krige: bugfixing Universal and ExtDrift --- gstools/krige/base.py | 1 + gstools/krige/methods.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gstools/krige/base.py b/gstools/krige/base.py index f33cd28b..781b9f05 100755 --- a/gstools/krige/base.py +++ b/gstools/krige/base.py @@ -157,6 +157,7 @@ def pre_ext_drift(self, point_no, ext_drift=None, set_cond=False): if len(ext_drift.shape) > 2 or ext_drift.shape[1] != point_no: raise ValueError("Krige: wrong number of cond. drifts.") return ext_drift + ext_drift = np.array(ext_drift, dtype=np.double, ndmin=2) ext_shape = np.shape(ext_drift) shape = (self.drift_no, point_no) if ext_shape[0] != self.drift_no: diff --git a/gstools/krige/methods.py b/gstools/krige/methods.py index c77b199e..41db3b83 100644 --- a/gstools/krige/methods.py +++ b/gstools/krige/methods.py @@ -162,17 +162,17 @@ def get_krige_mat(self): """Update the kriging model settings.""" size = self.cond_no + int(self.unbiased) + self.drift_no res = np.empty((size, size), dtype=np.double) - res[:size, :size] = self.model.vario_nugget( + res[: self.cond_no, : self.cond_no] = self.model.vario_nugget( self.get_dists(self.krige_pos) ) if self.unbiased: - res[size, :] = 1 - res[:, size] = 1 - res[size, size] = 0 + res[self.cond_no, : self.cond_no] = 1 + res[: self.cond_no, self.cond_no] = 1 for i, f in enumerate(self.drift_functions): drift_tmp = f(*self.cond_pos) res[-self.drift_no + i, : self.cond_no] = drift_tmp res[: self.cond_no, -self.drift_no + i] = drift_tmp + res[self.cond_no :, self.cond_no :] = 0 return inv(res) def get_krige_vecs(self, pos, chunk_slice=(0, None), ext_drift=None): @@ -186,7 +186,7 @@ def get_krige_vecs(self, pos, chunk_slice=(0, None), ext_drift=None): ) if self.unbiased: res[self.cond_no, :] = 1 - chunk_pos = pos[: self.model.dim] + chunk_pos = list(pos[: self.model.dim]) for i in range(self.model.dim): chunk_pos[i] = chunk_pos[i][slice(*chunk_slice)] for i, f in enumerate(self.drift_functions): @@ -228,15 +228,15 @@ def get_krige_mat(self): """Update the kriging model settings.""" size = self.cond_no + int(self.unbiased) + self.drift_no res = np.empty((size, size), dtype=np.double) - res[:size, :size] = self.model.vario_nugget( + res[: self.cond_no, : self.cond_no] = self.model.vario_nugget( self.get_dists(self.krige_pos) ) if self.unbiased: - res[size, :] = 1 - res[:, size] = 1 - res[size, size] = 0 + res[self.cond_no, : self.cond_no] = 1 + res[: self.cond_no, self.cond_no] = 1 res[-self.drift_no :, : self.cond_no] = self.krige_ext_drift res[: self.cond_no, -self.drift_no :] = self.krige_ext_drift.T + res[self.cond_no :, self.cond_no :] = 0 return inv(res) def get_krige_vecs(self, pos, chunk_slice=(0, None), ext_drift=None): @@ -250,7 +250,7 @@ def get_krige_vecs(self, pos, chunk_slice=(0, None), ext_drift=None): ) if self.unbiased: res[self.cond_no, :] = 1 - res[-self.drift_no :, :] = ext_drift[: slice(*chunk_slice)] + res[-self.drift_no :, :] = ext_drift[:, slice(*chunk_slice)] return res @property