Skip to content

Commit 128909f

Browse files
authored
Merge pull request #71 from Loop3D/dataprocessor
Dataprocessor
2 parents bedc7ab + 4ed6fa2 commit 128909f

29 files changed

Lines changed: 1042 additions & 2102 deletions

DockerfileDev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ USER ${NB_USER}
4646
RUN mkdir notebooks
4747
RUN mkdir LoopStructural
4848
RUN mkdir map2loop
49+
RUN mkdir LoopProjectFile
4950

5051
# RUN pip install -e LoopStructural
5152
CMD ["jupyter", "notebook", "--ip='0.0.0.0'", "--NotebookApp.token=''", "--no-browser" ]

LoopStructural/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ch.setFormatter(formatter)
1616
ch.setLevel(logging.WARNING)
1717
loggers = {}
18-
__version__ = '1.1.0'
18+
__version__ = '1.2.0'
1919
from .modelling.core.geological_model import GeologicalModel
2020
from .utils import log_to_console, log_to_file, getLogger
2121
logger = getLogger(__name__)

LoopStructural/datasets/data/refolded_fold.csv

Lines changed: 1 addition & 1922 deletions
Large diffs are not rendered by default.

LoopStructural/interpolators/finite_difference_interpolator.py

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -79,58 +79,62 @@ def _setup_interpolator(self, **kwargs):
7979
for key in kwargs:
8080
self.up_to_date = False
8181
if 'regularisation' in kwargs:
82-
self.interpolation_weights['dxy'] = kwargs[
83-
'regularisation'] * 0.7
84-
self.interpolation_weights['dyz'] = kwargs[
85-
'regularisation'] * 0.7
86-
self.interpolation_weights['dxz'] = kwargs[
87-
'regularisation'] * 0.7
88-
self.interpolation_weights['dxx'] = kwargs[
89-
'regularisation'] * 1.
90-
self.interpolation_weights['dyy'] = kwargs[
91-
'regularisation'] * 1.
92-
self.interpolation_weights['dzz'] = kwargs[
93-
'regularisation'] * 1.
82+
self.interpolation_weights['dxy'] = 0.1*kwargs[
83+
'regularisation']
84+
self.interpolation_weights['dyz'] = 0.1*kwargs[
85+
'regularisation']
86+
self.interpolation_weights['dxz'] = 0.1*kwargs[
87+
'regularisation']
88+
self.interpolation_weights['dxx'] = 0.1*kwargs[
89+
'regularisation']
90+
self.interpolation_weights['dyy'] = 0.1*kwargs[
91+
'regularisation']
92+
self.interpolation_weights['dzz'] = 0.1*kwargs[
93+
'regularisation']
9494
self.interpolation_weights[key] = kwargs[key]
9595
# if we want to define the operators manually
9696
if 'operators' in kwargs:
9797
for n, o in kwargs['operators'].items():
9898
self.assemble_inner(o[0], o[1])
9999
# otherwise just use defaults
100100
if 'operators' not in kwargs:
101+
101102
operator = Operator.Dxy_mask
102-
103-
self.assemble_inner(operator, np.sqrt(2 * self.vol) *
104-
self.interpolation_weights['dxy'])
103+
weight = self.interpolation_weights['dxy'] / \
104+
1#(4*self.support.step_vector[0]*self.support.step_vector[1])
105+
self.assemble_inner(operator, weight )
105106
operator = Operator.Dyz_mask
106-
self.assemble_inner(operator, np.sqrt(2 * self.vol) *
107-
self.interpolation_weights['dyz'])
107+
weight = self.interpolation_weights['dyz'] / \
108+
1#(4*self.support.step_vector[1]*self.support.step_vector[2])
109+
self.assemble_inner(operator, weight)
108110
operator = Operator.Dxz_mask
109-
self.assemble_inner(operator, np.sqrt(2 * self.vol) *
110-
self.interpolation_weights['dxz'])
111+
weight = self.interpolation_weights['dxz'] / \
112+
1#(4*self.support.step_vector[0]*self.support.step_vector[2])
113+
self.assemble_inner(operator, weight)
111114
operator = Operator.Dxx_mask
115+
weight = self.interpolation_weights['dxx'] \
116+
/ 1#self.support.step_vector[0]**2
112117
self.assemble_inner(operator,
113-
np.sqrt(self.vol) * self.interpolation_weights[
114-
'dxx'])
118+
weight)
115119
operator = Operator.Dyy_mask
116-
self.assemble_inner(operator,
117-
np.sqrt(self.vol) * self.interpolation_weights[
118-
'dyy'])
120+
weight = self.interpolation_weights['dyy'] / \
121+
1#self.support.step_vector[1]**2
122+
self.assemble_inner(operator,weight)
119123
operator = Operator.Dzz_mask
120-
self.assemble_inner(operator,
121-
np.sqrt(self.vol) * self.interpolation_weights[
122-
'dzz'])
124+
weight = self.interpolation_weights['dzz'] / \
125+
1#self.support.step_vector[2]**2
126+
self.assemble_inner(operator,weight)
123127
self.add_norm_constraint(
124-
np.sqrt(self.vol) * self.interpolation_weights['npw'])
128+
self.interpolation_weights['npw'])
125129
self.add_gradient_constraint(
126-
np.sqrt(self.vol) * self.interpolation_weights['gpw'])
130+
self.interpolation_weights['gpw'])
127131
self.add_vaue_constraint(
128-
np.sqrt(self.vol) * self.interpolation_weights['cpw'])
132+
self.interpolation_weights['cpw'])
129133
self.add_tangent_ctr_pts(
130-
np.sqrt(self.vol) * self.interpolation_weights['tpw']
134+
self.interpolation_weights['tpw']
131135
)
132136
self.add_interface_ctr_pts(
133-
np.sqrt(self.vol)*self.interpolation_weights['ipw']
137+
self.interpolation_weights['ipw']
134138
)
135139

