Loading repository data…
Loading repository data…
GeostatsGuy / repository
GeostatsPy Python package for spatial data analytics and geostatistics. Started as a reimplementation of GSLIB, Geostatistical Library (Deutsch and Journel, 1992) from Fortran to Python, Geostatistics in a Python package. Now with many additional methods. I hope this resources is helpful, Prof. Michael Pyrcz
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Pyrcz, M.J., Jo. H., Kupenko, A., Liu, W., Gigliotti, A.E., Salomaki, T., and Santos, J., 2021, GeostatsPy Python Package: Open-source Spatial Data Analytics and Geostatistics, DOI: /doi/10.5281/zenodo.13835444.
I have a confession: many of the GSLIB functions in the GeostatsPy Python package were ported or written from scratch by me—often late at night and into the early morning hours—just in time for the next day’s lecture.
Back in 2018, I desperately needed a usable, open-source geostatistics Python package to teach my courses. I found one, but on the first day of the semester, it broke due to an update in a dependent package. With no alternatives, I decided to build my own. My goal was simple: implement the minimum necessary tools to teach geostatistics in practice, not just in theory.
Because:
you can’t teach geostatistics without algorithms, and…
students weren’t going to edit parameter files and run old FORTRAN GSLIB executables. (I tried that once—many students dropped the course in the first week!)
my Excel demonstrations are great for theory and math, but they don’t support building full models.
So, in those early days, I made a key decision, everything would be in 2D only. Why?
it made testing and debugging much easier.
it was perfect for live demos and slides: easy to explain, visualize, and diagnose.
Fast forward to now... I’m lucky to have an amazing graduate student team—typically 12–15 students, mostly PhDs—and many of them want to build 3D geostatistical models. So, I couldn’t help myself. I went back and updated everything—search algorithms, kriging, distance metrics with geometric anisotropy, and more... and finally,
sgsim_3D - a 3D implimentation of sequential Gaussian simulation
sisim_3D - a 3D implimentation of sequetial indicator simulation
Tested:
simple and ordinary kriging
stationary mean or proportion realizations
data conditioning
Not yet tested:
locally variable mean / proportion
collocated cokriging
I’ll be asking one of my PhD students to test these soon!
I made some improvements over the current 2D implimentations,
continued to replace legacy FORTRAN-style loops from GSLIB with NumPy broadcasting, making the code more readable, robust, and concise.
fixed the reference distribution option in sgsim_3D, allowing users to transform/back-transform with limited conditioning data using an external Gaussian table.
I did make a couple of improvements,
I'm always looking to replace the FORTRAN loops of GSLIB with broadcast methods from NumPy for more robust, readable and concise codes.
I have fixed the reference distribution option for SGSIM, so you can use few data and another file to provide the Gaussian transformation and back-transformation table.
Huge thanks to Professor Honggeun Jo, whose prior work on 3D variograms, covariance functions, and more made this possible. Your contributions to GeostatsPy have been incredible.
The goal of this e-book is to teach the application of geostatistics in Python, for those new to geostatistics I provide theory and links to my course content, and for those experienced practitioners I provide example workflows and plots that you can implement.
e-book citation and link:
Pyrcz, M.J., 2024, Applied Geostatistics in Python: A Hands-on Guide with GeostatsPy, https://geostatsguy.github.io/GeostatsPyDemos_Book.
The GeostatsPy Package brings GSLIB: Geostatistical Library (Deutsch and Journel, 1998) functions to Python. GSLIB is a practical and extremely robust set of code for building spatial modeling workflows.
I created the GeostatsPy Package to support my students in my Data Analytics, Geostatistics and Machine Learning courses. I find my students benefit from hands-on opportunities, in fact it is hard to imagine teaching these topics without providing the opportunity to handle the numerical methods and build workflows. Last year, I tried to have them use the original FORTRAN executables and even with support and worked out examples, it was an uphill battle. In addition, all my students and I are now working in Python for our research. Thus, having access to geostatistical methods in Python directly impacts and facilitates the research of my group. This package retains the spirit of GSLIB:
This package contains 2 parts:
geostatspy.geostats includes GSLIB functions rewritten in Python. This currently includes all the variogram, distribution transformations, and spatial estimation and simulation methods. I will continue adding functions to support modeling operations for practical subsurface model cosntruction.
geostatspy.GSLIB includes reimplimentation of the GSLIB visualizations and low tech wrappers of the numerical methods (note: the low-tech wrapper require access to GSLIB executables).
I have built out many well-documented workflow in Jupyter Notebooks using GeostatsPy functions to complete common workflows in spatial data analytics and geostatistics. They are available in my GeostatsPy_Demos Repository. I hope these are helpful!
A minimum environment includes:
GeostatsPy is available on the Python Package Index (PyPI) GeostatsPy PyPI.
To install GeostatsPy, use pip command,
pip install geostatspy
To update GeostatsPy to the most recent version, use pip,
pip install --upgrade --force-reinstall geostatspy
The functions rely on the following packages:
| Package / Component | Included by Default in Anaconda? | Notes | Application in GeostatsPy |
|---|---|---|---|
| numpy | ✅ Yes | Core numerical package | arrays with ndarrays |
| pandas | ✅ Yes | Essential for dataframes and time series | data tables with DataFrames |
| numpy.linalg | ✅ Yes | Part of NumPy (not a separate package) | linear algebra for solving kriging systems |
| scipy | ✅ Yes | Scientific computing tools, including optimization | fast data search with KD Trees, |
| matplotlib.pyplot | ✅ Yes | From the Matplotlib library for plotting | standard plots, location maps, pixel plots, etc. |
| numba | ✅ Yes (often included) | JIT compiler; included in most full Anaconda installs | for numerical speed up of array math |
| tqdm | ❌ No | Not included by default — install manually | for progress bar |
| statsmodels | ❌ No | Often used, but not in the default distribution | for weighted (debiased) statistics |
Most of these packages should be available with any modern Python distribution, like Anaconda.
pip install tqdm
pip install statsmodels
If you get a package import error, you may have to first install some of these packages. This can usually be accomplished by opening up a command window on Windows and then typing
python -m pip install [package-name]
More assistance is available with the respective package docs.
Here's some highlights from recent updates:
New contributions from Dr. Misael Morales,
ensemble Kalman filtering (ENFk), ENFK()
ensemble smoothing ESMDA, ESMDA()
2D indicator simulation, sisim()
2D kriging at a list of locations instead of a grid, kb2d_locations()
sampling functions
simulated realizations post processing, postsim()
gamma bar calculation for volume variance, gammabar()
3D irregular data variogram calculation, gamv()
Professor Honggeun Jo's (Inha University, South Korea) lead the implimentation of 3D methods to GeostatsPy. This include:
Note, GeostatsPy follows the NumPy standard and assumes 3D arrays indexed as my_array[nz,ny,nx] with both y and z reversed. I will add a few well-documented demonstrations to my GitHub shortly.
Finally got to those bugs in sequential Gaussian simulation! We now have improved reproduction of the variogram and a big simplication of the inputs.
This package is being developed at The University of Texas in the Texas Center for Geostatistics.
Professor Michael J. Pyrcz, Ph.D., P.Eng. - professor with The University of Texas at Austin. Primary author of the package.
Professor Honggeun Jo, Ph.D. - assistant professor with Inha University, South Korea. Author of 3D subroutines, 3D variogram calculation and modeling and wrapper for sgsim for 3D modeling and more! Thank you, Professor Jo!
Anton Kupenko - bug fixes, added docstrings, code refractory for PEP8, removed duplicated functions and variables. Thank you, Anton!
Wendi Liu, Ph.D. - while a Ph.D. student working with Michael Pyrcz at The University of Texas at Austin. Author of 3D subroutines and gammabar method. Also, GSLIB compiles in Mac OSX, and