|
| 1 | +import dataclasses |
1 | 2 | import os
|
2 | 3 | import pytest
|
3 | 4 | import matplotlib.pyplot as plt
|
4 | 5 | import numpy as np
|
5 | 6 |
|
| 7 | +from gempy_engine.API.interp_single._interp_scalar_field import _solve_interpolation, _evaluate_sys_eq |
| 8 | +from gempy_engine.API.interp_single._interp_single_feature import input_preprocess |
| 9 | +from gempy_engine.core.data.internal_structs import SolverInput |
6 | 10 | from gempy_engine.core.data.interp_output import InterpOutput
|
7 | 11 | from gempy_engine.modules.activator.activator_interface import activate_formation_block
|
8 | 12 | from gempy_engine.API.interp_single.interp_features import interpolate_single_field
|
@@ -35,21 +39,51 @@ def test_activator(simple_model_values_block_output):
|
35 | 39 | plt.show()
|
36 | 40 |
|
37 | 41 |
|
38 |
| -@pytest.mark.skip(reason="This is unfinished I have to extract the 3 layers values") |
39 |
| -def test_activator_3_layers(simple_model_3_layers): |
40 |
| - interpolation_input, options, structure = simple_model_3_layers |
| 42 | +# @pytest.mark.skip(reason="This is unfinished I have to extract the 3 layers values") |
| 43 | +def test_activator_3_layers(simple_model_3_layers, simple_grid_3d_more_points_grid): |
| 44 | + interpolation_input = simple_model_3_layers[0] |
| 45 | + options = simple_model_3_layers[1] |
| 46 | + data_shape = simple_model_3_layers[2].tensors_structure |
| 47 | + grid = dataclasses.replace(simple_grid_3d_more_points_grid) |
| 48 | + interpolation_input.grid = grid |
| 49 | + |
| 50 | + ids = np.array([1, 2, 3, 4]) |
41 | 51 |
|
42 |
| - res = interpolation_input.grid.regular_grid.resolution |
| 52 | + interp_input: SolverInput = input_preprocess(data_shape, interpolation_input) |
| 53 | + weights = _solve_interpolation(interp_input, options.kernel_options) |
43 | 54 |
|
44 |
| - output: InterpOutput = interpolate_single_field(interpolation_input, options, structure) |
45 |
| - Z_x = output.exported_fields.scalar_field |
| 55 | + exported_fields = _evaluate_sys_eq(interp_input, weights, options) |
| 56 | + |
| 57 | + exported_fields.set_structure_values( |
| 58 | + reference_sp_position=data_shape.reference_sp_position, |
| 59 | + slice_feature=interpolation_input.slice_feature, |
| 60 | + grid_size=interpolation_input.grid.len_all_grids) |
| 61 | + |
| 62 | + Z_x: np.ndarray = exported_fields.scalar_field |
| 63 | + sasp = exported_fields.scalar_field_at_surface_points |
| 64 | + ids = np.array([1, 2, 3, 4]) |
| 65 | + |
| 66 | + print(Z_x, Z_x.shape[0]) |
| 67 | + print(sasp) |
| 68 | + |
| 69 | + |
| 70 | + ids_block = activate_formation_block( |
| 71 | + exported_fields=exported_fields, |
| 72 | + ids= ids, |
| 73 | + sigmoid_slope=50000 |
| 74 | + )[:, :-7] |
46 | 75 |
|
47 | 76 | if plot:
|
48 |
| - plt.contourf(Z_x.reshape(res)[:, 0, :].T, N=40, cmap="autumn", |
| 77 | + plt.contourf(Z_x.reshape(50, 5, 50)[:, 0, :].T, N=40, cmap="autumn", |
49 | 78 | extent=(.25, .75, .25, .75))
|
50 | 79 |
|
51 | 80 | xyz = interpolation_input.surface_points.sp_coords
|
52 | 81 | plt.plot(xyz[:, 0], xyz[:, 2], "o")
|
53 | 82 | plt.colorbar()
|
54 | 83 |
|
55 | 84 | plt.show()
|
| 85 | + |
| 86 | + plt.contourf(ids_block[0, :-4].reshape(50, 5, 50)[:, 2, :].T, N=40, cmap="viridis") |
| 87 | + plt.colorbar() |
| 88 | + |
| 89 | + plt.show() |
0 commit comments