Skip to content

Commit c588b02

Browse files
Figure.grdview: Deprecate parameter drapegrid to drape_grid (Will be removed in v0.20.0) (#4276)
1 parent 7d30ac8 commit c588b02

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

examples/tutorials/advanced/draping_on_3d_surface.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
==================================================
44
55
It can be visually appealing to "drape" a dataset over a topographic surface. This can
6-
be accomplished using the ``drapegrid`` parameter of :meth:`pygmt.Figure.grdview`.
6+
be accomplished using the ``drape_grid`` parameter of :meth:`pygmt.Figure.grdview`.
77
88
This tutorial consists of two examples:
99
@@ -41,9 +41,9 @@
4141
# The topographic surface is created based on the grid passed to the ``grid`` parameter
4242
# of :meth:`pygmt.Figure.grdview`; here we use a grid of the Earth relief. To add a
4343
# color-coding based on *another* grid we have to pass a second grid to the
44-
# ``drapegrid`` parameter; here we use a grid of the crustal age. In this case the
44+
# ``drape_grid`` parameter; here we use a grid of the crustal age. In this case the
4545
# colormap specified via the ``cmap`` parameter applies to the grid passed to
46-
# ``drapegrid``, not to ``grid``. The azimuth and elevation of the 3-D plot are set via
46+
# ``drape_grid``, not to ``grid``. The azimuth and elevation of the 3-D plot are set via
4747
# the ``perspective`` parameter.
4848

4949
fig = pygmt.Figure()
@@ -56,7 +56,7 @@
5656
projection="M12c", # Mercator projection with a width of 12 centimeters
5757
region=region_3d,
5858
grid=grd_relief, # Use elevation grid for z values
59-
drapegrid=grd_age, # Use crustal age grid for color-coding
59+
drape_grid=grd_age, # Use crustal age grid for color-coding
6060
cmap=True, # Use colormap created for the crustal age
6161
surftype="i", # Create an image plot
6262
# Use an illumination from the azimuthal directions 0° (north) and 270°
@@ -101,12 +101,12 @@
101101
url_to_image = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Flag_of_Europe.svg/1000px-Flag_of_Europe.svg.png"
102102
with rasterio.open(url_to_image) as dataset:
103103
data = dataset.read()
104-
drapegrid = xr.DataArray(data, dims=("band", "y", "x"))
104+
drape_grid = xr.DataArray(data, dims=("band", "y", "x"))
105105

106106
# %%
107107
# Again we create a 3-D plot with :meth:`pygmt.Figure.grdview` and pass an Earth relief
108108
# grid to the ``grid`` parameter to create the topographic surface. But now we pass the
109-
# PNG image which was loaded into an :class:`xarray.DataArray` to the ``drapgrid``
109+
# PNG image which was loaded into an :class:`xarray.DataArray` to the ``drape_grid``
110110
# parameter.
111111

112112
fig = pygmt.Figure()
@@ -120,7 +120,7 @@
120120
projection="M12c", # Mercator projection with a width of 12 centimeters
121121
region=region_3d,
122122
grid=grd_relief, # Use elevation grid for z values
123-
drapegrid=drapegrid, # Drap image grid for the EU flag on top
123+
drape_grid=drape_grid, # Drape image grid for the EU flag on top
124124
cmap=True, # Use colormap defined for the EU flag
125125
surftype="i", # Create an image plot
126126
# Use an illumination from the azimuthal directions 0° (north) and 270° (west) with

pygmt/src/grdview.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
@deprecate_parameter("contourpen", "contour_pen", "v0.18.0", remove_version="v0.20.0")
1919
@deprecate_parameter("facadepen", "facade_pen", "v0.18.0", remove_version="v0.20.0")
2020
@deprecate_parameter("meshpen", "mesh_pen", "v0.18.0", remove_version="v0.20.0")
21+
@deprecate_parameter("drapegrid", "drape_grid", "v0.18.0", remove_version="v0.20.0")
2122
@use_alias(
2223
C="cmap",
23-
G="drapegrid",
24+
G="drape_grid",
2425
Q="surftype",
2526
I="shading",
2627
f="coltypes",
@@ -86,11 +87,11 @@ def grdview( # noqa: PLR0913
8687
$frame
8788
cmap : str
8889
The name of the color palette table to use.
89-
drapegrid : str or :class:`xarray.DataArray`
90+
drape_grid : str or :class:`xarray.DataArray`
9091
The file name or a :class:`xarray.DataArray` of the image grid to be draped on
9192
top of the relief provided by ``grid`` [Default determines colors from ``grid``]
92-
Note that ``zscale`` and ``plane`` always refer to ``grid``. ``drapegrid`` only
93-
provides the information pertaining to colors, which (if ``drapegrid`` is a
93+
Note that ``zscale`` and ``plane`` always refer to ``grid``. ``drape_grid`` only
94+
provides the information pertaining to colors, which (if ``drape_grid`` is a
9495
grid) will be looked-up via the CPT (see ``cmap``).
9596
surftype : str
9697
Specify cover type of the grid. Select one of following settings:

pygmt/tests/test_grdview.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,27 +232,27 @@ def test_grdview_facadepen_default_plane(xrgrid):
232232
@pytest.mark.mpl_image_compare
233233
def test_grdview_drapegrid_dataarray(xrgrid):
234234
"""
235-
Run grdview by passing in both a grid and drapegrid as an xarray.DataArray, setting
235+
Run grdview by passing in both a grid and drape_grid as an xarray.DataArray, setting
236236
a colormap for producing an image plot.
237237
"""
238-
drapegrid = 1.1 * xrgrid
238+
drape_grid = 1.1 * xrgrid
239239

240240
# accessor information are lost during xarray multiplication
241-
drapegrid.gmt.registration = xrgrid.gmt.registration
242-
drapegrid.gmt.gtype = xrgrid.gmt.gtype
241+
drape_grid.gmt.registration = xrgrid.gmt.registration
242+
drape_grid.gmt.gtype = xrgrid.gmt.gtype
243243

244244
fig = Figure()
245245
fig.grdview(
246-
grid=xrgrid, drapegrid=drapegrid, cmap="oleron", surftype="c", frame=True
246+
grid=xrgrid, drape_grid=drape_grid, cmap="oleron", surftype="c", frame=True
247247
)
248248
return fig
249249

250250

251251
def test_grdview_wrong_kind_of_drapegrid(xrgrid):
252252
"""
253-
Run grdview using drapegrid input that is not an xarray.DataArray or file.
253+
Run grdview using drape_grid input that is not an xarray.DataArray or file.
254254
"""
255255
dataset = xrgrid.to_dataset() # convert xarray.DataArray to xarray.Dataset
256256
fig = Figure()
257257
with pytest.raises(GMTTypeError):
258-
fig.grdview(grid=xrgrid, drapegrid=dataset)
258+
fig.grdview(grid=xrgrid, drape_grid=dataset)

0 commit comments

Comments
 (0)