Skip to content

Commit c8d6046

Browse files
committed
2 parents 2536604 + 6ca36c5 commit c8d6046

File tree

5 files changed

+51
-14
lines changed

5 files changed

+51
-14
lines changed

LoopStructural/modelling/core/geological_model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ def _add_feature(self, feature):
253253
self._add_domain_fault_above(feature)
254254
self._add_unconformity_above(feature)
255255
feature.set_model(self)
256-
256+
257+
def data_for_feature(self,feature_name):
258+
return self.data.loc[self.data['feature_name'] == series_surface_data,:]
259+
257260
def set_model_data(self, data):
258261
"""
259262
Set the data array for the model

LoopStructural/modelling/fault/fault_segment.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def evaluate(self, locations):
138138

139139
return self.faultframe.features[0].evaluate_value(locations) > 0
140140

141+
def inside_volume(self,locations):
142+
v = self.faultframe.evaluate_value(locations)
143+
return np.all(np.logical_and(v > -1,v<1),axis=1)
144+
141145
def evaluate_value(self, locations):
142146
"""
143147
Return the value of the fault surface scalar field
@@ -192,6 +196,27 @@ def evaluate_gradient(self, locations):
192196
# need to scale with fault displacement
193197
return self.faultframe[1].evaluate_gradient(locations[mask, :])
194198

199+
def evaluate_displacement(self, points):
200+
newp = np.copy(points).astype(float)
201+
# evaluate fault function for all points then define mask for only points affected by fault
202+
with ThreadPoolExecutor(max_workers=8) as executor:
203+
# all of these operations should be independent so just run as different threads
204+
gx_future = executor.submit(self.faultframe.features[0].evaluate_value, newp)
205+
gy_future = executor.submit(self.faultframe.features[1].evaluate_value, newp)
206+
gz_future = executor.submit(self.faultframe.features[2].evaluate_value, newp)
207+
gx = gx_future.result()
208+
gy = gy_future.result()
209+
gz = gz_future.result()
210+
d = np.zeros(gx.shape)
211+
mask = np.logical_and(~np.isnan(gx),~np.isnan(gy))
212+
mask = np.logical_and(mask,~np.isnan(gz))
213+
d[~mask] = 0
214+
gx_mask = np.zeros_like(mask,dtype=bool)
215+
gx_mask[mask] = gx[mask] > 0
216+
d[gx_mask] = 1.
217+
if self.faultfunction is not None:
218+
d[mask] = self.faultfunction(gx[mask], gy[mask], gz[mask])
219+
return d
195220
def apply_to_points(self, points):
196221
"""
197222
Unfault the array of points

LoopStructural/modelling/features/geological_feature_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def get_gradient_constraints(self):
225225
mask, xyz_names() + gradient_vec_names() + weight_name(
226226
)].to_numpy()
227227
else:
228-
return np.zeros(0, 7)
228+
return np.zeros((0, 7))
229229

230230
def get_tangent_constraints(self):
231231
"""
@@ -242,7 +242,7 @@ def get_tangent_constraints(self):
242242
mask, xyz_names() + tangent_vec_names() + weight_name(
243243
)].to_numpy()
244244
else:
245-
return np.zeros(0, 7)
245+
return np.zeros((0, 7))
246246

247247
def get_norm_constraints(self):
248248
"""
@@ -260,15 +260,15 @@ def get_norm_constraints(self):
260260

261261
)].to_numpy()
262262
else:
263-
return np.zeros(0,7)
263+
return np.zeros((0,7))
264264

265265
def get_interface_constraints(self):
266266
mask = np.all(~np.isnan(self.data.loc[:, interface_name()].to_numpy()), axis=1)
267267
if mask.shape[0] > 0:
268268
return self.data.loc[
269269
mask, xyz_names() + interface_name() + weight_name()].to_numpy()
270270
else:
271-
return np.zeros(0,5)
271+
return np.zeros((0,5))
272272

273273
def get_data_locations(self):
274274
"""

