Skip to main content

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:

  1. In RMS set python path to include: /project/res/nrlib/nrlib-dist

  2. In python script: import gaussianfft as grf

  3. 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.

  4. 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

  5. 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)

  6. To get the start seed that is used: seed = grf.seed()

  7. 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


Download files

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

Source Distribution

gaussianfft-1.1.1b4.tar.gz (6.9 MB view details)

Uploaded Source

Built Distributions

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

gaussianfft-1.1.1b4-cp312-cp312-macosx_13_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 13.0+ ARM64

gaussianfft-1.1.1b4-cp312-cp312-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ x86-64

gaussianfft-1.1.1b4-cp311-cp311-macosx_13_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 13.0+ ARM64

gaussianfft-1.1.1b4-cp311-cp311-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

gaussianfft-1.1.1b4-cp310-cp310-macosx_13_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 13.0+ ARM64

gaussianfft-1.1.1b4-cp310-cp310-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

gaussianfft-1.1.1b4-cp39-cp39-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

gaussianfft-1.1.1b4-cp38-cp38-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

gaussianfft-1.1.1b4-cp37-cp37m-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.7mmacOS 11.0+ x86-64

File details

Details for the file gaussianfft-1.1.1b4.tar.gz.

File metadata

  • Download URL: gaussianfft-1.1.1b4.tar.gz
  • Upload date:
  • Size: 6.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for gaussianfft-1.1.1b4.tar.gz
Algorithm Hash digest
SHA256 bf873ca70b209e135b9878492d50c0e5e34e350667f6e1a92e4a03eaba58757e
MD5 4c5c6e51a2626c63f1bc7a01a7c5b1a6
BLAKE2b-256 0c89ca343feed7b27ac9844a69340df93bc85a18a65b5ebc090c2a94e4b267cd

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp312-cp312-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 8ded29db10f07ce7a76edbfb9f2ae08d32a1b629b2bc95db31417f2f8285f20e
MD5 0831f39a1b37e77f77653a7c0f62a357
BLAKE2b-256 2f1f5a0e23035a0b8584dbd04a5ae0d62ea50fac0232d2a4f264e24e9b76d943

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 03a6b7ad48eba0c6e2ee6697bc17b89105bd76b2bb0c2b47e23638c897032e70
MD5 98eae8ed7ea2f1ff41acbeee48478779
BLAKE2b-256 11d5c0a9c781255691421e7e8e4f23f3709ee173143a3e22d19515a78759f917

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp311-cp311-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 fba0c39d7950efb40299f4efe3f34c884d26f12fa85be8d7c39dc118e17bdd91
MD5 9a48feaecb8472eedaada525beb9323f
BLAKE2b-256 f75acf36656c41c05af44acd1ce9b78e11158355b96703681c719c4e6702b8e3

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 98ab47fedeb3e7b68c026eafe2722deab189f210b9538609d699006b7d504893
MD5 90b847a7316d779cbfbc91dd50d0b9bd
BLAKE2b-256 319a7de5617573376f19a67f2eae68112029d88533bc330bebfae70ed9a59719

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp310-cp310-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 ecfceb28f5aa65f965019c8d90c254ccbf09c494f545d1e28795d007651090cb
MD5 822531d8bec1d63936cecfaf8b597832
BLAKE2b-256 f160307f18194a6f3ab1de9baa9cc6e7ea71cf62abd6ba39930917a961c52a6e

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 2f4c0e33a95002d629a1f81b22fff032c28615547ed57b02aa635ba5404245e1
MD5 0d053269b8def354bea5369801e2ac4e
BLAKE2b-256 ee859739e236f3db277bcf9bbd66698c077271b524f0e5a87eb074756c1e9628

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 8f4b754cdce3273ecbbc3770442eebad9bb16547143a5d047903b272a5390116
MD5 84acc0570f184f19d2d405f9c64e072b
BLAKE2b-256 a6a6a1303aef8bbc2a3610ad7318971ab053f13e600bf00370111427f6c7fe55

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 97b701d888cf8413eb9e56d291cf40eac6270f7f0c01b0267d233f1396e66366
MD5 8f5b63dfda5a8f18c0e124558e27872d
BLAKE2b-256 1bc0832cfc06d75c28eb19a769e2717da2250fcbf14d5f90b9b791840dad600c

See more details on using hashes here.

File details

Details for the file gaussianfft-1.1.1b4-cp37-cp37m-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for gaussianfft-1.1.1b4-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 3f9748cd1cf4a351cddd53ae79ed343a58e01d682f6f951f40570651293f4c92
MD5 6dfcf8ee60033cf757820125c0c11261
BLAKE2b-256 9172e7e6c9649474d0e023139e64ea839b17572caece916a14f61e4522899c69

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