From b9f2bdf6641e8bae3b5b63dcef830323d73114c8 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 30 Dec 2021 15:32:21 +0000 Subject: [PATCH 1/5] add inline example for grdcut.py --- pygmt/src/grdcut.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pygmt/src/grdcut.py b/pygmt/src/grdcut.py index b16b3234acc..c02b5931ba1 100644 --- a/pygmt/src/grdcut.py +++ b/pygmt/src/grdcut.py @@ -87,6 +87,19 @@ def grdcut(grid, **kwargs): - :class:`xarray.DataArray` if ``outgrid`` is not set - None if ``outgrid`` is set (grid output will be stored in file set by ``outgrid``) + + Examples + -------- + >>> import pygmt + + >>> # 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] + ... ) + >>> # Create a new grid from an input grid, with an x-range of -3 to 1, + >>> # and a y-range of 2 to 5 + >>> new_grid = pygmt.grdcut(grid=grid, region=[-3, 1, 2, 5]) """ with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: From 7f9d417cb46b324536fd65a4a1a4ca18db7336f7 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 30 Dec 2021 15:40:28 +0000 Subject: [PATCH 2/5] formatting fix --- pygmt/src/grdcut.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/grdcut.py b/pygmt/src/grdcut.py index c02b5931ba1..ba0d2156ca9 100644 --- a/pygmt/src/grdcut.py +++ b/pygmt/src/grdcut.py @@ -91,7 +91,6 @@ def grdcut(grid, **kwargs): Examples -------- >>> import pygmt - >>> # 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( From 1e8f4c7d0a34bd9c228d30cc19cc1cd5f0a59cd4 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 14 Jan 2022 00:26:05 +0000 Subject: [PATCH 3/5] Update pygmt/src/grdcut.py Co-authored-by: Meghan Jones --- pygmt/src/grdcut.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdcut.py b/pygmt/src/grdcut.py index ba0d2156ca9..832151d3e8f 100644 --- a/pygmt/src/grdcut.py +++ b/pygmt/src/grdcut.py @@ -96,9 +96,9 @@ def grdcut(grid, **kwargs): >>> grid = pygmt.datasets.load_earth_relief( ... resolution="30m", region=[10, 30, 15, 25] ... ) - >>> # Create a new grid from an input grid, with an x-range of -3 to 1, - >>> # and a y-range of 2 to 5 - >>> new_grid = pygmt.grdcut(grid=grid, region=[-3, 1, 2, 5]) + >>> # Create a new grid from an input grid, with an x-range of 12 to 15, + >>> # and a y-range of 21 to 24 + >>> new_grid = pygmt.grdcut(grid=grid, region=[12, 15, 21, 24]) """ with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: From fb6c820d9c2511e7591fcbf89153c82a61fb0f9a Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 25 Jan 2022 07:53:59 +0000 Subject: [PATCH 4/5] add doctest skipping comments --- pygmt/src/grdcut.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pygmt/src/grdcut.py b/pygmt/src/grdcut.py index 832151d3e8f..8d9a583fc3a 100644 --- a/pygmt/src/grdcut.py +++ b/pygmt/src/grdcut.py @@ -90,15 +90,15 @@ def grdcut(grid, **kwargs): Examples -------- - >>> import pygmt + >>> 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] - ... ) + >>> grid = pygmt.datasets.load_earth_relief( # doctest: +SKIP + ... resolution="30m", region=[10, 30, 15, 25] # doctest: +SKIP + ... ) # doctest: +SKIP >>> # Create a new grid from an input grid, with an x-range of 12 to 15, >>> # and a y-range of 21 to 24 - >>> new_grid = pygmt.grdcut(grid=grid, region=[12, 15, 21, 24]) + >>> new_grid = pygmt.grdcut(grid=grid, region=[12, 15, 21, 24]) # doctest: +SKIP """ with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: From bcbc5a9a08bf9c0b2bd3fe443ccbbb20982ebb1b Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 25 Jan 2022 08:04:39 +0000 Subject: [PATCH 5/5] run make format --- pygmt/src/grdcut.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pygmt/src/grdcut.py b/pygmt/src/grdcut.py index 8d9a583fc3a..f922aaaf04f 100644 --- a/pygmt/src/grdcut.py +++ b/pygmt/src/grdcut.py @@ -90,15 +90,17 @@ def grdcut(grid, **kwargs): Examples -------- - >>> import pygmt # doctest: +SKIP + >>> 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( # doctest: +SKIP - ... resolution="30m", region=[10, 30, 15, 25] # doctest: +SKIP - ... ) # doctest: +SKIP + >>> grid = pygmt.datasets.load_earth_relief( + ... resolution="30m", region=[10, 30, 15, 25] + ... ) # doctest: +SKIP >>> # Create a new grid from an input grid, with an x-range of 12 to 15, >>> # and a y-range of 21 to 24 - >>> new_grid = pygmt.grdcut(grid=grid, region=[12, 15, 21, 24]) # doctest: +SKIP + >>> new_grid = pygmt.grdcut( + ... grid=grid, region=[12, 15, 21, 24] + ... ) # doctest: +SKIP """ with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: