Skip to content

Commit 4a76201

Browse files
authored
[ENH] Add name_id_map parameter to add_orientations and enable serialization validation (#1060)
# Description Added support for name_id_map parameter in add_orientations function to maintain consistent ID mapping between surface points and orientations. Updated the Hecho example to use this parameter and fixed tuple formatting in section_dict. Also enabled validation during serialization in the compute_model call. Relates to #validation-and-serialization-improvements # Checklist - [ ] My code uses type hinting for function and method arguments and return values. - [ ] I have created tests which cover my code. - [ ] The test code either 1. demonstrates at least one valuable use case (e.g. integration tests) or 2. verifies that outputs are as expected for given inputs (e.g. unit tests). - [ ] New tests pass locally with my changes.
2 parents 436f0f9 + fd5675f commit 4a76201

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

examples/examples/real/Hecho.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# Aux imports
1414
import pandas as pn
15+
from gempy.modules.serialization.save_load import _validate_serialization
1516

1617
# Importing gempy
1718
import gempy as gp
@@ -126,7 +127,7 @@
126127
gp.set_section_grid(
127128
grid=geo_model.grid,
128129
section_dict={
129-
'section': ([0, 0], [16, 0], [321, 91])
130+
'section': ((0., 0.), (16., 0.), (321, 91))
130131
},
131132
)
132133

@@ -149,7 +150,8 @@
149150
y=new_orientations.data['Y'],
150151
z=new_orientations.data['Z'],
151152
pole_vector=new_orientations.grads,
152-
elements_names=fn
153+
elements_names=fn,
154+
name_id_map=element.surface_points.name_id_map
153155
)
154156

155157
# %%
@@ -216,14 +218,15 @@
216218
# Setting verbose and condition number options for debugging
217219
geo_model.interpolation_options.kernel_options.compute_condition_number = True
218220

221+
219222
# %%
220223
gp.compute_model(
221224
gempy_model=geo_model,
222225
engine_config=gp.data.GemPyEngineConfig(
223226
backend=gp.data.AvailableBackends.PYTORCH,
224227
dtype='float64'
225228
),
226-
validate_serialization=False
229+
validate_serialization=True
227230
)
228231

229232
# %%

gempy/modules/data_manipulation/manipulate_points.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def add_orientations(geo_model: GeoModel,
9696
elements_names: Sequence[str],
9797
pole_vector: Optional[Union[Sequence[np.ndarray], np.ndarray]] = None,
9898
orientation: Optional[Union[Sequence[np.ndarray], np.ndarray]] = None,
99-
nugget: Optional[Sequence[float]] = None
99+
nugget: Optional[Sequence[float]] = None,
100+
name_id_map: Optional[dict[str, int]] = None #: A mapping between orientation names and ids.
100101
) -> StructuralFrame:
101102
"""Add orientation data to the geological model.
102103
@@ -176,6 +177,7 @@ def add_orientations(geo_model: GeoModel,
176177
G_z=data['pole_vector'][..., 2],
177178
names=[element_name] * len(data['x']),
178179
nugget=data['nugget'],
180+
name_id_map=name_id_map
179181
)
180182

181183
element: StructuralElement = geo_model.structural_frame.get_element_by_name(element_name)

0 commit comments

Comments
 (0)