A fast library for simulating Gaussian Random Fields, using the fast Fourier transform
Project description
Gaussianfft
A fast library for simulating Gaussian Random Fields, using the fast Fourier transform (Intel MKL).
Originally developed by Norsk Regnesentral on commission from Equinor. Documentation from Norsk Regnesentral: SAND_04_18.pdf (also available on GitHub)
Usage
pip install gaussianfft
import gaussianfft as grf
grf.seed(100) # For deterministic / repeatable output
variogram = grf.variogram(grf.VariogramType.GAUSSIAN, 1000)
simulation = grf.simulate(variogram, nx=100, dx=1, ny=100, dy=1) # 2D 100 x 100 grid
See examples for examples, getting started, and other documentation.
Previous versions
nrlib version pr 28.02.2018 for RMS10 is the final version compiled for RMS10
The directory for this version: nrlib-dist-RMS10-180228 Compatibility: Compatible with python 3.4 which is used in RMS10
nrlib version pr 28.02.2018 for RMS11Beta is the final version compiled for RMS11Beta
The directory for this version: nrlib-dist-RMS11Beta-180228 Compatibility: Compatible with python 3.6 which is used in RMS11Beta
nrlib version 09.02.2018 for RMS11Beta
The directory nrlib-dist-RMS11Beta is the one to use for RMS11Beta Compatibility: Compatible with python 3.6 which is used in RMS11Beta
nrlib version pr 13.02.2018 for RMS10
The directory nrlib-dist-RMS10-optimalized is the one to use for RMS10. Is updated to be more efficient. It generates an message which can be ignored: "RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa" This "error" message can be ignored. Compatibility: Compatible with python 3.4 which is used in RMS10
Description
Python wrapper around Gaussian simulation methods for 1D, 2D and 3D simulation using the FFT based method.
Written by: Norsk Regnesentral for Equinor APS GUI project, but can be used for all in Equinor for internal use.
Contact person in Norsk Regnesentral: Vegard Berg Kvernelv (2018) Contact person in Equinor: Oddvar Lia
This directory contains both source code and compiled version of nrlib, a library for simulating gaussian fields in 1D, 2D and 3D using python 3.4 (RMS version 10 installation of python)
This code is for Equinor internal use and the development of the code is paid by the APS GUI project. Norsk Regnesentral (contact person: Vegard Berg Kvernelv, 2018) has developed the code which is based on FFT and can handle very large grids (The ambition is to handle up to 1000x1000x1000 grid size). Check Docstring for usage but a brief summary follows:
How to use it in python scripts called up from RMS:
-
In RMS set python path to include:
/project/res/nrlib/nrlib-dist
-
In python script:
import gaussianfft as grf
-
Set variogram:
variogram = grf.variogram(variogramName, mainRange, perpRange,vertRange, azimuth, dip, power)
variogramName is one of:
exponential
spherical
gaussian
general_exponential
(this is the only one using the exponent called power in the variogram function)matern32
matern52
matern72
constant
The ranges are given the same name as in IPL but corresponds to x,y,z directions. Note that the simulation is a regular 3D grid and the coordinate system is right-handed. This means that input azimuth angle should be(90 - azimut_used_in_rms)
for standard RMS grids which are left-handed. So if you want to use this in RMS and load the result into a zone in a grid in RMS (e.g by using Roxar API) then be aware of this. -
Simulation is done by:
gaussVector = grf.simulation(variogram, nx, dx, ny, dy, nz, dz)
The gauss field output is a 1D numpy array and by using
gaussResult = grf.reshape(gaussVector,(nx,ny,nz),order='F')
one get a 3D numpy array -
To check how large the extension of the internal simulation grid is (to avoid edge effects in the result from the FFT algorithm) the grid is increased before it is simulated internally in the nrlib module. You can check this extension to see the actual grid size used. This grid size is reported by using the function:
[nx_extended, ny_extended, nz_extended] = grf.simulation_size(variogram, nx, dx, ny, dy, nz, dz)
and depends very much on the relative size of the correlation lengths and the grid size (length, width, height)
-
To get the start seed that is used:
seed = grf.seed()
-
To set a seed before calling any simulation:
grf.seed(seedValue)
Note: the returned seed from grf.seed()
is created automatically by the clock time. If you use multiprocessing, and run several processes in parallel
be sure to delay start of a new process by at least 1 second after the previous process to avoid that two different processes get the same start seed.
The return seed is the same regardless of how many times you call simulation since it is the start seed of the first call to simulation.
It must however not be called before the first call to simulation if you want the start seed to be automatically generated.
If you want to run with a predefined start seed, call grf.seed(seedValue)
before the first call to simulation.
Building
We use scikit-build-core
as the build tool, in order to use pyproject.toml
to facilitate easier building while using cmake
to build the C++ extension.
We also use Boost.Python (version 1.76.0 for Python <=3.10 and 1.81.0 for newer versions).
While compiling Boost, a python interpreter needs to be set.
You may want to create a virtual environment before building gaussianfft
.
python -m venv venv
source venv/bin/activate
For the time being, Windows is not supported due to difficulties making gaussianfft
compile there (on a windows runner on GitHub Actions).
Contributions for making it compile reliably on Windows are welcome.
The rest of this section assumes you are working on a UNIX-like system. It has been tested on macOS (Intel/Apple Silicon) and Linux (x86).
To build the distribution wheel(s), run
export PYTHON=<which python to use> # Only useful when not running in a virtual environment
make build
This will build the binary, and source distributions with the build
package in a temporary / ephemeral directory.
There is no caching of build artifacts in this case.
If you need to build, and iterate on the extension module, you may want to execute
cmake -S . -B build -DPython3_EXECUTABLE=$(which python)
cmake --build build
Contributing
Report bugs (description with reproducible steps + run environment) and feature requests are welcome.
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 gaussianfft-1.1.1b5.dev0-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbd3b571e2b9976ba262dba7997655c0acc0a3dfe4b6f7767a770cf99a98f8a3 |
|
MD5 | 0c796d71b16e77fe824a3371eb8accc5 |
|
BLAKE2b-256 | 145c91904afa30ebb22d3fa2c376cd32a8d218d6347bb4f5774964604619440e |
Hashes for gaussianfft-1.1.1b5.dev0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8378e70574e41336bc2c8cb5d9796ecc2f2ddd8ebea34c29eea1582e79337f1 |
|
MD5 | d91b854aea85d411d0fadb707c964f19 |
|
BLAKE2b-256 | f0a4a751f8b756d275beed302809d75c3c30eee05c3cf7768e4580297ca891a9 |
Hashes for gaussianfft-1.1.1b5.dev0-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b577fd51f4faedfafb1f237edb1727ca9757d799547761eba675bcfc67fbf352 |
|
MD5 | c880c5c904983471200116703d9740ac |
|
BLAKE2b-256 | 3c6a7f0d44cada2936b3624faa1744384a74b370a5ce0a1e12f924bb3cbde3e0 |
Hashes for gaussianfft-1.1.1b5.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efb01acdcc8f9463826240372fe96b185fea583606d726a4a5d065450083ecec |
|
MD5 | d4b29223a28f0c77cbc2433493d716d5 |
|
BLAKE2b-256 | 2d0a060f85df6b51e1ca37e79d1683c1016676c5121071b1bf5d3e94f93a41b4 |
Hashes for gaussianfft-1.1.1b5.dev0-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0446f926fbf0d2e597ce7146392ec89a6c0b457608d718ce06d80b9f79280e92 |
|
MD5 | d75809b03218ce9aee319f8c8b6f8545 |
|
BLAKE2b-256 | e7fafa9b8c8d1a59931e4e9cc8ba8bafe236d2abac6de8897aa28c8ae375bf48 |
Hashes for gaussianfft-1.1.1b5.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f941220ea387b03483225ee5e73d5635e14c08d00b94927627deda082cbc16d |
|
MD5 | 209ae14b30237f776d0297142e6ad245 |
|
BLAKE2b-256 | 25b3db19da36edc1658b142475d19dbdeb7c4663ea0cfee7bbf8cd1260a64692 |
Hashes for gaussianfft-1.1.1b5.dev0-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9cf8838f4b750ffaa3c1483ccf16ee8fd222f09d24d230c02b6d502c9f28357 |
|
MD5 | 5f24f2a0888e7b9d068a926acf98a920 |
|
BLAKE2b-256 | d339663d186dea150e7114839a0e841e6e4828e5f8c8c9f1eb2c952a4281489f |
Hashes for gaussianfft-1.1.1b5.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cd45c937256cf1061427fa888c621fbd2a664a3d99ce528920148582fdafcad |
|
MD5 | 7632703418b83748bcf2a721375bed31 |
|
BLAKE2b-256 | 5d6e8937c0a927af7752cc08cd876772c71e2c83cf774a2d07bc2ee352363008 |
Hashes for gaussianfft-1.1.1b5.dev0-cp38-cp38-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c650887074af7e27b3aa96723d87e1bb2743de385abe9f00ee69a696981ca50b |
|
MD5 | ed4780e9f6be92de48c4f179b9e06c48 |
|
BLAKE2b-256 | b14f98c67c4c837d576fe72a04612427bed6448c921c4edbb114d597f0b6baeb |
Hashes for gaussianfft-1.1.1b5.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d46c58c578749f3d06a2ff94b46d612b4ff60a5fb9e19ba09d0c130ab5ae79cd |
|
MD5 | bf0eb46ce7332835bd253dadccfc00cf |
|
BLAKE2b-256 | afc7365e072a8407827911dc666f5709fd14ec9e4c670c40a679f6e647d1a0d2 |
Hashes for gaussianfft-1.1.1b5.dev0-cp37-cp37m-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72a6d3ba13b878fc377c0a244f7578f8bd79f6d0d23f1c8dc401f814c480971b |
|
MD5 | 0eb80c65bdb0e4193fea3ff4ab8680df |
|
BLAKE2b-256 | 01fc084d1bac8c725db14e1716b846fbe21388aa54ff95709638b97ea3430b36 |
Hashes for gaussianfft-1.1.1b5.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d5ada16e597cca92a5a5fa47ddf99e87e572b4db014370f0e9baebe37bc00a3 |
|
MD5 | bb5aac4df7a67cc864846b254c86c4cd |
|
BLAKE2b-256 | 1cd39c043e3bef1a0d864164919720c42285db24896e8fec75f53f8ded455fef |