Skip to content

Commit f3b2b54

Browse files
committed
Merge branch 'pull/333' into release
# Conflicts: # gempy/core/data.py # test/test_core/test_grids/test_grid.py
2 parents 0cc36ff + 7c0f000 commit f3b2b54

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

gempy/core/data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def create_centered_grid(self, centers, radius, resolution=None):
201201
self.set_active('centered')
202202

203203
def deactivate_all_grids(self):
204+
"""
205+
Deactivates the active grids array
206+
:return:
207+
"""
204208
self.active_grids = np.zeros(5, dtype=bool)
205209
self.update_grid_values()
206210
return self.active_grids

gempy/core/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def set_custom_grid(self, custom_grid):
216216
if self.grid.custom_grid is None:
217217
self.grid.create_custom_grid(custom_grid)
218218
else:
219-
self.grid.custom_grid.set_custmo_grid(custom_grid)
219+
self.grid.custom_grid.set_custom_grid(custom_grid)
220220
self.grid.update_grid_values()
221221

222222
self.update_from_grid()
@@ -1051,8 +1051,8 @@ def set_surface_order_from_solution(self):
10511051
Surfaces
10521052
"""
10531053
# TODO time this function
1054-
# spu = self.surface_points.df['surface'].unique()
1055-
# sps = self.surface_points.df['series'].unique()
1054+
# spu = self.surface_points.df['surface'].unique()
1055+
# sps = self.surface_points.df['series'].unique()
10561056

10571057
# # Boolean array of size len surfaces with True active surfaces minus Basemes
10581058
# sel = self.surfaces.df['isActive'] & ~self.surfaces.df['isBasement'] #self.surfaces.df['surface'].isin(spu)

test/test_core/test_grids/test_grid.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,22 @@ def test_set_section_twice(self):
5050
geo_data.set_section_grid(section_dict)
5151
geo_data.set_section_grid(section_dict)
5252
print(geo_data.grid.sections)
53+
54+
55+
def test_custom_grid(self):
56+
# create custom grid
57+
grid = gp.Grid()
58+
cg = np.array([[1, 2, 3],
59+
[4, 5, 6],
60+
[7, 8, 9]])
61+
grid.create_custom_grid(cg)
62+
# make sure the custom grid is active
63+
assert grid.active_grids[1]
64+
# make sure the custom grid is equal to the provided values
65+
np.testing.assert_array_almost_equal(cg, grid.custom_grid.values)
66+
# make sure we have the correct number of values in our grid
67+
l0, l1 = grid.get_grid_args('custom')
68+
assert l0 == 0
69+
assert l1 == 3
70+
71+

test/test_core/test_solution.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import gempy
22
import os
3+
import numpy as np
34
input_path = os.path.dirname(__file__)+'/../input_data'
45

56

67
def test_rescaled_marching_cube(interpolator_islith_nofault):
78
"""
8-
2 Horizontal layers with drift 0
9-
"""
9+
2 Horizontal layers with drift 0
10+
"""
1011
# Importing the data from csv files and settign extent and resolution
1112
geo_data = gempy.create_data([0, 10, 0, 10, -10, 0], [50, 50, 50],
1213
path_o=input_path + "/GeoModeller/test_a/test_a_Foliations.csv",
@@ -18,4 +19,32 @@ def test_rescaled_marching_cube(interpolator_islith_nofault):
1819
sol = gempy.compute_model(geo_data, compute_mesh_options={'rescale': True})
1920
print(sol.vertices)
2021

21-
return geo_data
22+
return geo_data
23+
24+
25+
def test_custom_grid_solution(interpolator_islith_nofault):
26+
"""
27+
Integration test for a gempy model using a custom grid
28+
29+
2 Horizontal layers with drift 0
30+
31+
:param interpolator_islith_nofault:
32+
:return:
33+
"""
34+
# Importing the data from csv files and settign extent and resolution
35+
geo_model = gempy.create_data([0, 10, 0, 10, -10, 0], [10, 10, 10],
36+
path_o=input_path + "/GeoModeller/test_a/test_a_Foliations.csv",
37+
path_i=input_path + "/GeoModeller/test_a/test_a_Points.csv")
38+
# add a custom grid
39+
cg = np.array([[5, 5, -9],
40+
[5, 5, -5],
41+
[5, 5, -5.1],
42+
[5, 5, -5.2],
43+
[5, 5, -1]])
44+
values = geo_model.set_custom_grid(cg)
45+
assert geo_model.grid.active_grids[1]
46+
# set the theano function
47+
geo_model.set_theano_function(interpolator_islith_nofault)
48+
# Compute model
49+
sol = gempy.compute_model(geo_model, compute_mesh=False)
50+
assert sol.custom.shape == (2,1,5)

0 commit comments

Comments
 (0)