geolime.operations.grid.editing

Classes:

BlockModel(data, metadata)

StatKind(value)

An enumeration.

Functions:

extend_grid_2d(bm, extension)

Extends a regular 2d bm with a given extension.

fill_missing_x_y(bm)

flatten_grid(bm[, sorting_type])

Flatten a DataFrame that has many rows with same (x,y).

geolime.operations.grid.editing.extend_grid_2d(bm: geolime.objects.blockmodel.BlockModel, extension: float)

Extends a regular 2d bm with a given extension. And then fills the new rows with the fill_missing_x_y function.

Parameters
  • bm (BlockModel) – GeoLime BlockModel object

  • extension (float) – Value of the extension to add

Returns

bm – GeoLime BlockModel object

Return type

BlockModel

Example

>>> bm.df
    x  y  z
0   0  0  0
1   0  0  1
2   0  1  2
3   0  1  0
4   0  2  1
5   0  2  2
6   1  0  0
7   1  0  1
8   1  1  2
9   1  1  0
10  1  2  1
11  1  2  2
12  2  0  0
13  2  0  1
14  2  1  2
15  2  1  0
16  2  2  1
17  2  2  2
>>> extend_grid_2d(bm,1)
    x  y    z
0  -1 -1  NaN
1  -1  0  NaN
2  -1  1  NaN
3  -1  2  NaN
4  -1  3  NaN
5   0 -1  NaN
6   0  0  0.0
7   0  0  1.0
8   0  1  2.0
9   0  1  0.0
10  0  2  1.0
11  0  2  2.0
12  0  3  NaN
13  1 -1  NaN
14  1  0  0.0
15  1  0  1.0
16  1  1  2.0
17  1  1  0.0
18  1  2  1.0
19  1  2  2.0
20  1  3  NaN
21  2 -1  NaN
22  2  0  0.0
23  2  0  1.0
24  2  1  2.0
25  2  1  0.0
26  2  2  1.0
27  2  2  2.0
28  2  3  NaN
29  3 -1  NaN
30  3  0  NaN
31  3  1  NaN
32  3  2  NaN
33  3  3  NaN
geolime.operations.grid.editing.fill_missing_x_y(bm: geolime.objects.blockmodel.BlockModel)

” Take a x,y bm and fill the missing x,y blocks.

Parameters

bm (BlockModel) – GeoLime BlockModel object

Returns

bm – GeoLime BlockModel object

Return type

BlockModel

Example

>>> bm.df
    x  y    z
0   0  0  0.0
1   0  0  1.0
2   0  1  2.0
3   0  1  0.0
4   0  2  1.0
5   0  2  2.0
6   1  0  0.0
7   1  0  1.0
8   1  1  2.0
9   1  1  0.0
10  1  2  1.0
11  1  2  2.0
12  2  0  0.0
13  2  0  1.0
14  2  1  2.0
15  2  1  0.0
16  2  2  1.0
17  2  2  2.0
18 -1 -1  NaN
19  3  3  NaN
>>> fill_missing_x_y(bm)
    x  y    z
0  -1 -1  NaN
1  -1  0  NaN
2  -1  1  NaN
3  -1  2  NaN
4  -1  3  NaN
5   0 -1  NaN
6   0  0  0.0
7   0  0  1.0
8   0  1  2.0
9   0  1  0.0
10  0  2  1.0
11  0  2  2.0
12  0  3  NaN
13  1 -1  NaN
14  1  0  0.0
15  1  0  1.0
16  1  1  2.0
17  1  1  0.0
18  1  2  1.0
19  1  2  2.0
20  1  3  NaN
21  2 -1  NaN
22  2  0  0.0
23  2  0  1.0
24  2  1  2.0
25  2  1  0.0
26  2  2  1.0
27  2  2  2.0
28  2  3  NaN
29  3 -1  NaN
30  3  0  NaN
31  3  1  NaN
32  3  2  NaN
33  3  3  NaN
geolime.operations.grid.editing.flatten_grid(bm: geolime.objects.blockmodel.BlockModel, sorting_type: geolime.enumerator.enumerator.StatKind = <StatKind.AVG: 'AVG'>)

Flatten a DataFrame that has many rows with same (x,y).

The function spatially flattens the bm : for one (x,y) with many z, only one row is kept using the defined sorting type

Parameters
  • bm (BlockModel) – GeoLime BlockModel object

  • sorting_type (StatKind, optional) – Type of how the values over a z column are flattened : - StatKind.AVG : mean value of the column is taken - StatKind.MIN : minimum value of the column is taken - StatKind.MAX : maximum value of the column is taken

Returns

bm – GeoLime BlockModel Object

Return type

BlockModel

Example

>>> bm.df
    x  y  z
0   0  0  0
1   0  0  1
2   0  1  2
3   0  1  0
4   0  2  1
5   0  2  2
6   1  0  0
7   1  0  1
8   1  1  2
9   1  1  0
10  1  2  1
11  1  2  2
12  2  0  0
13  2  0  1
14  2  1  2
15  2  1  0
16  2  2  1
17  2  2  2
>>> flatten_grid(bm)
   x  y  z
0  0  0  0.5
1  0  1  1.0
2  0  2  1.5
3  1  0  0.5
4  1  1  1.0
5  1  2  1.5
6  2  0  0.5
7  2  1  1.0
8  2  2  1.5
>>> flatten_grid(bm, sorting_type = StatKind.MIN)
   x  y  z
0  0  0  0
1  0  1  0
2  0  2  1
3  1  0  0
4  1  1  0
5  1  2  1
6  2  0  0
7  2  1  0
8  2  2  1