Skip to content

Commit 717ca35

Browse files
authored
Merge pull request #1020 from gempy-project/options_preset
[ENH] Add interpolation options type selection and improve documentation | GEN-12034
2 parents 765d22c + eb3b213 commit 717ca35

File tree

7 files changed

+42
-20
lines changed

7 files changed

+42
-20
lines changed

gempy/API/initialization_API.py

+34-16
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
from gempy.API.io_API import read_surface_points, read_orientations
88
from gempy_engine.core.data import InterpolationOptions
9-
from ..core.data.grid_modules import RegularGrid
10-
from ..optional_dependencies import require_subsurface
119
from ..core.data import StructuralElement
1210
from ..core.data.geo_model import GeoModel
1311
from ..core.data.grid import Grid
1412
from ..core.data.importer_helper import ImporterHelper
13+
from ..core.data.options import InterpolationOptionsType
1514
from ..core.data.orientations import OrientationsTable
1615
from ..core.data.structural_frame import StructuralFrame
1716
from ..core.data.surface_points import SurfacePointsTable
1817
from ..optional_dependencies import require_pooch
18+
from ..optional_dependencies import require_subsurface
1919

2020

2121
def create_geomodel(
@@ -26,23 +26,40 @@ def create_geomodel(
2626
refinement: int = 1,
2727
structural_frame: StructuralFrame = None,
2828
importer_helper: ImporterHelper = None,
29+
intpolation_options_tye: InterpolationOptionsType = InterpolationOptionsType.OCTREE,
2930
) -> GeoModel: # ? Do I need to pass pandas read kwargs?
3031
"""
31-
Initializes and returns a GeoModel instance with specified parameters.
32+
Creates a geological model based on input parameters, spatial configuration, and interpolation options.
33+
34+
This function initializes a geological model by defining the grid (dense grid or
35+
octree-based), selecting interpolation options based on the desired type, and
36+
configuring the structural frame using either a provided structural frame or an
37+
importer helper instance. The geological model is tailored for specific project-based
38+
requirements and can be either dense or with variable resolution depending on the
39+
refinement level.
3240
3341
Args:
34-
project_name (str, optional): The name of the project. Defaults to 'default_project'.
35-
extent (Union[List, np.ndarray], optional): The 3D extent of the grid. Must be provided if resolution is specified. Defaults to None.
36-
resolution (Union[List, np.ndarray], optional): The resolution of the grid. If None, an octree grid will be initialized. Defaults to None.
37-
refinement (int, optional): The level of refinement for the octree grid. Defaults to 1.
38-
structural_frame (StructuralFrame, optional): The structural frame of the GeoModel. Either this or importer_helper must be provided. Defaults to None.
39-
importer_helper (ImporterHelper, optional): Helper object for importing structural elements. Either this or structural_frame must be provided. Defaults to None.
42+
project_name (str): Name of the geological model project. Defaults to 'default_project'.
43+
extent (list, ndarray): Spatial extent of the geological model in the form of
44+
[min_x, max_x, min_y, max_y, min_z, max_z].
45+
resolution (list, ndarray): Resolution of the model grid in the form [x_res, y_res, z_res].
46+
If not provided, the function will default to octree initialization.
47+
refinement (int): Refinement level for the octree grid. Ignored if resolution is provided.
48+
Defaults to 1.
49+
structural_frame (StructuralFrame): Pre-configured instance of StructuralFrame
50+
for the geological model. If not provided, an importer_helper must be supplied.
51+
importer_helper (ImporterHelper): Helper object for initializing a structural frame if none
52+
is explicitly provided.
53+
intpolation_options_tye (InterpolationOptionsType): Enum representing the desired type of
54+
interpolation options. Defaults to InterpolationOptionsType.OCTREE.
4055
4156
Returns:
42-
GeoModel: The initialized GeoModel object.
57+
GeoModel: An initialized geological model with specified spatial configuration
58+
and interpolation properties.
4359
4460
Raises:
4561
ValueError: If neither structural_frame nor importer_helper is provided.
62+
ValueError: If the interpolation options type is unrecognized.
4663
"""
4764

4865
# init resolutions well
@@ -57,12 +74,13 @@ def create_geomodel(
5774
resolution=resolution
5875
)
5976

60-
interpolation_options: InterpolationOptions = InterpolationOptions(
61-
range=1.7,
62-
c_o=10,
63-
mesh_extraction=True,
64-
number_octree_levels=refinement,
65-
)
77+
match intpolation_options_tye:
78+
case InterpolationOptionsType.DENSE_GRID:
79+
interpolation_options: InterpolationOptions = InterpolationOptions.init_dense_grid_options()
80+
case InterpolationOptionsType.OCTREE:
81+
interpolation_options: InterpolationOptions = InterpolationOptions.init_octree_options(refinement=refinement)
82+
case _:
83+
raise ValueError(f"Interpolation options type {intpolation_options_tye} not recognized. Use InterpolationOptionsType.DENSE_GRID or InterpolationOptionsType.OCTREE.")
6684

6785
match (structural_frame, importer_helper):
6886
case (None, None):

gempy/core/data/options.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import enum
2+
class InterpolationOptionsType(enum.Enum):
3+
4+
DENSE_GRID = enum.auto()
5+
OCTREE = enum.auto()

requirements/base-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-r requirements.txt
22

33
# This install matplotlib
4-
gempy_viewer~=2024.2.0
4+
gempy_viewer~=2025.1.0
55
pandas

requirements/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This install also numpy
2-
gempy_engine~=2024.2.0
2+
gempy_engine~=2025.1.1

test/test_QA/__init__.py

Whitespace-only changes.

test/test_QA/test_chuncking.py

Whitespace-only changes.

test/test_modules/test_marching_cubes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def test_marching_cubes_implementation():
2626
reset=True
2727
)
2828

29-
model.interpolation_options.evaluation_options.number_octree_levels = 1
30-
model.interpolation_options.evaluation_options.mesh_extraction = False # * Not extracting the mesh with dual contouring
29+
model.interpolation_options = gp.data.InterpolationOptions.init_dense_grid_options()
3130
gp.compute_model(model)
3231

3332
# Assert

0 commit comments

Comments
 (0)