-
-
Notifications
You must be signed in to change notification settings - Fork 231
/
test_map2loop.py
200 lines (161 loc) · 6.73 KB
/
test_map2loop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import gempy as gp
import numpy as np
import pandas as pd
import pytest
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import os
# Input files
from gempy.addons.map2gempy import loop2gempy
from gempy.core.grid_modules.create_topography import GDAL_IMPORT
root = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/data/input_data/turner_syncline/'
root2 = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/data/input_data/australia/'
path = os.path.dirname(__file__) + '/../input_data/'
orientations_file = root + 'orientations_clean.csv'
orientations_file2 = root2 + 'orientations_clean.csv'
contacts_file = root + 'contacts_clean.csv'
contacts_file2 = root2 + 'contacts_clean.csv'
faults_contact = root + 'faults.csv'
faults_contact2 = root2 + 'faults.csv'
faults_orientations = root + 'fault_orientations.csv'
faults_orientations2 = root2 + 'fault_orientations.csv'
series_file = root + 'all_sorts_clean.csv'
series_file2 = root2 + 'all_sorts_clean.csv'
faults_rel_matrix = root + 'fault-fault-relationships.csv'
faults_rel_matrix2 = root2 + 'fault-fault-relationships.csv'
series_rel_matrix = root + 'group-fault-relationships.csv'
series_rel_matrix2 = root2 + 'group-fault-relationships.csv'
ff = root2 + 'fault-fault-relationships.csv'
fg = root2 + 'group-fault-relationships.csv'
fp = path + 'dtm_rp.tif'
fp2 = path + 'dtm_rp2.tif'
bbox = (500000, 7490000, 545000, 7520000)
model_base = -0 # Original 3200
model_top = 800
extent_g = [515687.3100586407, 562666.8601065436,
7473446.765934078, 7521273.574077863,
-3200, 1200.0]
extent = [515687.3100586407, 7473446.765934078,
562666.8601065436, 7521273.574077863,
-3200, 1200.0]
@pytest.mark.skipif(("TRAVIS" in os.environ and os.environ["TRAVIS"] == "true") or
("GITHUBACTION" in os.environ and os.environ["GITHUBACTION"] == "true"),
reason="Skipping this test on Travis CI. For some reason there is a linalg "
"error.")
def test_loop2gempy():
topo = fp
topo = None
loop2gempy(contacts_file, orientations_file, bbox, series_file, model_base,
model_top, topo, faults_contact, faults_orientations, 'testing_map',
vtk=True, vtk_path=None, image_2d=True)
def test_map2loop2relmatrix():
ff_ = pd.read_csv(ff).set_index('fault_id')
fg_ = pd.read_csv(fg).set_index('group')
p = pd.concat((ff_, fg_.T), axis=1)
print(p)
@pytest.mark.skipif(("TRAVIS" in os.environ and os.environ["TRAVIS"] == "true") or
("GITHUBACTION" in os.environ and os.environ["GITHUBACTION"] == "true" or
GDAL_IMPORT is False),
reason="Skipping this test on Travis CI. For some reason there is a linalg "
"error.")
def test_loop2gempy2():
topo = fp2
# topo = None
loop2gempy(contacts_file2, orientations_file2, extent[:4], series_file2,
extent[4],
extent[5],
dtm_reproj_file=topo,
faults_contact=faults_contact2,
faults_orientations=faults_orientations2,
faults_faults_rel=ff,
faults_groups_rel=fg,
model_name='testing_map',
compute=True,
vtk=True, vtk_path=None, image_2d=True)
@pytest.mark.skipif(("TRAVIS" in os.environ and os.environ["TRAVIS"] == "true") or
("GITHUBACTION" in os.environ and os.environ["GITHUBACTION"] == "true" or
GDAL_IMPORT is False
),
reason="Skipping this test on Travis CI. For some reason there is a linalg "
"error.")
def test_map2loop_model_import_data():
geo_model = gp.create_model('test_map2Loop')
gp.init_data(
geo_model,
extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base, model_top],
resolution=[50, 50, 50],
path_o=orientations_file,
path_i=contacts_file
)
# Load Topology
geo_model.set_topography(source='gdal', filepath=fp)
gp.plot_2d(geo_model, ve=10, show_topography=True)
plt.show()
# Plot in 3D
gp.plot_3d(geo_model, ve=None, show_topography=False, image=True,
kwargs_plot_data={'arrow_size': 400}
)
print(geo_model.orientations)
# skip test i
@pytest.mark.skipif(("TRAVIS" in os.environ and os.environ["TRAVIS"] == "true") or
("GITHUBACTION" in os.environ and os.environ["GITHUBACTION"] == "true" or
GDAL_IMPORT is False
),
reason="Skipping this test on Travis CI. For some reason there is a linalg "
"error.")
def test_map2loop_model_no_faults():
# Location box
bbox = (500000, 7490000, 545000, 7520000)
model_base = -3200 # Original 3200
model_top = 800
# Input files
geo_model = gp.create_model('test_map2Loop')
gp.init_data(
geo_model,
extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base, model_top],
resolution=[50, 50, 80],
path_o=orientations_file,
path_i=contacts_file
)
gp.set_interpolator(geo_model)
# Load Topology
geo_model.set_topography(source='gdal', filepath=fp)
# Stack Processing
contents = np.genfromtxt(series_file,
delimiter=',', dtype='U100')[1:, 4:-1]
map_series_to_surfaces = {}
for pair in contents:
map_series_to_surfaces.setdefault(pair[1], []).append(pair[0])
gp.map_stack_to_surfaces(geo_model, map_series_to_surfaces,
remove_unused_series=False)
gp.plot_2d(geo_model, ve=10, show_topography=False)
plt.show()
# Plot in 3D
gp.plot_3d(geo_model, ve=10, show_topography=False, image=True)
# Stack Processing
contents = np.genfromtxt(series_file,
delimiter=',', dtype='U100')[1:, 4:-1]
map_series_to_surfaces = {}
for pair in contents:
map_series_to_surfaces.setdefault(pair[1], []).append(pair[0])
gp.map_stack_to_surfaces(geo_model, map_series_to_surfaces,
remove_unused_series=False)
# Adding axial rescale
# geo_model._rescaling.toggle_axial_anisotropy()
# Increasing nugget effect
geo_model.modify_surface_points(
geo_model.surface_points.df.index,
smooth=0.001
)
geo_model.modify_kriging_parameters('drift equations', [9, 9, 9, 9, 9])
gp.compute_model(geo_model)
gp.plot_2d(geo_model,
section_names=['topography'],
show_topography=True,
)
plt.show()
gp.plot_3d(geo_model, ve=10, show_topography=True,
image=True,
show_lith=False,
)