From 5f2a4b9ac320640d2b63c11844a36404edd08b25 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 5 Feb 2022 15:34:52 +0000 Subject: [PATCH 01/10] add inline example to grdvolume.py --- pygmt/src/grdvolume.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index bd05bea29eb..014a9fff4c3 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -75,6 +75,21 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): - :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is not set (depends on ``output_type`` [Default is class:`pandas.DataFrame`]) + + Example + ------- + >>> import pygmt # doctest: +SKIP + >>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30, + >>> # and a y-range of 15 to 25 + >>> grid = pygmt.datasets.load_earth_relief( + ... resolution="30m", region=[10, 30, 15, 25] + ... ) # doctest: +SKIP + >>> # Create a numpy array for the volume of slices in the grid file; set + >>> # the minimum z-value to 200, the maximum to 400, + >>> # and the interval to 10 + >>> output_array = pygmt.grdvolume( + ... grid=grid, contour=[200, 400, 50], output_type="numpy" + ... ) # doctest: +SKIP """ if output_type not in ["numpy", "pandas", "file"]: raise GMTInvalidInput( From 8a1f5d1ab45747b39dc6faaa69ef7674958c0fd2 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 11 Feb 2022 17:56:56 +0000 Subject: [PATCH 02/10] Update pygmt/src/grdvolume.py Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- pygmt/src/grdvolume.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index 014a9fff4c3..7127e2c9425 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -79,8 +79,8 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): Example ------- >>> import pygmt # doctest: +SKIP - >>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30, - >>> # and a y-range of 15 to 25 + >>> # 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] ... ) # doctest: +SKIP From 3855b1a5f873231294cd580f8197404c98d64ef0 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 11 Mar 2022 08:44:29 +0000 Subject: [PATCH 03/10] Update pygmt/src/grdvolume.py Co-authored-by: Dongdong Tian --- pygmt/src/grdvolume.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index 7127e2c9425..c1128e28300 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -86,7 +86,7 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): ... ) # doctest: +SKIP >>> # Create a numpy array for the volume of slices in the grid file; set >>> # the minimum z-value to 200, the maximum to 400, - >>> # and the interval to 10 + >>> # and the interval to 50 >>> output_array = pygmt.grdvolume( ... grid=grid, contour=[200, 400, 50], output_type="numpy" ... ) # doctest: +SKIP From 4564a05f75d66b999237c49a4be8fab2160dc24a Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 11 Mar 2022 08:45:35 +0000 Subject: [PATCH 04/10] update doctest skip format --- pygmt/src/grdvolume.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index 7127e2c9425..fd059126a26 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -12,6 +12,8 @@ use_alias, ) +__doctest_skip__ = ["grdvolume"] + @fmt_docstring @use_alias( @@ -78,18 +80,18 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): Example ------- - >>> import pygmt # doctest: +SKIP + >>> 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] - ... ) # doctest: +SKIP + ... ) >>> # Create a numpy array for the volume of slices in the grid file; set >>> # the minimum z-value to 200, the maximum to 400, >>> # and the interval to 10 >>> output_array = pygmt.grdvolume( ... grid=grid, contour=[200, 400, 50], output_type="numpy" - ... ) # doctest: +SKIP + ... ) """ if output_type not in ["numpy", "pandas", "file"]: raise GMTInvalidInput( From ed458d96300da28be10b7f025c05b76d8cc95402 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 11 Mar 2022 22:21:35 +0800 Subject: [PATCH 05/10] Fix formatting --- pygmt/src/grdvolume.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index 25e8ccd48f5..c1479bc263e 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -81,8 +81,8 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): 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 + >>> # 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] ... ) From 4f69b869b4f9f3056e003b6b6cf5d886bf9f3b5e Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 11 Mar 2022 18:28:29 +0000 Subject: [PATCH 06/10] Update pygmt/src/grdvolume.py Co-authored-by: Meghan Jones --- pygmt/src/grdvolume.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index c1479bc263e..6e7c905f90e 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -86,9 +86,10 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): >>> grid = pygmt.datasets.load_earth_relief( ... resolution="30m", region=[10, 30, 15, 25] ... ) - >>> # Create a numpy array for the volume of slices in the grid file; set - >>> # the minimum z-value to 200, the maximum to 400, - >>> # and the interval to 50 + >>> # Create a numpy ndarray 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_array = pygmt.grdvolume( ... grid=grid, contour=[200, 400, 50], output_type="numpy" ... ) From 56dc7c6e93f17089c05e02375e70f9a957360b0a Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 12 Mar 2022 07:07:24 +0000 Subject: [PATCH 07/10] Update pygmt/src/grdvolume.py Co-authored-by: Meghan Jones --- pygmt/src/grdvolume.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index 6e7c905f90e..ead597ecd6d 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -76,7 +76,7 @@ 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 ------- From a022c1134b40730c35b1a45a99d9141a7298cfc5 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 14 Mar 2022 10:45:08 +0000 Subject: [PATCH 08/10] Update pygmt/src/grdvolume.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/grdvolume.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index ead597ecd6d..2559ecedb5b 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -93,7 +93,14 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): >>> output_array = pygmt.grdvolume( ... grid=grid, contour=[200, 400, 50], output_type="numpy" ... ) - """ + >>> 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( """Must specify format as either numpy, pandas, or file.""" From cc4b56f60b36a80754a845a5d7cea08efe84b99e Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 14 Mar 2022 10:45:16 +0000 Subject: [PATCH 09/10] Update pygmt/src/grdvolume.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/grdvolume.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index 2559ecedb5b..b956bf1bde1 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -86,12 +86,12 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): >>> grid = pygmt.datasets.load_earth_relief( ... resolution="30m", region=[10, 30, 15, 25] ... ) - >>> # Create a numpy ndarray 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_array = pygmt.grdvolume( - ... grid=grid, contour=[200, 400, 50], output_type="numpy" + >>> # 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 From c3596ff474be1ea7f52c9b30d93733c35e7abe0e Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 16 Mar 2022 09:38:37 +0000 Subject: [PATCH 10/10] run make format --- pygmt/src/grdvolume.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index b956bf1bde1..0beb3d4523f 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -100,7 +100,7 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs): 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( """Must specify format as either numpy, pandas, or file."""