%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
return false;
}
import numpy as np
import os
import pandas as pd
import gstlearn as gl
import gstlearn.plot as gp
We construct a Meshing Standard based on a set of Data Points
nech = 40
extendmin = [0,0]
extendmax = [150,100]
data = gl.Db.createFromBox(nech,extendmin, extendmax)
data
Data Base Characteristics ========================= Data Base Summary ----------------- File is organized as a set of isolated points Space dimension = 2 Number of Columns = 3 Maximum Number of UIDs = 3 Total number of samples = 40 Variables --------- Column = 0 - Name = rank - Locator = NA Column = 1 - Name = x-1 - Locator = x1 Column = 2 - Name = x-2 - Locator = x2
gp.setDefaultGeographic(dims=[7,7])
ax = data.plot()
ax.decoration(title="Display of Data Set")
Creating the Meshing
Instead we can use Turbo Meshing to cover an area, without specifically honoring each datum
mesh3 = gl.MeshETurbo()
err = mesh3.initFromExtend(extendmin, extendmax, [5,5])
mesh3.display()
Grid characteristics: --------------------- Origin : 0.000 0.000 Mesh : 5.000 5.000 Number : 31 21 Turbo Meshing ============= Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 1200 Number of Apices = 651 Bounding Box Extension ---------------------- Dim #1 - Min:0 - Max:150 Dim #2 - Min:0 - Max:100
ax = mesh3.plot()
ax.decoration(title="Turbo Meshing on the whole area")
ax = data.plot(color="black")
We can create a regular grid covering the same area (based on the data set)
grid = gl.DbGrid()
err = grid.resetCoveringDb(data, [50,50])
Define a Polygon as the Convex hull of the data
polygon = gl.Polygons()
err = polygon.resetFromDb(data)
Use the Polygon to mask off some nodes of the regular grid, located too far from the data
err = gl.db_polygon(grid, polygon)
We create a Turbo Meshing from the grid (which contains a selection)
mesh4 = gl.MeshETurbo(grid)
mesh4.display()
Grid characteristics: --------------------- Origin : 0.648 3.385 Mesh : 2.892 1.928 Number : 50 50 Turbo Meshing ============= Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 3481 Number of Apices = 1830 Bounding Box Extension ---------------------- Dim #1 - Min:0.648392 - Max:142.336 Dim #2 - Min:3.38503 - Max:97.8622 Mask Information ................ Mesh Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 4802 - Number of active positions = 3481 Grid Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 2500 - Number of active positions = 1830
ax = mesh4.plot()
ax = data.plot(color="black")
ax = polygon.plot()
ax.decoration(title="Turbo Meshing restricted to the Convex Hull of Data")
Testing the read and write into a Neutral File (with masked meshes)
gl.ASerializable.setContainerName(True)
gl.ASerializable.setPrefixName("Tuto-Meshing")
err = mesh4.dumpToNF("Mesh_masked")
mesh5 = gl.MeshETurbo.createFromNF("Mesh_masked")
mesh5.display()
Grid characteristics: --------------------- Origin : 0.648 3.385 Mesh : 2.892 1.928 Number : 50 50 Turbo Meshing ============= Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 3481 Number of Apices = 1830 Bounding Box Extension ---------------------- Dim #1 - Min:0.648392 - Max:142.336 Dim #2 - Min:3.38503 - Max:97.8624 Mask Information ................ Mesh Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 4802 - Number of active positions = 3481 Grid Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 2500 - Number of active positions = 1830
mesh5.display()
Grid characteristics: --------------------- Origin : 0.648 3.385 Mesh : 2.892 1.928 Number : 50 50 Turbo Meshing ============= Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 3481 Number of Apices = 1830 Bounding Box Extension ---------------------- Dim #1 - Min:0.648392 - Max:142.336 Dim #2 - Min:3.38503 - Max:97.8624 Mask Information ................ Mesh Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 4802 - Number of active positions = 3481 Grid Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 2500 - Number of active positions = 1830
grid = gl.DbGrid.create(nx=[6,4], dx=[1.,5.], x0=[10.,20.], angles=[-80.,0.])
grid.display()
ax = gp.point(grid,color="black")
Data Base Grid Characteristics ============================== Data Base Summary ----------------- File is organized as a regular grid Space dimension = 2 Number of Columns = 3 Maximum Number of UIDs = 3 Total number of samples = 24 Grid characteristics: --------------------- Origin : 10.000 20.000 Mesh : 1.000 5.000 Number : 6 4 Rotation Angles = -80.000 0.000 Direct Rotation Matrix [, 0] [, 1] [ 0,] 0.174 0.985 [ 1,] -0.985 0.174 Inverse Rotation Matrix [, 0] [, 1] [ 0,] 0.174 -0.985 [ 1,] 0.985 0.174 Variables --------- Column = 0 - Name = rank - Locator = NA Column = 1 - Name = x1 - Locator = x1 Column = 2 - Name = x2 - Locator = x2
model = gl.Model.createFromParam(gl.ECov.CUBIC,ranges=[10.,5.], angles=[30.,0.])
model.display()
Model characteristics ===================== Space dimension = 2 Number of variable(s) = 1 Number of basic structure(s) = 1 Number of drift function(s) = 0 Number of drift equation(s) = 0 Covariance Part --------------- Cubic - Sill = 1.000 - Ranges = 10.000 5.000 - Angles = 30.000 0.000 - Rotation Matrix [, 0] [, 1] [ 0,] 0.866 -0.500 [ 1,] 0.500 0.866 Total Sill = 1.000
mesh6 = gl.MeshETurbo()
mesh6.initFromCova(model.getCova(0),grid,ratio=10,nbExt=2,flagNoStatRot=False,useSel=True)
mesh6.display()
Grid characteristics: --------------------- Origin : 12.201 8.767 Mesh : 1.000 0.500 Number : 21 25 Rotation Angles = 30.000 0.000 Direct Rotation Matrix [, 0] [, 1] [ 0,] 0.866 -0.500 [ 1,] 0.500 0.866 Inverse Rotation Matrix [, 0] [, 1] [ 0,] 0.866 0.500 [ 1,] -0.500 0.866 Turbo Meshing ============= Diamond construction is activated Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 960 Number of Apices = 525 Bounding Box Extension ---------------------- Dim #1 - Min:12.2013 - Max:32.2013 Dim #2 - Min:8.76696 - Max:20.767
ax = mesh6.plot()
ax = gp.point(grid,color="black")
ax.decoration(title="Turbo Meshing for Rotated Grid")