
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
The gstlearn Python package is a cross-platform Python package wrapping the gstlearn C++ Library. It offers to Python users all famous Geostatistical methodologies developed and/or invented by the Geostatistic Team of the Geosciences Research Center!
More details for gstlearn are available here: https://gstlearn.org
If you need to plot gstlearn outputs, you can import gstlearn.plot module which is based on matplotlib.
The gstlearn Python package is a Python wrapper of the gstlearn C++ Library.
This package contains a copy of doxy2swig python script (see LICENSE.doxy2swig in doc folder).
The gstlearn Python package is a derivative work based on the swigex0 project: https://github.com/fabien-ors/swigex0
When using the gstlearn Python Package, please, use this to cite us in any publication or results for which gstlearn has been used:
You may be interested in the citation file gstlearn.bib
For using this Python package you only need Python 3.8 (or higher) (with numpy, pandas and matplotlib) and execute the following command:
pip install gstlearn
We refer the reader to this course page for an introduction and important information about Python gstlearn package.
Simply import the gstlearn Python package and its plot module, then enjoy:
# Import packages
import numpy as np
import matplotlib.pyplot as plt
import gstlearn as gl
import gstlearn.plot as gp
# Grid size
nx = 60
ny = 30
mygrid = gl.DbGrid.create([nx,ny],[1,1])
# Add a gaussian random field
var = np.random.randn(nx * ny)
mygrid.addColumns(var, "var1", gl.ELoc.Z)
# Display the field
ax = gp.grid(mygrid)
ax.decoration(title="Gaussian random field")
plt.show()
Some tutorials (Jupyter Notebooks) are provided in the demo directory here and their HTML rendering is provided here.
Some tests (Python scripts) are available in the tests directory of the gstlearn github repository.
Known caveats
If you experience the following error while importing gstlearn package under Python:
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xe
... you may need to upgrade numpy:
python -m pip install --upgrade numpy
The classes and functions documentation is provided with the gstlearn C++ library as html files generated by Doxygen. Please, refer to gstlearn C++ library API See here for more details. Only the public methods are exported by SWIG and must be considered in the Python package.
Please, look at CHANGES file.
For building the gstlearn Python package, the requirements for compiling gstlearn C++ library must be installed beforehand. Then, the following additional tools must be also available:
If you modified your system, you must reinstall the requirements from scratch following next instructions. You must delete 'gstlearn' existing source folders (if so).
Note :
Install gstlearn C++ library requirements for Linux here
Then, execute the following commands:
sudo apt install python3
sudo apt install python3-pip
sudo apt install swig
python3 -m pip install numpy pandas scipy matplotlib
sudo apt install pandoc jupyter libsuitesparse-dev
python3 -m pip install pypandoc plotly jupyter notebook scikit-sparse
Install gstlearn C++ library requirements for MacOS here
Then, execute the following commands (Not tested):
brew install python3
brew install swig
python3 -m pip install numpy pandas scipy matplotlib
brew install pandoc jupyter libsuitesparse-dev
python3 -m pip install pypandoc plotly jupyter notebook scikit-sparse
Notes:
Install gstlearn C++ library requirements for Windows (Microsoft Visual Studio) here
Then, download and install the following tools using default options during installation:
C:\swigwin-4.1.0
))python -m pip install numpy pandas scipy matplotlib
python -m pip install pypandoc plotly jupyter notebook scikit-sparse
The Path environment variable (System variables) must be updated to make swig.exe available in the batch command line:
C:\swigwin-4.1.0
)git clone https://github.com/gstlearn/gstlearn.git
cd gstlearn
Next time, you will only need to pull the repository (If you have some local undesirable modifications, you have to revert them and execute the pull, otherwise do not execute git reset
):
cd gstlearn
git reset --hard
git pull
...or any other single configuration compilers:
cmake -Bbuild -S. -DBUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --target python_install
or for those who prefer a single command line:
mkdir -p build & cd build & cmake .. -DBUILD_PYTHON=ON & make python_install
or even faster:
make python_install
...or any other multiple configurations compilers:
cmake -Bbuild -S. -DBUILD_PYTHON=ON
cmake --build build --target python_install --config Release
The check*
targets bring some required runtime customization, so do not use the standard ctest command for triggering the non-regression tests.
To build and launch non-regression Python tests, you need to execute the following command:
...or any other single configuration compiler:
cmake --build build --target check_py
cmake --build build --target check_ipynb
or even faster:
make check_py
make check_ipynb
...or any other multiple configurations compiler:
cmake --build build --target check_py --config Release
cmake --build build --target check_ipynb --config Release
-DBUILD_DOXYGEN=ON
to the first cmake command above.-G "Visual Studio 16 2019"
in the first command (adapt version).Release
by Debug
above-DBoost_ROOT="path/to/boost"
-DEigen3_ROOT="path/to/eigen3"
-DSWIG_ROOT="path/to/swig"
-DDoxygen_ROOT="path/to/doxygen"
-DHDF5_ROOT="path/to/hdf5"
-DNLopt_ROOT="path/to/nlopt"
To uninstall the gstlearn Python package, execute following command:
python3 -m pip uninstall gstlearn
Note : You may need to directly modify your site-packages folder by:
BSD 3-clause
2025 Team gstlearn
FAQs
Geostatistics & Machine Learning toolbox
We found that gstlearn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.