-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from GeoStat-Framework/finalize_151
update Changelog, add pseudo-inv option to RK, update examples in documentation
- Loading branch information
Showing
14 changed files
with
284 additions
and
208 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 |
---|---|---|
|
@@ -121,3 +121,4 @@ pykrige/_version.py | |
*.vtr | ||
examples/meuse_example_data/* | ||
*.ipynb_checkpoints/* | ||
examples/output.asc |
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
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
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,58 @@ | ||
""" | ||
Ordinary Kriging Example | ||
======================== | ||
First we will create a 2D dataset together with the associated x, y grids. | ||
""" | ||
|
||
import numpy as np | ||
import pykrige.kriging_tools as kt | ||
from pykrige.ok import OrdinaryKriging | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
data = np.array( | ||
[ | ||
[0.3, 1.2, 0.47], | ||
[1.9, 0.6, 0.56], | ||
[1.1, 3.2, 0.74], | ||
[3.3, 4.4, 1.47], | ||
[4.7, 3.8, 1.74], | ||
] | ||
) | ||
|
||
gridx = np.arange(0.0, 5.5, 0.5) | ||
gridy = np.arange(0.0, 5.5, 0.5) | ||
|
||
############################################################################### | ||
# Create the ordinary kriging object. Required inputs are the X-coordinates of | ||
# the data points, the Y-coordinates of the data points, and the Z-values of the | ||
# data points. If no variogram model is specified, defaults to a linear variogram | ||
# model. If no variogram model parameters are specified, then the code automatically | ||
# calculates the parameters by fitting the variogram model to the binned | ||
# experimental semivariogram. The verbose kwarg controls code talk-back, and | ||
# the enable_plotting kwarg controls the display of the semivariogram. | ||
|
||
OK = OrdinaryKriging( | ||
data[:, 0], | ||
data[:, 1], | ||
data[:, 2], | ||
variogram_model="linear", | ||
verbose=False, | ||
enable_plotting=False, | ||
) | ||
|
||
############################################################################### | ||
# Creates the kriged grid and the variance grid. Allows for kriging on a rectangular | ||
# grid of points, on a masked rectangular grid of points, or with arbitrary points. | ||
# (See OrdinaryKriging.__doc__ for more information.) | ||
|
||
z, ss = OK.execute("grid", gridx, gridy) | ||
|
||
############################################################################### | ||
# Writes the kriged grid to an ASCII grid file and plot it. | ||
|
||
kt.write_asc_grid(gridx, gridy, z, filename="output.asc") | ||
plt.imshow(z) | ||
plt.show() |
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,50 @@ | ||
""" | ||
Universal Kriging Example | ||
========================= | ||
In this example we apply a regional linear trend to the kriging system. | ||
""" | ||
|
||
from pykrige.uk import UniversalKriging | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
data = np.array( | ||
[ | ||
[0.3, 1.2, 0.47], | ||
[1.9, 0.6, 0.56], | ||
[1.1, 3.2, 0.74], | ||
[3.3, 4.4, 1.47], | ||
[4.7, 3.8, 1.74], | ||
] | ||
) | ||
|
||
gridx = np.arange(0.0, 5.5, 0.5) | ||
gridy = np.arange(0.0, 5.5, 0.5) | ||
|
||
############################################################################### | ||
# Create the universal kriging object. Required inputs are the X-coordinates of | ||
# the data points, the Y-coordinates of the data points, and the Z-values of the | ||
# data points. Variogram is handled as in the ordinary kriging case. | ||
# drift_terms is a list of the drift terms to include; currently supported terms | ||
# are 'regional_linear', 'point_log', and 'external_Z'. Refer to | ||
# UniversalKriging.__doc__ for more information. | ||
|
||
UK = UniversalKriging( | ||
data[:, 0], | ||
data[:, 1], | ||
data[:, 2], | ||
variogram_model="linear", | ||
drift_terms=["regional_linear"], | ||
) | ||
|
||
############################################################################### | ||
# Creates the kriged grid and the variance grid. Allows for kriging on a rectangular | ||
# grid of points, on a masked rectangular grid of points, or with arbitrary points. | ||
# (See UniversalKriging.__doc__ for more information.) | ||
|
||
z, ss = UK.execute("grid", gridx, gridy) | ||
plt.imshow(z) | ||
plt.show() |
Oops, something went wrong.