From 3342c7b3d75a11f178759bc63704d3fe7db80d13 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:35:40 +0000 Subject: [PATCH 1/9] Initial plan From aeda5c8350bc5fb87cba4e70a276c3189e00a30b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:46:57 +0000 Subject: [PATCH 2/9] Figure.grdview: Add alias for option -S (smooth_contour) Co-authored-by: seisman <3974108+seisman@users.noreply.github.com> --- doc/changes.md | 6 ++++++ pygmt/src/grdview.py | 8 +++++++- pygmt/tests/test_grdview.py | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/changes.md b/doc/changes.md index 99451b3a299..e6715805edf 100644 --- a/doc/changes.md +++ b/doc/changes.md @@ -1,5 +1,11 @@ # Changelog +## Release v0.19.0 (unreleased) + +### Enhancements + +* Figure.grdview: Add alias for option ``-S`` (smooth_contour) ([#4444](https://github.com/GenericMappingTools/pygmt/pull/4444)) + ## Release v0.18.0 (2026/01/12) [![Digital Object Identifier for PyGMT v0.18.0](https://zenodo.org/badge/DOI/10.5281/zenodo.18080259.svg)](https://doi.org/10.5281/zenodo.18080259) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 74285a46815..6dfdd58bde7 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -114,7 +114,7 @@ def _alias_option_Q( # noqa: N802 @deprecate_parameter("facadepen", "facade_pen", "v0.18.0", remove_version="v0.20.0") @deprecate_parameter("meshpen", "mesh_pen", "v0.18.0", remove_version="v0.20.0") @deprecate_parameter("drapegrid", "drape_grid", "v0.18.0", remove_version="v0.20.0") -@use_alias(I="shading", f="coltypes", n="interpolation") +@use_alias(I="shading", S="smooth_contour", f="coltypes", n="interpolation") def grdview( # noqa: PLR0913 self, grid: PathLike | xr.DataArray, @@ -134,6 +134,7 @@ def grdview( # noqa: PLR0913 facade_fill: str | None = None, facade_pen: str | None = None, projection: str | None = None, + smooth_contour: int | None = None, zscale: float | str | None = None, zsize: float | str | None = None, region: Sequence[float | str] | str | None = None, @@ -166,6 +167,7 @@ def grdview( # noqa: PLR0913 - N = plane, facade_fill - R = region - Q = surftype, dpi, mesh_fill, nan_transparent, **+m**: monochrome + - S = smooth_contour - V = verbose - Wc = contour_pen - Wf = facade_pen @@ -231,6 +233,10 @@ def grdview( # noqa: PLR0913 function, or just give **+d** to select the default arguments [Default is ``"+a-45+nt1+m0"``]. $projection + smooth_contour : int or None + Used in conjunction with ``contour_pen`` (``-Wc``). Smooth the contour lines + by means of splines. The value specifies the number of equidistant points along + the contour used for smoothing [Default is 0, no smoothing]. zscale zsize Set z-axis scaling or z-axis size. diff --git a/pygmt/tests/test_grdview.py b/pygmt/tests/test_grdview.py index ede0fdb41f1..ace3a57e598 100644 --- a/pygmt/tests/test_grdview.py +++ b/pygmt/tests/test_grdview.py @@ -243,6 +243,22 @@ def test_grdview_surface_plot_styled_with_contourpen(xrgrid): return fig +@pytest.mark.mpl_image_compare +def test_grdview_surface_plot_with_smooth_contour(xrgrid): + """ + Run grdview by passing in a grid with contour lines that are smoothed. + """ + fig = Figure() + fig.grdview( + grid=xrgrid, + cmap="gmt/relief", + surftype="surface", + contour_pen="0.5p,black", + smooth_contour=5, + ) + return fig + + @pytest.mark.mpl_image_compare def test_grdview_surface_mesh_plot_styled_with_meshpen(xrgrid): """ From 1d85cc4e208f3b9f158191f9e60ab94ceded49ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 10:32:24 +0000 Subject: [PATCH 3/9] Figure.grdview: Add alias for option -S as smooth Co-authored-by: seisman <3974108+seisman@users.noreply.github.com> --- doc/changes.md | 6 ------ pygmt/src/grdview.py | 9 +++++---- pygmt/tests/test_grdview.py | 16 ---------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/doc/changes.md b/doc/changes.md index e6715805edf..99451b3a299 100644 --- a/doc/changes.md +++ b/doc/changes.md @@ -1,11 +1,5 @@ # Changelog -## Release v0.19.0 (unreleased) - -### Enhancements - -* Figure.grdview: Add alias for option ``-S`` (smooth_contour) ([#4444](https://github.com/GenericMappingTools/pygmt/pull/4444)) - ## Release v0.18.0 (2026/01/12) [![Digital Object Identifier for PyGMT v0.18.0](https://zenodo.org/badge/DOI/10.5281/zenodo.18080259.svg)](https://doi.org/10.5281/zenodo.18080259) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 6dfdd58bde7..4afb862d27b 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -114,7 +114,7 @@ def _alias_option_Q( # noqa: N802 @deprecate_parameter("facadepen", "facade_pen", "v0.18.0", remove_version="v0.20.0") @deprecate_parameter("meshpen", "mesh_pen", "v0.18.0", remove_version="v0.20.0") @deprecate_parameter("drapegrid", "drape_grid", "v0.18.0", remove_version="v0.20.0") -@use_alias(I="shading", S="smooth_contour", f="coltypes", n="interpolation") +@use_alias(I="shading", f="coltypes", n="interpolation") def grdview( # noqa: PLR0913 self, grid: PathLike | xr.DataArray, @@ -134,7 +134,7 @@ def grdview( # noqa: PLR0913 facade_fill: str | None = None, facade_pen: str | None = None, projection: str | None = None, - smooth_contour: int | None = None, + smooth: int | None = None, zscale: float | str | None = None, zsize: float | str | None = None, region: Sequence[float | str] | str | None = None, @@ -167,7 +167,7 @@ def grdview( # noqa: PLR0913 - N = plane, facade_fill - R = region - Q = surftype, dpi, mesh_fill, nan_transparent, **+m**: monochrome - - S = smooth_contour + - S = smooth - V = verbose - Wc = contour_pen - Wf = facade_pen @@ -233,7 +233,7 @@ def grdview( # noqa: PLR0913 function, or just give **+d** to select the default arguments [Default is ``"+a-45+nt1+m0"``]. $projection - smooth_contour : int or None + smooth : int or None Used in conjunction with ``contour_pen`` (``-Wc``). Smooth the contour lines by means of splines. The value specifies the number of equidistant points along the contour used for smoothing [Default is 0, no smoothing]. @@ -321,6 +321,7 @@ def grdview( # noqa: PLR0913 Wc=Alias(contour_pen, name="contour_pen"), Wf=Alias(facade_pen, name="facade_pen"), Wm=Alias(mesh_pen, name="mesh_pen"), + S=Alias(smooth, name="smooth"), ).add_common( B=frame, J=projection, diff --git a/pygmt/tests/test_grdview.py b/pygmt/tests/test_grdview.py index ace3a57e598..ede0fdb41f1 100644 --- a/pygmt/tests/test_grdview.py +++ b/pygmt/tests/test_grdview.py @@ -243,22 +243,6 @@ def test_grdview_surface_plot_styled_with_contourpen(xrgrid): return fig -@pytest.mark.mpl_image_compare -def test_grdview_surface_plot_with_smooth_contour(xrgrid): - """ - Run grdview by passing in a grid with contour lines that are smoothed. - """ - fig = Figure() - fig.grdview( - grid=xrgrid, - cmap="gmt/relief", - surftype="surface", - contour_pen="0.5p,black", - smooth_contour=5, - ) - return fig - - @pytest.mark.mpl_image_compare def test_grdview_surface_mesh_plot_styled_with_meshpen(xrgrid): """ From 0b8169c7004f803254719bea6832bb2296ce0725 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 10:47:16 +0000 Subject: [PATCH 4/9] Figure.grdview: Update docstring for smooth parameter Co-authored-by: seisman <3974108+seisman@users.noreply.github.com> --- pygmt/src/grdview.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 4afb862d27b..30abdcd41f9 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -234,9 +234,8 @@ def grdview( # noqa: PLR0913 ``"+a-45+nt1+m0"``]. $projection smooth : int or None - Used in conjunction with ``contour_pen`` (``-Wc``). Smooth the contour lines - by means of splines. The value specifies the number of equidistant points along - the contour used for smoothing [Default is 0, no smoothing]. + Sets the smooth factor used for smoothing the contours before plotting + [Default is no smoothing]. zscale zsize Set z-axis scaling or z-axis size. From d206b30447d2593eed95c38fe0ab86b15196aba1 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 5 Mar 2026 18:59:13 +0800 Subject: [PATCH 5/9] Update pygmt/src/grdview.py --- pygmt/src/grdview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 30abdcd41f9..5b23f4d9b18 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -233,7 +233,7 @@ def grdview( # noqa: PLR0913 function, or just give **+d** to select the default arguments [Default is ``"+a-45+nt1+m0"``]. $projection - smooth : int or None + smooth Sets the smooth factor used for smoothing the contours before plotting [Default is no smoothing]. zscale From 51ad46ff8ddb4d5d0fc88adfa339d7d060f65dde Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:01:06 +0000 Subject: [PATCH 6/9] Figure.grdview: Order S alphabetically in AliasSystem Co-authored-by: seisman <3974108+seisman@users.noreply.github.com> --- pygmt/src/grdview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 5b23f4d9b18..98452ffd4a1 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -317,10 +317,10 @@ def grdview( # noqa: PLR0913 Alias(plane, name="plane"), Alias(facade_fill, name="facade_fill", prefix="+g"), ], + S=Alias(smooth, name="smooth"), Wc=Alias(contour_pen, name="contour_pen"), Wf=Alias(facade_pen, name="facade_pen"), Wm=Alias(mesh_pen, name="mesh_pen"), - S=Alias(smooth, name="smooth"), ).add_common( B=frame, J=projection, From 3669c67759037cd03066d1813c12d6957cb07fab Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 5 Mar 2026 20:00:35 +0800 Subject: [PATCH 7/9] Apply suggestion from @seisman --- pygmt/src/grdview.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 98452ffd4a1..03cb2ce2b2e 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -165,9 +165,9 @@ def grdview( # noqa: PLR0913 - Jz = zscale - JZ = zsize - N = plane, facade_fill - - R = region - - Q = surftype, dpi, mesh_fill, nan_transparent, **+m**: monochrome - - S = smooth + - Q = surftype, dpi, mesh_fill, nan_transparent, **+m**: monochrome + - R = region + - S = smooth - V = verbose - Wc = contour_pen - Wf = facade_pen From 58213bbdde28dc5d7477585596da6ae8fb5aa323 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 5 Mar 2026 20:00:52 +0800 Subject: [PATCH 8/9] Apply suggestion from @seisman --- pygmt/src/grdview.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 03cb2ce2b2e..58a1067c073 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -165,9 +165,9 @@ def grdview( # noqa: PLR0913 - Jz = zscale - JZ = zsize - N = plane, facade_fill - - Q = surftype, dpi, mesh_fill, nan_transparent, **+m**: monochrome - - R = region - - S = smooth + - Q = surftype, dpi, mesh_fill, nan_transparent, **+m**: monochrome + - R = region + - S = smooth - V = verbose - Wc = contour_pen - Wf = facade_pen From 93796c003a1ffa8a114c3cd275b3f17f88fa0c36 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 5 Mar 2026 20:01:59 +0800 Subject: [PATCH 9/9] Fix styling --- pygmt/src/grdview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 58a1067c073..228f193ca00 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -166,7 +166,7 @@ def grdview( # noqa: PLR0913 - JZ = zsize - N = plane, facade_fill - Q = surftype, dpi, mesh_fill, nan_transparent, **+m**: monochrome - - R = region + - R = region - S = smooth - V = verbose - Wc = contour_pen