pygmt.grdvolume

pygmt.grdvolume(grid, output_type='pandas', outfile=None, *, contour=None, region=None, unit=None, verbose=None, **kwargs)[source]

Determine the volume between the surface of a grid and a plane.

Read a 2-D grid file and calculate the volume contained below the surface and above the plane specified by the given contour (or zero if not given) and return the contour, area, volume, and maximum mean height (volume/area). Alternatively, a range of contours can be specified to return the volume and area inside the contour for all contour values.

Full option list at https://docs.generic-mapping-tools.org/latest/grdvolume.html

Aliases:

  • C = contour

  • R = region

  • S = unit

  • V = verbose

Parameters
  • grid (str or xarray.DataArray) – The file name of the input grid or the grid loaded as a DataArray.

  • output_type (str) –

    Determine the format the output data will be returned in [Default is pandas]:

  • outfile (str) – The file name for the output ASCII file.

  • contour (str or int or float or list) – cval|low/high/delta|rlow/high|rcval. Find area, volume and mean height (volume/area) inside and above the cval contour. Alternatively, search using all contours from low to high in steps of delta. [Default returns area, volume and mean height of the entire grid]. The area is measured in the plane of the contour. Adding the r prefix computes the volume below the grid surface and above the planes defined by low and high, or below cval and grid’s minimum. Note that this is an outside volume whilst the other forms compute an inside (below the surface) area volume. Use this form to compute for example the volume of water between two contours. If no contour is given then there is no contour and the entire grid area, volume and the mean height is returned and cval will be reported as 0.

  • region (str or list) – xmin/xmax/ymin/ymax[+r][+uunit]. Specify the region of interest.

  • verbose (bool or str) –

    Select verbosity level [Default is w], which modulates the messages written to stderr. Choose among 7 levels of verbosity:

    • q - Quiet, not even fatal error messages are produced

    • e - Error messages only

    • w - Warnings [Default]

    • t - Timings (report runtimes for time-intensive algorithms);

    • i - Informational messages (same as verbose=True)

    • c - Compatibility warnings

    • d - Debugging messages

Returns

ret (pandas.DataFrame or numpy.ndarray or None) – Return type depends on outfile and output_type:

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