Skip to content

Commit

Permalink
fix: faults not rescaling when incorrect norm vectors used
Browse files Browse the repository at this point in the history
fault frame now rescales the vector norm and converts
to gradient constraints when using points.
  • Loading branch information
Lachlan Grose committed Feb 7, 2022
1 parent ba6f391 commit 9706f25
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 12 additions & 2 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,9 @@ def create_and_add_fault(
logger.info(f'Major axis: {major_axis}')
logger.info(f'Minor axis: {minor_axis}')
logger.info(f'Intermediate axis: {intermediate_axis}')
fault_slip_vector = np.array(fault_slip_vector,dtype='float')
fault_center = np.array(fault_center,dtype='float')

for k, v in kwargs.items():
logger.info(f'{k}: {v}')

Expand Down Expand Up @@ -1393,9 +1396,14 @@ def create_and_add_fault(
mask = np.logical_and(
fault_frame_data["coord"] == 0, ~np.isnan(fault_frame_data["gz"])
)
fault_normal_vector = (
fault_frame_data.loc[mask, ["gx", "gy", "gz"]].mean(axis=0).to_numpy()
vector_data = fault_frame_data.loc[mask, ["gx", "gy", "gz"]].to_numpy()
mask2 = np.logical_and(
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)
logger.info(f'Fault normal vector: {fault_normal_vector}')

mask = np.logical_and(
fault_frame_data["coord"] == 1, ~np.isnan(fault_frame_data["gz"])
)
Expand Down Expand Up @@ -1423,6 +1431,8 @@ def create_and_add_fault(
logger.warning("Fault slip vector is nan, estimating from fault normal")
strike_vector, dip_vector = get_vectors(fault_normal_vector[None, :])
fault_slip_vector = dip_vector[:, 0]
logger.info(f'Estimated fault slip vector: {fault_slip_vector}')

if fault_center is not None:
fault_center = self.scale(fault_center, inplace=False)
if fault_center is None:
Expand Down
11 changes: 11 additions & 0 deletions LoopStructural/modelling/fault/fault_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,24 @@ def create_data_from_geometry(
0,
w,
]
logger.warning("Converting fault norm data to gradient data")
mask = np.logical_and(data["coord"] == 0, ~np.isnan(data["nx"]))
data.loc[mask, ['gx','gy','gz']] = data.loc[mask,['nx','ny','nz']]
data.loc[mask, ['nx','ny','nz']] = np.nan
if points == False:
logger.warning("Rescaling fault norm constraint length for fault frame")
mask = np.logical_and(data["coord"] == 0, ~np.isnan(data["gx"]))
data.loc[mask, ["gx", "gy", "gz"]] /= np.linalg.norm(
data.loc[mask, ["gx", "gy", "gz"]], axis=1
)[:, None]
# scale vector so that the distance between -1 and 1 is the minor axis length
data.loc[mask, ["gx", "gy", "gz"]] /= minor_axis * 0.5
mask = np.logical_and(data["coord"] == 0, ~np.isnan(data["nx"]))
data.loc[mask, ["nx", "ny", "nz"]] /= np.linalg.norm(
data.loc[mask, ["nx", "ny", "nz"]], axis=1
)[:, None]
# scale vector so that the distance between -1 and 1 is the minor axis length
data.loc[mask, ["nx", "ny", "nz"]] /= minor_axis * 0.5
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
Expand Down

0 comments on commit 9706f25

Please sign in to comment.