GeostatTools: A geostatistical toolbox.
Project description
Welcome to GSTools
Purpose
GeoStatTools provides geostatistical tools for random field generation and variogram estimation based on many readily provided and even user-defined covariance models.
Installation
The package can be installed via pip. On Windows you can install WinPython to get Python and pip running.
pip install gstools
Documentation for GSTools
You can find the documentation under geostat-framework.readthedocs.io.
Tutorials and Examples
The documentation also includes some tutorials, showing the most important use cases of GSTools, which are
Some more examples are provided in the examples folder.
Spatial Random Field Generation
The core of this library is the generation of spatial random fields. These fields are generated using the randomisation method, described by Heße et al. 2014.
Examples
Gaussian Covariance Model
This is an example of how to generate a 2 dimensional spatial random field with a gaussian covariance model.
from gstools import SRF, Gaussian
import matplotlib.pyplot as plt
# structured field with a size 100x100 and a grid-size of 1x1
x = y = range(100)
model = Gaussian(dim=2, var=1, len_scale=10)
srf = SRF(model)
field = srf((x, y), mesh_type='structured')
plt.imshow(field)
plt.show()
Truncated Power Law Model
GSTools also implements truncated power law variograms, which can be represented as a superposition of scale dependant modes in form of standard variograms, which are truncated by an upper lengthscale lu.
This example shows the truncated power law based on the stable model and is given by
which gives Gaussian modes for alpha=2
or exponential modes for alpha=1
This results in:
import numpy as np
import matplotlib.pyplot as plt
from gstools import SRF, TPLStable
x = y = np.linspace(0, 100, 100)
model = TPLStable(
dim=2, # spatial dimension
var=1, # variance (C is calculated internally, so that the variance is actually 1)
len_low=0, # lower truncation of the power law
len_scale=10, # length scale (a.k.a. range), len_up = len_low + len_scale
nugget=0.1, # nugget
anis=0.5, # anisotropy between main direction and transversal ones
angles=np.pi/4, # rotation angles
alpha=1.5, # shape parameter from the stable model
hurst=0.7, # hurst coefficient from the power law
)
srf = SRF(model, mean=1, mode_no=1000, seed=19970221, verbose=True)
field = srf((x, y), mesh_type='structured', force_moments=True)
# show the field in xy coordinates
plt.imshow(field.T, origin="lower")
plt.show()
Estimating and fitting variograms
The spatial structure of a field can be analyzed with the variogram, which contains the same information as the covariance function.
All covariance models can be used to fit given variogram data by a simple interface.
Example
This is an example of how to estimate the variogram of a 2 dimensional unstructured field and estimate the parameters of the covariance model again.
import numpy as np
from gstools import SRF, Exponential, Stable, vario_estimate_unstructured
from gstools.covmodel.plot import plot_variogram
import matplotlib.pyplot as plt
# generate a synthetic field with an exponential model
x = np.random.RandomState(19970221).rand(1000) * 100.
y = np.random.RandomState(20011012).rand(1000) * 100.
model = Exponential(dim=2, var=2, len_scale=8)
srf = SRF(model, mean=0, seed=19970221)
field = srf((x, y))
# estimate the variogram of the field with 40 bins
bins = np.arange(40)
bin_center, gamma = vario_estimate_unstructured((x, y), field, bins)
plt.plot(bin_center, gamma)
# fit the variogram with a stable model. (no nugget fitted)
fit_model = Stable(dim=2)
fit_model.fit_variogram(bin_center, gamma, nugget=False)
plot_variogram(fit_model, x_max=40)
# output
print(fit_model)
plt.show()
Which gives:
Stable(dim=2, var=1.92, len_scale=8.15, nugget=0.0, anis=[1.], angles=[0.], alpha=1.05)
User defined covariance models
One of the core-features of GSTools is the powerfull CovModel class, which allows to easy define covariance models by the user.
Example
Here we reimplement the Gaussian covariance model by defining just the correlation function:
from gstools import CovModel
import numpy as np
# use CovModel as the base-class
class Gau(CovModel):
def correlation(self, r):
return np.exp(-(r/self.len_scale)**2)
And that's it! With Gau
you now have a fully working covariance model,
which you could use for field generation or variogram fitting as shown above.
Have a look at the documentation for further information on incorporating optional parameters and optimizations.
VTK Export
After you have created a field, you may want to save it to file, so we provide a handy VTK export routine:
from gstools import SRF, Gaussian, vtk_export
x = y = range(100)
model = Gaussian(dim=2, var=1, len_scale=10)
srf = SRF(model)
field = srf((x, y), mesh_type='structured')
vtk_export("field", (x, y), field, mesh_type='structured')
Which gives a RectilinearGrid VTK file field.vtr
.
Requirements:
Contact
You can contact us via info@geostat-framework.org.
License
GPL © 2018-2019
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file gstools-1.0.0.tar.gz
.
File metadata
- Download URL: gstools-1.0.0.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c3a4f7d6073bcdb8d209492f57e19d65725b15e7a1cbebb077b1dfa37e8352a |
|
MD5 | c0e0c143152bf657b0bc1d97baab4632 |
|
BLAKE2b-256 | d2593962d3e34b74e6eff2582fa2ad43acb7135ec6220a87c7e9453046f78083 |
Provenance
File details
Details for the file gstools-1.0.0-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: gstools-1.0.0-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 271.9 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b35a605d6d8dd2fcf6586a84df06e96191d5a2aef7ec1d92f6e772a04380b4af |
|
MD5 | 9bdb04590f2d21ec5374ccb52dc81e4e |
|
BLAKE2b-256 | 2016edfc305e70b65263fb16e8a033087e582fbf25a70f0314d074d7e28fbb0a |
Provenance
File details
Details for the file gstools-1.0.0-cp36-cp36m-win32.whl
.
File metadata
- Download URL: gstools-1.0.0-cp36-cp36m-win32.whl
- Upload date:
- Size: 254.3 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d433998102bf4d7e979fb54dc4dc29798de482f5d267d4e6ebdd5a5967836be9 |
|
MD5 | 840817c875dd246e8d8f4e402abd4ae6 |
|
BLAKE2b-256 | 0114e9eb0bf5f7f7d6ee26602ef06aaf6c4c817446f7b282801249a10a600eb3 |
Provenance
File details
Details for the file gstools-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: gstools-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 538.2 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f47e823ed3f7ecd601945e68e74fa4632aaa9f0d303de7ae10ea165bcb5373c1 |
|
MD5 | 7a6cb010e5e1078e45558867a7562fb2 |
|
BLAKE2b-256 | 13e255111757a941b0bda1681df8f6256adc3608c44dfae58cad8cb41c105f3b |
Provenance
File details
Details for the file gstools-1.0.0-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: gstools-1.0.0-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 512.4 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8be40d76d3a6e69516648bced021a2b5eee9819740524150d0c48ec8ffcad438 |
|
MD5 | 2431e63683353e1e7c6850f531d9b87d |
|
BLAKE2b-256 | c354066e4f9c8c5fd9e7d2c2d49df5a060cfc574d325c895ca89580e97b668bf |
Provenance
File details
Details for the file gstools-1.0.0-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: gstools-1.0.0-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 368.2 kB
- Tags: CPython 3.6m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afff25837de087aa11b81c5113f329d70a80fd67ef69c2c0d744f9e21a5a978b |
|
MD5 | 8e6545258b98a81296911e856639c13d |
|
BLAKE2b-256 | 76922f9d719f22a6f3bb1cc78103a9be9b20c7937f6a7e13af4146d12717ad19 |
Provenance
File details
Details for the file gstools-1.0.0-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: gstools-1.0.0-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 269.2 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02772188c09a82a71df3ffb57e1dba8d5f98b430a6eaee667b96c96ef87607f3 |
|
MD5 | c49ed4c5da397c3d5521eb1b6a58bf5c |
|
BLAKE2b-256 | 0bf77b02f2aee254e624a331a45fefe909d1eb1b307f8c523eaff660d36aa5a6 |
Provenance
File details
Details for the file gstools-1.0.0-cp35-cp35m-win32.whl
.
File metadata
- Download URL: gstools-1.0.0-cp35-cp35m-win32.whl
- Upload date:
- Size: 252.4 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a62c5666b0a160b557226f0a7d78e773a7c215a477a856fd5eeb708d05a86f65 |
|
MD5 | 483804e9d5d702866d72eb72c7681101 |
|
BLAKE2b-256 | 2a0686a51dc8b104bc73e277e7b4be38c895869dd1bafa24d3f824cca9e7dc25 |
Provenance
File details
Details for the file gstools-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: gstools-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 529.8 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61eb695209decab0a457ac2a928764b4cef6d4c63aa843908088965e109fc7e3 |
|
MD5 | 702acaace21176cf5fe676e3ffc25af4 |
|
BLAKE2b-256 | bdfc6ec735c7f9e5bb9a7ffcc3fbd9f7d8f9e3b3e5737b20e02da6dc0c46a923 |
Provenance
File details
Details for the file gstools-1.0.0-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: gstools-1.0.0-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 502.2 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44770e52e310a94062ccba8496c816f5fef7072c7b9d40030f049f29c878abde |
|
MD5 | 33f484eaafc999b1c577452dcd3edf5d |
|
BLAKE2b-256 | 71b693a484eb411abd80a0aa52cdacad35012ec8eb148301c213dbbc0d21caef |
Provenance
File details
Details for the file gstools-1.0.0-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: gstools-1.0.0-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 359.8 kB
- Tags: CPython 3.5m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41f29347e6a4bd53d62e73e0c2331e0a787131f0d9a02cf4f9b1afd314f81cc5 |
|
MD5 | c5daa47e8ca5ec8c76455434d4366505 |
|
BLAKE2b-256 | 5bef1a30f0c1b1b93764f5b675017df7d1e2faf029a36e4faf6f9e78053220bc |
Provenance
File details
Details for the file gstools-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl
.
File metadata
- Download URL: gstools-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl
- Upload date:
- Size: 527.9 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f65de5e20ce18d1b41583b45320dfab454a9f1bcd01a9f21aca88c5e51b3d954 |
|
MD5 | 0fc294697697437636069475f17e8e1d |
|
BLAKE2b-256 | 6e70494c30e9816e91248ade96abb2d57c51176e574554b740ef2e324ff01b3f |
Provenance
File details
Details for the file gstools-1.0.0-cp27-cp27mu-manylinux1_i686.whl
.
File metadata
- Download URL: gstools-1.0.0-cp27-cp27mu-manylinux1_i686.whl
- Upload date:
- Size: 503.3 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5adc5fcac457bdb35bbf2a949460010034b8f7a46f9feafb56dbf7ac38b38182 |
|
MD5 | a20c6aabd87cf4acde035aba34540e38 |
|
BLAKE2b-256 | 6028234d662f213500238707afdc98baa9f140e74cf4d233e0ea4f85040903f8 |
Provenance
File details
Details for the file gstools-1.0.0-cp27-cp27m-win_amd64.whl
.
File metadata
- Download URL: gstools-1.0.0-cp27-cp27m-win_amd64.whl
- Upload date:
- Size: 276.0 kB
- Tags: CPython 2.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ca9e9b89f838f4f590abb2ea32be7408ae0d08d9606a65aeab14eb436a113c6 |
|
MD5 | 035bec38c34f8ae9c16860a6c16b5adc |
|
BLAKE2b-256 | 17b43ebd0091410bb395f897b190b6e0619226c63693c6f9362a9dc8fcaf9ea5 |
Provenance
File details
Details for the file gstools-1.0.0-cp27-cp27m-win32.whl
.
File metadata
- Download URL: gstools-1.0.0-cp27-cp27m-win32.whl
- Upload date:
- Size: 258.3 kB
- Tags: CPython 2.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36229d725d4e74ecf33f944c5cd2aa910c65944d7a72c71b393f339b5d5e04e9 |
|
MD5 | 04f75679b6ce1f5046e59aa89ea40a72 |
|
BLAKE2b-256 | f00ca24f5527bb0ace75fc6054c5d5f948fe0b20af3aad905689fbd1a42eb46a |
Provenance
File details
Details for the file gstools-1.0.0-cp27-cp27m-manylinux1_x86_64.whl
.
File metadata
- Download URL: gstools-1.0.0-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 527.9 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b52002fc8df4b9f8b8367b015d550bc06c587ebbf69f9e858711c603c94f582 |
|
MD5 | 8db61d9ad79d2c89f6bd8bd868fcf879 |
|
BLAKE2b-256 | 6df5a9549bebc01e458b392ed2a8350f7de71585f4beb70ae2beb1493f3c3a1a |
Provenance
File details
Details for the file gstools-1.0.0-cp27-cp27m-manylinux1_i686.whl
.
File metadata
- Download URL: gstools-1.0.0-cp27-cp27m-manylinux1_i686.whl
- Upload date:
- Size: 503.2 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e400a0621875f5c0e8ec9df9640f05abb665ab10225f7b1deefcff38094be81 |
|
MD5 | 96e95c0c45e9598fe32bf1293cda3a28 |
|
BLAKE2b-256 | 718b7ae5bb285982cd592e79e6dff2a621dcd6a1b0f35412912e85e4c2c270eb |
Provenance
File details
Details for the file gstools-1.0.0-cp27-cp27m-macosx_10_6_intel.whl
.
File metadata
- Download URL: gstools-1.0.0-cp27-cp27m-macosx_10_6_intel.whl
- Upload date:
- Size: 375.3 kB
- Tags: CPython 2.7m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff63b860d0d562694416e6dcaf26fa8fc9c106fbaa8bacdb4c913852a43ed1b2 |
|
MD5 | 06f6f25838054e112c0bbd8f8490e350 |
|
BLAKE2b-256 | 6172b677f6532cbda18c1857a77632b51023a0a0ea888342309d01665eb9fa7d |