136140
def copy(self):
@@ -172,7 +176,7 @@ def add_vaue_constraint(self, w=1.):
172176
inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
173177
a = self.support.position_to_dof_coefs(points[inside, :3])
174178
# a*=w
175-
179+
# a/=np.product(self.support.step_vector)
176180
self.add_constraints_to_least_squares(a.T * w,
177181
points[inside, 3] * w,
178182
idc[inside, :],
@@ -259,6 +263,8 @@ def add_gradient_constraint(self, w=1.):
259263
inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
260264

261265
T = self.support.calcul_T(points[inside, :3])
266+
norm = np.linalg.norm(T,axis=2)
267+
T/=norm[:,:,None]
262268
strike_vector, dip_vector = get_vectors(points[inside, 3:6])
263269
A = np.einsum('ij,ijk->ik', strike_vector.T, T)
264270

@@ -284,7 +290,6 @@ def add_norm_constraint(self, w=1.):
284290
if points.shape[0] > 0:
285291
# calculate unit vector for orientation data
286292
# points[:,3:]/=np.linalg.norm(points[:,3:],axis=1)[:,None]
287-
288293
node_idx, inside = self.support.position_to_cell_corners(
289294
points[:, :3])
290295
gi = np.zeros(self.support.n_nodes)
@@ -299,16 +304,17 @@ def add_norm_constraint(self, w=1.):
299304
# this means we are only constraining direction of grad not the
300305
# magnitude
301306
T = self.support.calcul_T(points[inside, :3])
302-
307+
# T*=np.product(self.support.step_vector)
308+
# T/=self.support.step_vector[0]
303309
w /= 3
304310
self.add_constraints_to_least_squares(T[:, 0, :] * w,
305-
points[inside, 3] * w,
311+
points[inside, 3] * w ,
306312
idc[inside, :], name='norm')
307313
self.add_constraints_to_least_squares(T[:, 1, :] * w,
308-
points[inside, 4] * w,
314+
points[inside, 4] * w ,
309315
idc[inside, :], name='norm')
310316
self.add_constraints_to_least_squares(T[:, 2, :] * w,
311-
points[inside, 5] * w,
317+
points[inside, 5] * w ,
312318
idc[inside, :], name='norm')
313319

314320
def add_gradient_orthogonal_constraint(self, points, vector, w=1.0,
@@ -345,9 +351,15 @@ def add_gradient_orthogonal_constraint(self, points, vector, w=1.0,
345351
idc[inside, :] = gi[node_idx[inside, :]]
346352
inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
347353

354+
#normalise element vector to unit vector for dot product
348355
T = self.support.calcul_T(points[inside, :3])
356+
norm = np.linalg.norm(T,axis=1)
357+
T/=norm[:,None,:]
358+
# normalise vector to unit vector for dot product
359+
vector[inside,:3] /= np.linalg.norm(vector[inside,:3],axis=1)[:,None]
360+
# dot product of vector and element gradient
349361
A = np.einsum('ij,ijk->ik', vector[inside, :3], T)
350-
362+
351363
B = np.zeros(points[inside, :].shape[0])
352364
self.add_constraints_to_least_squares(A * w, B, idc[inside, :], name='gradient orthogonal')
353365

@@ -390,9 +402,11 @@ def assemble_inner(self, operator, w):
390402
gi[:] = -1
391403
gi[self.region] = np.arange(0, self.nx)
392404
idc = gi[idc]
393-
inside = ~np.any(idc == -1, axis=1)
405+
inside = ~np.any(idc == -1, axis=1)#np.ones(a.shape[0],dtype=bool)#
406+
# a[idc==-1] = 0
407+
# idc[idc==-1] = 0
394408
B = np.zeros(global_indexes.shape[1])
395-
self.add_constraints_to_least_squares(a[inside, :] * w,
409+
self.add_constraints_to_least_squares(a[inside, :] * w ,
396410
B[inside],
397411
idc[inside, :],
398412
name='regularisation'

LoopStructural/interpolators/operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Operator(object):
3333
[-0.25, 0, 0.25],
3434
[0, 0, 0],
3535
[0.25, 0, -0.25]
36-
], z])
36+
], z]) / np.sqrt(2)
3737
Dxz_mask = Dxy_mask.swapaxes(0, 1)
3838
Dyz_mask = Dxy_mask.swapaxes(0, 2)
3939

