From 3b2cf1ef79462a52232e059217d19a1a0a07088c Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 29 Jan 2022 07:47:07 +0000 Subject: [PATCH 1/6] add inline example for grd2xyz --- pygmt/src/grd2xyz.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pygmt/src/grd2xyz.py b/pygmt/src/grd2xyz.py index 0a33a5bbe67..07c73150db6 100644 --- a/pygmt/src/grd2xyz.py +++ b/pygmt/src/grd2xyz.py @@ -126,6 +126,18 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs): - :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is not set (depends on ``output_type``) + Examples + -------- + >>> 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 with the xyz data from an input grid + >>> xyz_array = pygmt.grd2xyz( + ... grid=grid, output_type="numpy" + ... ) # doctest: +SKIP """ if output_type not in ["numpy", "pandas", "file"]: raise GMTInvalidInput( From aeccf197390a962a5e9f2353006741397a82b721 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 29 Jan 2022 18:51:58 +0000 Subject: [PATCH 2/6] change example to use pandas dataframe --- pygmt/src/grd2xyz.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grd2xyz.py b/pygmt/src/grd2xyz.py index 07c73150db6..2d5575c3bfd 100644 --- a/pygmt/src/grd2xyz.py +++ b/pygmt/src/grd2xyz.py @@ -134,9 +134,9 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs): >>> grid = pygmt.datasets.load_earth_relief( ... resolution="30m", region=[10, 30, 15, 25] ... ) # doctest: +SKIP - >>> # Create a numpy array with the xyz data from an input grid + >>> # Create a pandas DataFrame with the xyz data from an input grid >>> xyz_array = pygmt.grd2xyz( - ... grid=grid, output_type="numpy" + ... grid=grid, output_type="pandas" ... ) # doctest: +SKIP """ if output_type not in ["numpy", "pandas", "file"]: From a5f8df79f514a695ee834323e8e3b7d5e7f3e5af Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 2 Feb 2022 15:24:43 +0000 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/grd2xyz.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pygmt/src/grd2xyz.py b/pygmt/src/grd2xyz.py index 2d5575c3bfd..0beb7643f86 100644 --- a/pygmt/src/grd2xyz.py +++ b/pygmt/src/grd2xyz.py @@ -135,9 +135,13 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs): ... resolution="30m", region=[10, 30, 15, 25] ... ) # doctest: +SKIP >>> # Create a pandas DataFrame with the xyz data from an input grid - >>> xyz_array = pygmt.grd2xyz( + >>> xyz_dataframe = pygmt.grd2xyz( ... grid=grid, output_type="pandas" ... ) # doctest: +SKIP + >>> print(xyz_dataframe.head(n=2)) # doctest: +SKIP + lon lat elevation + 0 10.25 24.75 903.5 + 1 10.75 24.75 820.0 """ if output_type not in ["numpy", "pandas", "file"]: raise GMTInvalidInput( From 70c59e09bee7a8ba082cd24760d286cd80596e11 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 3 Feb 2022 10:56:16 +0000 Subject: [PATCH 4/6] change header from "Examples" to "Example" --- pygmt/src/grd2xyz.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grd2xyz.py b/pygmt/src/grd2xyz.py index 0beb7643f86..ee9275953c6 100644 --- a/pygmt/src/grd2xyz.py +++ b/pygmt/src/grd2xyz.py @@ -126,8 +126,8 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs): - :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is not set (depends on ``output_type``) - Examples - -------- + 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 From e51c4588d55d94a6fa385632dd5b34f2a375ffe7 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 5 Feb 2022 14:32:05 +0000 Subject: [PATCH 5/6] change "Examples" to "Example" for inline examples in grdcut.py, grdfilter.py, and grdclip.py --- pygmt/src/grdclip.py | 4 ++-- pygmt/src/grdcut.py | 4 ++-- pygmt/src/grdfilter.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pygmt/src/grdclip.py b/pygmt/src/grdclip.py index 56cb829ffe5..4ace6011683 100644 --- a/pygmt/src/grdclip.py +++ b/pygmt/src/grdclip.py @@ -78,8 +78,8 @@ def grdclip(grid, **kwargs): - None if ``outgrid`` is set (grid output will be stored in file set by ``outgrid``) - Examples - -------- + 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 diff --git a/pygmt/src/grdcut.py b/pygmt/src/grdcut.py index f922aaaf04f..a212b0e6a01 100644 --- a/pygmt/src/grdcut.py +++ b/pygmt/src/grdcut.py @@ -88,8 +88,8 @@ def grdcut(grid, **kwargs): - None if ``outgrid`` is set (grid output will be stored in file set by ``outgrid``) - Examples - -------- + 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 diff --git a/pygmt/src/grdfilter.py b/pygmt/src/grdfilter.py index eb57b271a54..cffcb928d22 100644 --- a/pygmt/src/grdfilter.py +++ b/pygmt/src/grdfilter.py @@ -119,8 +119,8 @@ def grdfilter(grid, **kwargs): - None if ``outgrid`` is set (grid output will be stored in file set by ``outgrid``) - Examples - -------- + Example + ------- >>> import os >>> import pygmt From 55f9b382efb93f61f3141646668cd888b1a40f48 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 8 Feb 2022 11:56:18 +0000 Subject: [PATCH 6/6] Update pygmt/src/grd2xyz.py Co-authored-by: Meghan Jones --- pygmt/src/grd2xyz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grd2xyz.py b/pygmt/src/grd2xyz.py index ee9275953c6..38cc1807d8c 100644 --- a/pygmt/src/grd2xyz.py +++ b/pygmt/src/grd2xyz.py @@ -138,7 +138,7 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs): >>> xyz_dataframe = pygmt.grd2xyz( ... grid=grid, output_type="pandas" ... ) # doctest: +SKIP - >>> print(xyz_dataframe.head(n=2)) # doctest: +SKIP + >>> xyz_dataframe.head(n=2) # doctest: +SKIP lon lat elevation 0 10.25 24.75 903.5 1 10.75 24.75 820.0