LoopStructural 1.0.4__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of LoopStructural might be problematic. Click here for more details.

Files changed (119) hide show
  1. Miniconda/envs/loop/Lib/site-packages/LoopStructural/__init__.py +33 -0
  2. Miniconda/envs/loop/Lib/site-packages/LoopStructural/__pycache__/__init__.cpython-37.pyc +0 -0
  3. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/__init__.py +12 -0
  4. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/__pycache__/__init__.cpython-37.pyc +0 -0
  5. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/__pycache__/_base.cpython-37.pyc +0 -0
  6. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/_base.py +65 -0
  7. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/claudius.csv +21049 -0
  8. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/claudiusbb.txt +2 -0
  9. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/duplex.csv +126 -0
  10. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/duplexbb.txt +2 -0
  11. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/intrusion.csv +1017 -0
  12. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/intrusionbb.txt +2 -0
  13. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/onefoldbb.txt +2 -0
  14. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/onefolddata.csv +2226 -0
  15. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/refolded_bb.txt +2 -0
  16. Miniconda/envs/loop/Lib/site-packages/LoopStructural/datasets/data/refolded_fold.csv +2126 -0
  17. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__init__.py +31 -0
  18. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/__init__.cpython-37.pyc +0 -0
  19. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/discrete_fold_interpolator.cpython-37.pyc +0 -0
  20. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/discrete_interpolator.cpython-37.pyc +0 -0
  21. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/finite_difference_interpolator.cpython-37.pyc +0 -0
  22. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/geological_interpolator.cpython-37.pyc +0 -0
  23. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/operator.cpython-37.pyc +0 -0
  24. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/piecewiselinear_interpolator.cpython-37.pyc +0 -0
  25. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/structured_grid.cpython-37.pyc +0 -0
  26. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/structured_tetra.cpython-37.pyc +0 -0
  27. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/__pycache__/surfe_wrapper.cpython-37.pyc +0 -0
  28. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/__init__.py +0 -0
  29. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/__pycache__/__init__.cpython-37.pyc +0 -0
  30. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/dsi_helper.c +27782 -0
  31. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/cython/dsi_helper.cp37-win_amd64.pyd +0 -0
  32. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/discrete_fold_interpolator.py +171 -0
  33. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/discrete_interpolator.py +551 -0
  34. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/finite_difference_interpolator.py +342 -0
  35. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/geological_interpolator.py +190 -0
  36. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/operator.py +60 -0
  37. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/piecewiselinear_interpolator.py +348 -0
  38. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/structured_grid.py +466 -0
  39. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/structured_tetra.py +638 -0
  40. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/surfe_wrapper.py +117 -0
  41. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/__init__.py +46 -0
  42. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/__pycache__/__init__.cpython-37.pyc +0 -0
  43. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/__init__.py +0 -0
  44. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/__pycache__/__init__.cpython-37.pyc +0 -0
  45. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/__pycache__/geological_model.cpython-37.pyc +0 -0
  46. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/core/geological_model.py +1351 -0
  47. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__init__.py +3 -0
  48. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/__init__.cpython-37.pyc +0 -0
  49. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/fault_function.cpython-37.pyc +0 -0
  50. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/fault_function_feature.cpython-37.pyc +0 -0
  51. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/__pycache__/fault_segment.cpython-37.pyc +0 -0
  52. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/fault_function.py +187 -0
  53. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/fault_function_feature.py +75 -0
  54. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fault/fault_segment.py +270 -0
  55. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__init__.py +7 -0
  56. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/__init__.cpython-37.pyc +0 -0
  57. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/cross_product_geological_feature.cpython-37.pyc +0 -0
  58. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/geological_feature.cpython-37.pyc +0 -0
  59. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/geological_feature_builder.cpython-37.pyc +0 -0
  60. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/region_feature.cpython-37.pyc +0 -0
  61. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/structural_frame.cpython-37.pyc +0 -0
  62. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/structural_frame_builder.cpython-37.pyc +0 -0
  63. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/__pycache__/unconformity_feature.cpython-37.pyc +0 -0
  64. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/cross_product_geological_feature.py +77 -0
  65. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/geological_feature.py +286 -0
  66. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/geological_feature_builder.py +329 -0
  67. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/region_feature.py +34 -0
  68. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/structural_frame.py +116 -0
  69. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/structural_frame_builder.py +179 -0
  70. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/unconformity_feature.py +69 -0
  71. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__init__.py +8 -0
  72. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/__init__.cpython-37.pyc +0 -0
  73. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/fold.cpython-37.pyc +0 -0
  74. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/fold_rotation_angle.cpython-37.pyc +0 -0
  75. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/fold_rotation_angle_feature.cpython-37.pyc +0 -0
  76. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/foldframe.cpython-37.pyc +0 -0
  77. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/__pycache__/svariogram.cpython-37.pyc +0 -0
  78. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/fold.py +135 -0
  79. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/fold_rotation_angle.py +132 -0
  80. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/fold_rotation_angle_feature.py +57 -0
  81. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/foldframe.py +192 -0
  82. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/fold/svariogram.py +179 -0
  83. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__init__.py +14 -0
  84. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/__init__.cpython-37.pyc +0 -0
  85. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/exceptions.cpython-37.pyc +0 -0
  86. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/helper.cpython-37.pyc +0 -0
  87. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/map2loop.cpython-37.pyc +0 -0
  88. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/__pycache__/utils.cpython-37.pyc +0 -0
  89. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/exceptions.py +9 -0
  90. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/helper.py +378 -0
  91. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/map2loop.py +314 -0
  92. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/utils.py +120 -0
  93. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__init__.py +19 -0
  94. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/__init__.cpython-37.pyc +0 -0
  95. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/map_viewer.cpython-37.pyc +0 -0
  96. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/model_plotter.cpython-37.pyc +0 -0
  97. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/model_visualisation.cpython-37.pyc +0 -0
  98. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/rotation_angle_plotter.cpython-37.pyc +0 -0
  99. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/__pycache__/sphinx_scraper.cpython-37.pyc +0 -0
  100. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/map_viewer.py +307 -0
  101. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/model_plotter.py +16 -0
  102. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/model_visualisation.py +1012 -0
  103. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/rotation_angle_plotter.py +82 -0
  104. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/sphinx_scraper.py +34 -0
  105. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/PKG-INFO +10 -0
  106. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/SOURCES.txt +60 -0
  107. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/dependency_links.txt +1 -0
  108. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/requires.txt +8 -0
  109. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.4-py3.7.egg-info/top_level.txt +2 -0
  110. Miniconda/envs/loop/Lib/site-packages/tests/__init__.py +0 -0
  111. Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/__init__.cpython-37.pyc +0 -0
  112. Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_faults.cpython-37.pyc +0 -0
  113. Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_fold.cpython-37.pyc +0 -0
  114. Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_interpolator.cpython-37.pyc +0 -0
  115. Miniconda/envs/loop/Lib/site-packages/tests/__pycache__/test_refolded.cpython-37.pyc +0 -0
  116. Miniconda/envs/loop/Lib/site-packages/tests/test_faults.py +17 -0
  117. Miniconda/envs/loop/Lib/site-packages/tests/test_fold.py +57 -0
  118. Miniconda/envs/loop/Lib/site-packages/tests/test_interpolator.py +88 -0
  119. Miniconda/envs/loop/Lib/site-packages/tests/test_refolded.py +22 -0
