Skip to content

Commit

Permalink
Merge branch 'pull/333' into release
Browse files Browse the repository at this point in the history
# Conflicts:
#	gempy/core/data.py
#	test/test_core/test_grids/test_grid.py
  • Loading branch information
Leguark committed Mar 24, 2020
2 parents 0cc36ff + 7c0f000 commit f3b2b54
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
4 changes: 4 additions & 0 deletions gempy/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ def create_centered_grid(self, centers, radius, resolution=None):
self.set_active('centered')

def deactivate_all_grids(self):
"""
Deactivates the active grids array
:return:
"""
self.active_grids = np.zeros(5, dtype=bool)
self.update_grid_values()
return self.active_grids
Expand Down
6 changes: 3 additions & 3 deletions gempy/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def set_custom_grid(self, custom_grid):
if self.grid.custom_grid is None:
self.grid.create_custom_grid(custom_grid)
else:
self.grid.custom_grid.set_custmo_grid(custom_grid)
self.grid.custom_grid.set_custom_grid(custom_grid)
self.grid.update_grid_values()

self.update_from_grid()
Expand Down Expand Up @@ -1051,8 +1051,8 @@ def set_surface_order_from_solution(self):
Surfaces
"""
# TODO time this function
# spu = self.surface_points.df['surface'].unique()
# sps = self.surface_points.df['series'].unique()
# spu = self.surface_points.df['surface'].unique()
# sps = self.surface_points.df['series'].unique()

# # Boolean array of size len surfaces with True active surfaces minus Basemes
# sel = self.surfaces.df['isActive'] & ~self.surfaces.df['isBasement'] #self.surfaces.df['surface'].isin(spu)
Expand Down
19 changes: 19 additions & 0 deletions test/test_core/test_grids/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,22 @@ def test_set_section_twice(self):
geo_data.set_section_grid(section_dict)
geo_data.set_section_grid(section_dict)
print(geo_data.grid.sections)


def test_custom_grid(self):
# create custom grid
grid = gp.Grid()
cg = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
grid.create_custom_grid(cg)
# make sure the custom grid is active
assert grid.active_grids[1]
# make sure the custom grid is equal to the provided values
np.testing.assert_array_almost_equal(cg, grid.custom_grid.values)
# make sure we have the correct number of values in our grid
l0, l1 = grid.get_grid_args('custom')
assert l0 == 0
assert l1 == 3


35 changes: 32 additions & 3 deletions test/test_core/test_solution.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import gempy
import os
import numpy as np
input_path = os.path.dirname(__file__)+'/../input_data'


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

return geo_data
return geo_data


def test_custom_grid_solution(interpolator_islith_nofault):
"""
Integration test for a gempy model using a custom grid
2 Horizontal layers with drift 0
:param interpolator_islith_nofault:
:return:
"""
# Importing the data from csv files and settign extent and resolution
geo_model = gempy.create_data([0, 10, 0, 10, -10, 0], [10, 10, 10],
path_o=input_path + "/GeoModeller/test_a/test_a_Foliations.csv",
path_i=input_path + "/GeoModeller/test_a/test_a_Points.csv")
# add a custom grid
cg = np.array([[5, 5, -9],
[5, 5, -5],
[5, 5, -5.1],
[5, 5, -5.2],
[5, 5, -1]])
values = geo_model.set_custom_grid(cg)
assert geo_model.grid.active_grids[1]
# set the theano function
geo_model.set_theano_function(interpolator_islith_nofault)
# Compute model
sol = gempy.compute_model(geo_model, compute_mesh=False)
assert sol.custom.shape == (2,1,5)

0 comments on commit f3b2b54

Please sign in to comment.