Skip to content

Commit 66ea721

Browse files
committed
- [TEST/CLN] Move orientations_from_surface points to gempy_plugins
1 parent 80454bc commit 66ea721

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import gempy as gp
2+
import numpy as np
3+
import os
4+
input_path = os.path.dirname(__file__) + '/../../examples/data'
5+
6+
7+
def test_set_orientations():
8+
# Importing the data from CSV-files and setting extent and resolution
9+
geo_data = gp.create_data_legacy(extent=[0, 2000, 0, 2000, 0, 2000], resolution=[50, 50, 50],
10+
path_o=input_path + '/input_data/tut_chapter1/simple_fault_model_orientations.csv',
11+
path_i=input_path + '/input_data/tut_chapter1/simple_fault_model_points.csv')
12+
13+
gp.get_data(geo_data)
14+
15+
# Assigning series to formations as well as their order (timewise)
16+
gp.map_stack_to_surfaces(geo_data, {"Fault_Series": 'Main_Fault',
17+
"Strat_Series": ('Sandstone_2', 'Siltstone')})
18+
19+
geo_data._orientations.create_orientation_from_surface_points(geo_data.surface_points, [0, 1, 2])
20+
21+
gp.set_orientation_from_surface_points(geo_data, [0, 1, 2])
22+
23+
24+
def test_select_nearest_surface_points():
25+
data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
26+
path_to_data = data_path + "/data/input_data/jan_models/"
27+
28+
geo_data = gp.create_data_legacy('fault', extent=[0, 1000, 0, 1000, 0, 1000],
29+
resolution=[50, 50, 50],
30+
path_o=path_to_data + "model5_orientations.csv",
31+
path_i=path_to_data + "model5_surface_points.csv")
32+
33+
# Assigning series to formations as well as their order (timewise)
34+
gp.map_stack_to_surfaces(geo_data, {"Fault_Series": 'fault',
35+
"Strat_Series": ('rock2', 'rock1')})
36+
geo_data.set_is_fault(['Fault_Series'])
37+
38+
# detect fault names
39+
f_id = geo_data._faults.df.index.categories[
40+
geo_data._faults.df.isFault.values]
41+
# find fault points
42+
fault_poi = geo_data._surface_points.df[
43+
geo_data._surface_points.df.series.isin(f_id)]
44+
45+
# find neighbours
46+
knn = gp.select_nearest_surfaces_points(geo_data, fault_poi, 1)
47+
radius = gp.select_nearest_surfaces_points(geo_data, fault_poi, 200.)
48+
49+
# sort neighbours, necessary for equal testing
50+
knn = [k.sort_values() for k in knn]
51+
radius = [r.sort_values() for r in radius]
52+
53+
# define reference
54+
reference = [[16,17],[16,17],[18,19],[18,19],[20,21],[20,21]]
55+
56+
assert np.array_equal(reference, knn) and np.array_equal(reference, radius)
57+
58+
59+
def test_set_orientation_from_neighbours():
60+
data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
61+
path_to_data = data_path + "/data/input_data/jan_models/"
62+
63+
geo_data = gp.create_data_legacy('fault', extent=[0, 1000, 0, 1000, 0, 1000],
64+
resolution=[50, 50, 50],
65+
path_o=path_to_data + "model5_orientations.csv",
66+
path_i=path_to_data + "model5_surface_points.csv")
67+
68+
# Assigning series to formations as well as their order (timewise)
69+
gp.map_stack_to_surfaces(geo_data, {"Fault_Series": 'fault',
70+
"Strat_Series": ('rock2', 'rock1')})
71+
geo_data.set_is_fault(['Fault_Series'])
72+
73+
# detect fault names
74+
f_id = geo_data._faults.df.index.categories[
75+
geo_data._faults.df.isFault.values]
76+
# find fault points
77+
fault_poi = geo_data._surface_points.df[
78+
geo_data._surface_points.df.series.isin(f_id)]
79+
# find neighbours
80+
neighbours = gp.select_nearest_surfaces_points(geo_data, fault_poi, 5)
81+
# calculate one fault orientation
82+
gp.set_orientation_from_neighbours(geo_data, neighbours[1])
83+
# find the calculated orientation
84+
test = geo_data._orientations.df.sort_index().iloc[-1][['dip', 'azimuth']].values
85+
86+
# calculate reference
87+
reference = [90-np.arctan(0.5)/np.pi*180, 90]
88+
89+
assert np.array_equal(reference, test)
90+
91+
92+
def test_set_orientation_from_neighbours_all():
93+
data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
94+
path_to_data = data_path + "/data/input_data/jan_models/"
95+
96+
geo_data = gp.create_data_legacy('fault', extent=[0, 1000, 0, 1000, 0, 1000],
97+
resolution=[50, 50, 50],
98+
path_o=path_to_data + "model5_orientations.csv",
99+
path_i=path_to_data + "model5_surface_points.csv")
100+
101+
# count orientations before orientation calculation
102+
length_pre = geo_data._orientations.df.shape[0]
103+
104+
# find neighbours
105+
neighbours = gp.select_nearest_surfaces_points(geo_data, geo_data._surface_points.df, 2)
106+
# calculate all fault orientations
107+
gp.set_orientation_from_neighbours_all(geo_data, neighbours)
108+
109+
# count orientations after orientation calculation
110+
length_after = geo_data._orientations.df.shape[0]
111+
112+
assert np.array_equal(geo_data._surface_points.df.shape[0],
113+
length_after-length_pre)

0 commit comments

Comments
 (0)