Skip to content

Commit

Permalink
fix: bug with calculating average fault ori
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Feb 7, 2022
1 parent ef4d7d0 commit a2099cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ def create_and_add_fault(
fault_frame_data["coord"] == 0, ~np.isnan(fault_frame_data["nz"])
)
vector_data = np.vstack([vector_data,fault_frame_data.loc[mask2, ["nx", "ny", "nz"]].to_numpy()])
fault_normal_vector = np.mean(vector_data,axis=1)
fault_normal_vector = np.mean(vector_data,axis=0)
logger.info(f'Fault normal vector: {fault_normal_vector}')

mask = np.logical_and(
Expand Down Expand Up @@ -1433,9 +1433,9 @@ def create_and_add_fault(
fault_slip_vector = dip_vector[:, 0]
logger.info(f'Estimated fault slip vector: {fault_slip_vector}')

if fault_center is not None:
if fault_center is not None and ~np.isnan(fault_center).any():
fault_center = self.scale(fault_center, inplace=False)
if fault_center is None:
else:
# if we haven't defined a fault centre take the center of mass for lines assocaited with
# the fault trace
if (
Expand Down
4 changes: 3 additions & 1 deletion LoopStructural/modelling/fault/fault_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def create_data_from_geometry(
fault_trace[:, None, :] - fault_trace[None, :, :], axis=2
)
if len(distance) == 0 or np.sum(distance) == 0:
logger.error("There is no fault trace for {}".format(self.name))
logger.warning("There is no fault trace for {}".format(self.name))
# this can mean there is only a single data point for the fault, its not critical
# but probably means the fault isn't well defined.
# add any data anyway - usually just orientation data
self.add_data_from_data_frame(data)
self.origin = self.model.bounding_box[0, :]
Expand Down
5 changes: 5 additions & 0 deletions tests/unit_tests/modelling/test_faults_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def test_create_and_add_fault():
data = pd.DataFrame(
[
[0.5, 0.5, 0.5, 0, 1, 0, 0, "fault", 0],
# [0.5, 0.5, 0.5, 0, 1, 0, 0, "fault", 0],

[0.5, 0.5, 0.5, 1, 0, 0, 1, "fault", 0],
[0.5, 0.5, 0.5, 0, 0, 1, 2, "fault", 0],
],
Expand All @@ -21,3 +23,6 @@ def test_create_and_add_fault():
# force_mesh_geometry=True
)
assert isinstance(model["fault"], FaultSegment)

if __name__ == "__main__":
test_create_and_add_fault()

0 comments on commit a2099cd

Please sign in to comment.