Skip to content

Commit 78ccbd3

Browse files
lachlangroseCopilot
andauthoredFeb 20, 2025··
fix: updating scaling for plotting (#219)
* docs: add pyvista plot directives and update some documentations * fix: interpolatorbuilder syntax/method naming * fix: bb global origin should be 0 if it is not being used. force origin/max to be numpy arrays. Change default ordering of regular grid to be fortran renaming centers to centres for english adding cell centres to structure grid/nodes * fix: allow fitting of rotation to be disabled for the euclidean transformation and ensure dimensionality is used * update copy of points Co-authored-by: Copilot <[email protected]> * Add Optional back Co-authored-by: Copilot <[email protected]> * fix: geoh5 format for grids * fix: adding spatially varying regularisation for fdi * fix: interpolator builder use bounding box geometry if no other mesh details are given * style: style fixes by ruff and autoformatting by black * fix: change nelements for interpolator using builder kwargs * style: black * style: remove unused imports * fix: allowing nelements to be updated for an interpolator * fix: allow small structured grid. needed for tetra * fix: adding distance to bounding box * style: style fixes by ruff and autoformatting by black * style: style fixes by ruff and autoformatting by black * fix: don't scale fdi regularisation * fix: add helper to get interpolator support as vtk with solution as node values * fix: if interpolation geometry changed, make sure build args are updated * style: style fixes by ruff and autoformatting by black * style: black autoformat * style: style fixes by ruff and autoformatting by black * tests: add fdi test for structural frame and make isclose less sensitive * tests: reducing sensitivity further... * fix: scaling vectors for visualisation * fix: copy interpolated feature * fix: add build args accessor/settor for structural frame * style: style fixes by ruff and autoformatting by black --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: lachlangrose <[email protected]>
1 parent 4b9f90f commit 78ccbd3

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed
 

‎LoopStructural/datatypes/_bounding_box.py

+3
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,9 @@ def project(self, xyz):
497497
(self.global_maximum - self.global_origin)
498498
) # np.clip(xyz, self.origin, self.maximum)
499499

500+
def scale_by_projection_factor(self, value):
501+
return value / np.max((self.global_maximum - self.global_origin))
502+
500503
def reproject(self, xyz):
501504
"""Reproject a point from the bounding box to the global space
502505

‎LoopStructural/datatypes/_point.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def from_dict(self, d):
129129
def vtk(
130130
self,
131131
geom='arrow',
132-
scale=0.10,
132+
scale=1.0,
133133
scale_function=None,
134-
normalise=True,
134+
normalise=False,
135135
tolerance=0.05,
136136
bb=None,
137137
scalars=None,
@@ -140,9 +140,15 @@ def vtk(
140140

141141
_projected = False
142142
vectors = np.copy(self.vectors)
143+
143144
if normalise:
144145
norm = np.linalg.norm(vectors, axis=1)
145146
vectors[norm > 0, :] /= norm[norm > 0][:, None]
147+
else:
148+
norm = np.linalg.norm(vectors, axis=1)
149+
vectors[norm > 0, :] /= norm[norm > 0][:, None]
150+
norm = norm[norm > 0] / norm[norm > 0].max()
151+
vectors *= norm[:, None]
146152
if scale_function is not None:
147153
# vectors /= np.linalg.norm(vectors, axis=1)[:, None]
148154
vectors *= scale_function(self.locations)[:, None]
@@ -151,6 +157,7 @@ def vtk(
151157
try:
152158
locations = bb.project(locations)
153159
_projected = True
160+
scale = bb.scale_by_projection_factor(scale)
154161
except Exception as e:
155162
logger.error(f'Failed to project points to bounding box: {e}')
156163
logger.error('Using unprojected points, this may cause issues with the glyphing')
@@ -161,10 +168,10 @@ def vtk(
161168
if geom == 'arrow':
162169
geom = pv.Arrow(scale=scale)
163170
elif geom == 'disc':
164-
geom = pv.Disc(inner=0, outer=scale).rotate_y(90)
171+
geom = pv.Disc(inner=0, outer=scale * 0.5, c_res=50).rotate_y(90)
165172

166173
# Perform the glyph
167-
glyphed = points.glyph(orient="vectors", geom=geom, tolerance=tolerance, scale=False)
174+
glyphed = points.glyph(orient="vectors", geom=geom, tolerance=tolerance)
168175
if _projected:
169176
glyphed.points = bb.reproject(glyphed.points)
170177
return glyphed

‎LoopStructural/modelling/features/_geological_feature.py

-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ def copy(self, name=None):
260260
regions=[], # feature.regions.copy(), # don't want to share regionsbetween unconformity and # feature.regions,
261261
builder=self.builder,
262262
model=self.model,
263-
interpolator=self.interpolator,
264263
)
265264
return feature
266265

‎LoopStructural/modelling/features/builders/_structural_frame_builder.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ def __init__(
120120
model=self.model,
121121
)
122122
self._frame.builder = self
123-
123+
@property
124+
def build_arguments(self):
125+
return self.builders[0].build_arguments
126+
def update_build_arguments(self, kwargs):
127+
for i in range(3):
128+
self.builders[i].update_build_arguments(kwargs)
124129
@property
125130
def frame(self):
126131
return self._frame

‎LoopStructural/modelling/features/fault/_fault_segment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def evaluate_gradient(self, locations):
270270
v[mask, :] = self.__getitem__(1).evaluate_gradient(locations[mask, :])
271271
v[mask, :] /= np.linalg.norm(v[mask, :], axis=1)[:, None]
272272
scale = self.displacementfeature.evaluate_value(locations[mask, :])
273-
v[mask, :] *= scale[:, None]
273+
v[mask, :] *= scale[:, None] * self.displacement
274274
return v
275275

276276
def evaluate_displacement(self, points):

0 commit comments

Comments
 (0)
Please sign in to comment.