-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples: add examples for universal and ext-drift kriging
- Loading branch information
1 parent
81d14e4
commit d44345e
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |