Grid Refinement¶
This case study is meant to demonstrate how to use gstlearn for coarsening or refining Grids (stored as DbGrid).
In [1]:
import gstlearn as gl
import gstlearn.plot as gp
import gstlearn.document as gdoc
import matplotlib.pyplot as plt
import numpy as np
gdoc.setNoScroll()
Global parameters
In [2]:
ndim = 2
gl.defineDefaultSpace(gl.ESpaceType.RN,ndim)
Generate initial grid
In [3]:
grid = gl.DbGrid.create([100,100], [0.01,0.01])
In [4]:
iatt = grid.addColumnsByConstant(1,1.2,"Bidon1")
model_init = gl.Model.createFromParam(gl.ECov.EXPONENTIAL, 0.1, 1.)
iatt = gl.simtub(None, grid, model_init)
iatt = grid.addColumnsByConstant(2,1.2,"Bidon2")
In [5]:
grid.display()
Data Base Grid Characteristics ============================== Data Base Summary ----------------- File is organized as a regular grid Space dimension = 2 Number of Columns = 7 Total number of samples = 10000 Grid characteristics: --------------------- Origin : 0.000 0.000 Mesh : 0.010 0.010 Number : 100 100 Variables --------- Column = 0 - Name = rank - Locator = NA Column = 1 - Name = x1 - Locator = x1 Column = 2 - Name = x2 - Locator = x2 Column = 3 - Name = Bidon1 - Locator = NA Column = 4 - Name = Simu - Locator = z1 Column = 5 - Name = Bidon2-1 - Locator = NA Column = 6 - Name = Bidon2-2 - Locator = NA
In [6]:
ax = grid.plot()
A new grid is created, coarser than the initial one
In [7]:
nmult = [3,3]
gridCoarse = grid.coarsify(nmult)
In [8]:
gridCoarse
Out[8]:
Data Base Grid Characteristics ============================== Data Base Summary ----------------- File is organized as a regular grid Space dimension = 2 Number of Columns = 7 Total number of samples = 1089 Grid characteristics: --------------------- Origin : 0.010 0.010 Mesh : 0.030 0.030 Number : 33 33 Variables --------- Column = 0 - Name = rank - Locator = NA Column = 1 - Name = x1 - Locator = x1 Column = 2 - Name = x2 - Locator = x2 Column = 3 - Name = Bidon1 - Locator = NA Column = 4 - Name = Simu - Locator = z1 Column = 5 - Name = Bidon2-1 - Locator = NA Column = 6 - Name = Bidon2-2 - Locator = NA
In [9]:
ax = gridCoarse.plot()
Another finer grid is created, starting from the Coarse grid.
In [10]:
gridFine = gridCoarse.refine(nmult)
In [11]:
gridFine
Out[11]:
Data Base Grid Characteristics ============================== Data Base Summary ----------------- File is organized as a regular grid Space dimension = 2 Number of Columns = 7 Total number of samples = 9409 Grid characteristics: --------------------- Origin : 0.010 0.010 Mesh : 0.010 0.010 Number : 97 97 Variables --------- Column = 0 - Name = rank - Locator = NA Column = 1 - Name = x1 - Locator = x1 Column = 2 - Name = x2 - Locator = x2 Column = 3 - Name = Bidon1 - Locator = NA Column = 4 - Name = Simu - Locator = z1 Column = 5 - Name = Bidon2-1 - Locator = NA Column = 6 - Name = Bidon2-2 - Locator = NA
In [12]:
ax = gridFine.plot()