|
| 1 | +import os |
| 2 | +import pathlib |
| 3 | +import dotenv |
| 4 | + |
| 5 | +import gempy as gp |
| 6 | +from gempy.API.io_API import read_surface_points |
| 7 | +from gempy.core.data.surface_points import SurfacePointsTable |
| 8 | +import gempy_viewer as gpv |
| 9 | + |
| 10 | +dotenv.load_dotenv() |
| 11 | + |
| 12 | + |
| 13 | +def test_2025_2(): |
| 14 | + rescale = 20 |
| 15 | + range_ = 2.4 |
| 16 | + orientation_loc = -286 * rescale |
| 17 | + # path_to_data = os.getenv("TEST_DATA") |
| 18 | + path_to_data = r"C:/Users/Benjamink/OneDrive - Mira Geoscience Limited/Documents/projects/implicit modelling/Nutrien/demo_terranigma/from_miguel" |
| 19 | + |
| 20 | + data = { |
| 21 | + "a": read_surface_points(f"{path_to_data}/a_cleaned.dat"), |
| 22 | + "b": read_surface_points(f"{path_to_data}/b.dat"), |
| 23 | + "c": read_surface_points(f"{path_to_data}/c.dat"), |
| 24 | + "d": read_surface_points(f"{path_to_data}/d.dat"), |
| 25 | + "e": read_surface_points(f"{path_to_data}/e.dat"), |
| 26 | + "f": read_surface_points(f"{path_to_data}/f.dat"), |
| 27 | + } |
| 28 | + |
| 29 | + # rescale the Z values |
| 30 | + data = { |
| 31 | + k: SurfacePointsTable.from_arrays( |
| 32 | + x=v.data["X"], |
| 33 | + y=v.data["Y"], |
| 34 | + z=rescale * v.data["Z"], |
| 35 | + names=[k] * len(v.data), |
| 36 | + nugget=v.data["nugget"] |
| 37 | + ) |
| 38 | + for k, v in data.items() |
| 39 | + } |
| 40 | + |
| 41 | + color_generator = gp.data.ColorsGenerator() |
| 42 | + elements = [] |
| 43 | + for event, pts in data.items(): |
| 44 | + orientations = gp.data.OrientationsTable.initialize_empty() |
| 45 | + element = gp.data.StructuralElement( |
| 46 | + name=event, |
| 47 | + color=next(color_generator), |
| 48 | + surface_points=pts, |
| 49 | + orientations=orientations, |
| 50 | + ) |
| 51 | + elements.append(element) |
| 52 | + |
| 53 | + group = gp.data.StructuralGroup( |
| 54 | + name="Series1", |
| 55 | + elements=elements, |
| 56 | + structural_relation=gp.data.StackRelationType.ERODE, |
| 57 | + fault_relations=gp.data.FaultsRelationSpecialCase.OFFSET_FORMATIONS, |
| 58 | + ) |
| 59 | + structural_frame = gp.data.StructuralFrame( |
| 60 | + structural_groups=[group], color_gen=color_generator |
| 61 | + ) |
| 62 | + |
| 63 | + xmin = 525816 |
| 64 | + xmax = 543233 |
| 65 | + ymin = 5652470 |
| 66 | + ymax = 5657860 |
| 67 | + zmin = -780 * rescale |
| 68 | + zmax = -636 * rescale |
| 69 | + |
| 70 | + # * Add 20% to extent |
| 71 | + xmin -= 0.2 * (xmax - xmin) |
| 72 | + xmax += 0.2 * (xmax - xmin) |
| 73 | + ymin -= 0.2 * (ymax - ymin) |
| 74 | + ymax += 0.2 * (ymax - ymin) |
| 75 | + zmin -= 0.2 * (zmax - zmin) |
| 76 | + zmax += 1 * (zmax - zmin) |
| 77 | + |
| 78 | + geo_model = gp.create_geomodel( |
| 79 | + project_name="test", |
| 80 | + extent=[xmin, xmax, ymin, ymax, zmin, zmax], |
| 81 | + refinement=5, |
| 82 | + structural_frame=structural_frame, |
| 83 | + ) |
| 84 | + |
| 85 | + if False: |
| 86 | + gpv.plot_3d( |
| 87 | + model=geo_model, |
| 88 | + ve=40, |
| 89 | + image=True, |
| 90 | + kwargs_pyvista_bounds={ |
| 91 | + 'show_xlabels': False, |
| 92 | + 'show_ylabels': False, |
| 93 | + } |
| 94 | + ) |
| 95 | + |
| 96 | + geo_model.interpolation_options.evaluation_options.number_octree_levels_surface = 4 |
| 97 | + geo_model.interpolation_options.kernel_options.range = range_ |
| 98 | + |
| 99 | + gp.add_orientations( |
| 100 | + geo_model=geo_model, |
| 101 | + x=[525825], |
| 102 | + y=[5651315], |
| 103 | + z=[orientation_loc], # * Moving the orientation further |
| 104 | + pole_vector=[[0, 0, 1]], |
| 105 | + elements_names=["a"] |
| 106 | + ) |
| 107 | + solution = gp.compute_model( |
| 108 | + geo_model, |
| 109 | + engine_config=gp.data.GemPyEngineConfig( |
| 110 | + backend=gp.data.AvailableBackends.numpy |
| 111 | + ), |
| 112 | + ) |
| 113 | + |
| 114 | + gpv.plot_3d( |
| 115 | + model=geo_model, |
| 116 | + ve=2, |
| 117 | + show_lith=True, |
| 118 | + image=False, |
| 119 | + kwargs_pyvista_bounds={ |
| 120 | + 'show_xlabels': False, |
| 121 | + 'show_ylabels': False, |
| 122 | + 'show_zlabels': False, |
| 123 | + }, |
| 124 | + ) |
| 125 | + |
| 126 | +if __name__ == "__main__": |
| 127 | + test_2025_2() |
0 commit comments