From 01dfc2738ef09cb977157ebfdc1455a6a10cdff6 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 5 Feb 2022 14:47:35 +0000 Subject: [PATCH 1/2] add inline example to grdsample.py --- pygmt/src/grdsample.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pygmt/src/grdsample.py b/pygmt/src/grdsample.py index 4acd7bc0fe5..158464f2873 100644 --- a/pygmt/src/grdsample.py +++ b/pygmt/src/grdsample.py @@ -73,6 +73,20 @@ def grdsample(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``) + + 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 new grid from an input grid, change the registration, + >>> # and set the x-spacing to 1 degree and the y-spacing to 0.5 degrees + >>> new_grid = pygmt.grdsample( + ... grid=grid, translate=True, spacing=[1, 0.5] + ... ) # doctest: +SKIP """ with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: From d955cc32a380aa14affdb6e676d33f357f9c3bce Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 14 Feb 2022 17:07:14 +0000 Subject: [PATCH 2/2] Update pygmt/src/grdsample.py Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- pygmt/src/grdsample.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grdsample.py b/pygmt/src/grdsample.py index 158464f2873..917ee79df3b 100644 --- a/pygmt/src/grdsample.py +++ b/pygmt/src/grdsample.py @@ -83,9 +83,9 @@ def grdsample(grid, **kwargs): ... resolution="30m", region=[10, 30, 15, 25] ... ) # doctest: +SKIP >>> # Create a new grid from an input grid, change the registration, - >>> # and set the x-spacing to 1 degree and the y-spacing to 0.5 degrees + >>> # and set both x- and y-spacing to 0.5 degrees >>> new_grid = pygmt.grdsample( - ... grid=grid, translate=True, spacing=[1, 0.5] + ... grid=grid, translate=True, spacing=[0.5, 0.5] ... ) # doctest: +SKIP """ with GMTTempFile(suffix=".nc") as tmpfile: