2
2
grdlandmask - Create a "wet-dry" mask grid from shoreline database.
3
3
"""
4
4
5
+ from typing import Literal
6
+
5
7
import xarray as xr
6
8
from pygmt ._typing import PathLike
7
9
from pygmt .clib import Session
8
10
from pygmt .exceptions import GMTInvalidInput
9
11
from pygmt .helpers import build_arg_list , fmt_docstring , kwargs_to_strings , use_alias
12
+ from pygmt .src ._common import _parse_coastline_resolution
10
13
11
14
__doctest_skip__ = ["grdlandmask" ]
12
15
13
16
14
17
@fmt_docstring
15
18
@use_alias (
16
19
A = "area_thresh" ,
17
- D = "resolution" ,
18
20
E = "bordervalues" ,
19
21
I = "spacing" ,
20
22
N = "maskvalues" ,
24
26
x = "cores" ,
25
27
)
26
28
@kwargs_to_strings (I = "sequence" , R = "sequence" , N = "sequence" , E = "sequence" )
27
- def grdlandmask (outgrid : PathLike | None = None , ** kwargs ) -> xr .DataArray | None :
29
+ def grdlandmask (
30
+ outgrid : PathLike | None = None ,
31
+ resolution : Literal [
32
+ "auto" , "full" , "high" , "intermediate" , "low" , "crude" , None
33
+ ] = None ,
34
+ ** kwargs ,
35
+ ) -> xr .DataArray | None :
28
36
r"""
29
37
Create a "wet-dry" mask grid from shoreline database.
30
38
@@ -44,17 +52,15 @@ def grdlandmask(outgrid: PathLike | None = None, **kwargs) -> xr.DataArray | Non
44
52
{spacing}
45
53
{region}
46
54
{area_thresh}
47
- resolution : str
48
- *res*\[\ **+f**\]. Select the resolution of the data set to use
49
- ((**f**)ull, (**h**)igh, (**i**)ntermediate, (**l**)ow, or
50
- (**c**)rude). The resolution drops off by ~80% between data sets.
51
- [Default is **l**]. Append **+f** to automatically select a lower
52
- resolution should the one requested not be available
53
- [abort if not found]. Alternatively, choose (**a**)uto to automatically
54
- select the best resolution given the chosen region. Note that because
55
- the coastlines differ in details a node in a mask file using one
56
- resolution is not guaranteed to remain inside [or outside] when a
57
- different resolution is selected.
55
+ resolution
56
+ Select the resolution of the coastline dataset to use. The available resolutions
57
+ from highest to lowest are: ``"full"``, ``"high"``, ``"intermediate"``,
58
+ ``"low"``, and ``"crude"``, which drops by 80% between levels. Alternatively,
59
+ choose ``"auto"`` to automatically select the most suitable resolution given the
60
+ chosen region. Note that because the coastlines differ in details, a node in a
61
+ mask file using one resolution is not guaranteed to remain inside [or outside]
62
+ when a different resolution is selected. If ``None``, the low resolution is used
63
+ by default.
58
64
maskvalues : list
59
65
Set the values that will be assigned to nodes, in the form of [*wet*, *dry*], or
60
66
[*ocean*, *land*, *lake*, *island*, *pond*]. Default is ``[0, 1, 0, 1, 0]``
@@ -102,6 +108,8 @@ def grdlandmask(outgrid: PathLike | None = None, **kwargs) -> xr.DataArray | Non
102
108
msg = "Both 'region' and 'spacing' must be specified."
103
109
raise GMTInvalidInput (msg )
104
110
111
+ kwargs ["D" ] = kwargs .get ("D" , _parse_coastline_resolution (resolution ))
112
+
105
113
with Session () as lib :
106
114
with lib .virtualfile_out (kind = "grid" , fname = outgrid ) as voutgrd :
107
115
kwargs ["G" ] = voutgrd
0 commit comments