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,57 @@
1
+ import logging
2
+
3
+ import numpy as np
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ class FoldRotationAngleFeature:
9
+ """
10
+
11
+ """
12
+ def __init__(self, fold_frame, rotation):
13
+ """
14
+
15
+ Parameters
16
+ ----------
17
+ fold_frame
18
+ rotation
19
+ """
20
+ self.fold_frame = fold_frame
21
+ self.rotation = rotation
22
+
23
+ def evaluate_value(self, location):
24
+ """
25
+
26
+ Parameters
27
+ ----------
28
+ location
29
+
30
+ Returns
31
+ -------
32
+
33
+ """
34
+ s1 = self.fold_frame.features[0].evaluate_value(location)
35
+ r = self.rotation(s1)
36
+ return r
37
+
38
+
39
+ def fourier_series(x, c0, c1, c2, w):
40
+ """
41
+
42
+ Parameters
43
+ ----------
44
+ x
45
+ c0
46
+ c1
47
+ c2
48
+ w
49
+
50
+ Returns
51
+ -------
52
+
53
+ """
54
+ v = np.array(x.astype(float))
55
+ # v.fill(c0)
56
+ v = c0 + c1 * np.cos(2 * np.pi / w * x) + c2 * np.sin(2 * np.pi / w * x)
57
+ return np.rad2deg(np.arctan(v))
@@ -0,0 +1,192 @@
1
+ import logging
2
+
3
+ import numpy as np
4
+
5
+ from LoopStructural.modelling.features.structural_frame import StructuralFrame
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+
10
+ class FoldFrame(StructuralFrame):
11
+ def __init__(self, name, features, fold=None):
12
+ """
13
+ A structural frame that can calculate the fold axis/limb rotation angle
14
+ Same constructor arguments as parent StructuralFrame
15
+
16
+ Parameters
17
+ ----------
18
+ name
19
+ features
20
+ """
21
+ super().__init__(name, features, fold)
22
+ self.model = None
23
+
24
+ def set_model(self, model):
25
+ self.model = model
26
+
27
+ def calculate_fold_axis_rotation(self, feature_builder):
28
+ """
29
+ Calculate the fold axis rotation angle by finding the angle between the
30
+ intersection lineation and the gradient to the 1st coordinate of the
31
+ fold frame
32
+ Parameters
33
+ ----------
34
+ feature_builder - GeologicalFeatureInterpolator
35
+ - the builder for the geological feature that is folded
36
+
37
+ Returns
38
+ -------
39
+
40
+ """
41
+ gpoints = feature_builder.get_gradient_constraints()[:,:6]
42
+ npoints = feature_builder.get_norm_constraints()[:,:6]
43
+ points = []
44
+ if gpoints.shape[0] > 0:
45
+ points.append(gpoints)
46
+ if npoints.shape[0] > 0:
47
+ points.append(npoints)
48
+ if len(points) == 0:
49
+ return 0, 0
50
+ points = np.vstack(points)
51
+ # We need to ignore the fault when we are calculating the splot because it is done
52
+ # in the restored space
53
+ # self.features[0].faults_enabled = False
54
+ # self.features[1].faults_enabled = False
55
+ s1g = self.features[0].evaluate_gradient(points[:, :3])
56
+ s1g /= np.linalg.norm(s1g, axis=1)[:, None]
57
+ s1gyg = self.features[1].evaluate_gradient(points[:, :3])
58
+ s1gyg /= np.linalg.norm(s1gyg, axis=1)[:, None]
59
+ l1 = points[:, 3:]
60
+ l1 /= np.linalg.norm(l1, axis=1)[:, None]
61
+ fad = self.features[1].evaluate_value(points[:, :3])
62
+ # Turn the faults back on
63
+ # self.features[0].faults_enabled = True
64
+ # self.features[1].faults_enabled = True
65
+
66
+ # project s0 onto axis plane B X A X B
67
+ projected_l1 = np.cross(s1g, np.cross(l1, s1g, axisa=1, axisb=1),
68
+ axisa=1, axisb=1)
69
+ projected_s1gyg = np.cross(s1g, np.cross(s1gyg, s1g, axisa=1, axisb=1),
70
+ axisa=1, axisb=1)
71
+
72
+ # einsum dot product
73
+ far = np.einsum('ij,ij->i', projected_l1, projected_s1gyg)
74
+ far = np.rad2deg(np.arccos(far))
75
+ # scalar triple product
76
+ stp = np.einsum('ij,ij->i', np.cross(l1, s1gyg, axisa=1, axisb=1), s1g)
77
+ # check bounds
78
+ far-=90
79
+ # far[stp < 0] = 360.- far[stp < 0]
80
+ far[far>90] = far[far>90]+-180
81
+ far[far<-90] = far[far<-90]+180
82
+
83
+ return far, fad
84
+
85
+ def calculate_fold_limb_rotation(self, feature_builder, axis=None):
86
+ """
87
+ Calculate the fold limb rotation angle using the axis specified and
88
+ the normals to the folded foliation
89
+ Parameters
90
+ ----------
91
+ feature_builder - GeologicalFeatureInterpolator
92
+ the feature interpolator for the folded feature that has the
93
+ datapoints the fold limb rotation angle is
94
+ going to be calculated for
95
+ axis - GeologicalFeature
96
+ Optional. Fold axis feature that when queried for location
97
+ returns the fold axis
98
+
99
+ Returns
100
+ -------
101
+ fold_limb_rotation, coordinate_0
102
+ """
103
+ # self.features[0].faults_enabled = False
104
+ # self.features[1].faults_enabled = False
105
+
106
+ gpoints = feature_builder.interpolator.get_gradient_constraints()[:,:6]
107
+ npoints = feature_builder.interpolator.get_norm_constraints()[:,:6]
108
+ points = []
109
+ if gpoints.shape[0] > 0:
110
+ points.append(gpoints)
111
+ if npoints.shape[0] > 0:
112
+ points.append(npoints)
113
+ if len(points) == 0:
114
+ logger.error("No points to calculate fold rotation angle")
115
+ return np.array([0]), np.array([0])
116
+ points = np.vstack(points)
117
+ # for f in feature_builder.faults:
118
+ # points[:,:3] = f.apply_to_points(points[:,:3])
119
+ # get the normals from the points array
120
+ s0g = points[:, 3:]
121
+
122
+ s0g/=np.linalg.norm(s0g,axis=1)[:,None]
123
+ # calculate the gradient and value of the first coordinate of the
124
+ # fold frame
125
+ # for the locations and normalise
126
+ s1g = self.features[0].evaluate_gradient(points[:, :3])
127
+ s1g /= np.linalg.norm(s1g, axis=1)[:, None]
128
+ s1 = self.features[0].evaluate_value(points[:, :3])
129
+ # self.features[0].faults_enabled = True
130
+ # self.features[1].faults_enabled = True
131
+
132
+ if axis is None:
133
+ logger.info("Not using fold axis for fold limb rotation angle calculation")
134
+ r2 = np.einsum('ij,ij->i', s1g, s0g)
135
+
136
+ return np.rad2deg(np.arcsin(r2)), s1
137
+ if axis is not None:
138
+ fold_axis = axis(points[:, :3])
139
+ # project s0 onto axis plane B X A X B
140
+ projected_s0 = np.cross(fold_axis,
141
+ np.cross(s0g, fold_axis, axisa=1, axisb=1),
142
+ axisa=1, axisb=1)
143
+ projected_s1 = np.cross(fold_axis,
144
+ np.cross(s1g, fold_axis, axisa=1, axisb=1),
145
+ axisa=1, axisb=1)
146
+ projected_s0 /= np.linalg.norm(projected_s0, axis=1)[:, None]
147
+ projected_s1 /= np.linalg.norm(projected_s1, axis=1)[:, None]
148
+ r2 = np.einsum('ij,ij->i', projected_s1, projected_s0) #
149
+ # adjust the fold rotation angle so that its always between -90
150
+ # and 90
151
+ vv = np.cross(s1g, s0g, axisa=1, axisb=1)
152
+ ds = np.einsum('ij,ij->i', fold_axis, vv)
153
+ flr = np.where(ds > 0, np.rad2deg(np.arcsin(r2)),
154
+ (- np.rad2deg(np.arcsin(r2))))
155
+ flr = np.where(flr < -90, (180. + flr), flr)
156
+ flr = np.where(flr > 90, -(180. - flr), flr)
157
+ return flr, s1
158
+
159
+ def calculate_intersection_lineation(self, feature_builder):
160
+ """
161
+ Calculate the intersection lineation by finding the cross product
162
+ between the first fold frame
163
+ coordinate and the vector representing the normal to the folded
164
+ foliation
165
+ Parameters
166
+ ----------
167
+ feature_builder - GeologicalFeatureInterpolator
168
+ the feature builder that contains the data points that the
169
+ intersection lineation is calculated for
170
+
171
+
172
+ Returns Nx3 array of doubles
173
+ -------
174
+
175
+ """
176
+ self.features[0].faults_enabled = False
177
+ gpoints = feature_builder.interpolator.get_gradient_constraints()[:,:6]
178
+ npoints = feature_builder.interpolator.get_norm_constraints()[:,:6]
179
+ points = []
180
+ if gpoints.shape[0] > 0:
181
+ points.append(gpoints)
182
+ if npoints.shape[0] > 0:
183
+ points.append(npoints)
184
+ points = np.vstack(points)
185
+ s1g = self.features[0].evaluate_gradient(points[:, :3])
186
+ s1g /= np.linalg.norm(points[:, :3], axis=1)[:, None]
187
+ s0g = points[:, 3:]
188
+ s0g /= np.linalg.norm(s0g, axis=1)[:, None]
189
+ l1 = np.cross(s1g, s0g, axisa=1, axisb=1)
190
+ l1 /= np.linalg.norm(l1, axis=1)[:, None]
191
+ self.features[0].faults_enabled = True
192
+ return l1
@@ -0,0 +1,179 @@
1
+ import logging
2
+
3
+ import numpy as np
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ def find_peaks_and_troughs(x, y):
9
+ """
10
+
11
+ Parameters
12
+ ----------
13
+ x np.array or list
14
+ x axis data for plot
15
+ y np.array or list
16
+ y axis data for plot
17
+ Returns
18
+ -------
19
+ (np.array, np.array)
20
+ Notes
21
+ -----
22
+ Returns the loations of maxima/minima on the curve using finite
23
+ difference forward/backwards
24
+ finding the change in derivative
25
+ """
26
+ if len(x) != len(y):
27
+ return False
28
+ pairsx = []
29
+ pairsy = []
30
+ # #TODO numpyize
31
+ for i in range(0, len(x)):
32
+ if i < 1:
33
+ pairsx.append(x[i])
34
+ pairsy.append(y[i])
35
+
36
+ continue
37
+ if i > len(x) - 2:
38
+ pairsx.append(x[i])
39
+ pairsy.append(y[i])
40
+ continue
41
+ left_grad = (y[i - 1] - y[i]) / (x[i - 1] - x[i])
42
+ right_grad = (y[i] - y[i + 1]) / (x[i] - x[i + 1])
43
+ if np.sign(left_grad) != np.sign(right_grad):
44
+ pairsx.append(x[i])
45
+ pairsy.append(y[i])
46
+ return pairsx, pairsy
47
+
48
+
49
+ class SVariogram():
50
+ """
51
+ The SVariogram is an experimental semi-variogram.
52
+ """
53
+
54
+ def __init__(self, xdata, ydata):
55
+ self.xdata = xdata
56
+ self.ydata = ydata
57
+ self.dist = np.abs(self.xdata[:, None] - self.xdata[None, :])
58
+ self.variance_matrix = (self.ydata[:, None] - self.ydata[None, :]) ** 2
59
+ self.lags = None
60
+ self.variogram = None
61
+
62
+ def calc_semivariogram(self, lag = None, nlag = None, lags = None):
63
+ """
64
+ Calculate a semi-variogram for the x and y data for this object.
65
+ You can specify the lags as an array or specify the step size and
66
+ number of steps.
67
+ If neither are specified then the lags are created to be the average
68
+ spacing of the data
69
+
70
+ Parameters
71
+ ----------
72
+ step: float
73
+ lag distance for the s-variogram
74
+ nstep: int
75
+ number of lags for the s-variogram
76
+ lags: array
77
+ num
78
+
79
+ Returns
80
+ -------
81
+
82
+ """
83
+ logger.info("Calculating S-Variogram")
84
+ if lag is not None:
85
+ step = lag
86
+ logger.info("Using lag: %f kwarg for S-variogram"%step)
87
+
88
+ if nlag is not None:
89
+ nstep = nlag
90
+ logger.info("Using nlag %i kwarg for s-variogram"%nstep)
91
+
92
+ self.lags = np.arange(step / 2., nstep * step, step)
93
+
94
+ if nlag is None and lag is not None:
95
+ nstep = int(
96
+ np.ceil((np.nanmax(self.xdata) - np.nanmin(self.xdata)) / step))
97
+ logger.info("Using lag kwarg but calculating nlag as %i for s-variogram"%nstep)
98
+
99
+ self.lags = np.arange(step / 2., nstep * step, step)
100
+
101
+ if lags is not None:
102
+ self.lags = lags
103
+
104
+ if self.lags is None:
105
+ # time to guess the step size
106
+ # find the average distance between elements in the input data
107
+ d = np.copy(self.dist)
108
+ d[d == 0] = np.nan
109
+
110
+ step = np.nanmean(np.nanmin(d, axis=1))*4.
111
+ # find number of steps to cover range in data
112
+ nstep = int(
113
+ np.ceil((np.nanmax(self.xdata) - np.nanmin(self.xdata)) / step))
114
+ self.lags = np.arange(step / 2., nstep * step, step)
115
+ logger.info("Using average minimum nearest neighbour distance "
116
+ "as lag distance size {} and using {} lags".format(step,nstep))
117
+ tol = self.lags[1] - self.lags[0]
118
+ self.variogram = np.zeros(self.lags.shape)
119
+ self.variogram[:] = np.nan
120
+ npairs = np.zeros(self.lags.shape)
121
+ for i in range(len(self.lags)):
122
+ logic = np.logical_and(self.dist > self.lags[i]
123
+ - tol / 2.,
124
+ self.dist < self.lags[i] + tol / 2.)
125
+ npairs[i] = np.sum(logic.astype(int))
126
+ if npairs[i] > 0:
127
+ self.variogram[i] = np.mean(self.variance_matrix[logic])
128
+ return self.lags, self.variogram, npairs
129
+
130
+ def find_wavelengths(self, **kwargs):
131
+ """
132
+ Picks the wavelengths of the fold by finding the maximum and
133
+ minimums of the s-variogram
134
+ the fold wavelength is the first minimum but it is more reliable to
135
+ use the first maximum
136
+ as the estimate of the wavelength.
137
+
138
+ Parameters
139
+ ----------
140
+ kwargs : object
141
+ """
142
+ h, var, npairs = self.calc_semivariogram(**kwargs)
143
+
144
+ px, py = find_peaks_and_troughs(h, var)
145
+
146
+ averagex = []
147
+ averagey = []
148
+ for i in range(len(px) - 1):
149
+ averagex.append((px[i] + px[i + 1]) / 2.)
150
+ averagey.append((py[i] + py[i + 1]) / 2.)
151
+ i += 1 # iterate twice
152
+ # find the extrema of the average curve
153
+ px2, py2 = find_peaks_and_troughs(averagex, averagey)
154
+ wl1 = 0.
155
+ wl1py = 0.
156
+ for i in range(len(px)):
157
+ if i > 0 and i < len(px) - 1:
158
+ if py[i] > 10:
159
+
160
+ if py[i - 1] < py[i] * .7:
161
+ if py[i + 1] < py[i] * .7:
162
+ wl1 = px[i]
163
+ if wl1 > 0.:
164
+ wl1py = py[i]
165
+ break
166
+ wl2 = 0.
167
+ for i in range(len(px2)):
168
+ if i > 0 and i < len(px2) - 1:
169
+ if py2[i - 1] < py2[i] * .90:
170
+ if py2[i + 1] < py2[i] * .90:
171
+ wl2 = px2[i]
172
+ if wl2 > 0. and wl2 > wl1 * 2 and wl1py < py2[i]:
173
+ break
174
+ if wl1 == 0.0 and wl2 == 0.0:
175
+ return 2 * (np.max(self.xdata) - np.min(self.xdata)), 0.
176
+ if np.isclose(wl1, 0.0):
177
+ return np.array([wl2 * 2., wl1 * 2.])
178
+ # wavelength is 2x the peak on the curve
179
+ return np.array([wl1 * 2., wl2 * 2.])
@@ -0,0 +1,14 @@
1
+ """
2
+ This is contains all of the utilities for loop structural
3
+
4
+ Submodules
5
+ ==========
6
+
7
+ .. autosummary::
8
+ :toctree: _autosummary
9
+
10
+ helper
11
+ utils
12
+
13
+ """
14
+ from .map2loop import process_map2loop, build_model
@@ -0,0 +1,9 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger(__name__)
4
+
5
+ class LoopBaseException(Exception):
6
+ """
7
+ Base loop exception
8
+ """
9
+ # logger.error("Raising loop base exception")