Skip to content

Commit 6ef3bd5

Browse files
committed
[DOC] Moving pyvista to optional-requirements
1 parent f3b2b54 commit 6ef3bd5

File tree

4 files changed

+74
-64
lines changed

4 files changed

+74
-64
lines changed

gempy/plot/plot_api.py

+67-61
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@
3535
import pandas as pn
3636

3737
# 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+
3945
from .visualization_2d_pro import Plot2D
4046

4147
try:
4248
import mplstereonet
43-
4449
mplstereonet_import = True
4550
except ImportError:
4651
mplstereonet_import = False
@@ -231,62 +236,63 @@ def plot_stereonet(self, litho=None, planes=True, poles=True,
231236
ax.grid(True, color='black', alpha=0.25)
232237

233238

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

gempy/plot/vista.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333
from matplotlib import cm
3434
import numpy as np
3535
import pandas as pn
36-
import pyvista as pv
37-
from pyvista.plotting.theme import parse_color
36+
try:
37+
import pyvista as pv
38+
from pyvista.plotting.theme import parse_color
39+
PYVISTA_IMPORT = True
40+
except ImportError:
41+
PYVISTA_IMPORT = False
3842

3943
import gempy as gp
4044

optional-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
git+git://github.com/Leguark/scikit-image@master
22
steno3d
33
vtk
4+
pyvista
45
gdal
56
qgrid==1.3.0
67
pymc3

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ networkx
1010
ipywidgets
1111
scikit-image
1212
nptyping
13-
pyvista
1413
IPython

0 commit comments

Comments
 (0)