Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[ENH] Making sure that compute_model_at only computes the custom grid
  • Loading branch information
Leguark committed Jun 12, 2025
commit 341a9ae24e2d00d91044aadcb050fdb6ec7af9f3
7 changes: 5 additions & 2 deletions gempy/API/compute_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ def compute_model_at(gempy_model: GeoModel, at: np.ndarray,
Returns:
np.ndarray: The computed geological model at the specified coordinates.
"""

print("WARNING: This function sets a custom grid and computes the model so be wary of side effects.")
set_custom_grid(
grid=gempy_model.grid,
xyz_coord=at
xyz_coord=at,
reset=True
)

sol = compute_model(gempy_model, engine_config, validate_serialization=True)
return sol.raw_arrays.custom

Expand Down
4 changes: 2 additions & 2 deletions gempy/API/grid_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def set_topography_from_file(grid: Grid, filepath: str, crop_to_extent: Union[Se
return set_topography_from_subsurface_structured_grid(grid, struct)


def set_custom_grid(grid: Grid, xyz_coord: np.ndarray):
def set_custom_grid(grid: Grid, xyz_coord: np.ndarray, reset: bool = False):
custom_grid = CustomGrid(values=xyz_coord)
grid.custom_grid = custom_grid

set_active_grid(grid, [Grid.GridTypes.CUSTOM])
set_active_grid(grid, grid_type=[Grid.GridTypes.CUSTOM], reset=reset)
return grid.custom_grid


Expand Down