2. bim

Module for defining the class related the structure of the BIM.

class bim.BlocksInMatrix(slopeCoords, blockProp, tileSize, seed=None)[source]

Bases: object

Creates an instance of an object that defines the structure of the block-in-rock material (BIM) that composes the slope.

BlocksInMatrix(slopeCoords, blockProp, tileSize, seed=None)

The BIM is defined as a grided array of vertical square tiles. Each tile is composed either of block or matrix. Those cells that correspond to a block-tile have value one (1), those cells that correspond to a matrix-tile have value zero (0), and those cells tath are located outside the polygon have vale minus one (-1).

slopeCoords

Coordinates of the polygon within which the BIM is defined. It is expected that the polygon corresponds to the slope boundary that is obtained with the method defineBoundary either from the classes AnthropicSlope or NaturalSlope (module slope), however it works for any closed polygon.

Type:(n, 2) numpy.ndarray
blockProp

Proportion of blocks relative to the total volume of the BIM. It’s given as a value between 0 and 1.

Type:float
tileSize

Length of each tile-side.

Type:int or float
seed

Seed value for repeatability in the random generation of the blocks.

Type:float

Note

The class BlocksInMatrix requires numpy and matplotlib.

Examples

>>> from pybimstab.slope import AnthropicSlope
>>> from pybimstab.bim import BlocksInMatrix
>>> slope = AnthropicSlope(slopeHeight=12, slopeDip=[1, 1.5],
>>>                        crownDist=10, toeDist=10)
>>> bim = BlocksInMatrix(slopeCoords=slope.coords, blockProp=0.25,
>>>                      tileSize=0.25)
>>> bim.__dict__.keys()
dict_keys(['slopeCoords', 'blockProp', 'tileSize', 'seed', 'grid',
           'xCells', 'yCells'])
defineGrid()[source]

Method to create the grid-structure of the BIM into de boundary.

Those cells that correspond to a block-tile have value one (1), those cells that correspond to a matrix-tile have value zero (0), and those cells tath are located outside the polygon have vale minus one (-1).

Returns:\(\left(m \times n \right)\) matrix that defines a grid-graph that represents the structure of the BIM.
Return type:(numpy.ndarray)

Examples

>>> from numpy import array
>>> from pybimstab.bim import BlocksInMatrix
>>> slopeCoords = array([[0, 1, 1, 0, 0], [0, 0, 1, 1, 0]])
>>> bim = BlocksInMatrix(slopeCoords=slopeCoords, blockProp=0.5,
>>>                      tileSize=0.1, seed=123)
>>> bim.defineGrid()
array([[1., 0., 0., 1., 1., 0., 1., 1., 0., 0.],
       [0., 1., 0., 0., 0., 1., 0., 0., 1., 1.],
       [1., 1., 1., 1., 1., 0., 0., 0., 0., 1.],
       [0., 0., 0., 0., 0., 0., 0., 1., 1., 1.],
       [1., 0., 0., 0., 1., 0., 0., 1., 1., 1.],
       [0., 1., 1., 1., 0., 0., 0., 1., 1., 1.],
       [1., 1., 1., 1., 1., 0., 1., 0., 0., 1.],
       [0., 1., 1., 1., 0., 1., 1., 0., 0., 1.],
       [0., 1., 1., 0., 1., 1., 0., 0., 0., 0.]])
>>> from pybimstab.slope import AnthropicSlope
>>> from pybimstab.bim import BlocksInMatrix
>>> slope = AnthropicSlope(slopeHeight=12, slopeDip=[1, 1.5],
>>>                        crownDist=10, toeDist=10)
>>> bim = BlocksInMatrix(slopeCoords=slope.coords, blockProp=0.25,
>>>                      tileSize=0.25, seed=123)
>>> bim.defineGrid()
array([[-1., -1., -1., ..., -1., -1., -1.],
       [ 0.,  1.,  0., ...,  1.,  0.,  1.],
       [ 1.,  0.,  0., ...,  1.,  0.,  0.],
       ...,
       [ 0.,  1.,  0., ..., -1., -1., -1.],
       [ 0.,  0.,  0., ..., -1., -1., -1.],
       [ 0.,  0.,  0., ..., -1., -1., -1.]])
plot()[source]

Method for generating a graphic of the grid structure of the BIM.

Returns:object with the matplotlib structure of the plot. You might use it to save the figure for example.
Return type:(matplotlib.figure.Figure)

Examples

>>> from numpy import array
>>> from pybimstab.bim import BlocksInMatrix
>>> slopeCoords = array([[0, 1, 1, 0, 0], [0, 0, 1, 1, 0]])
>>> bim = BlocksInMatrix(slopeCoords=slopeCoords, blockProp=0.5,
>>>                      tileSize=0.1, seed=123)
>>> fig = bim.plot()
bim_example1

example script.

>>> from pybimstab.slope import AnthropicSlope
>>> from pybimstab.bim import BlocksInMatrix
>>> slope = AnthropicSlope(slopeHeight=12, slopeDip=[1, 1.5],
>>>                        crownDist=10, toeDist=10)
>>> bim = BlocksInMatrix(slopeCoords=slope.coords, blockProp=0.2,
>>>                      tileSize=0.25, seed=123)
>>> fig = bim.plot()
bim_example2
example script.
fig = bim.plot()
>>> from numpy import array
>>> from pybimstab.slope import NaturalSlope
>>> from pybimstab.bim import BlocksInMatrix
>>> terrainCoords = array(
>>>     [[-2.49, 0.1 , 1.7 , 3.89, 5.9 , 8.12, 9.87, 13.29, 20.29,
>>>       21.43, 22.28, 23.48, 24.65, 25.17],
>>>      [18.16, 17.88, 17.28, 15.73, 14.31, 13.58, 13, 3.61, 3.61,
>>>       3.32, 2.71, 2.23, 1.21, 0.25]])
>>> slope = NaturalSlope(terrainCoords)
>>> bim = BlocksInMatrix(slopeCoords=slope.coords, blockProp=0.25,
>>>                      tileSize=0.4, seed=123)
>>> fig = bim.plot()
bim_example3

example script.