LoopStructural 1.0.1__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 +27805 -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 +168 -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 +339 -0
  35. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/geological_interpolator.py +178 -0
  36. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/operator.py +46 -0
  37. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/piecewiselinear_interpolator.py +300 -0
  38. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/structured_grid.py +460 -0
  39. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/structured_tetra.py +637 -0
  40. Miniconda/envs/loop/Lib/site-packages/LoopStructural/interpolators/surfe_wrapper.py +119 -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 +1179 -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 +276 -0
  66. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/geological_feature_builder.py +289 -0
  67. Miniconda/envs/loop/Lib/site-packages/LoopStructural/modelling/features/region_feature.py +31 -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 +191 -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 +373 -0
  91. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/map2loop.py +229 -0
  92. Miniconda/envs/loop/Lib/site-packages/LoopStructural/utils/utils.py +76 -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 +122 -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 +704 -0
  103. Miniconda/envs/loop/Lib/site-packages/LoopStructural/visualisation/rotation_angle_plotter.py +66 -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.1-py3.7.egg-info/PKG-INFO +10 -0
  106. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.1-py3.7.egg-info/SOURCES.txt +60 -0
  107. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.1-py3.7.egg-info/dependency_links.txt +1 -0
  108. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.1-py3.7.egg-info/requires.txt +3 -0
  109. Miniconda/envs/loop/Lib/site-packages/LoopStructural-1.0.1-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,373 @@
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
+ normal /= np.linalg.norm(normal,axis=1)[:,None]
255
+ strikedip = normal_vector_to_strike_and_dip(normal)
256
+ strike_vec = get_strike_vector(strikedip[:, 0])
257
+ strike_vec /= np.linalg.norm(strike_vec,axis=0)[None,:]
258
+ dip_vec = np.cross(strike_vec, normal, axisa=0, axisb=1).T # (strikedip[:, 0], strikedip[:, 1])
259
+ dip_vec /= np.linalg.norm(dip_vec,axis=0)[None,:]
260
+ return strike_vec, dip_vec
261
+
262
+
263
+ def get_strike_vector(strike):
264
+ """
265
+
266
+ Parameters
267
+ ----------
268
+ strike
269
+
270
+ Returns
271
+ -------
272
+
273
+ """
274
+
275
+ v = np.array([np.sin(np.deg2rad(-strike)),
276
+ -np.cos(np.deg2rad(-strike)),
277
+ np.zeros(strike.shape[0])
278
+ ])
279
+
280
+ return v
281
+
282
+
283
+ def get_dip_vector(strike, dip):
284
+ v = np.array([-np.cos(np.deg2rad(-strike)) * np.cos(-np.deg2rad(dip)),
285
+ np.sin(np.deg2rad(-strike)) * np.cos(-np.deg2rad(dip)),
286
+ np.sin(-np.deg2rad(dip))
287
+ ])
288
+ return v
289
+
290
+
291
+ def rotation(axis, angle):
292
+ c = np.cos(np.deg2rad(angle))
293
+ s = np.sin((np.deg2rad(angle)))
294
+ C = 1.0 - c
295
+ x = axis[0]
296
+ y = axis[1]
297
+ z = axis[2]
298
+ xs = x * s
299
+ ys = y * s
300
+ zs = z * s
301
+ xC = x * C
302
+ yC = y * C
303
+ zC = z * C
304
+ xyC = x * yC
305
+ yzC = y * zC
306
+ zxC = z * xC
307
+ rotation_mat = np.zeros((3, 3))
308
+ rotation_mat[0][0] = x * xC + c
309
+ rotation_mat[0][1] = xyC - zs
310
+ rotation_mat[0][2] = zxC + ys
311
+
312
+ rotation_mat[1][0] = xyC + zs
313
+ rotation_mat[1][1] = y * yC + c
314
+ rotation_mat[1][2] = yzC - xs
315
+
316
+ rotation_mat[2][0] = zxC - ys
317
+ rotation_mat[2][1] = yzC + xs
318
+ rotation_mat[2][2] = z * zC + c
319
+ return rotation_mat
320
+
321
+
322
+ def strike_dip_vector(strike, dip):
323
+ vec = np.zeros((len(strike), 3))
324
+ s_r = np.deg2rad(strike)
325
+ d_r = np.deg2rad((dip))
326
+ vec[:, 0] = np.sin(d_r) * np.cos(s_r)
327
+ vec[:, 1] = -np.sin(d_r) * np.sin(s_r)
328
+ vec[:, 2] = np.cos(d_r)
329
+ vec /= np.linalg.norm(vec, axis=1)[:, None]
330
+ return vec
331
+
332
+
333
+ def normal_vector_to_strike_and_dip(normal_vector):
334
+ normal_vector /= np.linalg.norm(normal_vector, axis=1)[:, None]
335
+ dip = np.rad2deg(np.arccos(normal_vector[:, 2]))
336
+ strike = -np.rad2deg(np.arctan2(normal_vector[:, 1], normal_vector[:,
337
+ 0])) # atan2(v2[1],v2[0])*rad2deg;
338
+
339
+ return np.array([strike, dip]).T
340
+
341
+
342
+ def xyz_names():
343
+ return ['X', 'Y', 'Z']
344
+
345
+
346
+ def normal_vec_names():
347
+ return ['nx', 'ny', 'nz']
348
+
349
+
350
+ def tangent_vec_names():
351
+ return ['tx', 'ty', 'tz']
352
+
353
+
354
+ def gradient_vec_names():
355
+ return ['gx', 'gy', 'gz']
356
+
357
+
358
+ def weight_name():
359
+ return ['w']
360
+
361
+
362
+ def val_name():
363
+ return ['val']
364
+
365
+ def coord_name():
366
+ return ['coord']
367
+
368
+ def feature_name():
369
+ return ['feature_name']
370
+
371
+ def all_heading():
372
+ return xyz_names() + normal_vec_names() + tangent_vec_names() + \
373
+ gradient_vec_names() + weight_name() + val_name() + coord_name() + feature_name()
@@ -0,0 +1,229 @@
1
+ import pandas as pd
2
+ import numpy as np
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+ def process_map2loop(m2l_directory, flags={}):
8
+ """
9
+ Extracts relevant information from map2loop outputs
10
+
11
+ Parameters
12
+ ----------
13
+ m2l_directory : string
14
+ absolute path to a directory containing map2loop outputs
15
+ Returns
16
+ -------
17
+ m2l_data : dict
18
+ a dictionary containing the extracted and collated data
19
+ """
20
+ tangents = pd.read_csv(m2l_directory + '/tmp/raw_contacts.csv')
21
+ groups = pd.read_csv(m2l_directory + '/tmp/all_sorts.csv', index_col=0)
22
+ contact_orientations = pd.read_csv(m2l_directory + '/output/orientations.csv')
23
+ formation_thickness = pd.read_csv(m2l_directory + '/output/formation_thicknesses.csv')
24
+ contacts = pd.read_csv(m2l_directory + '/output/contacts4.csv')
25
+ displacements = pd.read_csv(m2l_directory + '/output/fault_displacements3.csv')
26
+ fault_orientations = pd.read_csv(m2l_directory + '/output/fault_orientations.csv')
27
+ fault_locations = pd.read_csv(m2l_directory + '/output/faults.csv')
28
+ fault_fault_relations = pd.read_csv(m2l_directory + '/output/fault-fault-relationships.csv')
29
+ fault_strat_relations = pd.read_csv(m2l_directory + '/output/group-fault-relationships.csv')
30
+ supergroups = {}
31
+ sgi = 0
32
+ try:
33
+ with open(m2l_directory + '/tmp/super_groups.csv') as f:
34
+ for l in f:
35
+ for g in l.split(','):
36
+ g = g.replace('-','_').replace(' ','_')
37
+ if g.find('\n') > 0:
38
+ g = g[:g.find('\n')]
39
+ supergroups[g] = 'supergroup_{}'.format(sgi)
40
+ if g == '\n':
41
+ sgi += 1
42
+ break
43
+ except:
44
+ for g in groups['group'].unique():
45
+ supergroups[g] = g
46
+ supergroups.pop('\n')
47
+
48
+
49
+
50
+ bb = pd.read_csv(m2l_directory+'/tmp/bbox.csv')
51
+
52
+ # process tangent data to be tx, ty, tz
53
+ tangents['tz'] = 0
54
+ tangents['tx'] = tangents['lsx']
55
+ tangents['ty'] = tangents['lsy']
56
+ tangents.drop(['angle', 'lsx', 'lsy'], inplace=True, axis=1)
57
+
58
+ # convert azimuth and dip to gx, gy, gz
59
+ from LoopStructural.utils.helper import strike_dip_vector
60
+ contact_orientations['strike'] = contact_orientations['azimuth'] - 90
61
+ contact_orientations['gx'] = np.nan
62
+ contact_orientations['gy'] = np.nan
63
+ contact_orientations['gz'] = np.nan
64
+ contact_orientations[['gx', 'gy', 'gz']] = strike_dip_vector(contact_orientations['strike'],
65
+ contact_orientations['dip'])
66
+ contact_orientations.drop(['strike', 'dip', 'azimuth'], inplace=True, axis=1)
67
+
68
+ # calculate scalar field values
69
+ thickness = {}
70
+ for f in formation_thickness['formation'].unique():
71
+ thickness[f] = np.mean(formation_thickness[formation_thickness['formation'] == f]['thickness'])
72
+
73
+ strat_val = {}
74
+ stratigraphic_column = {}
75
+ unit_id = 0
76
+ val = {}
77
+ for i in groups['group number'].unique():
78
+ g = supergroups[groups.loc[groups['group number'] == i, 'group'].iloc[0]]
79
+ if g not in stratigraphic_column:
80
+ stratigraphic_column[g] = {}
81
+ val[g] = 0
82
+
83
+ for c in groups.loc[groups['group number'] == i, 'code']:
84
+ strat_val[c] = np.nan
85
+ if c in thickness:
86
+ stratigraphic_column[g][c] = {'min': val[g], 'max': val[g] + thickness[c], 'id': unit_id}
87
+ unit_id += 1
88
+ strat_val[c] = val[g]
89
+ val[g] += thickness[c]
90
+ group_name = None
91
+ for g, i in stratigraphic_column.items():
92
+ if len(i) ==0:
93
+ for gr, sg in supergroups.items():
94
+ if sg == g:
95
+ group_name = gr
96
+ break
97
+ try:
98
+ if group_name is None:
99
+ continue
100
+ c=groups.loc[groups['group']==group_name,'code'].to_numpy()[0]
101
+ strat_val[c] = 0
102
+ stratigraphic_column[g] = {c:{'min':0,'max':9999,'id':unit_id}}
103
+ unit_id+=1
104
+ group_name = None
105
+ except:
106
+ print('Couldnt process {}'.format(g))
107
+ contacts['val'] = np.nan
108
+ for o in strat_val:
109
+ contacts.loc[contacts['formation'] == o, 'val'] = strat_val[o]
110
+
111
+ tangents['feature_name'] = tangents['group']
112
+ contact_orientations['feature_name'] = None
113
+ contacts['feature_name'] = None
114
+ for g in groups['group'].unique():
115
+ val = 0
116
+ for c in groups.loc[groups['group'] == g, 'code']:
117
+ contact_orientations.loc[contact_orientations['formation'] == c, 'feature_name'] = supergroups[g]
118
+ contacts.loc[contacts['formation'] == c, 'feature_name'] = supergroups[g]
119
+ displacements['dip_dir'] = np.nan
120
+ for fname in fault_orientations['formation'].unique():
121
+ displacements.loc[displacements['fname'] == fname, 'dip_dir'] = np.mean(
122
+ fault_orientations.loc[fault_orientations['formation'] == fname, 'DipDirection'])
123
+ max_displacement = {}
124
+ for f in displacements['fname'].unique():
125
+ displacements_numpy = displacements.loc[
126
+ displacements['fname'] == f, ['vertical_displacement', 'downthrow_dir', 'dip_dir']].to_numpy()
127
+ # index = np.argmax(np.abs(displacements_numpy[:, 0]), )
128
+ index = np.argsort(np.abs(displacements_numpy[:, 0]))[len(np.abs(displacements_numpy[:, 0]))//2]
129
+
130
+ max_displacement[f] = displacements_numpy[
131
+ index, 0]
132
+ if displacements_numpy[index, 1] - displacements_numpy[index, 2] > 90:
133
+ fault_orientations.loc[fault_orientations['formation'] == fname, 'DipDirection'] = displacements_numpy[
134
+ index, 1]
135
+ # .loc[displacements['fname'] == f,'vertical_displacement'].max()
136
+ for g in groups['group'].unique():
137
+ groups.loc[groups['group']==g,'group'] = supergroups[g]
138
+ fault_orientations['strike'] = fault_orientations['DipDirection'] - 90
139
+ fault_orientations['gx'] = np.nan
140
+ fault_orientations['gy'] = np.nan
141
+ fault_orientations['gz'] = np.nan
142
+
143
+ fault_orientations[['gx', 'gy', 'gz']] = strike_dip_vector(fault_orientations['strike'], fault_orientations['dip'])
144
+ fault_orientations.drop(['strike', 'DipDirection', 'dip', 'DipPolarity'], inplace=True, axis=1)
145
+ fault_orientations['feature_name'] = fault_orientations['formation']
146
+
147
+ fault_locations['val'] = 0
148
+ fault_locations['feature_name'] = fault_locations['formation']
149
+
150
+
151
+ data = pd.concat([tangents, contact_orientations, contacts, fault_orientations, fault_locations])
152
+ data.reset_index()
153
+
154
+ return {'data': data,
155
+ 'groups': groups,
156
+ 'max_displacement': max_displacement,
157
+ 'fault_fault': fault_fault_relations,
158
+ 'stratigraphic_column': stratigraphic_column,
159
+ 'bounding_box':bb,
160
+ 'strat_va':strat_val}
161
+
162
+ def build_model(m2l_data, skip_faults = False, unconformities=False, fault_params = None, foliation_params=None):
163
+ """[summary]
164
+
165
+ [extended_summary]
166
+
167
+ Parameters
168
+ ----------
169
+ m2l_data : dict
170
+ [description]
171
+ skip_faults : bool, optional
172
+ [description], by default False
173
+ fault_params : dict, optional
174
+ [description], by default None
175
+ foliation_params : dict, optional
176
+ [description], by default None
177
+
178
+ Returns
179
+ -------
180
+ [type]
181
+ [description]
182
+ """
183
+ from LoopStructural import GeologicalModel
184
+
185
+
186
+ boundary_points = np.zeros((2, 3))
187
+ boundary_points[0, 0] = m2l_data['bounding_box']['minx']
188
+ boundary_points[0, 1] = m2l_data['bounding_box']['miny']
189
+ boundary_points[0, 2] = m2l_data['bounding_box']['lower']
190
+ boundary_points[1, 0] = m2l_data['bounding_box']['maxx']
191
+ boundary_points[1, 1] = m2l_data['bounding_box']['maxy']
192
+ boundary_points[1, 2] = m2l_data['bounding_box']['upper']
193
+
194
+ model = GeologicalModel(boundary_points[0, :], boundary_points[1, :])
195
+ model.set_model_data(m2l_data['data'])
196
+ if not skip_faults:
197
+ faults = []
198
+ for f in m2l_data['max_displacement'].keys():
199
+ if model.data[model.data['feature_name'] == f].shape[0] == 0:
200
+ continue
201
+ fault_id = f
202
+ overprints = []
203
+ try:
204
+ overprint_id = m2l_data['fault_fault'][m2l_data['fault_fault'][fault_id] == 1]['fault_id'].to_numpy()
205
+ for i in overprint_id:
206
+ overprints.append(i)
207
+ logger.info('Adding fault overprints {}'.format(f))
208
+ except:
209
+ logger.info('No entry for %s in fault_fault_relations' % f)
210
+ # continue
211
+ faults.append(model.create_and_add_fault(f,
212
+ -m2l_data['max_displacement'][f],
213
+ faultfunction='BaseFault',
214
+ overprints=overprints,
215
+ **fault_params,
216
+ )
217
+ )
218
+
219
+ ## loop through all of the groups and add them to the model in youngest to oldest.
220
+ group_features = []
221
+ for i in np.sort(m2l_data['groups']['group number'].unique()):
222
+ g = m2l_data['groups'].loc[m2l_data['groups']['group number'] == i, 'group'].unique()[0]
223
+ group_features.append(model.create_and_add_foliation(g,
224
+ **foliation_params))
225
+ # if the group was successfully added (not null) then lets add the base (0 to be unconformity)
226
+ if group_features[-1] and unconformities:
227
+ model.add_unconformity(group_features[-1], 0)
228
+ model.set_stratigraphic_column(m2l_data['stratigraphic_column'])
229
+ return model
@@ -0,0 +1,76 @@
1
+ import logging
2
+
3
+ import numpy as np
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ def strike_symbol(strike):
9
+ R = np.zeros((2, 2))
10
+ R[0, 0] = np.cos(np.deg2rad(-strike))
11
+ R[0, 1] = -np.sin(np.deg2rad(-strike))
12
+ R[1, 0] = np.sin(np.deg2rad(-strike))
13
+ R[1, 1] = np.cos(np.deg2rad(-strike))
14
+ R = np.zeros((2, 2))
15
+ R[0, 0] = np.cos(np.deg2rad(-strike))
16
+ R[0, 1] = -np.sin(np.deg2rad(-strike))
17
+ R[1, 0] = np.sin(np.deg2rad(-strike))
18
+ R[1, 1] = np.cos(np.deg2rad(-strike))
19
+
20
+ vec = np.array([0, 1])
21
+ rotated = R @ vec
22
+ vec2 = np.array([-0.5, 0])
23
+ r2 = R @ vec2
24
+ return rotated, r2
25
+ def get_levels():
26
+ """dict for converting to logger levels from string
27
+
28
+
29
+ Returns
30
+ -------
31
+ dict
32
+ contains all strings with corresponding logging levels.
33
+ """
34
+ return {'info':logging.INFO,'warning':logging.WARNING,'error':logging.ERROR,'debug':logging.DEBUG}
35
+
36
+ def log_to_file(filename,level='info'):
37
+ """Set the logging parameters for log file
38
+
39
+
40
+ Parameters
41
+ ----------
42
+ filename : string
43
+ name of file or path to file
44
+ level : str, optional
45
+ 'info', 'warning', 'error', 'debug' mapped to logging levels, by default 'info'
46
+ """
47
+ levels = get_levels()
48
+ level = levels.get(level,logging.WARNING)
49
+ logging.basicConfig(level=level,
50
+ format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
51
+ datefmt='%m-%d %H:%M',
52
+ filename=filename,
53
+ filemode='w')
54
+
55
+ def log_to_console(level='warning'):
56
+ """Set the level of logging to the console
57
+
58
+
59
+ Parameters
60
+ ----------
61
+ level : str, optional
62
+ 'info', 'warning', 'error', 'debug' mapped to logging levels, by default 'info'
63
+ """
64
+ levels = get_levels()
65
+ level = levels.get(level,logging.WARNING)
66
+
67
+ changed_level = False
68
+ for h in logging.getLogger().handlers:
69
+ if type(h) is logging.StreamHandler:
70
+ h.setLevel(level)
71
+ changed_level = True
72
+ if not changed_level:
73
+ console = logging.StreamHandler()
74
+ console.setLevel(level)
75
+ # add the handler to the root logger
76
+ logging.getLogger().addHandler(console)
@@ -0,0 +1,19 @@
1
+ """
2
+ This is the base visualistion module for loop structural
3
+
4
+ Submodules
5
+ ==========
6
+
7
+ .. autosummary::
8
+ :toctree: _autosummary
9
+
10
+ map_viewer
11
+ model_visualisation
12
+ rotation_angle_plotter
13
+
14
+ """
15
+
16
+ from .map_viewer import MapView
17
+ from .model_visualisation import LavaVuModelViewer
18
+ from .sphinx_scraper import _get_loop_visualisation_scraper
19
+ from .rotation_angle_plotter import RotationAnglePlotter