%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
return false;
}
This case study is meant to demonstrate how to use gstlearn for coarsening or refining Grids (stored as DbGrid).
import gstlearn as gl
import gstlearn.plot as gp
import matplotlib.pyplot as plt
import numpy as np
Global parameters
ndim = 2
gl.defineDefaultSpace(gl.ESpaceType.RN,ndim)
Generate initial grid
grid = gl.DbGrid.create([100,100], [0.01,0.01])
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")
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
ax = grid.plot()
A new grid is created, coarser than the initial one
nmult = [3,3]
gridCoarse = grid.coarsify(nmult)
gridCoarse
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
ax = gridCoarse.plot()
Another finer grid is created, starting from the Coarse grid.
gridFine = gridCoarse.refine(nmult)
gridFine
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
ax = gridFine.plot()