Skip to content

Commit 8a62136

Browse files
authored
Merge branch 'main' into static-earth-relief/grdcontour
2 parents 07bc63e + 7dc0a6b commit 8a62136

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

pygmt/clib/session.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ class Session:
9999
Examples
100100
--------
101101
102-
>>> from pygmt.datasets import load_earth_relief
102+
>>> from pygmt.helpers.testing import load_static_earth_relief
103103
>>> from pygmt.helpers import GMTTempFile
104-
>>> grid = load_earth_relief()
104+
>>> grid = load_static_earth_relief()
105105
>>> type(grid)
106106
<class 'xarray.core.dataarray.DataArray'>
107107
>>> # Create a session and destroy it automatically when exiting the "with"
@@ -117,7 +117,7 @@ class Session:
117117
... # Read the contents of the temp file before it's deleted.
118118
... print(fout.read().strip())
119119
...
120-
-180 180 -90 90 -8182 5651.5 1 1 360 180 1 1
120+
-55 -47 -24 -10 190 981 1 1 8 14 1 1
121121
"""
122122

123123
# The minimum version of GMT required
@@ -1295,17 +1295,17 @@ def virtualfile_from_grid(self, grid):
12951295
Examples
12961296
--------
12971297
1298-
>>> from pygmt.datasets import load_earth_relief
1298+
>>> from pygmt.helpers.testing import load_static_earth_relief
12991299
>>> from pygmt.helpers import GMTTempFile
1300-
>>> data = load_earth_relief(resolution="01d")
1300+
>>> data = load_static_earth_relief()
13011301
>>> print(data.shape)
1302-
(180, 360)
1302+
(14, 8)
13031303
>>> print(data.lon.values.min(), data.lon.values.max())
1304-
-179.5 179.5
1304+
-54.5 -47.5
13051305
>>> print(data.lat.values.min(), data.lat.values.max())
1306-
-89.5 89.5
1306+
-23.5 -10.5
13071307
>>> print(data.values.min(), data.values.max())
1308-
-8182.0 5651.5
1308+
190.0 981.0
13091309
>>> with Session() as ses:
13101310
... with ses.virtualfile_from_grid(data) as fin:
13111311
... # Send the output to a file so that we can read it
@@ -1314,7 +1314,7 @@ def virtualfile_from_grid(self, grid):
13141314
... ses.call_module("grdinfo", args)
13151315
... print(fout.read().strip())
13161316
...
1317-
-180 180 -90 90 -8182 5651.5 1 1 360 180 1 1
1317+
-55 -47 -24 -10 190 981 1 1 8 14 1 1
13181318
>>> # The output is: w e s n z0 z1 dx dy n_columns n_rows reg gtype
13191319
"""
13201320
_gtype = {0: "GMT_GRID_IS_CARTESIAN", 1: "GMT_GRID_IS_GEO"}[grid.gmt.gtype]

pygmt/src/grdsample.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ def grdsample(grid, **kwargs):
7373
- :class:`xarray.DataArray` if ``outgrid`` is not set
7474
- None if ``outgrid`` is set (grid output will be stored in file set by
7575
``outgrid``)
76+
77+
Example
78+
-------
79+
>>> import pygmt # doctest: +SKIP
80+
>>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30,
81+
>>> # and a y-range of 15 to 25
82+
>>> grid = pygmt.datasets.load_earth_relief(
83+
... resolution="30m", region=[10, 30, 15, 25]
84+
... ) # doctest: +SKIP
85+
>>> # Create a new grid from an input grid, change the registration,
86+
>>> # and set both x- and y-spacing to 0.5 degrees
87+
>>> new_grid = pygmt.grdsample(
88+
... grid=grid, translate=True, spacing=[0.5, 0.5]
89+
... ) # doctest: +SKIP
7690
"""
7791
with GMTTempFile(suffix=".nc") as tmpfile:
7892
with Session() as lib:

0 commit comments

Comments
 (0)