Comments (8)
PyKrige doesn't use search parameters in the same way that Surfer does; by default all points in the dataset are used to solve the kriging system. There is an option to specify a number of closest points to use in solving the kriging problem (the 'moving window' capability). You can invoke that by using the n_closest_points
kwarg when calling the execute
method (see the docstrings). We currently don't support the elliptical search window thing that other kriging packages use. (Mainly because no one has requested or worked on that yet, although in my opinion this capability also can cause more trouble than it's worth.)
from pykrige.
Sounds like you would want to use the anisotropy parameters in your problem -- you can specify the angle of anisotropy and the relative scaling between the principle directions in order to essentially define a new internal coordinate system in which the variogram model is the same in all directions. Inside the code, once you specify the anisotropy direction and scaling, the data coordinates are translated into this new coordinate system and then the kriging problem is actually solved in this 'uniform' coordinate system. The point is just to take into account exactly your kind of problem, where things aren't changing in the same way in different directions. Adjusting for anisotropy makes the problem 'homogeneous' in some sense.
You're right, using a uniform search radius or n_closest_points does somewhat ignore this kind of anisotropy. @rth, if we do end up implementing a search radius kwarg (which I think we should do, definitely a nice feature to have), we should be sure to search on the anisotropy-adjusted data, that way it'll be in the 'uniform' coordinate space...
Using an elliptical search window would allow you to do something similar, but I think actually implementing anisotropy explicitly (i.e., in the PyKrige formulation) would be a better bet in your case... If you end up using it on your data, please let us know how it works for you! I've never used the anisotropy parameters myself in any problems, so any input on how it's working would be useful. (Also, if you need help making sense of the anisotropy settings, let us know...)
from pykrige.
So the call to OrdinaryKriging
should look something like this:
OrdinaryKriging(x, y, z, anisotropy_angle=90., anisotropy_scaling=2., variogram_model='linear', variogram_parameters=[1., 0.])
I'd recommend looking at the docstring for the OrdinaryKriging
class as well, just to make sure the way in which the anisotropy is handle is as you'd expect with these values (specifically, the new y direction is multiplied by 2 I think, not the x direction...).
from pykrige.
Also, a good description of Surfer search parameters can be found here and in here, I think (never used it myself).
As @bsmurphy mentioned, the only search parameter we support at the moment is n_closest_points
, though I believe we could add a spherical search radius (which would be simpler than the elliptical one) if that would be useful. What search parameters are you interested in?
from pykrige.
so forgive me here, as i'm not all that familar with the innards of the krigging. but doesn't the search ellipse allow one to make an assumption about the data, ie the data are going to vary in a similar manner. for my case, we use the search window to define the cross shore and along shore widths of beach transect data. where we can make the assumption about the data that the beach profile will vary more in the cross shore direction than it does in the alongshore direction. ie the beach gets deeper faster than it varies moving down the beach. if one uses a 'moving window' or n_closest_points I feel like that would weight them, for lack of a better way to put it, weird? no?
from pykrige.
so i implement the following arguments in addition to the search ellipse in surfer. which I've also included in the initialization on your OK class
anisotropyAngle = 90
anisotropyRatio=2
VariogramSlope=1
from pykrige.
so my notes are two fold: First, If the anisotropy parameters take care of the anisotropy of the data, then what do the search parameters do? are the simply to make the variogram generation more efficient (ie not looking at the whole data set) ?
Secondly, while I've added those, i'm running into constant memory issues when using this interpolation scheme. I've attached the data (and code) for reference.
from pykrige.ok import OrdinaryKriging
import numpy as np
x _grid = np.loadtxt('gridX.txt', delimiter=',', usecols=[0])
y_grid = np.loadtxt('gridY.txt', delimiter=',', usecols=[0])
data_x, data_y, data_z = np.loadtxt('xyzGridparms.txt', delimiter=',', usecols=[0,1,2], unpack=True)
ok = OrdinaryKriging(data_x, data_y, data_z, anisotropy_angle=90,
anisotropy_scaling=2,
variogram_parameters=[1, 0.],
variogram_model='linear')
newBathyGrid, ss = ok.execute('grid', x_grid, y_grid, backend='C', n_closest_points=40)
gridX.txt
gridY.txt
xyzGridparms.txt
from pykrige.
Closing due to inactivity. Feel free to re-open.
from pykrige.
Related Issues (20)
- AttributeError: 'UniversalKriging' object has no attribute 'external_Z_array' HOT 2
- Incompatible with SciPy 1.9.0, AttributeError on scipy.linalg.pinv2 HOT 2
- GSTools 1.4 requirement for PyKrige 1.7
- Bug: Problem with exact_values when ordinary kriging with backend = 'C' HOT 2
- search radius HOT 3
- Bug: pykrige.ok using deprecated function from SciPy 1.7.0 HOT 1
- Excessive memory use creating OrdinaryKriging object (even if not estimating variogram) HOT 1
- Memory Issue with Large Dataset
- How do you save a model once you fit it
- kr and ck are not imported in __init__.py HOT 1
- `x0` is infeasible.
- uk3d.execute prints statement of 'Executing Ordinary Kriging' HOT 1
- The result is very difference with arcmap, and result grid missing maximum value.
- Can variogram start at zero distance?
- Bug variogram_model parameter ? HOT 1
- zero-size array Erro in OrdinaryKriging HOT 1
- Questions about setting the search range for regular kriging
- Kriging with external drift for temperature interpolation using elevation... again
- regression and kriging, rk.py
- Attempt at using pyKrige.ok3d with xarray.apply_ufunc to reduce memory issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pykrige.