tpgs module¶
Module to use Truncated plurigaussians.
Warning
The C functions are not working anymore due to incompatibilities between linux, windows and mac os.
- tpgs.Cstruc2geoCm2D(Cstruc)¶
Inverse of geoCm2Cstruc
Pass from a C structure in ctypes to a geone covmodel
- tpgs.Cstruc2geoCm3D(Cstruc)¶
inverse of geoCm2Cstruc3D
- tpgs.Gspace2Pspace(flag)¶
Return a flag in the probability space given a flag in gaussian space
- tpgs.Ivario(x, v, icat, ncla=10, dim=1, alpha=0.0, hmax=nan)¶
Compute experimental indicator variogram using geone variogram
- Parameters:
x (ndarray of size (n, k)) – coordinates of data points, where n is the number of points and k is the dimension
v (ndarray of size (n,)) – values at data points
icat (ndarray of size (n,)) – category of data points
ncla (int) – number of categories
dim (int) – dimension of the space
alpha (float) – angle of rotation
hmax (float) – maximum distance
- Return type:
Experimental variogram
- tpgs.Truncation2D(nx, ny, sims, flag)¶
Function that operates the truncation process for TPGs
- tpgs.Truncation3D(nx, ny, nz, sims, flag)¶
Function that operates the truncation process for TPGs in 3D
- Parameters:
nx (int) – number of cells in x direction
ny (int) – number of cells in y direction
nz (int) – number of cells in z direction
sims (ndarray of size (nsim, nz, ny, nx)) – simulations to apply the truncation
flag (dictionnary) – It contains for each facies a list of the thresholds (in gaussian space) for the two gaussian fields example with 3 facies of ID : (1,2,3):
{ 1: [[(-inf, -0.3), (-inf, 0)], [(0.3, inf), (-inf, 0.5)]], 2: [[(-inf, -0.3), (0, inf)]], 3: [[(-0.3, 0.3), (-inf, inf)], [(0.3, inf), (0.5, inf)]] }
- class tpgs.VarStruc2D¶
Bases:
Structure- alpha¶
Structure/Union member
- c¶
Structure/Union member
- nstruc¶
Structure/Union member
- rx¶
Structure/Union member
- ry¶
Structure/Union member
- var_type¶
Structure/Union member
- class tpgs.VarStruc3D¶
Bases:
Structure- alpha¶
Structure/Union member
- beta¶
Structure/Union member
- c¶
Structure/Union member
- gamma¶
Structure/Union member
- nstruc¶
Structure/Union member
- rx¶
Structure/Union member
- ry¶
Structure/Union member
- rz¶
Structure/Union member
- var_type¶
Structure/Union member
- tpgs.coord2cell(xg, yg, zg, x, y, z)¶
- class tpgs.fa_domains¶
Bases:
Structure- bnd_vector¶
Structure/Union member
- ncuboids¶
Structure/Union member
- tpgs.flag2Cflag(flag)¶
From a dictionary of facies to dic of C structures for the flag of the Truncated Plurigau
- Parameters:
flag (dictionary) – dictionary containing the thresholds for each facies
- Returns:
dictionary of facies to C structure
- Return type:
dictionnary
- tpgs.geoCm2Cstruc2D(covmodel)¶
Pass from a geone covmodel to a C structure in ctypes that will be used in C functions
- tpgs.geoCm2Cstruc3D(covmodel)¶
Pass from a geone covmodel to a C structure in ctypes that will be used in C functions
- tpgs.infacies(g1v, g2v, flag)¶
return the facies in which a point of coordinate (g1v, g2v) is.
- Parameters:
g1v (float) – value of the first gaussian field x coordinate to evaluate on the flag
g2v (float) – value of the second gaussian field y coordinate to evaluate on the flag
flag (dictionnary) – Threshold flag for the TPGs
- tpgs.opti_vario(IK_covmodels, covmodels_to_fit, pk, flag, n=8, du=0.03, dv=0.03, c_reg=0.001, print_infos=False, min_method='Nelder-mead', ftol=0.2, xtol=0.2)¶
Optimize parameters of the two covmodels (covmodels_to_fit) of the tpgs in order to reproduce the IK_covmodels using a least-square method Very slow –> To improve
- Parameters:
IK_covmodels (list of size k) – list of k indicator covmodels (geone.covModel) where k is the number of facies order in the list must be the same than the keys of the flag
covmodels_to_fit (list of size 2) – list of 2 covmodels (geone.covModel) to infer. Parameters to infer should be specified with a string. Example:
G1_to_opt = gcm.CovModel3D(elem=[(“gaussian”,{“w”:1,”r”:[“rx1”,”rx1”,”rz1”]})], alpha=”alpha”,beta=0,gamma=0) G2_to_opt = gcm.CovModel3D(elem=[(“gaussian”,{“w”:1,”r”:[“rx2”,”rx2”,”rz2”]})], alpha=”alpha2”,beta=”beta2”,gamma=0) covmodels_to_fit = [G1_to_opt,G2_to_opt]
pk (array-like of size k) – proportion for each facies (order in the list must be the same than the keys of the flag)
flag (dictionnary) – dictionnary containing for each facies a list of the thresholds (in gaussian space) for the two gaussian fields
Example with 3 facies of ID : (1,2,3):
{ 1: [[(-inf, -0.3), (-inf, 0)], [(0.3, inf), (-inf, 0.5)]], 2: [[(-inf, -0.3), (0, inf)]], 3: [[(-0.3, 0.3), (-inf, inf)], [(0, inf), (0.5, inf)]] }
n (int, optional) – number of points to use to compute the variogram
du (float, optional) – precision to use in the calcul of the probability btw facies, values of 0.05 are generally enough.
dv (float, optional) – precision to use in the calcul of the probability btw facies, values of 0.05 are generally enough.
c_reg (float, optional) – regularization coefficient to apply on radius parameters (radius of covmodels only), problem dependent.
print_infos (bool, optional) – if True, print informations about the optimization process
min_method (str, optional) – method to use for the optimization, see scipy.optimize.minimize
ftol (float, optional) – tolerance on the function value for the stop criterion, see scipy.optimize.minimize
xtol (float, optional) – tolerance on the parameters for the stop criterion, see scipy.optimize.minimize
- Returns:
result of the optimization process
- Return type:
scipy.optimize.OptimizeResult
- tpgs.p1zone(flag_facies)¶
Calculate the probability of a facies to belongs to a certain part of the facies (on the flag –> facies are separated by thresholds and it is possible to have multiple zones for 1 facies)
- Parameters:
flag_facies (list of list of tuples) – Each sublist contains two tuples that are the threshold coordinates (in gaussian space) that form a rectangle where the facies is present (format : [[(x0,x1),(y0,y1)],[(x1,x3),(y1,y4)]], xi –> 1st gaussian field, yi –> second gaussian field
- tpgs.pfa(flag)¶
Determine the probability of each facies according to the flag for TPGs
- tpgs.plot_flag(flag, **kwargs)¶
- tpgs.run_tpgs(nsim, xg, yg, zg, data, Gk, flag, nit=100, nmax=24, grf_method='fft', mask=None)¶
Run simulations using the Truncated plurigaussian (2 gaussian fields) methods : Covmodels must be provided !
- Parameters:
nsim (int) – number of simulations
xg (1D array) – x coordinates of the grid (edges)
yg (1D array) – y coordinates of the grid (edges)
zg (1D array) – z coordinates of the grid (edges)
data (2D array) – (x, y, z, g1, g2, v), where x,y,z are the cartesian coordinates, g1 and g2 are the values of first/second gaussian fields and v is the facies value
Gk (list of 2 3D covmodels (geone object)) – list of 2 3D covmodels (geone object)
flag (dict) – dictionnary containing for each facies a list of the thresholds (in gaussian space) for the two gaussian fields
Generic example for one facies:
{ f_i: [(x0, x1), (y0, y1) }
Example with 3 facies:
{ 1: [[(-inf, -0.3), (-inf, 0)], [(0.3, inf), (-inf, 0.5)]], 2: [[(-inf, -0.3), (0, inf)]], 3: [[(-0.3, 0.3), (-inf, inf)], [(0, inf), (0.5, inf)]] }
nit (int) – number of iterations for the gibbs sampler (used for the conditional simulations)
nmax (int) – maximum number of neighbors to consider, lower values will speed up the simulation
grf_method (str) – method to use for the grf simulation, either “fft” or “sgs”
mask (3D array) – mask to use for the simulation, if None, no mask is used
- Returns:
sim – 4D array of the simulations (nsim, nz, ny, nx)
- Return type:
4D array
- tpgs.simple_kriging(x, xu, cov_model, mean)¶
Performs kriging - interpolates at locations xu the values v measured at locations x. Covariance model given should be:
in same dimension as dimension of locations x, xu
in 1D, it is then used as an omni-directional covariance model
(see below).
- Parameters:
x (2-dimensional array of shape (n, d)) – coordinates of the data points (n: number of points, d: dimension) Note: for data in 1D, it can be a 1-dimensional array of shape (n,)
v (1-dimensional array of shape (n,)) – values at data points
xu (2-dimensional array of shape (nu, d)) – coordinates of the points where the interpolation has to be done (nu: number of points, d: dimension same as for x) called unknown points Note: for data in 1D, it can be a 1-dimensional array of shape (nu,)
cov_model (CovModel1D or CovModel2D or CovModel3D or CovModel1D) – Covariance model to use. Available covariance models classes are:
in same dimension as dimension of points (d), i.e.:
CovModel1D class if data in 1D (d=1)
CovModel2D class if data in 2D (d=2)
CovModel3D class if data in 3D (d=3)
or CovModel1D whatever dimension of points (d):
used as an omni-directional covariance model
mean (None or float or ndarray) – mean of the simulation (for simple kriging only) Possible values are:
None : mean of hard data values (stationary), i.e. mean of v
float : for stationary mean (set manually)
ndarray: of of shape (nu,) for non stationary mean, mean at point xu
For ordinary kriging (method = ‘ordinary_kriging’) this parameter ignored (not used)
- Returns:
kriging weights kriging variance
- Return type:
(weight, variance)
- tpgs.zone_facies(g1v, g2v, flag_facies)¶
Given gaussian values for gaussian fields (g1v,g2v) check if the point is inside a certain facies and in which interval
- Parameters:
flag_facies (list) – list of thresholds for a certain facies. Comes from the flag.
- Returns:
index position to indicate which interval of the facies or None if the point is not inside
- Return type:
int