-
Notifications
You must be signed in to change notification settings - Fork 80
Krige unification #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
122f9c5
Krige: unify kriging; add exact option / measurement errors / pseudo-…
MuellerSeb 75dc861
Krige: update methods to use new krige base class
MuellerSeb 0efa040
SRF: update conditioning to new krige base class
MuellerSeb 9997063
Krige: add Krige class to __init__ in krige
MuellerSeb ecc2060
Tools: add confidence_scaling function
MuellerSeb 7f20a9e
Examples: add confidece interval to conditioned ensemble
MuellerSeb a87d987
field.base: allways use np.double as dytpe for pos tuple conversion
MuellerSeb 6565d55
krige: add selector for pseudo-inverse method
MuellerSeb abec5ee
examples: update kriging examples
MuellerSeb 301f2a4
krige test: test pseudo-inverse to result in mean value
MuellerSeb 01f9392
krige: remove the restriction, that the measurement error needs to be…
MuellerSeb 5ccf45a
tests: test kriging with measurement errors
MuellerSeb 3ba2f2e
examples: update examples for kriging with measurement errors
MuellerSeb d14b10d
krige: modify input parameter list for kriging methods to incorporate…
MuellerSeb a3f8287
krige: add possibility to pass callable to calculate (pseudo)inverse
MuellerSeb 697f959
krige: apply trend_function instantly when set
MuellerSeb 81a5b39
examples: update kriging examples
MuellerSeb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,55 @@ | ||
| r""" | ||
| Incorporating measurement errors | ||
| -------------------------------- | ||
|
|
||
| To incorporate the nugget effect and/or given measurement errors, | ||
| one can set `exact` to `False` and provide either individual measurement errors | ||
| for each point or set the nugget as a constant measurement error everywhere. | ||
|
|
||
| In the following we will show the influence of the nugget and | ||
| measurement errors. | ||
| """ | ||
|
|
||
| import numpy as np | ||
| import gstools as gs | ||
|
|
||
| # condtions | ||
| cond_pos = [0.3, 1.1, 1.9, 3.3, 4.7] | ||
| cond_val = [0.47, 0.74, 0.56, 1.47, 1.74] | ||
| cond_err = [0.01, 0.0, 0.1, 0.05, 0] | ||
| # resulting grid | ||
| gridx = np.linspace(0.0, 15.0, 151) | ||
| # spatial random field class | ||
| model = gs.Gaussian(dim=1, var=0.9, len_scale=1, nugget=0.1) | ||
|
|
||
| ############################################################################### | ||
| # Here we will use Simple kriging (`unbiased=False`) to interpolate the given | ||
| # conditions. | ||
|
|
||
| krig = gs.krige.Krige( | ||
| model=model, | ||
| cond_pos=cond_pos, | ||
| cond_val=cond_val, | ||
| mean=1, | ||
| unbiased=False, | ||
| exact=False, | ||
| cond_err=cond_err, | ||
| ) | ||
| krig(gridx) | ||
|
|
||
| ############################################################################### | ||
| # Let's plot the data. You can see, that the estimated values differ more from | ||
| # the input, when the given measurement errors get bigger. | ||
| # In addition we plot the standard deviation. | ||
|
|
||
| ax = krig.plot() | ||
| ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") | ||
| ax.fill_between( | ||
| gridx, | ||
| # plus/minus standard deviation (70 percent confidence interval) | ||
| krig.field - np.sqrt(krig.krige_var), | ||
| krig.field + np.sqrt(krig.krige_var), | ||
| alpha=0.3, | ||
| label="Standard deviation", | ||
| ) | ||
| ax.legend() |
This file contains hidden or 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,38 @@ | ||
| r""" | ||
| Redundant data and pseudo-inverse | ||
| --------------------------------- | ||
|
|
||
| It can happen, that the kriging system gets numerically unstable. | ||
| One reason could be, that the input data contains redundant conditioning points | ||
| that hold different values. | ||
|
|
||
| To smoothly deal with such situations, you can use the pseudo | ||
| inverse for the kriging matrix, which is enabled by default. | ||
|
|
||
| This will result in the average value for the redundant data. | ||
|
|
||
| Example | ||
| ^^^^^^^ | ||
|
|
||
| In the following we have two different values at the same location. | ||
| The resulting kriging field will hold the average at this point. | ||
| """ | ||
| import numpy as np | ||
| from gstools import Gaussian, krige | ||
|
|
||
| # condtions | ||
| cond_pos = [0.3, 1.9, 1.1, 3.3, 1.1] | ||
| cond_val = [0.47, 0.56, 0.74, 1.47, 1.14] | ||
| # resulting grid | ||
| gridx = np.linspace(0.0, 8.0, 81) | ||
| # spatial random field class | ||
| model = Gaussian(dim=1, var=0.5, len_scale=1) | ||
|
|
||
| ############################################################################### | ||
| krig = krige.Ordinary(model, cond_pos=cond_pos, cond_val=cond_val) | ||
| krig(gridx) | ||
|
|
||
| ############################################################################### | ||
| ax = krig.plot() | ||
| ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") | ||
| ax.legend() |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.