2
2
grdlandmask - Create a "wet-dry" mask grid from shoreline data base
3
3
"""
4
4
5
+ from typing import Literal
6
+
5
7
import xarray as xr
6
8
from pygmt .clib import Session
7
9
from pygmt .exceptions import GMTInvalidInput
23
25
x = "cores" ,
24
26
)
25
27
@kwargs_to_strings (I = "sequence" , R = "sequence" , N = "sequence" , E = "sequence" )
26
- def grdlandmask (outgrid : str | None = None , ** kwargs ) -> xr .DataArray | None :
28
+ def grdlandmask (
29
+ outgrid : str | None = None ,
30
+ resolution : Literal ["full" , "high" , "intermediate" , "low" , "crude" ] = "low" , # noqa: ARG001
31
+ ** kwargs ,
32
+ ) -> xr .DataArray | None :
27
33
r"""
28
34
Create a grid file with set values for land and water.
29
35
@@ -44,17 +50,13 @@ def grdlandmask(outgrid: str | None = None, **kwargs) -> xr.DataArray | None:
44
50
{spacing}
45
51
{region}
46
52
{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.
53
+ resolution
54
+ Ignored unless ``mask`` is set. Select the resolution of the coastline dataset
55
+ to use. The available resolutions from highest to lowest are: ``"full"``,
56
+ ``"high"``, ``"intermediate"``, ``"low"``, and ``"crude"``, which drops by 80%
57
+ between levels. Note that because the coastlines differ in details it is not
58
+ guaranteed that a point will remain inside [or outside] when a different
59
+ resolution is selected.
58
60
bordervalues : bool, str, float, or list
59
61
Nodes that fall exactly on a polygon boundary should be
60
62
considered to be outside the polygon [Default considers them to be
@@ -98,6 +100,10 @@ def grdlandmask(outgrid: str | None = None, **kwargs) -> xr.DataArray | None:
98
100
if kwargs .get ("I" ) is None or kwargs .get ("R" ) is None :
99
101
raise GMTInvalidInput ("Both 'region' and 'spacing' must be specified." )
100
102
103
+ # Resolution
104
+ if kwargs .get ("D" ) is not None :
105
+ kwargs ["D" ] = kwargs ["D" ][0 ]
106
+
101
107
with Session () as lib :
102
108
with lib .virtualfile_out (kind = "grid" , fname = outgrid ) as voutgrd :
103
109
kwargs ["G" ] = voutgrd
0 commit comments