Geostatistics & Machine Learning toolbox
Project description
Overview
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.
References
The gstlearn Python package is a Python wrapper of the gstlearn C++ Library.
When using the gstlearn Python Package, please use the citation from doc/gstlearn.bib
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
How to cite
Please, use this to cite us in any publication or results for which gstlearn has been used:
--------------------------------------------------
gstlearn
Geostatistics and Machine Learning toolbox
Copyright © MINES Paris - PSL University
Free download from https://gstlearn.org
--------------------------------------------------
Installation
For using this Python package you only need Python 3 (or higher) (with numpy, pandas and matplotlib) and execute the following command:
pip install -i https://test.pypi.org/simple/ gstlearn
Note: In a close future, gstlearn will be available directly on pypi repository (not the test version)
Usage
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.
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
Documentation
The classes and functions documentation is provided with the gstlearn C++ library as html files generated by Doxygen (optional). Please refer to gstlearn C++ library README file for more details.
Changelog
Please, look at CHANGES file.
Development
Requirements
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:
- SWIG 4 or higher
- Python 3 or higher with pip, numpy, pandas, scipy, pybind11[global] and matplotlib modules installed
- pypandoc, scikit-sparse, geopandas, plotly and jupyter Python modules [Optional]
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 :
- In case of issues, see Important Notes below.
Linux (Ubuntu)
-
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 "pybind11[global]" numpy pandas scipy matplotlib
- Finally, execute the following commands (optional):
sudo apt install pandoc jupyter libsuitesparse-dev
python3 -m pip install pypandoc geopandas plotly jupyter scikit-sparse
MacOS
-
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 "pybind11[global]" numpy pandas scipy matplotlib
- Finally, execute the following commands (optional):
brew install pandoc jupyter libsuitesparse-dev
python3 -m pip install pypandoc geopandas plotly jupyter scikit-sparse
Notes:
- These instructions for MacOS are currently not tested - above packages may not exist
Windows
Install all tools
-
Install gstlearn C++ library requirements for Windows (Microsoft Visual Studio) [here](https://github.com/gstlearn/gstlearn#Windows - Microsoft Visual Studio)
-
Then, download and install the following tools using default options during installation:
- Python 3+ from here (Windows installer [exe] - check 'Add python.exe to PATH' in the first panel)
- SWIG 4+ from here (swigwin archive [zip], archive file to be extracted in a folder of your choice, but not in the gstlearn source folder - remind the installation folder, assume it is
C:\swigwin-4.1.0
)) - Pandoc from here (msi installer [msi] - simply execute the program)
- Then, install additional Python modules by running following instructions in a command prompt:
python -m pip install "pybind11[global]" numpy pandas scipy matplotlib
- Finally, install optional Python modules by running following instructions in a command prompt:
python -m pip install pypandoc geopandas plotly jupyter scikit-sparse
Update the Path environment variable
The Path environment variable (System variables) must be updated to make swig.exe available in the batch command line:
- Follow this guide to add SWIG installation folders in the Path System variable (i.e:
C:\swigwin-4.1.0
) - Restart Windows
Installation from Source
- For getting the gstlearn Python package sources files, just clone the github repository:
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
- Then, these instructions will compile and install the gstlearn Python package in your usual Python site-packages directory.
GCC, Clang, ...
...or any other single configuration compilers:
cmake -Bbuild -H. -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
Microsoft Visual Studio, ...
...or any other multiple configurations compilers:
cmake -Bbuild -H. -DBUILD_PYTHON=ON
cmake --build build --target python_install --config Release
Execute Non-regression Tests
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:
GCC, Clang, MinGW, ...
...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
Microsoft Visual Studio, ...
...or any other multiple configurations compiler:
cmake --build build --target check_py --config Release
cmake --build build --target check_ipynb --config Release
Important Notes
- If your system distribution repository doesn't provide minimum required versions, please install the tools manually (see provider website)
- You may have to add the directory containing
pybind11-config
executable to the PATH environment variable - If you plan to generate the documentation, add
-DBUILD_DOXYGEN=ON
to the first cmake command above. - If you don't know how to execute github commands, you may read this.
- Using Visual Studio on a Windows where MinGW is also installed may need to add
-G "Visual Studio 16 2019"
in the first command (adapt version). - The Windows C++ Compiler used must be the same that the one used for compiling Python (Visual C++). Using another compiler than Visual C++ is not supported.
- If you want to build and install the Debug version, you must replace
Release
byDebug
above - You may need to precise the location of Boost, SWIG, Doxygen or HDF5 installation directory. In that case, add the following variables in the first cmake command above:
-DBoost_ROOT="path/to/boost"
-DSWIG_ROOT="path/to/swig"
-DDoxygen_ROOT="path/to/doxygen"
-DHDF5_ROOT="path/to/hdf5"
Remove Installed Package
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:
- Removing the reference to the old gstlearn package version (see this topic)
- Removing a line which contains gstlearn in the ./easy-install.pth file of the site-packages folder
- Removing all directories starting with '~stlearn from the site-packages folder
License
BSD 3-clause 2023 Team gstlearn
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 Distributions
Built Distributions
Hashes for gstlearn-0.3.3-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a47b40307c8f461ba112e399d805b76346922ed8ecf674bffc954afa81c85e9 |
|
MD5 | 89e77e50cbee01e739a9a92e322a7e6f |
|
BLAKE2b-256 | f04d3b614edc7787ff485596a124b683f40eea61967f6b6c08101c3ccea811ff |
Hashes for gstlearn-0.3.3-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e901228f402a2ee0f31fa7785e1f8b5c8ce6e642f512f2349a1d054f029e3e60 |
|
MD5 | 0d99c9e2fdfa72cf2e66d4af501f34ad |
|
BLAKE2b-256 | f0f671c86c26441a6d7735aa46e7aa423f4be467519d5a5e2e2230fd78d0c91f |
Hashes for gstlearn-0.3.3-cp311-cp311-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db73792f6d0d511c0a488f623874d7f0163db545d631c14024696d1970a48e40 |
|
MD5 | e1deb2ba3b233ddfba2da09012148113 |
|
BLAKE2b-256 | 235f52196fef57ae1467fd5df30a2ada0ffbb5711e3a5e5425c59200ac3242fc |
Hashes for gstlearn-0.3.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dacfc7ca022449d05ea3a657198a95f3b18e5e0b7a6b7067cf3caa770d010e2c |
|
MD5 | c603b9cdc4098204c4840e933b499da7 |
|
BLAKE2b-256 | 3ec77aca61a9fbf6f48335f343b4e68e447f46c60de5059ce5d95745b233bf57 |
Hashes for gstlearn-0.3.3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17a3c76c629ac00c0d0a9fb51876a4599cd4dda0e0593bc4ceb403685d5aa6cc |
|
MD5 | 89a7a9ac60964b23adede7c89d082876 |
|
BLAKE2b-256 | b41a420e0321f907e8a1372d7cdbde850abb30da6d33d22da1f6eb730503eb7a |
Hashes for gstlearn-0.3.3-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60d92980e3419d490bc4b3b1de12d6d026eed3a33d3abf46c15164657c4d1f11 |
|
MD5 | a1da45676ca41399f8493e7d1197c01b |
|
BLAKE2b-256 | d60fd32d386232debe938543d271776a0266914693bf8164e712c8d0ed0d1d63 |
Hashes for gstlearn-0.3.3-cp310-cp310-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6d5fd314d5a65eb69f645cb82e4733dce4f4641cb6340f8fff48a9194547330 |
|
MD5 | 46bce4c5d86a2cbd5cb591852c625a92 |
|
BLAKE2b-256 | 664d870ff115a0cd704aec5dd6c4c0c3d7fd0a2b9aa70ba3a31e94dcdcf90c06 |
Hashes for gstlearn-0.3.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7026925a75c46d75a5f154071797265c0da2a65c686c9806945a9c105c23379 |
|
MD5 | 12a64a50ab01a337926213901e3a7ba2 |
|
BLAKE2b-256 | 218c45fb02ad505e79af0b79bbbd6451175259205a4a5d98694f36f220916cef |
Hashes for gstlearn-0.3.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4552c5e13c6b3a04a3a354e0c5eaf3da6ce8081e0eb65aa0c186f50315a12243 |
|
MD5 | 492dd4369e7b43752d8cfecffc3791a2 |
|
BLAKE2b-256 | 114ba4a40d886c37b945eccfe2182de6b63974bce902198676b2f1c3ab03fa5b |
Hashes for gstlearn-0.3.3-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc92d098a9d579e9a9ab3df2bafaa7f2d79ad03526db2937043caea9d323296e |
|
MD5 | acd7432fbaaf0bf4c862ffc05bc9a872 |
|
BLAKE2b-256 | d3823466047bc348f016c08d67b80abafd8080a4f2b4a5e86473d3c4b5cc3405 |
Hashes for gstlearn-0.3.3-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fb932223249a463c80b5e5c8fd04d193b042298e1f5e4c0e1a802aaac8e90a9 |
|
MD5 | 36133f90d61102f000a8ff1b0ab0a87f |
|
BLAKE2b-256 | f480b9e6c44d8280fc87c568e874f3b0041a33c844a73ef8f1843e98dbaa2400 |
Hashes for gstlearn-0.3.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 842e2ad55603786e792935f94f00c3d54349d6640e6fb17c037991b8706b6cf1 |
|
MD5 | e6c7aeb1177591497334c9fa2ff07a22 |
|
BLAKE2b-256 | 47eceaf91bcc9215e057f99482482120a4655396735b20b4bbb8920015677932 |
Hashes for gstlearn-0.3.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 375e194b6f773982302b31cadf58abf8a5647ab43f8970b494c7cea84d792a5d |
|
MD5 | fe812c3f9b19f03fa30c0b2213667bff |
|
BLAKE2b-256 | adac29320988057958538cfd39c162213e16cb7cfe7e2721c263eeae5b996534 |
Hashes for gstlearn-0.3.3-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c117a02135e4a6fcc4f6309bbf34b8e2ba8b3a4ad2ca0c6d95f7044b909d59f8 |
|
MD5 | c1426f7c74fbf8db24805d5ae928492f |
|
BLAKE2b-256 | a9aff4bcce71af89aac85c37ec64597b9e0aaa19d7b1e63d9d048e4f1cd12fcd |
Hashes for gstlearn-0.3.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e7a1fa6570d399acb53f0b56f764caf90d267d82141f00bbdce6c5d27314b0e |
|
MD5 | a7218deb54c8e193061d7d9616ee96f3 |
|
BLAKE2b-256 | 2c84d197cd17f7f8fad2f12920bfe87b021c760b5fbfd8a206ea79bccc077cdf |
Hashes for gstlearn-0.3.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ed91c7114e45a5e192a3ba9422b9dbe4c94fc7fccd2e0793459d4015f994b00 |
|
MD5 | bfbf9a1360d0a24ebad2533a260b6592 |
|
BLAKE2b-256 | f2b8036b7276fcb52203c4620979baf45e43bae4820245a7f986203e9fd97de1 |