Skip to content

Commit

Permalink
fix: adding gradient option for m2l wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Oct 7, 2021
1 parent cedcffb commit cdce6e8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
15 changes: 12 additions & 3 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,14 @@ def _ipython_key_completions_(self):
return self.feature_name_index.keys()

@classmethod
def from_map2loop_directory(cls, m2l_directory,foliation_params={},fault_params={},use_thickness=True,vector_scale=1,**kwargs):
def from_map2loop_directory(cls,
m2l_directory,
foliation_params={},
fault_params={},
use_thickness=True,
vector_scale=1,
gradient=False,
**kwargs):
"""Alternate constructor for a geological model using m2l output
Uses the information saved in the map2loop files to build a geological model.
Expand All @@ -179,6 +186,7 @@ def from_map2loop_directory(cls, m2l_directory,foliation_params={},fault_params=
"""
from LoopStructural.modelling.input.map2loop_processor import Map2LoopProcessor
processor=Map2LoopProcessor(m2l_directory,use_thickness)
processor._gradient = gradient
processor.vector_scale = vector_scale
for foliation_name in processor.stratigraphic_column.keys():
if foliation_name != 'faults':
Expand Down Expand Up @@ -219,7 +227,8 @@ def from_processor(cls, processor):
continue
splay = False
if 'angle' in properties:
if float(properties['angle']) < 30 and np.abs(processor.stratigraphic_column['faults'][edge[0]]['dip_dir']-processor.stratigraphic_column['faults'][edge[1]]['dip_dir']) <90:
if float(properties['angle']) < 30 and np.abs(processor.stratigraphic_column['faults'][edge[0]]['dip_dir']-
processor.stratigraphic_column['faults'][edge[1]]['dip_dir']) < 90:
# splay
region = model[edge[1]].builder.add_splay(model[edge[0]])

Expand Down Expand Up @@ -419,7 +428,7 @@ def data(self, data):
self._data[h] = 1.
if h == 'coord':
self._data[h] = 0

self.data.loc[np.isnan(self.data['w']),'w'] = 1.
if 'strike' in self._data and 'dip' in self._data:
logger.info('Converting strike and dip to vectors')
mask = np.all(~np.isnan(self._data.loc[:, ['strike', 'dip']]),
Expand Down
31 changes: 16 additions & 15 deletions LoopStructural/modelling/fault/fault_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def create_data_from_geometry(self,
slip_vector,
minor_axis = None,
major_axis = None,
intermediate_axis = None):
intermediate_axis = None,
w=1.):
"""Generate the required data for building a fault frame for a fault with the
specified parameters
Expand Down Expand Up @@ -82,35 +83,35 @@ def create_data_from_geometry(self,
fault_edges[0,:] = fault_center[:3]+normal_vector*minor_axis
fault_edges[1,:] = fault_center[:3]-normal_vector*minor_axis
self.update_geometry(fault_edges)
data.loc[len(data),['X','Y','Z','feature_name','val','coord']] = \
[fault_edges[0,0],fault_edges[0,1],fault_edges[0,2],self.name,1,0]
data.loc[len(data),['X','Y','Z','feature_name','val','coord']] = \
[fault_edges[1,0],fault_edges[1,1],fault_edges[1,2],self.name,-1,0]
data.loc[len(data),['X','Y','Z','feature_name','val','coord','w']] = \
[fault_edges[0,0],fault_edges[0,1],fault_edges[0,2],self.name,1,0,w]
data.loc[len(data),['X','Y','Z','feature_name','val','coord','w']] = \
[fault_edges[1,0],fault_edges[1,1],fault_edges[1,2],self.name,-1,0,w]
if major_axis is not None:
fault_tips[0,:] = fault_center[:3]+strike_vector*0.5*major_axis
fault_tips[1,:] = fault_center[:3]-strike_vector*0.5*major_axis
self.update_geometry(fault_tips)
data.loc[len(data),['X','Y','Z','feature_name','val','coord']] = \
[fault_center[0],fault_center[1],fault_center[2],self.name,0,2]
data.loc[len(data),['X','Y','Z','feature_name','val','coord']] = \
[fault_tips[1,0],fault_tips[1,1],fault_tips[1,2],self.name,-.5,2]
data.loc[len(data),['X','Y','Z','feature_name','val','coord']] = \
[fault_tips[0,0],fault_tips[0,1],fault_tips[0,2],self.name,.5,2]
data.loc[len(data),['X','Y','Z','feature_name','val','coord','w']] = \
[fault_center[0],fault_center[1],fault_center[2],self.name,0,2,w]
data.loc[len(data),['X','Y','Z','feature_name','val','coord','w']] = \
[fault_tips[1,0],fault_tips[1,1],fault_tips[1,2],self.name,-.5,2,w]
data.loc[len(data),['X','Y','Z','feature_name','val','coord','w']] = \
[fault_tips[0,0],fault_tips[0,1],fault_tips[0,2],self.name,.5,2,w]
strike_vector /= major_axis
if intermediate_axis is not None:
fault_depth[0,:] = fault_center[:3]+slip_vector*intermediate_axis
fault_depth[1,:] = fault_center[:3]-slip_vector*intermediate_axis
data.loc[len(data),['X','Y','Z','feature_name','val','coord']] = \
[fault_center[0],fault_center[1],fault_center[2],self.name,0,1]
data.loc[len(data),['X','Y','Z','feature_name','val','coord','w']] = \
[fault_center[0],fault_center[1],fault_center[2],self.name,0,1,w]
# data.loc[len(data),['X','Y','Z','feature_name','val','coord']] = \
# [fault_depth[1,0],fault_depth[1,1],fault_depth[1,2],self.name,-1,1]
self.update_geometry(fault_depth)
#TODO need to add data here
# print(np.linalg.norm(slip_vector))
slip_vector /= intermediate_axis
# print(np.linalg.norm(slip_vector))
data.loc[len(data),['X','Y','Z','feature_name','nx','ny','nz','val','coord']] =\
[fault_center[0],fault_center[1],fault_center[2],self.name,slip_vector[0],slip_vector[1],slip_vector[2],0,1]
data.loc[len(data),['X','Y','Z','feature_name','nx','ny','nz','val','coord','w']] =\
[fault_center[0],fault_center[1],fault_center[2],self.name,slip_vector[0],slip_vector[1],slip_vector[2],0,1,w]
# add strike vector to constraint fault extent
# data.loc[len(data),['X','Y','Z','feature_name','nx','ny','nz','coord']] = [fault_center[0],fault_center[1],fault_center[2],\
# self.name, strike_vector[0], strike_vector[1], strike_vector[2], 2]
Expand Down

0 comments on commit cdce6e8

Please sign in to comment.