diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index bd05bea29eb..0beb3d4523f 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -12,6 +12,8 @@ use_alias, ) +__doctest_skip__ = ["grdvolume"] + @fmt_docstring @use_alias( @@ -74,7 +76,30 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): ``outfile``) - :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is not set (depends on ``output_type`` [Default is - class:`pandas.DataFrame`]) + :class:`pandas.DataFrame`]) + + Example + ------- + >>> import pygmt + >>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30 + >>> # degrees, and a y-range of 15 to 25 degrees + >>> grid = pygmt.datasets.load_earth_relief( + ... resolution="30m", region=[10, 30, 15, 25] + ... ) + >>> # Create a pandas dataframe that contains the contour, area, volume, + >>> # and maximum mean height above the plane specified by the given + >>> # contour and below the surface; set the minimum contour z-value to + >>> # 200, the maximum to 400, and the interval to 50. + >>> output_dataframe = pygmt.grdvolume( + ... grid=grid, contour=[200, 400, 50], output_type="pandas" + ... ) + >>> print(output_dataframe) + 0 1 2 3 + 0 200 2.144285e+12 7.972228e+14 371.789489 + 1 250 2.104042e+12 6.908183e+14 328.329232 + 2 300 2.014978e+12 5.877195e+14 291.675420 + 3 350 1.892109e+12 4.897545e+14 258.840510 + 4 400 1.744792e+12 3.988316e+14 228.584026 """ if output_type not in ["numpy", "pandas", "file"]: raise GMTInvalidInput(