MCRF and MCP¶
Markov-type categorical prediction and Markov chain random field simulation; both return the classes of the TP simulation page. See the guide.
mcp_predict
builtin
¶
mcp_predict(
model: TransitionModel,
grid: Grid | object,
coords: ArrayLike | str | object,
codes: ArrayLike | str | None = None,
*,
mask: ArrayLike | None = None,
neighbours: Literal["sectors"] | int | None = None,
closeness_limit: float = 0.01,
memory: int | None = None,
data: Mapping[str, ArrayLike] | object | None = None,
) -> Prediction
Markov-type categorical prediction (Li and Zhang): at each cell, the probability of each
category from its nearest hard data, p_k prod_g t_{k, c_g}(h_g) normalised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
TransitionModel
|
|
required |
grid
|
Grid
|
|
required |
coords
|
array_like
|
|
required |
codes
|
array_like or str
|
|
None
|
mask
|
array_like
|
|
None
|
neighbours
|
(sectors, int or None)
|
Nearest datum per quadrant (2D) or octant (3D) ("sectors" or None), or the nearest
|
None
|
closeness_limit
|
float
|
|
0.01
|
memory
|
int
|
|
None
|
data
|
mapping
|
|
None
|
Returns:
| Type | Description |
|---|---|
Prediction
|
|
Raises:
| Type | Description |
|---|---|
InvalidInput
|
When the coordinates are not |
Examples:
>>> model = tg.TransitionModel.from_geology(
... [0.5, 0.3, 0.2], [[40.0, 30.0, 20.0], [40.0, 30.0, 20.0], [4.0, 3.0, 2.0]])
>>> grid = tg.Grid((0.0, 0.0, 0.0), (10.0, 10.0, 1.0), (12, 12, 6))
>>> xyz, codes = [[55.0, 55.0, 0.5], [55.0, 55.0, 3.5], [5.0, 105.0, 2.5]], [0, 1, 2]
>>> cells, hard = grid.snap(xyz, codes)
>>> pred = tg.mcp_predict(model, grid, xyz, codes)
>>> pred.probabilities.shape
(864, 3)
>>> pred.most_likely[cells], hard
(array([0, 2, 1]), array([0, 2, 1]))
mcrf_simulate
builtin
¶
mcrf_simulate(
model: TransitionModel,
grid: Grid | object,
coords: ArrayLike | str | object,
codes: ArrayLike | str | None = None,
*,
n: int = 1,
seed: int = 0,
mask: ArrayLike | None = None,
neighbours: Literal["sectors"] | int | None = None,
closeness_limit: float = 0.01,
memory: int | None = None,
data: Mapping[str, ArrayLike] | object | None = None,
) -> Realizations
Sequential Markov chain random field simulation: cells visited along a seeded random path, each drawn from its MCP conditional given the hard data and the cells already simulated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
TransitionModel
|
As in |
required |
grid
|
TransitionModel
|
As in |
required |
coords
|
TransitionModel
|
As in |
required |
codes
|
TransitionModel
|
As in |
required |
mask
|
TransitionModel
|
As in |
required |
neighbours
|
TransitionModel
|
As in |
required |
closeness_limit
|
TransitionModel
|
As in |
required |
memory
|
TransitionModel
|
As in |
required |
data
|
TransitionModel
|
As in |
required |
n
|
int
|
Number of realizations. |
1
|
seed
|
int
|
|
0
|
Returns:
| Type | Description |
|---|---|
Realizations
|
|
Raises:
| Type | Description |
|---|---|
InvalidInput
|
When the coordinates are not |
Examples:
>>> model = tg.TransitionModel.from_geology(
... [0.5, 0.3, 0.2], [[40.0, 30.0, 20.0], [40.0, 30.0, 20.0], [4.0, 3.0, 2.0]])
>>> grid = tg.Grid((0.0, 0.0, 0.0), (10.0, 10.0, 1.0), (12, 12, 6))
>>> xyz, codes = [[55.0, 55.0, 0.5], [55.0, 55.0, 3.5], [5.0, 105.0, 2.5]], [0, 1, 2]
>>> cells, hard = grid.snap(xyz, codes)
>>> real = tg.mcrf_simulate(model, grid, xyz, codes, n=2, seed=1, neighbours=8)
>>> real.realizations.shape
(2, 864)
>>> bool(np.array_equal(real.realizations, tg.mcrf_simulate(model, grid, xyz, codes, n=2, seed=1, neighbours=8).realizations))
True