|
35 | 35 | import pandas as pn
|
36 | 36 |
|
37 | 37 | # Keep Alex code hidden until we merge it properly
|
38 |
| -from .vista import _Vista as Vista |
| 38 | +try: |
| 39 | + import pyvista as pv |
| 40 | + from .vista import _Vista as Vista |
| 41 | + PYVISTA_IMPORT = True |
| 42 | +except ImportError: |
| 43 | + PYVISTA_IMPORT = False |
| 44 | + |
39 | 45 | from .visualization_2d_pro import Plot2D
|
40 | 46 |
|
41 | 47 | try:
|
42 | 48 | import mplstereonet
|
43 |
| - |
44 | 49 | mplstereonet_import = True
|
45 | 50 | except ImportError:
|
46 | 51 | mplstereonet_import = False
|
@@ -231,62 +236,63 @@ def plot_stereonet(self, litho=None, planes=True, poles=True,
|
231 | 236 | ax.grid(True, color='black', alpha=0.25)
|
232 | 237 |
|
233 | 238 |
|
234 |
| -def plot_3d( |
235 |
| - geo_model, |
236 |
| - render_surfaces: bool = True, |
237 |
| - render_data: bool = True, |
238 |
| - render_topography: bool = False, |
239 |
| - **kwargs, |
240 |
| -) -> Vista: |
241 |
| - """Plot 3-D geomodel. |
242 |
| -
|
243 |
| - Args: |
244 |
| - geo_model: Geomodel object with solutions. |
245 |
| - render_surfaces: Render geomodel surfaces. Defaults to True. |
246 |
| - render_data: Render geomodel input data. Defaults to True. |
247 |
| - render_topography: Render topography. Defaults to False. |
248 |
| - real_time: Toggles modyfiable input data and real-time geomodel |
249 |
| - updating. Defaults to False. |
250 |
| -
|
251 |
| - Returns: |
252 |
| - (Vista) GemPy Vista object for plotting. |
253 |
| - """ |
254 |
| - gpv = Vista(geo_model, **kwargs) |
255 |
| - gpv.set_bounds() |
256 |
| - if render_surfaces: |
257 |
| - gpv.plot_surfaces_all() |
258 |
| - if render_data: |
259 |
| - gpv._plot_surface_points_all() |
260 |
| - gpv._plot_orientations_all() |
261 |
| - if render_topography and geo_model.grid.topography is not None: |
262 |
| - gpv.plot_topography() |
263 |
| - gpv.show() |
264 |
| - return gpv |
265 |
| - |
266 |
| - |
267 |
| -def plot_interactive_3d( |
268 |
| - geo_model, |
269 |
| - name: str, |
270 |
| - render_topography: bool = False, |
271 |
| - **kwargs, |
272 |
| -) -> Vista: |
273 |
| - """Plot interactive 3-D geomodel with three cross sections in subplots. |
274 |
| -
|
275 |
| - Args: |
276 |
| - geo_model: Geomodel object with solutions. |
277 |
| - name (str): Can be either one of the following |
278 |
| - 'lith' - Lithology id block. |
279 |
| - 'scalar' - Scalar field block. |
280 |
| - 'values' - Values matrix block. |
281 |
| - render_topography: Render topography. Defaults to False. |
282 |
| - **kwargs: |
283 |
| -
|
284 |
| - Returns: |
285 |
| - (Vista) GemPy Vista object for plotting. |
286 |
| - """ |
287 |
| - gpv = Vista(geo_model, plotter_type='background', shape="1|3") |
288 |
| - gpv.set_bounds() |
289 |
| - gpv.plot_structured_grid_interactive(name=name, render_topography=render_topography, **kwargs) |
290 |
| - |
291 |
| - gpv.show() |
292 |
| - return gpv |
| 239 | +if PYVISTA_IMPORT: |
| 240 | + def plot_3d( |
| 241 | + geo_model, |
| 242 | + render_surfaces: bool = True, |
| 243 | + render_data: bool = True, |
| 244 | + render_topography: bool = False, |
| 245 | + **kwargs, |
| 246 | + ) -> Vista: |
| 247 | + """Plot 3-D geomodel. |
| 248 | +
|
| 249 | + Args: |
| 250 | + geo_model: Geomodel object with solutions. |
| 251 | + render_surfaces: Render geomodel surfaces. Defaults to True. |
| 252 | + render_data: Render geomodel input data. Defaults to True. |
| 253 | + render_topography: Render topography. Defaults to False. |
| 254 | + real_time: Toggles modyfiable input data and real-time geomodel |
| 255 | + updating. Defaults to False. |
| 256 | +
|
| 257 | + Returns: |
| 258 | + (Vista) GemPy Vista object for plotting. |
| 259 | + """ |
| 260 | + gpv = Vista(geo_model, **kwargs) |
| 261 | + gpv.set_bounds() |
| 262 | + if render_surfaces: |
| 263 | + gpv.plot_surfaces_all() |
| 264 | + if render_data: |
| 265 | + gpv._plot_surface_points_all() |
| 266 | + gpv._plot_orientations_all() |
| 267 | + if render_topography and geo_model.grid.topography is not None: |
| 268 | + gpv.plot_topography() |
| 269 | + gpv.show() |
| 270 | + return gpv |
| 271 | + |
| 272 | + |
| 273 | + def plot_interactive_3d( |
| 274 | + geo_model, |
| 275 | + name: str, |
| 276 | + render_topography: bool = False, |
| 277 | + **kwargs, |
| 278 | + ) -> Vista: |
| 279 | + """Plot interactive 3-D geomodel with three cross sections in subplots. |
| 280 | +
|
| 281 | + Args: |
| 282 | + geo_model: Geomodel object with solutions. |
| 283 | + name (str): Can be either one of the following |
| 284 | + 'lith' - Lithology id block. |
| 285 | + 'scalar' - Scalar field block. |
| 286 | + 'values' - Values matrix block. |
| 287 | + render_topography: Render topography. Defaults to False. |
| 288 | + **kwargs: |
| 289 | +
|
| 290 | + Returns: |
| 291 | + (Vista) GemPy Vista object for plotting. |
| 292 | + """ |
| 293 | + gpv = Vista(geo_model, plotter_type='background', shape="1|3") |
| 294 | + gpv.set_bounds() |
| 295 | + gpv.plot_structured_grid_interactive(name=name, render_topography=render_topography, **kwargs) |
| 296 | + |
| 297 | + gpv.show() |
| 298 | + return gpv |
0 commit comments