Skip to content

Commit 1b6b040

Browse files
willschlitzermichaelgrundseismanMeghan Jonesweiji14
authored
Add inline example for grdvolume (#1726)
* Add an inline example to grdvolume.py Co-authored-by: Michael Grund <[email protected]> Co-authored-by: Dongdong Tian <[email protected]> Co-authored-by: Meghan Jones <[email protected]> Co-authored-by: Wei Ji <[email protected]>
1 parent 28a2aef commit 1b6b040

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pygmt/src/grdvolume.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use_alias,
1313
)
1414

15+
__doctest_skip__ = ["grdvolume"]
16+
1517

1618
@fmt_docstring
1719
@use_alias(
@@ -74,7 +76,30 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs):
7476
``outfile``)
7577
- :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile``
7678
is not set (depends on ``output_type`` [Default is
77-
class:`pandas.DataFrame`])
79+
:class:`pandas.DataFrame`])
80+
81+
Example
82+
-------
83+
>>> import pygmt
84+
>>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30
85+
>>> # degrees, and a y-range of 15 to 25 degrees
86+
>>> grid = pygmt.datasets.load_earth_relief(
87+
... resolution="30m", region=[10, 30, 15, 25]
88+
... )
89+
>>> # Create a pandas dataframe that contains the contour, area, volume,
90+
>>> # and maximum mean height above the plane specified by the given
91+
>>> # contour and below the surface; set the minimum contour z-value to
92+
>>> # 200, the maximum to 400, and the interval to 50.
93+
>>> output_dataframe = pygmt.grdvolume(
94+
... grid=grid, contour=[200, 400, 50], output_type="pandas"
95+
... )
96+
>>> print(output_dataframe)
97+
0 1 2 3
98+
0 200 2.144285e+12 7.972228e+14 371.789489
99+
1 250 2.104042e+12 6.908183e+14 328.329232
100+
2 300 2.014978e+12 5.877195e+14 291.675420
101+
3 350 1.892109e+12 4.897545e+14 258.840510
102+
4 400 1.744792e+12 3.988316e+14 228.584026
78103
"""
79104
if output_type not in ["numpy", "pandas", "file"]:
80105
raise GMTInvalidInput(

0 commit comments

Comments
 (0)