diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 40e29800075..f2fdae251d9 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -2,13 +2,20 @@ grdlandmask - Create a "wet-dry" mask grid from shoreline database. """ +from collections.abc import Sequence from typing import Literal import xarray as xr from pygmt._typing import PathLike from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import ( + build_arg_list, + fmt_docstring, + kwargs_to_strings, + sequence_join, + use_alias, +) from pygmt.src._common import _parse_coastline_resolution __doctest_skip__ = ["grdlandmask"] @@ -18,17 +25,19 @@ @use_alias( A="area_thresh", D="resolution-", - E="bordervalues", + E="bordervalues-", I="spacing", - N="maskvalues", + N="maskvalues-", R="region", V="verbose", r="registration", x="cores", ) -@kwargs_to_strings(I="sequence", R="sequence", N="sequence", E="sequence") +@kwargs_to_strings(I="sequence", R="sequence") def grdlandmask( outgrid: PathLike | None = None, + maskvalues: Sequence[float] | None = None, + bordervalues: bool | float | Sequence[float] | None = None, resolution: Literal[ "auto", "full", "high", "intermediate", "low", "crude", None ] = None, @@ -62,7 +71,7 @@ def grdlandmask( mask file using one resolution is not guaranteed to remain inside [or outside] when a different resolution is selected. If ``None``, the low resolution is used by default. - maskvalues : list + maskvalues Set the values that will be assigned to nodes, in the form of [*wet*, *dry*], or [*ocean*, *land*, *lake*, *island*, *pond*]. Default is ``[0, 1, 0, 1, 0]`` (i.e., ``[0, 1]``), meaning that all "wet" nodes will be assigned a value of 0 @@ -70,7 +79,7 @@ def grdlandmask( one of ``None``, ``"NaN"``, and ``np.nan`` for setting nodes to NaN. Use ``bordervalues`` to control how nodes on feature boundaries are handled. - bordervalues : bool, float, or list + bordervalues Sets the behavior for nodes that fall exactly on a polygon boundary. Valid values are: @@ -110,6 +119,8 @@ def grdlandmask( raise GMTInvalidInput(msg) kwargs["D"] = kwargs.get("D", _parse_coastline_resolution(resolution)) + kwargs["N"] = sequence_join(maskvalues, size=(2, 5), name="maskvalues") + kwargs["E"] = sequence_join(bordervalues, size=(1, 4), name="bordervalues") with Session() as lib: with lib.virtualfile_out(kind="grid", fname=outgrid) as voutgrd: