@@ -22,26 +22,22 @@ def plot_data(gempy_vista: GemPyToVista,
2222
2323 plot_surface_points (
2424 gempy_vista = gempy_vista ,
25- surface_points = surface_points_copy ,
26- elements_colors = model .structural_frame .elements_colors ,
27- ** kwargs
25+ surface_points = surface_points_copy
2826 )
2927
3028 plot_orientations (
3129 gempy_vista = gempy_vista ,
3230 orientations = orientations_copy ,
33- elements_colors = model . structural_frame . elements_colors_orientations ,
31+ surface_points = surface_points_copy ,
3432 arrows_factor = arrows_factor
3533 )
3634
3735
3836def plot_surface_points (
3937 gempy_vista : GemPyToVista ,
4038 surface_points : SurfacePointsTable ,
41- elements_colors : list [str ],
4239 render_points_as_spheres = True ,
43- point_size = 10 ,
44- ** kwargs
40+ point_size = 10
4541):
4642 # Selecting the surfaces to plot
4743 xyz = surface_points .xyz
@@ -54,22 +50,24 @@ def plot_surface_points(
5450 ids = surface_points .ids
5551 if ids .shape [0 ] == 0 :
5652 return
57- poly ['id' ] = _vectorize_ids (ids )
53+ vectorize_ids = _vectorize_ids (ids , ids )
54+ poly ['id' ] = vectorize_ids
5855
5956 gempy_vista .surface_points_mesh = poly
6057 gempy_vista .surface_points_actor = gempy_vista .p .add_mesh (
6158 mesh = poly ,
6259 scalars = 'id' ,
6360 render_points_as_spheres = render_points_as_spheres ,
6461 point_size = point_size ,
65- show_scalar_bar = False
62+ show_scalar_bar = False ,
63+ # clim=(0, ids.max())
6664 )
6765
6866
6967def plot_orientations (
7068 gempy_vista : GemPyToVista ,
7169 orientations : OrientationsTable ,
72- elements_colors : list [ str ] ,
70+ surface_points : SurfacePointsTable ,
7371 arrows_factor : float ,
7472):
7573 orientations_xyz = orientations .xyz
@@ -81,16 +79,11 @@ def plot_orientations(
8179 pv = require_pyvista ()
8280 poly = pv .PolyData (orientations_xyz )
8381
84- ids = orientations .ids
85-
86- poly ['id' ] = _vectorize_ids (ids )
87- poly ['vectors' ] = orientations_grads
88-
89- # TODO: I am still trying to figure out colors and ids in orientations and surface points
90- cmap = get_geo_model_cmap (
91- elements_colors = np .array (elements_colors ),
92- reverse = False
82+ poly ['id' ] = _vectorize_ids (
83+ mapping_ids = surface_points .ids ,
84+ ids_to_map = orientations .ids
9385 )
86+ poly ['vectors' ] = orientations_grads
9487
9588 arrows = poly .glyph (
9689 orient = 'vectors' ,
@@ -100,17 +93,21 @@ def plot_orientations(
10093
10194 gempy_vista .orientations_actor = gempy_vista .p .add_mesh (
10295 mesh = arrows ,
103- cmap = cmap ,
96+ scalars = 'id' ,
10497 show_scalar_bar = False
10598 )
10699 gempy_vista .orientations_mesh = arrows
107100
108101
109- def _vectorize_ids (ids ):
110- unique_values , first_indices = np .unique (ids , return_index = True ) # Find the unique elements and their first indices
111- unique_values_order = unique_values [np .argsort (first_indices )] # Sort the unique values by their first appearance in `a`
112- # Flip order to please pyvista vertical scalarbar
113- unique_values_order = unique_values_order [::- 1 ]
114- mapping_dict = {value : i + 1 for i , value in enumerate (unique_values_order )} # Use a dictionary to map the original numbers to new values
115- mapped_array = np .vectorize (mapping_dict .get )(ids ) # Map the original array to the new values
102+ def _vectorize_ids (mapping_ids , ids_to_map ):
103+ def _mapping_dict (ids ):
104+ unique_values , first_indices = np .unique (ids , return_index = True ) # Find the unique elements and their first indices
105+ unique_values_order = unique_values [np .argsort (first_indices )] # Sort the unique values by their first appearance in `a`
106+ # Flip order to please pyvista vertical scalarbar
107+ unique_values_order = unique_values_order [::- 1 ]
108+ mapping_dict = {value : i + 1 for i , value in enumerate (unique_values_order )} # Use a dictionary to map the original numbers to new values
109+ return mapping_dict
110+
111+ mapping_dict = _mapping_dict (mapping_ids )
112+ mapped_array = np .vectorize (mapping_dict .get )(ids_to_map ) # Map the original array to the new values
116113 return mapped_array
0 commit comments