Skip to main content

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.

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

When using the gstlearn Python Package, 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
--------------------------------------------------

You may be interested in the citation file [gstlearn.bib](https://soft.mines-paristech.fr/cran/gstlearn.bib

Installation

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

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. Please, refer to gstlearn C++ library API [See here]](https://gstlearn.org/) for more details. Only the public methods are exported by SWIG and must be considered in the Python package.

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 :

Linux (Ubuntu)

  1. Install gstlearn C++ library requirements for Linux here

  2. 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
  1. Finally, execute the following commands (optional):
sudo apt install pandoc jupyter libsuitesparse-dev
python3 -m pip install pypandoc geopandas plotly jupyter scikit-sparse

MacOS

  1. Install gstlearn C++ library requirements for MacOS here

  2. Then, execute the following commands (Not tested):

brew install python3
brew install swig
python3 -m pip install "pybind11[global]" numpy pandas scipy matplotlib
  1. 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
  1. Install gstlearn C++ library requirements for Windows (Microsoft Visual Studio) [here](https://github.com/gstlearn/gstlearn#Windows - Microsoft Visual Studio)

  2. 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)
  1. Then, install additional Python modules by running following instructions in a command prompt:
python -m pip install "pybind11[global]" numpy pandas scipy matplotlib
  1. 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:

  1. Follow this guide to add SWIG installation folders in the Path System variable (i.e: C:\swigwin-4.1.0)
  2. Restart Windows

Installation from Source

  1. 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
  1. 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 by Debug 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gstlearn-0.4.0-cp311-cp311-manylinux1_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.11

gstlearn-0.4.0-cp310-cp310-manylinux1_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.10

gstlearn-0.4.0-cp39-cp39-win32.whl (3.9 MB view details)

Uploaded CPython 3.9Windows x86

gstlearn-0.4.0-cp39-cp39-manylinux1_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.9

gstlearn-0.4.0-cp38-cp38-win32.whl (3.9 MB view details)

Uploaded CPython 3.8Windows x86

gstlearn-0.4.0-cp38-cp38-manylinux1_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.8

File details

Details for the file gstlearn-0.4.0-cp311-cp311-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gstlearn-0.4.0-cp311-cp311-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ee89b1d80633aa4be83475f67dee093eda8152c5b4c5a526c39bf7fa16203765
MD5 4691cbee5286e5ada50120b67e491ba2
BLAKE2b-256 de05ff7821f1a86247e5abf850e7ad41bb65732654656c02b32a69e47850fc5a

See more details on using hashes here.

File details

Details for the file gstlearn-0.4.0-cp310-cp310-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gstlearn-0.4.0-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 74bb636168018fa2d3c915770d4386ba5fd9ab75d1d0794434e17ea17e37bcda
MD5 49e264f2e5c250da79468f45fe160041
BLAKE2b-256 9773bf2943c8c5f1fbddd278245986f151d72cafcc205fa94d3e169d0318d4e9

See more details on using hashes here.

File details

Details for the file gstlearn-0.4.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: gstlearn-0.4.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for gstlearn-0.4.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 1eec92f540973041282152dff882f3f073752979ed9b1550060a8722dd0672d9
MD5 fe49eee07cd71a03ed53a0e2e0453352
BLAKE2b-256 15f16a3f070dd1d64faf6c015c7bff7f24e2e9e1c823ec83ed6ac2488bb1dd9a

See more details on using hashes here.

File details

Details for the file gstlearn-0.4.0-cp39-cp39-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gstlearn-0.4.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 095bef388287953e12c68c0fe02033e63cb501abdc1a9090b80b3c1d27b30615
MD5 69fe8de9974de2fbb5b03193c113a7e3
BLAKE2b-256 db55fb9bc34a7f1533044eb38e916465ce2174dcbcb7568eac0fa7de8d832d07

See more details on using hashes here.

File details

Details for the file gstlearn-0.4.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: gstlearn-0.4.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for gstlearn-0.4.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 5d68cb0094df42aeb16362459fc398a421c64cd35c872f524288c9a3ad26caa9
MD5 e319b7a60148d8a2cce4fe1de7a9ea31
BLAKE2b-256 8e2a14130940fbf52ddf0b75eb52fa4aa33b310eb2c74dedd94c5090a5cfe7e0

See more details on using hashes here.

File details

Details for the file gstlearn-0.4.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gstlearn-0.4.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8c962058521565af75ca5734658f56bf1659fe4f5103280d21e8d4370204eccb
MD5 a0f7df2de7841be86d13d036bc9da7b8
BLAKE2b-256 ce54f5c1febda2f22fa9f5206a4b934e2f398dd30621657ecc592f5eb8f6e49b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page