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,342 @@
1
+ """
2
+ FiniteDifference interpolator
3
+ """
4
+ import logging
5
+
6
+ import numpy as np
7
+
8
+ from LoopStructural.utils.helper import get_vectors
9
+ from .discrete_interpolator import DiscreteInterpolator
10
+ from .operator import Operator
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class FiniteDifferenceInterpolator(DiscreteInterpolator):
16
+ """
17
+
18
+ """
19
+
20
+ def __init__(self, grid):
21
+ """
22
+ Finite difference interpolation on a regular cartesian grid
23
+
24
+ Parameters
25
+ ----------
26
+ grid : StructuredGrid
27
+ """
28
+ self.shape = 'rectangular'
29
+ DiscreteInterpolator.__init__(self, grid)
30
+ # default weights for the interpolation matrix are 1 in x,y,z and
31
+ # 1/
32
+ self.set_interpolation_weights({'dxy': .7,
33
+ 'dyz': .7,
34
+ 'dxz': .7,
35
+ 'dxx': 1.,
36
+ 'dyy': 1.,
37
+ 'dzz': 1.,
38
+ 'dx': 1.,
39
+ 'dy': 1.,
40
+ 'dz': 1.,
41
+ 'cpw': 1.,
42
+ 'gpw': 1.,
43
+ 'npw': 1.,
44
+ 'tpw': 1.})
45
+
46
+ self.vol = grid.step_vector[0] * grid.step_vector[1] * \
47
+ grid.step_vector[2]
48
+
49
+ def _setup_interpolator(self, **kwargs):
50
+ """
51
+
52
+ Parameters
53
+ ----------
54
+ kwargs
55
+ possible kwargs are weights for the different masks and masks.
56
+
57
+ Notes
58
+ -----
59
+ Default masks are the second derivative in x,y,z direction and the second derivative of x wrt
60
+ y and y wrt z and z wrt x. Custom masks can be used by specifying the operator as a 3d numpy array
61
+ e.g. [ [ [ 0 0 0 ]
62
+ [ 0 1 0 ]
63
+ [ 0 0 0 ] ]
64
+ [ [ 1 1 1 ]
65
+ [ 1 1 1 ]
66
+ [ 1 1 1 ] ]
67
+ [ [ 0 0 0 ]
68
+ [ 0 1 0 ]
69
+ [ 0 0 0 ] ]
70
+
71
+ Returns
72
+ -------
73
+
74
+ """
75
+
76
+ for key in kwargs:
77
+ self.up_to_date = False
78
+ if 'regularisation' in kwargs:
79
+ self.interpolation_weights['dxy'] = kwargs[
80
+ 'regularisation'] * 0.7
81
+ self.interpolation_weights['dyz'] = kwargs[
82
+ 'regularisation'] * 0.7
83
+ self.interpolation_weights['dxz'] = kwargs[
84
+ 'regularisation'] * 0.7
85
+ self.interpolation_weights['dxx'] = kwargs[
86
+ 'regularisation'] * 1.
87
+ self.interpolation_weights['dyy'] = kwargs[
88
+ 'regularisation'] * 1.
89
+ self.interpolation_weights['dzz'] = kwargs[
90
+ 'regularisation'] * 1.
91
+ self.interpolation_weights[key] = kwargs[key]
92
+ # if we want to define the operators manually
93
+ if 'operators' in kwargs:
94
+ for n, o in kwargs['operators'].items():
95
+ self.assemble_inner(o[0], o[1])
96
+ # otherwise just use defaults
97
+ if 'operators' not in kwargs:
98
+ operator = Operator.Dxy_mask
99
+
100
+ self.assemble_inner(operator, np.sqrt(2 * self.vol) *
101
+ self.interpolation_weights['dxy'])
102
+ operator = Operator.Dyz_mask
103
+ self.assemble_inner(operator, np.sqrt(2 * self.vol) *
104
+ self.interpolation_weights['dyz'])
105
+ operator = Operator.Dxz_mask
106
+ self.assemble_inner(operator, np.sqrt(2 * self.vol) *
107
+ self.interpolation_weights['dxz'])
108
+ operator = Operator.Dxx_mask
109
+ self.assemble_inner(operator,
110
+ np.sqrt(self.vol) * self.interpolation_weights[
111
+ 'dxx'])
112
+ operator = Operator.Dyy_mask
113
+ self.assemble_inner(operator,
114
+ np.sqrt(self.vol) * self.interpolation_weights[
115
+ 'dyy'])
116
+ operator = Operator.Dzz_mask
117
+ self.assemble_inner(operator,
118
+ np.sqrt(self.vol) * self.interpolation_weights[
119
+ 'dzz'])
120
+ self.add_norm_constraint(
121
+ np.sqrt(self.vol) * self.interpolation_weights['npw'])
122
+ self.add_gradient_constraint(
123
+ np.sqrt(self.vol) * self.interpolation_weights['gpw'])
124
+ self.add_vaue_constraint(
125
+ np.sqrt(self.vol) * self.interpolation_weights['cpw'])
126
+ self.add_tangent_ctr_pts(
127
+ np.sqrt(self.vol) * self.interpolation_weights['tpw']
128
+ )
129
+
130
+ def copy(self):
131
+ """
132
+ Create a new identical interpolator
133
+
134
+ Returns
135
+ -------
136
+ returns a new empy interpolator from the same support
137
+ """
138
+ return FiniteDifferenceInterpolator(self.support)
139
+
140
+ def add_vaue_constraint(self, w=1.):
141
+ """
142
+
143
+ Parameters
144
+ ----------
145
+ w : double or numpy array
146
+
147
+ Returns
148
+ -------
149
+
150
+ """
151
+
152
+ points = self.get_value_constraints()
153
+ # check that we have added some points
154
+ if points.shape[0] > 0:
155
+ node_idx, inside = self.support.position_to_cell_corners(
156
+ points[:, :3])
157
+ # print(points[inside,:].shape)
158
+
159
+ gi = np.zeros(self.support.n_nodes)
160
+ gi[:] = -1
161
+ gi[self.region] = np.arange(0, self.nx)
162
+ idc = np.zeros(node_idx.shape)
163
+ idc[:] = -1
164
+
165
+ idc[inside, :] = gi[node_idx[inside, :]]
166
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
167
+ a = self.support.position_to_dof_coefs(points[inside, :3])
168
+ # a*=w
169
+
170
+ self.add_constraints_to_least_squares(a.T * w,
171
+ points[inside, 3] * w,
172
+ idc[inside, :])
173
+
174
+ def add_gradient_constraint(self, w=1.):
175
+ """
176
+
177
+ Parameters
178
+ ----------
179
+ w : double / numpy array
180
+
181
+ Returns
182
+ -------
183
+
184
+ """
185
+
186
+ points = self.get_gradient_constraints()
187
+ if points.shape[0] > 0:
188
+ # calculate unit vector for orientation data
189
+ # points[:,3:]/=np.linalg.norm(points[:,3:],axis=1)[:,None]
190
+
191
+ node_idx, inside = self.support.position_to_cell_corners(
192
+ points[:, :3])
193
+ # calculate unit vector for node gradients
194
+ # this means we are only constraining direction of grad not the
195
+ # magnitude
196
+ gi = np.zeros(self.support.n_nodes)
197
+ gi[:] = -1
198
+ gi[self.region] = np.arange(0, self.nx)
199
+ idc = np.zeros(node_idx.shape)
200
+ idc[:] = -1
201
+ idc[inside, :] = gi[node_idx[inside, :]]
202
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
203
+
204
+ T = self.support.calcul_T(points[inside, :3])
205
+ strike_vector, dip_vector = get_vectors(points[inside, 3:6])
206
+ A = np.einsum('ij,ijk->ik', strike_vector.T, T)
207
+
208
+ B = np.zeros(points[inside, :].shape[0])
209
+ self.add_constraints_to_least_squares(A * w, B, idc[inside, :])
210
+ A = np.einsum('ij,ijk->ik', dip_vector.T, T)
211
+ self.add_constraints_to_least_squares(A * w, B, idc[inside, :])
212
+
213
+ def add_norm_constraint(self, w=1.):
214
+ """
215
+ Add constraints to control the norm of the gradient of the scalar field
216
+
217
+ Parameters
218
+ ----------
219
+ w : double
220
+ weighting of this constraint (double)
221
+
222
+ Returns
223
+ -------
224
+
225
+ """
226
+ points = self.get_norm_constraints()
227
+ if points.shape[0] > 0:
228
+ # calculate unit vector for orientation data
229
+ # points[:,3:]/=np.linalg.norm(points[:,3:],axis=1)[:,None]
230
+
231
+ node_idx, inside = self.support.position_to_cell_corners(
232
+ points[:, :3])
233
+ gi = np.zeros(self.support.n_nodes)
234
+ gi[:] = -1
235
+ gi[self.region] = np.arange(0, self.nx)
236
+ idc = np.zeros(node_idx.shape)
237
+ idc[:] = -1
238
+ idc[inside, :] = gi[node_idx[inside, :]]
239
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
240
+
241
+ # calculate unit vector for node gradients
242
+ # this means we are only constraining direction of grad not the
243
+ # magnitude
244
+ T = self.support.calcul_T(points[inside, :3])
245
+
246
+ w /= 3
247
+ self.add_constraints_to_least_squares(T[:, 0, :] * w,
248
+ points[inside, 3] * w,
249
+ idc[inside, :])
250
+ self.add_constraints_to_least_squares(T[:, 1, :] * w,
251
+ points[inside, 4] * w,
252
+ idc[inside, :])
253
+ self.add_constraints_to_least_squares(T[:, 2, :] * w,
254
+ points[inside, 5] * w,
255
+ idc[inside, :])
256
+
257
+ def add_gradient_orthogonal_constraint(self, points, vector, w=1.0,
258
+ B=0):
259
+ """
260
+ constraints scalar field to be orthogonal to a given vector
261
+
262
+ Parameters
263
+ ----------
264
+ elements : np.array
265
+ normals : np.array
266
+ w : double
267
+ B : np.array
268
+
269
+ Returns
270
+ -------
271
+
272
+ """
273
+ if points.shape[0] > 0:
274
+ # calculate unit vector for orientation data
275
+ # points[:,3:]/=np.linalg.norm(points[:,3:],axis=1)[:,None]
276
+
277
+ node_idx, inside = self.support.position_to_cell_corners(
278
+ points[:, :3])
279
+ # calculate unit vector for node gradients
280
+ # this means we are only constraining direction of grad not the
281
+ # magnitude
282
+ gi = np.zeros(self.support.n_nodes)
283
+ gi[:] = -1
284
+ gi[self.region] = np.arange(0, self.nx)
285
+ idc = np.zeros(node_idx.shape)
286
+ idc[:] = -1
287
+
288
+ idc[inside, :] = gi[node_idx[inside, :]]
289
+ inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
290
+
291
+ T = self.support.calcul_T(points[inside, :3])
292
+ A = np.einsum('ij,ijk->ik', vector[inside, :3], T)
293
+
294
+ B = np.zeros(points[inside, :].shape[0])
295
+ self.add_constraints_to_least_squares(A * w, B, idc[inside, :])
296
+
297
+ def add_regularisation(self, operator, w=0.1):
298
+ """
299
+
300
+ Parameters
301
+ ----------
302
+ operator
303
+ w
304
+
305
+ Returns
306
+ -------
307
+
308
+ """
309
+ self.assemble_inner(operator)
310
+ # self.assemble_borders()
311
+
312
+ def assemble_inner(self, operator, w):
313
+ """
314
+
315
+ Parameters
316
+ ----------
317
+ operator : Operator
318
+ w : double
319
+
320
+ Returns
321
+ -------
322
+
323
+ """
324
+ # First get the global indicies of the pairs of neighbours this should be an
325
+ # Nx27 array for 3d and an Nx9 array for 2d
326
+
327
+ global_indexes = self.support.neighbour_global_indexes() # np.array([ii,jj]))
328
+
329
+ a = np.tile(operator.flatten(), (global_indexes.shape[1], 1))
330
+ idc = global_indexes.T
331
+
332
+ gi = np.zeros(self.support.n_nodes)
333
+ gi[:] = -1
334
+ gi[self.region] = np.arange(0, self.nx)
335
+ idc = gi[idc]
336
+ inside = ~np.any(idc == -1, axis=1)
337
+ B = np.zeros(global_indexes.shape[1])
338
+ self.add_constraints_to_least_squares(a[inside, :] * w,
339
+ B[inside],
340
+ idc[inside, :]
341
+ )
342
+ return
@@ -0,0 +1,190 @@
1
+ """
2
+ Base geological interpolator
3
+ """
4
+ import logging
5
+
6
+ import numpy as np
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+
11
+ class GeologicalInterpolator:
12
+ """
13
+ Attributes
14
+ ----------
15
+ data : dict
16
+ a dictionary with np.arrays for gradient, value, normal, tangent data
17
+ """
18
+ def __init__(self):
19
+ """
20
+ This class is the base class for a geological interpolator and contains all of the
21
+ main interface functions. Any class that is inheriting from this should be callable
22
+ by using any of these functions. This will enable interpolators to be interchanged.
23
+ """
24
+
25
+ self.data = {'gradient': np.zeros((0,7)),
26
+ 'value' : np.zeros((0,5)),
27
+ 'normal': np.zeros((0,7)),
28
+ 'tangent': np.zeros((0,7)),
29
+ 'interface' : np.zeros((0,5))
30
+ }
31
+ self.n_g = 0
32
+ self.n_i = 0
33
+ self.n_n = 0
34
+ self.n_t = 0
35
+
36
+ self.type = 'undefined'
37
+ self.up_to_date = False
38
+ self.constraints = []
39
+ self.propertyname = 'defaultproperty'
40
+ self.__str = 'Base Geological Interpolator'
41
+
42
+ def __str__(self):
43
+
44
+ return self.__str
45
+
46
+ def set_region(self,**kwargs):
47
+ pass
48
+
49
+ def set_property_name(self, name):
50
+ """
51
+ Set the name of the interpolated property
52
+ Parameters
53
+ ----------
54
+ name : string
55
+ name of the property to be saved on a mesh
56
+
57
+ Returns
58
+ -------
59
+
60
+ """
61
+ self.propertyname = name
62
+
63
+ def set_value_constraints(self, points):
64
+ """
65
+
66
+ Parameters
67
+ ----------
68
+ points
69
+
70
+ Returns
71
+ -------
72
+
73
+ """
74
+
75
+ self.data['value'] = points
76
+ self.n_i = points.shape[0]
77
+
78
+ def set_gradient_constraints(self, points):
79
+ """
80
+
81
+ Parameters
82
+ ----------
83
+ points
84
+
85
+ Returns
86
+ -------
87
+
88
+ """
89
+ self.n_g = points.shape[0]
90
+ self.data['gradient'] = points
91
+
92
+ def set_normal_constraints(self, points):
93
+ """
94
+
95
+ Parameters
96
+ ----------
97
+ points
98
+
99
+ Returns
100
+ -------
101
+
102
+ """
103
+ self.n_n = points.shape[0]
104
+ self.data['normal'] = points
105
+
106
+ def set_tangent_constraints(self, points):
107
+ """
108
+
109
+ Parameters
110
+ ----------
111
+ points
112
+
113
+ Returns
114
+ -------
115
+
116
+ """
117
+ self.data['tangent'] = points
118
+
119
+ def set_interface_constraints(self, points):
120
+ self.data['interface'] = points
121
+
122
+ def get_value_constraints(self):
123
+ """
124
+
125
+ Returns
126
+ -------
127
+ numpy array
128
+ """
129
+ return self.data['value']
130
+
131
+ def get_gradient_constraints(self):
132
+ """
133
+
134
+ Returns
135
+ -------
136
+ numpy array
137
+ """
138
+ return self.data['gradient']
139
+
140
+
141
+ def get_tangent_constraints(self):
142
+ """
143
+
144
+ Returns
145
+ -------
146
+ numpy array
147
+ """
148
+
149
+ return self.data['tangent']
150
+
151
+ def get_norm_constraints(self):
152
+ """
153
+
154
+ Returns
155
+ -------
156
+ numpy array
157
+ """
158
+ return self.data['normal']
159
+
160
+ def get_interface_constraints(self):
161
+ return self.data['interface']
162
+ def setup_interpolator(self, **kwargs):
163
+ """
164
+ Runs all of the required setting up stuff
165
+ """
166
+ self._setup_interpolator(**kwargs)
167
+
168
+ def solve_system(self, **kwargs):
169
+ """
170
+ Solves the interpolation equations
171
+ """
172
+ self._solve(**kwargs)
173
+ self.up_to_date = True
174
+
175
+ def update(self):
176
+ return False
177
+
178
+ def reset(self):
179
+ """
180
+ Removes all of the data from an interpolator
181
+
182
+ Returns
183
+ -------
184
+
185
+ """
186
+ self.n_g = 0
187
+ self.n_i = 0
188
+ self.n_n = 0
189
+ self.n_t = 0
190
+
@@ -0,0 +1,60 @@
1
+ """
2
+ Finite difference masks
3
+ """
4
+ import logging
5
+
6
+ import numpy as np
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+
11
+ class Operator(object):
12
+ """
13
+
14
+ """
15
+ z = np.zeros((3, 3))
16
+ Dx_mask = np.array([z, [
17
+ [0.0, 0.0, 0.0],
18
+ [-0.5, 0.0, 0.5],
19
+ [0.0, 0.0, 0.0]], z
20
+ ])
21
+ Dy_mask = Dx_mask.swapaxes(1, 2)
22
+ Dz_mask = Dx_mask.swapaxes(0, 2)
23
+
24
+ Dxx_mask = np.array([z, [
25
+ [0, 0, 0],
26
+ [1, -2, 1],
27
+ [0, 0, 0]], z])
28
+ Dyy_mask = Dxx_mask.swapaxes(1, 2)
29
+ Dzz_mask = Dxx_mask.swapaxes(0, 2)
30
+
31
+ Dxy_mask = np.array([z, [
32
+ [-0.25, 0, 0.25],
33
+ [0, 0, 0],
34
+ [0.25, 0, -0.25]
35
+ ], z])
36
+ Dxz_mask = Dxy_mask.swapaxes(0, 1)
37
+ Dyz_mask = Dxy_mask.swapaxes(0, 2)
38
+
39
+ # from https://en.wikipedia.org/wiki/Discrete_Laplace_operator
40
+ Lapacian = np.array([[[0, 0, 0],
41
+ [0, 1, 0], # first plane
42
+ [0, 0, 0]]
43
+ , [[0, 1, 0],
44
+ [1, -6, 1], # second plane
45
+ [0, 1, 0]],
46
+ [[0, 0, 0],
47
+ [0, 1, 0], # third plane
48
+ [0, 0, 0]]]
49
+ )
50
+
51
+ #Hessian is
52
+ # Dxx Dxy Dxz
53
+ # Dxy Dyy Dzy
54
+ # Dzx Dzy Dzz
55
+
56
+ #det of hessian
57
+ # Det_Hessian_operator =
58
+ # Dxx_mask.dot(Dyy_mask.dot(Dzz_mask)) - Dxx_mask.dot(Dyz_mask.dot(Dyz_mask) -
59
+ # Dxy_mask.dot(Dxy_mask.dot(Dzz_mask)) - Dxy_mask.dot(Dxz_mask.dot(Dyz_mask)) +
60
+ # Dxz_mask.dot(Dxy_mask.dot(Dyz_mask)) - Dxz_mask.dot(Dyy_mask.dot(Dxz_mask))