Skip to content

Commit

Permalink
Krige: bugfixing Universal and ExtDrift
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Dec 30, 2019
1 parent e41214b commit 81d14e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions gstools/krige/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 10 additions & 10 deletions gstools/krige/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 81d14e4

Please sign in to comment.