@@ -0,0 +1,378 @@
1
+ import logging
2
+
3
+ import numpy as np
4
+ from sklearn.decomposition import PCA
5
+
6
+ logger = logging.getLogger(__name__)
7
+
8
+
9
+ def get_data_axis_aligned_bounding_box(xyz, buffer):
10
+ """
11
+
12
+ Parameters
13
+ ----------
14
+ xyz
15
+ buffer
16
+
17
+ Returns
18
+ -------
19
+
20
+ """
21
+ minx = np.min(xyz[:, 0])
22
+ maxx = np.max(xyz[:, 0])
23
+ miny = np.min(xyz[:, 1])
24
+ maxy = np.max(xyz[:, 1])
25
+ minz = np.min(xyz[:, 2])
26
+ maxz = np.max(xyz[:, 2])
27
+
28
+ xlen = maxx - minx
29
+ ylen = maxy - miny
30
+ zlen = maxz - minz
31
+ length = np.max([xlen, ylen, zlen])
32
+ minx -= length * buffer
33
+ maxx += length * buffer
34
+
35
+ miny -= length * buffer
36
+ maxy += length * buffer
37
+
38
+ minz -= length * buffer
39
+ maxz += length * buffer
40
+
41
+ bb = np.array([[minx, miny, minz],
42
+ [maxx, maxy, maxz]
43
+ ])
44
+
45
+ def region(xyz):
46
+ """
47
+
48
+ Parameters
49
+ ----------
50
+ xyz
51
+
52
+ Returns
53
+ -------
54
+
55
+ """
56
+ # print(xyz)
57
+ # print(bb)
58
+ b = np.ones(xyz.shape[0]).astype(bool)
59
+ b = np.logical_and(b, xyz[:, 0] > minx)
60
+ b = np.logical_and(b, xyz[:, 0] < maxx)
61
+ b = np.logical_and(b, xyz[:, 1] > miny)
62
+ b = np.logical_and(b, xyz[:, 1] < maxy)
63
+ # b = np.logical_and(b,xyz[:,2]>minz)
64
+ # b = np.logical_and(b,xyz[:,2]<maxz)
65
+ return b
66
+
67
+ return bb, region
68
+
69
+ def get_data_bounding_box_map(xyz, buffer):
70
+ """
71
+
72
+ Parameters
73
+ ----------
74
+ xyz
75
+ buffer
76
+
77
+ Returns
78
+ -------
79
+
80
+ """
81
+ # find the aligned coordinates box using pca
82
+ modelpca = PCA(n_components=3)
83
+ modelpca.fit(xyz)
84
+ # transform the data to this new coordinate then find extents
85
+ transformed_xyz = modelpca.transform(xyz)
86
+ minx = np.min(xyz[:, 0])
87
+ maxx = np.max(xyz[:, 0])
88
+ miny = np.min(xyz[:, 1])
89
+ maxy = np.max(xyz[:, 1])
90
+ minz = np.min(xyz[:, 2])
91
+ maxz = np.max(xyz[:, 2])
92
+
93
+ xlen = maxx - minx
94
+ ylen = maxy - miny
95
+ zlen = maxz - minz
96
+ length = np.max([xlen, ylen, zlen])
97
+ minx -= buffer
98
+ maxx += buffer
99
+
100
+ miny -= buffer
101
+ maxy += buffer
102
+
103
+ minz -= buffer
104
+ maxz += buffer
105
+
106
+ bb = np.array([[minx, miny, minz],
107
+ [maxx, maxy, maxz]
108
+ ])
109
+
110
+ def region(xyz):
111
+ b = np.ones(xyz.shape[0]).astype(bool)
112
+ b = np.logical_and(b, xyz[:, 0] > minx)
113
+ b = np.logical_and(b, xyz[:, 0] < maxx)
114
+ b = np.logical_and(b, xyz[:, 1] > miny)
115
+ b = np.logical_and(b, xyz[:, 1] < maxy)
116
+
117
+ return b
118
+
119
+ return bb, region
120
+ def get_data_bounding_box(xyz, buffer):
121
+ """
122
+
123
+ Parameters
124
+ ----------
125
+ xyz
126
+ buffer
127
+
128
+ Returns
129
+ -------
130
+
131
+ """
132
+ # find the aligned coordinates box using pca
133
+ modelpca = PCA(n_components=3)
134
+ modelpca.fit(xyz)
135
+ # transform the data to this new coordinate then find extents
136
+ transformed_xyz = modelpca.transform(xyz)
137
+ minx = np.min(xyz[:, 0])
138
+ maxx = np.max(xyz[:, 0])
139
+ miny = np.min(xyz[:, 1])
140
+ maxy = np.max(xyz[:, 1])
141
+ minz = np.min(xyz[:, 2])
142
+ maxz = np.max(xyz[:, 2])
143
+
144
+ xlen = maxx - minx
145
+ ylen = maxy - miny
146
+ zlen = maxz - minz
147
+ length = np.max([xlen,ylen,zlen])
148
+ minx -= length * buffer
149
+ maxx += length * buffer
150
+
151
+ miny -= length * buffer
152
+ maxy += length * buffer
153
+
154
+ minz -= length * buffer
155
+ maxz += length * buffer
156
+
157
+ bb = np.array([[minx, miny, minz],
158
+ [maxx, maxy, maxz]
159
+ ])
160
+
161
+ def region(xyz):
162
+ b = np.ones(xyz.shape[0]).astype(bool)
163
+ b = np.logical_and(b, xyz[:, 0] > minx)
164
+ b = np.logical_and(b, xyz[:, 0] < maxx)
165
+ b = np.logical_and(b, xyz[:, 1] > miny)
166
+ b = np.logical_and(b, xyz[:, 1] < maxy)
167
+ b = np.logical_and(b, xyz[:, 2] > minz)
168
+ b = np.logical_and(b, xyz[:, 2] < maxz)
169
+ return b
170
+
171
+ return bb, region
172
+
173
+
174
+ def plunge_and_plunge_dir_to_vector(plunge, plunge_dir):
175
+ plunge = np.deg2rad(plunge)
176
+ plunge_dir = np.deg2rad(plunge_dir)
177
+ vec = np.zeros(3)
178
+ vec[0] = np.sin(plunge_dir) * np.cos(plunge)
179
+ vec[1] = np.cos(plunge_dir) * np.cos(plunge)
180
+ vec[2] = -np.sin(plunge)
181
+ return vec
182
+
183
+
184
+ def create_surface(bounding_box, nstep):
185
+ x = np.linspace(bounding_box[0, 0], bounding_box[1, 0], nstep[0]) #
186
+ y = np.linspace(bounding_box[0, 1], bounding_box[1, 1], nstep[1])
187
+ xx, yy = np.meshgrid(x, y, indexing='xy')
188
+
189
+ def gi(i, j):
190
+ return i + j * nstep[0]
191
+
192
+ corners = np.array([[0, 1, 0, 1], [0, 0, 1, 1]])
193
+ i = np.arange(0, nstep[0] - 1)
194
+
195
+ j = np.arange(0, nstep[1] - 1)
196
+ ii, jj = np.meshgrid(i, j, indexing='ij')
197
+ corner_gi = gi(ii[:, :, None] + corners[None, None, 0, :, ],
198
+ jj[:, :, None] + corners[None, None, 1, :, ])
199
+ corner_gi = corner_gi.reshape((nstep[0] - 1) * (nstep[1] - 1), 4)
200
+ tri = np.vstack([corner_gi[:, :3], corner_gi[:, 1:]])
201
+ return tri, xx.flatten(), yy.flatten()
202
+
203
+ def create_box(bounding_box, nsteps):
204
+ tri, xx, yy = create_surface(bounding_box[0:2, :], nsteps[0:2])
205
+
206
+ zz = np.zeros(xx.shape)
207
+ zz[:] = bounding_box[1, 2]
208
+
209
+ tri = np.vstack([tri, tri + np.max(tri) + 1])
210
+ xx = np.hstack([xx, xx])
211
+ yy = np.hstack([yy, yy])
212
+
213
+ z = np.zeros(zz.shape)
214
+ z[:] = bounding_box[0, 2]
215
+ zz = np.hstack([zz, z])
216
+ # y faces
217
+ t, x, z = create_surface(bounding_box[:, [0, 2]], nsteps[[0, 2]])
218
+ tri = np.vstack([tri, t + np.max(tri) + 1])
219
+
220
+ y = np.zeros(x.shape)
221
+ y[:] = bounding_box[0, 1]
222
+ xx = np.hstack([xx, x])
223
+ zz = np.hstack([zz, z])
224
+ yy = np.hstack([yy, y])
225
+
226
+ tri = np.vstack([tri, t + np.max(tri) + 1])
227
+ y[:] = bounding_box[1, 1]
228
+ xx = np.hstack([xx, x])
229
+ zz = np.hstack([zz, z])
230
+ yy = np.hstack([yy, y])
231
+
232
+ # x faces
233
+ t, y, z = create_surface(bounding_box[:, [1, 2]], nsteps[[1, 2]])
234
+ tri = np.vstack([tri, t + np.max(tri) + 1])
235
+ x = np.zeros(y.shape)
236
+ x[:] = bounding_box[0, 0]
237
+ xx = np.hstack([xx, x])
238
+ zz = np.hstack([zz, z])
239
+ yy = np.hstack([yy, y])
240
+
241
+ tri = np.vstack([tri, t + np.max(tri) + 1])
242
+ x[:] = bounding_box[1, 0]
243
+ xx = np.hstack([xx, x])
244
+ zz = np.hstack([zz, z])
245
+ yy = np.hstack([yy, y])
246
+
247
+ points = np.zeros((len(xx), 3)) #
248
+ points[:, 0] = xx
249
+ points[:, 1] = yy
250
+ points[:, 2] = zz
251
+ return points, tri
252
+
253
+ def get_vectors(normal):
254
+ length = np.linalg.norm(normal,axis=1)[:,None]
255
+ normal /= length#np.linalg.norm(normal,axis=1)[:,None]
256
+ strikedip = normal_vector_to_strike_and_dip(normal)
257
+ strike_vec = get_strike_vector(strikedip[:, 0])
258
+ strike_vec /= np.linalg.norm(strike_vec,axis=0)[None,:]
259
+ dip_vec = np.cross(strike_vec, normal, axisa=0, axisb=1).T # (strikedip[:, 0], strikedip[:, 1])
260
+ dip_vec /= np.linalg.norm(dip_vec,axis=0)[None,:]
261
+ return strike_vec*length.T, dip_vec*length.T
262
+
263
+
264
+ def get_strike_vector(strike):
265
+ """
266
+
267
+ Parameters
268
+ ----------
269
+ strike
270
+
271
+ Returns
272
+ -------
273
+
274
+ """
275
+
276
+ v = np.array([np.sin(np.deg2rad(-strike)),
277
+ -np.cos(np.deg2rad(-strike)),
278
+ np.zeros(strike.shape[0])
279
+ ])
280
+
281
+ return v
282
+
283
+
284
+ def get_dip_vector(strike, dip):
285
+ v = np.array([-np.cos(np.deg2rad(-strike)) * np.cos(-np.deg2rad(dip)),
286
+ np.sin(np.deg2rad(-strike)) * np.cos(-np.deg2rad(dip)),
287
+ np.sin(-np.deg2rad(dip))
288
+ ])
289
+ return v
290
+
291
+
292
+ def rotation(axis, angle):
293
+ c = np.cos(np.deg2rad(angle))
294
+ s = np.sin((np.deg2rad(angle)))
295
+ C = 1.0 - c
296
+ x = axis[0]
297
+ y = axis[1]
298
+ z = axis[2]
299
+ xs = x * s
300
+ ys = y * s
301
+ zs = z * s
302
+ xC = x * C
303
+ yC = y * C
304
+ zC = z * C
305
+ xyC = x * yC
306
+ yzC = y * zC
307
+ zxC = z * xC
308
+ rotation_mat = np.zeros((3, 3))
309
+ rotation_mat[0][0] = x * xC + c
310
+ rotation_mat[0][1] = xyC - zs
311
+ rotation_mat[0][2] = zxC + ys
312
+
313
+ rotation_mat[1][0] = xyC + zs
314
+ rotation_mat[1][1] = y * yC + c
315
+ rotation_mat[1][2] = yzC - xs
316
+
317
+ rotation_mat[2][0] = zxC - ys
318
+ rotation_mat[2][1] = yzC + xs
319
+ rotation_mat[2][2] = z * zC + c
320
+ return rotation_mat
321
+
322
+
323
+ def strike_dip_vector(strike, dip):
324
+ vec = np.zeros((len(strike), 3))
325
+ s_r = np.deg2rad(strike)
326
+ d_r = np.deg2rad((dip))
327
+ vec[:, 0] = np.sin(d_r) * np.cos(s_r)
328
+ vec[:, 1] = -np.sin(d_r) * np.sin(s_r)
329
+ vec[:, 2] = np.cos(d_r)
330
+ vec /= np.linalg.norm(vec, axis=1)[:, None]
331
+ return vec
332
+
333
+
334
+ def normal_vector_to_strike_and_dip(normal_vector):
335
+ normal_vector /= np.linalg.norm(normal_vector, axis=1)[:, None]
336
+ dip = np.rad2deg(np.arccos(normal_vector[:, 2]))
337
+ strike = -np.rad2deg(np.arctan2(normal_vector[:, 1], normal_vector[:,
338
+ 0])) # atan2(v2[1],v2[0])*rad2deg;
339
+
340
+ return np.array([strike, dip]).T
341
+
342
+
343
+ def xyz_names():
344
+ return ['X', 'Y', 'Z']
345
+
346
+
347
+ def normal_vec_names():
348
+ return ['nx', 'ny', 'nz']
349
+
350
+
351
+ def tangent_vec_names():
352
+ return ['tx', 'ty', 'tz']
353
+
354
+
355
+ def gradient_vec_names():
356
+ return ['gx', 'gy', 'gz']
357
+
358
+
359
+ def weight_name():
360
+ return ['w']
361
+
362
+
363
+ def val_name():
364
+ return ['val']
365
+
366
+ def coord_name():
367
+ return ['coord']
368
+
369
+ def interface_name():
370
+ return ['interface']
371
+
372
+
373
+ def feature_name():
374
+ return ['feature_name']
375
+
376
+ def all_heading():
377
+ return xyz_names() + normal_vec_names() + tangent_vec_names() + \
378
+ gradient_vec_names() + weight_name() + val_name() + coord_name() + feature_name() + interface_name()
@@ -0,0 +1,314 @@
1
+ import pandas as pd
2
+ import numpy as np
3
+ import os
4
+ import logging
5
+
6
+ logger = logging.getLogger(__name__)
7
+
8
+ def process_map2loop(m2l_directory, flags={}):
9
+ """
10
+ Extracts relevant information from map2loop outputs
11
+
12
+ Parameters
13
+ ----------
14
+ m2l_directory : string
15
+ absolute path to a directory containing map2loop outputs
16
+ Returns
17
+ -------
18
+ m2l_data : dict
19
+ a dictionary containing the extracted and collated data
20
+ """
21
+ gradient = flags.get('gradient',False)
22
+ vector_scale = flags.get('vector_scale',None)
23
+ tangents = pd.read_csv(m2l_directory + '/tmp/raw_contacts.csv')
24
+ groups = pd.read_csv(m2l_directory + '/tmp/all_sorts_clean.csv', index_col=0)
25
+ contact_orientations = pd.read_csv(m2l_directory + '/output/orientations_clean.csv')
26
+ # formation_thickness = pd.read_csv)
27
+ contacts = pd.read_csv(m2l_directory + '/output/contacts_clean.csv')
28
+ displacements = pd.read_csv(m2l_directory + '/output/fault_displacements3.csv')
29
+ fault_orientations = pd.read_csv(m2l_directory + '/output/fault_orientations.csv')
30
+ fault_locations = pd.read_csv(m2l_directory + '/output/faults.csv')
31
+ fault_fault_relations = pd.read_csv(m2l_directory + '/output/fault-fault-relationships.csv')
32
+ fault_strat_relations = pd.read_csv(m2l_directory + '/output/group-fault-relationships.csv')
33
+ fault_dimensions = pd.read_csv(m2l_directory + '/output/fault_dimensions.csv')
34
+
35
+ supergroups = {}
36
+ sgi = 0
37
+ try:
38
+ with open(m2l_directory + '/tmp/super_groups.csv') as f:
39
+ for l in f:
40
+ for g in l.split(','):
41
+ g = g.replace('-','_').replace(' ','_')
42
+ if g.find('\n') > 0:
43
+ g = g[:g.find('\n')]
44
+ supergroups[g] = 'supergroup_{}'.format(sgi)
45
+ if g == '\n':
46
+ sgi += 1
47
+ break
48
+ except:
49
+ for g in groups['group'].unique():
50
+ supergroups[g] = g
51
+ try:
52
+ supergroups.pop('\n')
53
+ except KeyError:
54
+ pass
55
+
56
+
57
+ bb = pd.read_csv(m2l_directory+'/tmp/bbox.csv')
58
+
59
+ # process tangent data to be tx, ty, tz
60
+ tangents['tz'] = 0
61
+ tangents['tx'] = tangents['lsx']
62
+ tangents['ty'] = tangents['lsy']
63
+ tangents.drop(['angle', 'lsx', 'lsy'], inplace=True, axis=1)
64
+
65
+ # convert azimuth and dip to gx, gy, gz
66
+
67
+
68
+ # calculate scalar field values
69
+ i = 0
70
+ thickness = {}
71
+ max_thickness = 0
72
+ thickness_file = flags.get('thickness',m2l_directory + '/output/formation_summary_thicknesses.csv')
73
+ with open(thickness_file) as file:
74
+ for l in file:
75
+ if i>=1:
76
+ linesplit = l.split(',')
77
+ thickness[linesplit[0]] = float(linesplit[1])
78
+ # normalise the thicknesses
79
+ if float(linesplit[1]) > max_thickness:
80
+ max_thickness=float(linesplit[1])
81
+ # print(l.split(',')[1])
82
+ i+=1
83
+ # for k in thickness.keys():
84
+ # thickness[k] /= max_thickness
85
+ if vector_scale is None:
86
+ vector_scale = max_thickness
87
+
88
+ if gradient:
89
+ from LoopStructural.utils.helper import strike_dip_vector
90
+ contact_orientations['strike'] = contact_orientations['azimuth'] - 90
91
+ contact_orientations['gx'] = np.nan
92
+ contact_orientations['gy'] = np.nan
93
+ contact_orientations['gz'] = np.nan
94
+ contact_orientations[['gx', 'gy', 'gz']] = strike_dip_vector(contact_orientations['strike'],
95
+ contact_orientations['dip'])*max_thickness
96
+ if not gradient:
97
+ from LoopStructural.utils.helper import strike_dip_vector
98
+ contact_orientations['strike'] = contact_orientations['azimuth'] - 90
99
+ contact_orientations['nx'] = np.nan
100
+ contact_orientations['ny'] = np.nan
101
+ contact_orientations['nz'] = np.nan
102
+ contact_orientations[['nx', 'ny', 'nz']] = strike_dip_vector(contact_orientations['strike'],
103
+ contact_orientations['dip'])*vector_scale *contact_orientations['polarity'].to_numpy()[:,None]
104
+ contact_orientations.drop(['strike', 'dip', 'azimuth'], inplace=True, axis=1)
105
+ # with open(m2l_directory + '/output/formation_summary_thicknesses.csv') as file:
106
+
107
+ # thickness = {}
108
+ # for f in formation_thickness['formation'].unique():
109
+ # thickness[f] = formation_thickness[formation_thickness['formation'] == f]['thickness'])
110
+
111
+ strat_val = {}
112
+ stratigraphic_column = {}
113
+ unit_id = 0
114
+ val = {}
115
+ for i in groups['group number'].unique():
116
+ g = supergroups[groups.loc[groups['group number'] == i, 'group'].iloc[0]]
117
+ if g not in stratigraphic_column:
118
+ stratigraphic_column[g] = {}
119
+ val[g] = 0
120
+
121
+ for c, colour in zip(groups.loc[groups['group number'] == i, 'code'],groups.loc[groups['group number'] == i, 'colour']):
122
+ strat_val[c] = np.nan
123
+ if c in thickness:
124
+ stratigraphic_column[g][c] = {'max': val[g], 'min': val[g] - thickness[c], 'id': unit_id, 'colour':colour}
125
+ unit_id += 1
126
+ strat_val[c] = val[g] - thickness[c]
127
+ val[g] -= thickness[c]
128
+ group_name = None
129
+ for g, i in stratigraphic_column.items():
130
+ if len(i) ==0:
131
+ for gr, sg in supergroups.items():
132
+ if sg == g:
133
+ group_name = gr
134
+ break
135
+ try:
136
+ if group_name is None:
137
+ continue
138
+ c=groups.loc[groups['group']==group_name,'code'].to_numpy()[0]
139
+ strat_val[c] = 0
140
+ stratigraphic_column[g] = {c:{'min':0,'max':9999,'id':unit_id}}
141
+ unit_id+=1
142
+ group_name = None
143
+ except:
144
+ print('Couldnt process {}'.format(g))
145
+ contacts['val'] = np.nan
146
+ for o in strat_val:
147
+ contacts.loc[contacts['formation'] == o, 'val'] = strat_val[o]
148
+
149
+ tangents['feature_name'] = tangents['group']
150
+ contact_orientations['feature_name'] = None
151
+ contacts['feature_name'] = None
152
+ for g in groups['group'].unique():
153
+ val = 0
154
+ for c in groups.loc[groups['group'] == g, 'code']:
155
+ contact_orientations.loc[contact_orientations['formation'] == c, 'feature_name'] = supergroups[g]
156
+ contacts.loc[contacts['formation'] == c, 'feature_name'] = supergroups[g]
157
+ displacements['dip_dir'] = np.nan
158
+ for fname in fault_orientations['formation'].unique():
159
+ displacements.loc[displacements['fname'] == fname, 'dip_dir'] = np.mean(
160
+ fault_orientations.loc[fault_orientations['formation'] == fname, 'DipDirection'])
161
+ max_displacement = {}
162
+ downthrow_dir = {}
163
+ fault_locations['val'] = 0
164
+ fault_locations['coord'] = 0
165
+ fault_orientations['coord'] = 0
166
+ fault_orientations['gx'] = np.nan
167
+ fault_orientations['gy'] = np.nan
168
+ fault_orientations['gz'] = np.nan
169
+
170
+
171
+ for f in displacements['fname'].unique():
172
+ fault_centers = np.zeros(6)
173
+ normal_vector = np.zeros(3)
174
+ strike_vector = np.zeros(3)
175
+ slip_vector = np.zeros(3)
176
+
177
+ fault_edges = np.zeros((2,3))
178
+ fault_tips = np.zeros((2,3))
179
+ fault_depth = np.zeros((2,3))
180
+ displacements_numpy = displacements.loc[
181
+ displacements['fname'] == f, ['vertical_displacement', 'downthrow_dir', 'dip_dir','X','Y']].to_numpy()
182
+ # index = np.argmax(np.abs(displacements_numpy[:, 0]), )
183
+ index = np.argsort(np.abs(displacements_numpy[:, 0]))[len(np.abs(displacements_numpy[:, 0]))//2]
184
+
185
+ max_displacement[f] = displacements_numpy[
186
+ index, 0]
187
+ downthrow_dir[f] = displacements_numpy[index,[1,3,4]]
188
+ if np.abs(displacements_numpy[index, 1] - displacements_numpy[index, 2]) > 90:
189
+ # fault_orientations.loc[fault_orientations['formation'] == f, ['gx','gy','gy']]=-fault_orientations.loc[fault_orientations['formation'] == f, ['gx','gy','gy']]
190
+ fault_orientations.loc[fault_orientations['formation'] == f, 'DipDirection'] -= 180#displacements_numpy[
191
+ # index, 1]
192
+ # find the middle of the fault as the mean of the line, average dip direction and the influence distance
193
+ fault_centers[:3] = np.mean(fault_locations.loc[fault_locations['formation']==f,['X','Y','Z']],axis=0)
194
+ fault_centers[3] = np.mean(fault_orientations.loc[fault_orientations['formation']==f,['DipDirection']])
195
+ fault_centers[4] = fault_dimensions.loc[fault_dimensions['Fault']==f,'InfluenceDistance']
196
+ fault_centers[5] = fault_dimensions.loc[fault_dimensions['Fault']==f,'HorizontalRadius']
197
+ normal_vector[0] = np.sin(np.deg2rad(fault_centers[3]))
198
+ normal_vector[1] = np.cos(np.deg2rad(fault_centers[3]))
199
+ strike_vector[0] = normal_vector[1]
200
+ strike_vector[1] = -normal_vector[0]
201
+ slip_vector[2]=1
202
+ fault_edges[0,:] = fault_centers[:3]+normal_vector*fault_centers[4]
203
+ fault_edges[1,:] = fault_centers[:3]-normal_vector*fault_centers[4]
204
+ fault_tips[0,:] = fault_centers[:3]+strike_vector*fault_centers[5]
205
+ fault_tips[1,:] = fault_centers[:3]-strike_vector*fault_centers[5]
206
+ # fault_depth[0,:] = fault_centers[:3]+slip_vector*fault_centers[5]
207
+ # fault_depth[1,:] = fault_centers[:3]-slip_vector*fault_centers[5]
208
+ fault_locations.loc[len(fault_locations),['X','Y','Z','formation','val','coord']] = [fault_edges[0,0],fault_edges[0,1],fault_edges[0,2],f,1,0]
209
+ fault_locations.loc[len(fault_locations),['X','Y','Z','formation','val','coord']] = [fault_edges[1,0],fault_edges[1,1],fault_edges[1,2],f,-1,0]
210
+ fault_locations.loc[len(fault_locations),['X','Y','Z','formation','val','coord']] = [fault_tips[0,0],fault_tips[0,1],fault_tips[0,2],f,1,2]
211
+ fault_locations.loc[len(fault_locations),['X','Y','Z','formation','val','coord']] = [fault_tips[1,0],fault_tips[1,1],fault_tips[1,2],f,-1,2]
212
+ # add strike vector to constraint fault extent
213
+ fault_orientations.loc[len(fault_orientations),['X','Y','Z','formation','DipDirection','coord']] = [fault_centers[0],fault_centers[1],fault_centers[2],f, fault_centers[3]-90,2]
214
+ fault_orientations.loc[len(fault_orientations),['X','Y','Z','formation','dip','coord']] = [fault_centers[0],fault_centers[1],fault_centers[2],f, 0,2]
215
+
216
+ # print('downthro',displacements_numpy[index, 1])
217
+
218
+ fault_orientations['strike'] = fault_orientations['DipDirection'] - 90
219
+ fault_orientations[['gx', 'gy', 'gz']] = strike_dip_vector(fault_orientations['strike'], fault_orientations['dip'])
220
+
221
+ for g in groups['group'].unique():
222
+ groups.loc[groups['group']==g,'group'] = supergroups[g]
223
+ # fault_orientations['strike'] = fault_orientations['DipDirection'] - 90
224
+ # fault_orientations['gx'] = np.nan
225
+ # fault_orientations['gy'] = np.nan
226
+ # fault_orientations['gz'] = np.nan
227
+
228
+ fault_orientations.drop(['strike', 'DipDirection', 'dip', 'DipPolarity'], inplace=True, axis=1)
229
+ fault_orientations['feature_name'] = fault_orientations['formation']
230
+ fault_locations['feature_name'] = fault_locations['formation']
231
+
232
+
233
+
234
+ data = pd.concat([tangents, contact_orientations, contacts, fault_orientations, fault_locations])
235
+ data.reset_index()
236
+
237
+ return {'data': data,
238
+ 'groups': groups,
239
+ 'max_displacement': max_displacement,
240
+ 'fault_fault': fault_fault_relations,
241
+ 'stratigraphic_column': stratigraphic_column,
242
+ 'bounding_box':bb,
243
+ 'strat_va':strat_val,
244
+ 'downthrow_dir':downthrow_dir}
245
+
246
+ def build_model(m2l_data, skip_faults = False, unconformities=False, fault_params = None, foliation_params=None, rescale = True,**kwargs):
247
+ """[summary]
248
+
249
+ [extended_summary]
250
+
251
+ Parameters
252
+ ----------
253
+ m2l_data : dict
254
+ [description]
255
+ skip_faults : bool, optional
256
+ [description], by default False
257
+ fault_params : dict, optional
258
+ [description], by default None
259
+ foliation_params : dict, optional
260
+ [description], by default None
261
+
262
+ Returns
263
+ -------
264
+ [type]
265
+ [description]
266
+ """
267
+ from LoopStructural import GeologicalModel
268
+
269
+
270
+ boundary_points = np.zeros((2, 3))
271
+ boundary_points[0, 0] = m2l_data['bounding_box']['minx']
272
+ boundary_points[0, 1] = m2l_data['bounding_box']['miny']
273
+ boundary_points[0, 2] = m2l_data['bounding_box']['lower']
274
+ boundary_points[1, 0] = m2l_data['bounding_box']['maxx']
275
+ boundary_points[1, 1] = m2l_data['bounding_box']['maxy']
276
+ boundary_points[1, 2] = m2l_data['bounding_box']['upper']
277
+
278
+ model = GeologicalModel(boundary_points[0, :], boundary_points[1, :], rescale=rescale)
279
+ # m2l_data['data']['val'] /= model.scale_factor
280
+ model.set_model_data(m2l_data['data'])
281
+ if not skip_faults:
282
+ faults = []
283
+ for f in m2l_data['max_displacement'].keys():
284
+ if model.data[model.data['feature_name'] == f].shape[0] == 0:
285
+ continue
286
+ fault_id = f
287
+ overprints = []
288
+ try:
289
+ overprint_id = m2l_data['fault_fault'][m2l_data['fault_fault'][fault_id] == 1]['fault_id'].to_numpy()
290
+ for i in overprint_id:
291
+ overprints.append(i)
292
+ logger.info('Adding fault overprints {}'.format(f))
293
+ except:
294
+ logger.info('No entry for %s in fault_fault_relations' % f)
295
+ # continue
296
+ faults.append(model.create_and_add_fault(f,
297
+ -m2l_data['max_displacement'][f],
298
+ faultfunction='BaseFault',
299
+ overprints=overprints,
300
+ **fault_params,
301
+ )
302
+ )
303
+
304
+ ## loop through all of the groups and add them to the model in youngest to oldest.
305
+ group_features = []
306
+ for i in np.sort(m2l_data['groups']['group number'].unique()):
307
+ g = m2l_data['groups'].loc[m2l_data['groups']['group number'] == i, 'group'].unique()[0]
308
+ group_features.append(model.create_and_add_foliation(g,
309
+ **foliation_params))
310
+ # if the group was successfully added (not null) then lets add the base (0 to be unconformity)
311
+ if group_features[-1] and unconformities:
312
+ model.add_unconformity(group_features[-1], 0)
313
+ model.set_stratigraphic_column(m2l_data['stratigraphic_column'])
314
+ return model