Skip to content

Commit

Permalink
fix: change fault segement evaluate value to scaled displacement vector
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose committed Jun 5, 2024
1 parent edadfb3 commit 3b8f8c3
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion LoopStructural/modelling/features/fault/_fault_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def evaluate_gradient(self, locations):
except:
logger.error("nan slicing ")
# need to scale with fault displacement
v[mask, :] = self.__getitem__(0).evaluate_gradient(locations[mask, :])
v[mask, :] = self.__getitem__(1).evaluate_gradient(locations[mask, :])
scale = self.displacementfeature.evaluate_value(locations[mask, :])
v[mask, :] *= scale[:, None]
return v

def evaluate_displacement(self, points):
Expand Down Expand Up @@ -458,3 +460,42 @@ def add_abutting_fault(self, abutting_fault_feature, positive=None):
)
self.abut[abutting_fault_feature.name] = abutting_region
self.__getitem__(0).add_region(abutting_region)

def save(self, filename, scalar_field=True, slip_vector=True, surface=True):
"""
Save the fault to a file
Parameters
----------
filename - str
filename to save to
Returns
-------
"""
filename = str(filename)
ext = filename.split(".")[-1]
info = ''
if scalar_field:
if ext == '.geoh5':
info = ''
else:
info = '_scalar_field'
a = self.features[0].scalar_field()
a.merge(self.features[1].scalar_field())
a.merge(self.features[2].scalar_field())
a.merge(self.displacementfeature.scalar_field())
a.save(f'{filename}{info}.{ext}')
if slip_vector:
if ext == '.geoh5':
info = ''
else:
info = '_slip_vector'
self.vector_field().save(f'{filename}{info}.{ext}')
if surface:
if ext == '.geoh5':
info = ''
else:
info = '_surface'
self.surfaces([0])[0].save(f'{filename}{info}.{ext}')

0 comments on commit 3b8f8c3

Please sign in to comment.