Skip to content

Commit

Permalink
Examples: add examples for universal and ext-drift kriging
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Dec 30, 2019
1 parent 81d14e4 commit d44345e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/21_extdrift_kriging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import numpy as np
from gstools import SRF, Gaussian, krige

# condtions
drift_model = Gaussian(dim=1, len_scale=4)
drift = SRF(drift_model, seed=1010)
cond_pos = [0.3, 1.9, 1.1, 3.3, 4.7]
ext_drift = drift(cond_pos)
cond_val = ext_drift * 2 + 1
# resulting grid
gridx = np.linspace(0.0, 15.0, 151)
grid_drift = drift(gridx)
# spatial random field class
model = Gaussian(dim=1, var=2, len_scale=4)
krig = krige.ExtDrift(model, cond_pos, cond_val, ext_drift)
krig(gridx, ext_drift=grid_drift)
ax = krig.plot()
ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions")
ax.plot(gridx, grid_drift, label="drift")
ax.legend()
20 changes: 20 additions & 0 deletions examples/22_universal_kriging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import numpy as np
from gstools import SRF, Gaussian, krige

# condtions
drift_model = Gaussian(dim=1, var=0.1, len_scale=2)
drift = SRF(drift_model, seed=101)
cond_pos = np.linspace(0.1, 8, 10)
cond_val = drift(cond_pos) + cond_pos * 0.1 + 1
# resulting grid
gridx = np.linspace(0.0, 15.0, 151)
drift_field = drift(gridx) + gridx * 0.1 + 1
# spatial random field class
model = Gaussian(dim=1, var=0.1, len_scale=2)
krig = krige.Universal(model, cond_pos, cond_val, "linear")
krig(gridx)
ax = krig.plot()
ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions")
ax.plot(gridx, gridx * 0.1 + 1, label="linear drift")
ax.plot(gridx, drift_field, "--", label="original field")
ax.legend()

0 comments on commit d44345e

Please sign in to comment.