Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fault function refactor #178

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions LoopStructural/modelling/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@


class FeatureType(IntEnum):
"""
Enum for the different interpolator types

1-9 should cover interpolators with supports
9+ are data supported
"""
""" """

BASE = 0
INTERPOLATED = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def build_arguments(self, build_arguments):
self._up_to_date = False

def update(self):
self._feature.faults = self.faults
self.build(**self.build_arguments)

def build(self, **kwargs):
Expand Down
49 changes: 31 additions & 18 deletions LoopStructural/modelling/features/builders/_fault_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,27 +139,29 @@ def create_data_from_geometry(
"You cannot model a fault without defining the orientation of the fault\n\
Defaulting to a vertical fault"
)
coefficients = np.polyfit(
fault_frame_data.loc[trace_mask, "X"],
fault_frame_data.loc[trace_mask, "Y"],
1,
)
slope, intercept = coefficients
if fault_frame_data.loc[trace_mask, :].shape[0] > 3:

# Create a direction vector using the slope
direction_vector = np.array([1, slope])
direction_vector /= np.linalg.norm(direction_vector)
print(f"Fault dip: {fault_dip}")
vector_data = np.array(
[
coefficients = np.polyfit(
fault_frame_data.loc[trace_mask, "X"],
fault_frame_data.loc[trace_mask, "Y"],
1,
)
slope, intercept = coefficients

# Create a direction vector using the slope
direction_vector = np.array([1, slope])
direction_vector /= np.linalg.norm(direction_vector)
print(f"Fault dip: {fault_dip}")
vector_data = np.array(
[
direction_vector[1],
-direction_vector[0],
np.sin(np.deg2rad(fault_dip)),
[
direction_vector[1],
-direction_vector[0],
np.sin(np.deg2rad(fault_dip)),
]
]
]
)
vector_data /= np.linalg.norm(vector_data, axis=1)[:, None]
)
vector_data /= np.linalg.norm(vector_data, axis=1)[:, None]

fault_normal_vector = np.mean(vector_data, axis=0)

Expand Down Expand Up @@ -500,6 +502,11 @@ def add_fault_trace_anisotropy(self, w: float = 1.0):
_description_, by default 1.0
"""
trace_data = self.builders[0].data.loc[self.builders[0].data["val"] == 0, :]
if trace_data.shape[0] < 2:
logger.warning(
f"Only {trace_data.shape[0]} point on fault trace, cannot add fault trace anisotropy. Need at least 3 points"
)
return
coefficients = np.polyfit(
trace_data["X"],
trace_data["Y"],
Expand All @@ -526,7 +533,13 @@ def add_fault_dip_anisotropy(self, dip: np.ndarray, w: float = 1.0):
w : float, optional
_description_, by default 1.0
"""

trace_data = self.builders[0].data.loc[self.builders[0].data["val"] == 0, :]
if trace_data.shape[0] < 2:
logger.warning(
f'Only {trace_data.shape[0]} point on fault trace, cannot add fault trace anisotropy. Need at least 3 points'
)
return
coefficients = np.polyfit(
trace_data["X"],
trace_data["Y"],
Expand Down
Loading
Loading