From 0c05124648839cb547e1231fa75a9309543ef13d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Aug 2026 20:32:51 +0800 Subject: [PATCH 1/2] Figure.coast/pygmt.grdlandmask/pygmt.select: Migrate the 'area_thresh' parameter to the new Alias System --- pygmt/helpers/decorators.py | 6 +++--- pygmt/src/coast.py | 5 ++++- pygmt/src/grdlandmask.py | 15 +++++++++++---- pygmt/src/select.py | 4 +++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 017aeb0710a..3374af11d29 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -17,12 +17,12 @@ COMMON_DOCSTRINGS = { "area_thresh": r""" - area_thresh : float or str + area_thresh *min_area*\ [/*min_level*/*max_level*][**+a**\[**g**\|\ **i**]\ [**s**\|\ **S**]][**+l**\|\ **r**][**+p**\ *percent*]. Features with an area smaller than *min_area* in km\ :sup:`2` or of - hierarchical level that is lower than *min_level* or higher than - *max_level* will not be plotted [Default is ``"0/0/4"`` (all features)].""", + hierarchical level that is lower than *min_level* or higher than *max_level* + will not be plotted [Default is ``"0/0/4"`` (all features)].""", "aspatial": r""" aspatial : bool or str [*col*\ =]\ *name*\ [,...]. diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index cd6123a1665..93e45ebc15a 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -68,7 +68,7 @@ def _alias_option_C(lakes=None, river_lakes=None): # ruff: ignore[invalid-funct @fmt_docstring -@use_alias(A="area_thresh", E="dcw") +@use_alias(E="dcw") def coast( self, resolution: Literal[ @@ -81,6 +81,7 @@ def coast( shorelines: bool | str | Sequence[int | str] = False, lakes: str | None = None, river_lakes: str | None = None, + area_thresh: float | str | None = None, map_scale: str | None = None, box: Box | bool = False, projection: str | None = None, @@ -113,6 +114,7 @@ def coast( Full GMT docs at :gmt-docs:`coast.html`. $aliases + - A = area_thresh - B = frame - C = lakes, river_lakes - D = resolution @@ -320,6 +322,7 @@ def coast( ) aliasdict = AliasSystem( + A=Alias(area_thresh, name="area_thresh"), C=_alias_option_C(lakes=lakes, river_lakes=river_lakes), D=Alias( resolution, diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 0c2dbb21b3e..5556ada6fbe 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -10,7 +10,7 @@ from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session from pygmt.exceptions import GMTParameterError -from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring, use_alias +from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring __doctest_skip__ = ["grdlandmask"] @@ -22,7 +22,6 @@ @deprecate_parameter( "bordervalues", "border_values", "v0.18.0", remove_version="v0.20.0" ) -@use_alias(A="area_thresh") def grdlandmask( outgrid: PathLike | None = None, spacing: Sequence[float | str] | None = None, @@ -31,6 +30,7 @@ def grdlandmask( resolution: Literal[ "auto", "full", "high", "intermediate", "low", "crude", None ] = None, + area_thresh: float | str | None = None, region: Sequence[float | str] | str | None = None, registration: Literal["gridline", "pixel"] | bool = False, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] @@ -38,7 +38,7 @@ def grdlandmask( cores: int | bool = False, **kwargs, ) -> xr.DataArray | None: - r""" + """ Create a "wet-dry" mask grid from shoreline database. Read the selected shoreline database and use that information to decide which nodes @@ -49,7 +49,13 @@ def grdlandmask( Full GMT docs at :gmt-docs:`grdlandmask.html`. - $aliases + + **Aliases** + + .. hlist:: + :columns: 3 + + - A = area_thresh - D = resolution - E = border_values - G = outgrid @@ -122,6 +128,7 @@ def grdlandmask( raise GMTParameterError(required=["region", "spacing"]) aliasdict = AliasSystem( + A=Alias(area_thresh, name="area_thresh"), D=Alias( resolution, name="resolution", diff --git a/pygmt/src/select.py b/pygmt/src/select.py index a266fc62163..b1195baa2eb 100644 --- a/pygmt/src/select.py +++ b/pygmt/src/select.py @@ -28,7 +28,6 @@ @deprecate_parameter("mask", "mask_values", "v0.18.0", remove_version="v0.20.0") @deprecate_parameter("gridmask", "mask_grid", "v0.18.0", remove_version="v0.20.0") @use_alias( - A="area_thresh", C="dist2pt", F="polygon", G="mask_grid", @@ -53,6 +52,7 @@ def select( resolution: Literal[ "auto", "full", "high", "intermediate", "low", "crude", None ] = None, + area_thresh: float | str | None = None, projection: str | None = None, region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] @@ -83,6 +83,7 @@ def select( Full GMT docs at :gmt-docs:`gmtselect.html`. $aliases + - A = area_thresh - D = resolution - J = projection - R = region @@ -226,6 +227,7 @@ def select( column_names = data.columns.to_list() aliasdict = AliasSystem( + A=Alias(area_thresh, name="area_thresh"), D=Alias( resolution, name="resolution", From 20a927c32c7dcbef2a4b7e97e88c40cf75d98184 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 14 Aug 2026 19:25:42 +0800 Subject: [PATCH 2/2] Fix styling --- pygmt/src/grdlandmask.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 0009c6e924b..a6f66144c48 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -10,7 +10,7 @@ from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session from pygmt.exceptions import GMTParameterError -from pygmt.helpers import build_arg_list, fmt_docstring, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring __doctest_skip__ = ["grdlandmask"]