LoopStructural/modelling/features/structural_frame.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Structural frames
33
"""
44
import logging
5-
5+
import numpy as np
66
logger = logging.getLogger(__name__)
77

88

@@ -86,7 +86,7 @@ def set_data(self, data):
8686
"""
8787
self.data = data
8888

89-
def evaluate_value(self, evaluation_points, i=None):
89+
def evaluate_value(self, evaluation_points):
9090
"""
9191
Evaluate the value of the structural frame for the points.
9292
Can optionally only evaluate one coordinate
@@ -100,11 +100,15 @@ def evaluate_value(self, evaluation_points, i=None):
100100
-------
101101
102102
"""
103-
if i is not None:
104-
self.features[i].support.evaluate_value(evaluation_points)
105-
return (self.features[0].support.evaluate_value(evaluation_points),
106-
self.features[1].support.evaluate_value(evaluation_points),
107-
self.features[2].support.evaluate_value(evaluation_points))
103+
v = np.zeros(evaluation_points.shape) #create new 3d array of correct length
104+
v[:] = np.nan
105+
v[:,0] = self.features[0].evaluate_value(evaluation_points)
106+
v[:,1] = self.features[1].evaluate_value(evaluation_points)
107+
v[:,2] = self.features[2].evaluate_value(evaluation_points)
108+
return v
109+
# return (self.features[0].evaluate_value(evaluation_points),
110+
# self.features[1].evaluate_value(evaluation_points),
111+
# self.features[2].evaluate_value(evaluation_points))
108112

109113
def evaluate_gradient(self, evaluation_points, i=None):
110114
"""

LoopStructural/utils/map2loop.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ def process_map2loop(m2l_directory, flags={}):
9292
contact_orientations['gy'] = np.nan
9393
contact_orientations['gz'] = np.nan
9494
contact_orientations[['gx', 'gy', 'gz']] = strike_dip_vector(contact_orientations['strike'],
95-
contact_orientations['dip'])*max_thickness
95+
contact_orientations['dip'])*max_thickness
96+
if np.sum(contact_orientations['polarity']==0) >0 and np.sum(contact_orientations['polarity']==-1)==0:
97+
# contact_orientations['polarity']+=1
98+
contact_orientations.loc[contact_orientations['polarity']==0]=-1
9699
if not gradient:
97100
from LoopStructural.utils.helper import strike_dip_vector
98101
contact_orientations['strike'] = contact_orientations['azimuth'] - 90
@@ -202,7 +205,9 @@ def process_map2loop(m2l_directory, flags={}):
202205
fault_centers[3] = np.mean(fault_orientations.loc[fault_orientations['formation']==f,['DipDirection']])
203206
fault_centers[4] = fault_dimensions.loc[fault_dimensions['Fault']==f,'InfluenceDistance']
204207
fault_centers[5] = fault_dimensions.loc[fault_dimensions['Fault']==f,'HorizontalRadius']
205-
stratigraphic_column['faults'][f] = {'InfluenceDistance':fault_dimensions.loc[fault_dimensions['Fault']==f,'InfluenceDistance'].to_numpy(),
208+
stratigraphic_column['faults'][f] = {'FaultCenter':fault_centers[:3],
209+
'FaultDipDirection':fault_centers[3],
210+
'InfluenceDistance':fault_dimensions.loc[fault_dimensions['Fault']==f,'InfluenceDistance'].to_numpy(),
206211
'HorizontalRadius':fault_dimensions.loc[fault_dimensions['Fault']==f,'HorizontalRadius'].to_numpy(),
207212
'VerticalRadius':fault_dimensions.loc[fault_dimensions['Fault']==f,'VerticalRadius'].to_numpy()}
208213
if 'colour' in fault_dimensions.columns:

0 commit comments

Comments
 (0)