LoopStructural/interpolators/piecewiselinear_interpolator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def add_norm_ctr_pts(self, w=1.0):
290290
# d_t = self.support.get_elements_gradients(e)
291291
norm = np.zeros((element_gradients.shape[0],element_gradients.shape[1]))
292292
norm[inside,:] = np.linalg.norm(element_gradients[inside,:,:], axis=2)
293-
element_gradients /= norm[:, :, None]
293+
# element_gradients /= norm[:, :, None]
294294

295295
d_t = element_gradients
296296
d_t[inside,:,:] *= vol[inside, None, None]

LoopStructural/interpolators/structured_grid.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,18 @@ def barycentre(self):
4040

4141

4242
def cell_centres(self, global_index):
43-
"""[summary]
44-
45-
[extended_summary]
43+
"""get the centre of specified cells
4644
45+
4746
Parameters
4847
----------
49-
global_index : [type]
50-
[description]
48+
global_index : array/list
49+
container of integer global indexes to cells
5150
5251
Returns
5352
-------
54-
[type]
55-
[description]
53+
numpy array
54+
Nx3 array of cell centres
5655
"""
5756
ix, iy, iz = self.global_index_to_cell_index(global_index)
5857
x = self.origin[None, 0] + self.step_vector[None, 0] * .5 + \
@@ -103,15 +102,14 @@ def position_to_local_coordinates(self, pos):
103102
104103
"""
105104
# TODO check if inside mesh
106-
pos = self.rotate(pos)
105+
# pos = self.rotate(pos)
107106
# calculate local coordinates for positions
108107
local_x = ((pos[:, 0] - self.origin[None, 0]) % self.step_vector[
109108
None, 0]) / self.step_vector[None, 0]
110109
local_y = ((pos[:, 1] - self.origin[None, 1]) % self.step_vector[
111110
None, 1]) / self.step_vector[None, 1]
112111
local_z = ((pos[:, 2] - self.origin[None, 2]) % self.step_vector[
113112
None, 2]) / self.step_vector[None, 2]
114-
115113
return local_x, local_y, local_z
116114

117115
def position_to_dof_coefs(self, pos):
@@ -325,9 +323,8 @@ def calcul_T(self, pos):
325323
# x, y, z = self.node_indexes_to_position(cellx, celly, cellz)
326324
T = np.zeros((pos.shape[0], 3, 8))
327325
x, y, z = self.position_to_local_coordinates(pos)
328-
# div = self.step_vector[0] * self.step_vector[1] * self.step_vector[2]
329-
330-
T[:, 0, 0] = -(1 - y) * (1 - z) # v000
326+
327+
T[:, 0, 0] = (1 - z) * (y- 1) # v000
331328
T[:, 0, 1] = (1 - y) * (1 - z) # (y[:, 3] - pos[:, 1]) / div
332329
T[:, 0, 2] = -y * (1 - z) # (pos[:, 1] - y[:, 0]) / div
333330
T[:, 0, 3] = -(1 - y) * z # (pos[:, 1] - y[:, 1]) / div
@@ -336,7 +333,7 @@ def calcul_T(self, pos):
336333
T[:, 0, 6] = y * (1 - z)
337334
T[:, 0, 7] = y * z
338335

339-
T[:, 1, 0] = - (1 - x) * (1 - z)
336+
T[:, 1, 0] = (x - 1) * (1 - z)
340337
T[:, 1, 1] = - x * (1 - z)
341338
T[:, 1, 2] = (1 - x) * (1 - z)
342339
T[:, 1, 3] = -(1 - x) * z
@@ -353,14 +350,7 @@ def calcul_T(self, pos):
353350
T[:, 2, 5] = (1 - x) * y
354351
T[:, 2, 6] = - x * y
355352
T[:, 2, 7] = x * y
356-
return T
353+
T/=self.step_vector[0]
354+
355+
return T
357356

358-
def slice(self, propertyname, isovalue, region):
359-
logger.error("function has been removed, please use the modelviewer class")
360-
return
361-
#
362-
# verts, faces, normals, values = marching_cubes(
363-
# self.properties[propertyname].reshape(self.nsteps, order='F'),
364-
# isovalue,
365-
# spacing=self.step_vector)
366-
# return faces, verts + self.origin[None, :]

LoopStructural/interpolators/surfe_wrapper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,7 @@ def evaluate_gradient(self, evaluation_points):
115115
if evaluation_points[~mask, :].shape[0] > 0:
116116
evaluated[~mask,:] = self.surfe.EvaluateVectorInterpolantAtPoints(
117117
evaluation_points[~mask])
118-
return evaluated
118+
return
119+
@property
120+
def nx(self):
121+
return self.get_data_locations().shape[0]

LoopStructural/modelling/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
44
"""
55

6+
from .input.process_data import ProcessInputData

0 commit comments

Comments
 (0)