From d44345ee28e270f7be32b32616ea2c5f1984c4b1 Mon Sep 17 00:00:00 2001 From: MuellerSeb Date: Mon, 30 Dec 2019 01:50:25 +0100 Subject: [PATCH] Examples: add examples for universal and ext-drift kriging --- examples/21_extdrift_kriging.py | 20 ++++++++++++++++++++ examples/22_universal_kriging.py | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 examples/21_extdrift_kriging.py create mode 100755 examples/22_universal_kriging.py diff --git a/examples/21_extdrift_kriging.py b/examples/21_extdrift_kriging.py new file mode 100755 index 00000000..f297eb33 --- /dev/null +++ b/examples/21_extdrift_kriging.py @@ -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() diff --git a/examples/22_universal_kriging.py b/examples/22_universal_kriging.py new file mode 100755 index 00000000..25222a24 --- /dev/null +++ b/examples/22_universal_kriging.py @@ -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()