22grdlandmask - Create a "wet-dry" mask grid from shoreline data base
33"""
44
5+ from typing import Literal
6+
57import xarray as xr
68from pygmt .clib import Session
79from pygmt .exceptions import GMTInvalidInput
2325 x = "cores" ,
2426)
2527@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 :
2733 r"""
2834 Create a grid file with set values for land and water.
2935
@@ -44,17 +50,13 @@ def grdlandmask(outgrid: str | None = None, **kwargs) -> xr.DataArray | None:
4450 {spacing}
4551 {region}
4652 {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.
5860 bordervalues : bool, str, float, or list
5961 Nodes that fall exactly on a polygon boundary should be
6062 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:
98100 if kwargs .get ("I" ) is None or kwargs .get ("R" ) is None :
99101 raise GMTInvalidInput ("Both 'region' and 'spacing' must be specified." )
100102
103+ # Resolution
104+ if kwargs .get ("D" ) is not None :
105+ kwargs ["D" ] = kwargs ["D" ][0 ]
106+
101107 with Session () as lib :
102108 with lib .virtualfile_out (kind = "grid" , fname = outgrid ) as voutgrd :
103109 kwargs ["G" ] = voutgrd
0 commit comments