Skip to content

Commit ff0f126

Browse files
committed
[!ENH] All content can be plotted transformed or not
1 parent b86ba6a commit ff0f126

File tree

3 files changed

+34
-50
lines changed

3 files changed

+34
-50
lines changed

gempy/core/data/geo_model.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,16 @@ def orientations_copy_transformed(self) -> OrientationsTable:
208208

209209
og_or.grads_view = total_transform.transform_gradient(og_or.grads)
210210
return og_or
211+
212+
@property
213+
def regular_grid_coordinates(self) -> np.ndarray:
214+
return self.grid.regular_grid.get_values_vtk_format(orthogonal=False)
215+
216+
@property
217+
def regular_grid_coordinates_transformed(self) -> np.ndarray:
218+
values_transformed = self.grid.regular_grid.get_values_vtk_format(orthogonal=True)
219+
values_transformed = self.input_transform.apply(values_transformed)
220+
return values_transformed
211221

212222
@property
213223
def orientations(self) -> OrientationsTable:
@@ -230,10 +240,6 @@ def extent_transformed(self) -> np.ndarray:
230240
transformed[:, 2].min(), transformed[:, 2].max()])
231241
return new_extents
232242

233-
@property
234-
def extent(self) -> np.ndarray:
235-
return self.grid.extent
236-
237243
@property
238244
def interpolation_input_copy(self):
239245
warnings.warn("This property is deprecated. Use directly "

gempy/core/data/grid_modules/grid_types.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def dz(self):
199199
return (self.extent[5] - self.extent[4]) / self.resolution[2]
200200

201201
@property
202-
def values_vtk_format(self):
202+
def values_vtk_format(self) -> np.ndarray:
203+
return self.get_values_vtk_format()
204+
205+
def get_values_vtk_format(self, orthogonal: bool = False) -> np.ndarray:
203206
extent = self.extent
204207
resolution = self.resolution + 1
205208

@@ -209,6 +212,14 @@ def values_vtk_format(self):
209212
xv, yv, zv = np.meshgrid(x, y, z, indexing="ij")
210213
g = np.vstack((xv.ravel(), yv.ravel(), zv.ravel())).T
211214

215+
216+
# Transform the values
217+
if self.transform is not None and orthogonal is False:
218+
g = self.transform.apply_inverse_with_pivot(
219+
points=g,
220+
pivot=np.array([self.extent[0], self.extent[2], self.extent[4]])
221+
)
222+
212223
return g
213224

214225
@staticmethod

test/test_modules/.benchmarks/test_transformed_space.py

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_plot_transformed_data_only_transform_input():
2424
'arrow_size': 10
2525
}
2626
)
27-
27+
2828
gpv.plot_3d(
2929
model,
3030
image=False,
@@ -35,81 +35,48 @@ def test_plot_transformed_data_only_transform_input():
3535
'arrow_size': .01
3636
}
3737
)
38-
39-
38+
39+
4040
def test_plot_transformed_data_including_grid_transform():
4141
model = gp.generate_example_model(ExampleModel.ANTICLINE, compute_model=False)
4242

4343
# Calculate point_y_axis
4444
regular_grid = gp.data.grid.RegularGrid.from_corners_box(
4545
pivot=(200, 200),
46-
point_x_axis=(800,800),
46+
point_x_axis=(800, 800),
4747
distance_point3=1000,
48-
zmin=model.extent[4],
49-
zmax=model.extent[5],
48+
zmin=model.grid.extent[4],
49+
zmax=model.grid.extent[5],
5050
resolution=np.array([20, 20, 20]),
5151
plot=True
5252
)
5353

5454
model.grid = gp.data.grid.Grid()
5555
model.grid.dense_grid = regular_grid
56-
56+
5757
gp.compute_model(model)
5858

59-
6059
if PLOT:
6160
gpv = require_gempy_viewer()
62-
63-
61+
6462
gpv.plot_3d(
6563
model,
66-
image=False,
64+
image=True,
6765
transformed_data=True,
6866
show_boundaries=True,
69-
show_lith=False,
67+
show_lith=True,
7068
kwargs_plot_data={
7169
'arrow_size': .01
7270
}
7371
)
7472

75-
7673
gpv.plot_3d(
7774
model,
78-
image=False,
75+
image=True,
7976
transformed_data=False,
8077
show_boundaries=True,
81-
show_lith=False,
78+
show_lith=True,
8279
kwargs_plot_data={
8380
'arrow_size': .01
8481
}
8582
)
86-
87-
88-
def test_transformed_data():
89-
if transfromed_data := True: # TODO: Expose this to user
90-
xyz2 = surface_points.model_transform.apply_with_pivot(
91-
points=xyz,
92-
# pivot=np.array([5_478_256.5, 5_698_528.946534388,0]),
93-
pivot=np.array([5.47825650e+06, 5.69852895e+06, -1.48920000e+03])
94-
95-
)
96-
97-
xyz = np.vstack([xyz, xyz2])
98-
99-
agggg = np.concatenate([mapped_array, mapped_array])
100-
101-
if transfromed_data := True:
102-
orientations_xyz2 = orientations.model_transform.apply_with_pivot(
103-
points=orientations_xyz,
104-
pivot=np.array([5.47825650e+06, 5.69852895e+06, -1.48920000e+03])
105-
)
106-
orientations_grads2 = orientations.model_transform.transform_gradient(orientations_grads)
107-
arrows_factor /= orientations.model_transform.isometric_scale
108-
109-
orientations_xyz = np.vstack([orientations_xyz, orientations_xyz2])
110-
111-
input_transform = regular_grid.input_transform
112-
transformed = input_transform.apply(regular_grid.bounding_box) # ! grid already has the grid transform applied
113-
new_extents = np.array([transformed[:, 0].min(), transformed[:, 0].max(),
114-
transformed[:, 1].min(), transformed[:, 1].max(),
115-
transformed[:, 2].min(), transformed[:, 2].max()])

0 commit comments

Comments
 (0)