Skip to content

Commit ff3dbb4

Browse files
seismanweiji14
andauthored
Figure.grdimage: Remove the unsupported 'img_out'/'A' parameter (#2907)
Co-authored-by: Wei Ji <[email protected]>
1 parent 013014b commit ff3dbb4

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

pygmt/src/grdimage.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
grdimage - Plot grids or images.
33
"""
44
from pygmt.clib import Session
5+
from pygmt.exceptions import GMTInvalidInput
56
from pygmt.helpers import (
67
build_arg_string,
78
deprecate_parameter,
@@ -16,7 +17,6 @@
1617
@fmt_docstring
1718
@deprecate_parameter("bit_color", "bitcolor", "v0.10.0", remove_version="v0.12.0")
1819
@use_alias(
19-
A="img_out",
2020
B="frame",
2121
C="cmap",
2222
D="img_in",
@@ -76,21 +76,6 @@ def grdimage(self, grid, **kwargs):
7676
Parameters
7777
----------
7878
{grid}
79-
img_out : str
80-
*out_img*\[=\ *driver*].
81-
Save an image in a raster format instead of PostScript. Append
82-
*out_img* to select the image file name and extension. If the
83-
extension is one of .bmp, .gif, .jpg, .png, or .tif then no driver
84-
information is required. For other output formats you must append
85-
the required GDAL driver. The *driver* is the driver code name used
86-
by GDAL; see your GDAL installation's documentation for available
87-
drivers. Append a **+c**\ *args* string where *args* is a list
88-
of one or more concatenated number of GDAL **-co** arguments. For
89-
example, to write a GeoPDF with the TerraGo format use
90-
``=PDF+cGEO_ENCODING=OGC_BP``. **Notes**: (1) If a tiff file (.tif)
91-
is selected then we will write a GeoTiff image if the GMT
92-
projection syntax translates into a PROJ syntax, otherwise a plain
93-
tiff file is produced. (2) Any vector elements will be lost.
9479
{frame}
9580
{cmap}
9681
img_in : str
@@ -172,6 +157,13 @@ def grdimage(self, grid, **kwargs):
172157
"""
173158
kwargs = self._preprocess(**kwargs)
174159

160+
# Do not support -A option
161+
if any(kwargs.get(arg) is not None for arg in ["A", "img_out"]):
162+
raise GMTInvalidInput(
163+
"Parameter 'img_out'/'A' is not implemented. "
164+
"Please consider submitting a feature request to us."
165+
)
166+
175167
with Session() as lib:
176168
with lib.virtualfile_from_data(
177169
check_kind="raster", data=grid

pygmt/tests/test_grdimage.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,14 @@ def test_grdimage_central_meridians_and_standard_parallels(grid, proj_type, lon0
241241
)
242242
fig_test.grdimage(grid, projection=f"{proj_type}{lon0}/{lat0}/15c", cmap="geo")
243243
return fig_ref, fig_test
244+
245+
246+
def test_grdimage_imgout_fails(grid):
247+
"""
248+
Test that an exception is raised if img_out/A is given.
249+
"""
250+
fig = Figure()
251+
with pytest.raises(GMTInvalidInput):
252+
fig.grdimage(grid, img_out="out.png")
253+
with pytest.raises(GMTInvalidInput):
254+
fig.grdimage(grid, A="out.png")

0 commit comments

Comments
 (0)