|
2 | 2 | grdlandmask - Create a "wet-dry" mask grid from shoreline database.
|
3 | 3 | """
|
4 | 4 |
|
| 5 | +from collections.abc import Sequence |
5 | 6 | from typing import Literal
|
6 | 7 |
|
7 | 8 | import xarray as xr
|
8 | 9 | from pygmt._typing import PathLike
|
9 | 10 | from pygmt.clib import Session
|
10 | 11 | from pygmt.exceptions import GMTInvalidInput
|
11 |
| -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias |
| 12 | +from pygmt.helpers import ( |
| 13 | + build_arg_list, |
| 14 | + fmt_docstring, |
| 15 | + kwargs_to_strings, |
| 16 | + sequence_join, |
| 17 | + use_alias, |
| 18 | +) |
12 | 19 | from pygmt.src._common import _parse_coastline_resolution
|
13 | 20 |
|
14 | 21 | __doctest_skip__ = ["grdlandmask"]
|
|
18 | 25 | @use_alias(
|
19 | 26 | A="area_thresh",
|
20 | 27 | D="resolution-",
|
21 |
| - E="bordervalues", |
| 28 | + E="bordervalues-", |
22 | 29 | I="spacing",
|
23 |
| - N="maskvalues", |
| 30 | + N="maskvalues-", |
24 | 31 | R="region",
|
25 | 32 | V="verbose",
|
26 | 33 | r="registration",
|
27 | 34 | x="cores",
|
28 | 35 | )
|
29 |
| -@kwargs_to_strings(I="sequence", R="sequence", N="sequence", E="sequence") |
| 36 | +@kwargs_to_strings(I="sequence", R="sequence") |
30 | 37 | def grdlandmask(
|
31 | 38 | outgrid: PathLike | None = None,
|
| 39 | + maskvalues: Sequence[float] | None = None, |
| 40 | + bordervalues: bool | float | Sequence[float] | None = None, |
32 | 41 | resolution: Literal[
|
33 | 42 | "auto", "full", "high", "intermediate", "low", "crude", None
|
34 | 43 | ] = None,
|
@@ -62,15 +71,15 @@ def grdlandmask(
|
62 | 71 | mask file using one resolution is not guaranteed to remain inside [or outside]
|
63 | 72 | when a different resolution is selected. If ``None``, the low resolution is used
|
64 | 73 | by default.
|
65 |
| - maskvalues : list |
| 74 | + maskvalues |
66 | 75 | Set the values that will be assigned to nodes, in the form of [*wet*, *dry*], or
|
67 | 76 | [*ocean*, *land*, *lake*, *island*, *pond*]. Default is ``[0, 1, 0, 1, 0]``
|
68 | 77 | (i.e., ``[0, 1]``), meaning that all "wet" nodes will be assigned a value of 0
|
69 | 78 | and all "dry" nodes will be assigned a value of 1. Values can be any number, or
|
70 | 79 | one of ``None``, ``"NaN"``, and ``np.nan`` for setting nodes to NaN.
|
71 | 80 |
|
72 | 81 | Use ``bordervalues`` to control how nodes on feature boundaries are handled.
|
73 |
| - bordervalues : bool, float, or list |
| 82 | + bordervalues |
74 | 83 | Sets the behavior for nodes that fall exactly on a polygon boundary. Valid
|
75 | 84 | values are:
|
76 | 85 |
|
@@ -110,6 +119,8 @@ def grdlandmask(
|
110 | 119 | raise GMTInvalidInput(msg)
|
111 | 120 |
|
112 | 121 | kwargs["D"] = kwargs.get("D", _parse_coastline_resolution(resolution))
|
| 122 | + kwargs["N"] = sequence_join(maskvalues, size=(2, 5), name="maskvalues") |
| 123 | + kwargs["E"] = sequence_join(bordervalues, size=(1, 4), name="bordervalues") |
113 | 124 |
|
114 | 125 | with Session() as lib:
|
115 | 126 | with lib.virtualfile_out(kind="grid", fname=outgrid) as voutgrd:
|
|
0 commit comments