|
6 | 6 |
|
7 | 7 | import xarray as xr
|
8 | 8 | from pygmt._typing import PathLike
|
| 9 | +from pygmt.alias import Alias, AliasSystem |
9 | 10 | from pygmt.clib import Session
|
10 | 11 | from pygmt.exceptions import GMTInvalidInput
|
11 | 12 | from pygmt.helpers import (
|
12 | 13 | build_arg_list,
|
13 | 14 | deprecate_parameter,
|
14 | 15 | fmt_docstring,
|
15 | 16 | kwargs_to_strings,
|
16 |
| - sequence_join, |
17 | 17 | use_alias,
|
18 | 18 | )
|
19 | 19 |
|
|
23 | 23 | # TODO(PyGMT>=0.19.0): Remove the deprecated "new" parameter.
|
24 | 24 | @fmt_docstring
|
25 | 25 | @deprecate_parameter("new", "replace", "v0.15.0", remove_version="v0.19.0")
|
26 |
| -@use_alias( |
27 |
| - R="region", Sa="above-", Sb="below-", Si="between-", Sr="replace-", V="verbose" |
28 |
| -) |
| 26 | +@use_alias(R="region", V="verbose") |
29 | 27 | @kwargs_to_strings(R="sequence")
|
30 | 28 | def grdclip(
|
31 | 29 | grid: PathLike | xr.DataArray,
|
@@ -54,6 +52,10 @@ def grdclip(
|
54 | 52 | Full GMT docs at :gmt-docs:`grdclip.html`.
|
55 | 53 |
|
56 | 54 | {aliases}
|
| 55 | + - Sa=above |
| 56 | + - Sb=below |
| 57 | + - Si=between |
| 58 | + - Sr=replace |
57 | 59 |
|
58 | 60 | Parameters
|
59 | 61 | ----------
|
@@ -113,19 +115,20 @@ def grdclip(
|
113 | 115 | )
|
114 | 116 | raise GMTInvalidInput(msg)
|
115 | 117 |
|
116 |
| - # Parse the -S option. |
117 |
| - kwargs["Sa"] = sequence_join(above, size=2, name="above") |
118 |
| - kwargs["Sb"] = sequence_join(below, size=2, name="below") |
119 |
| - kwargs["Si"] = sequence_join(between, size=3, ndim=2, name="between") |
120 |
| - kwargs["Sr"] = sequence_join(replace, size=2, ndim=2, name="replace") |
| 118 | + aliasdict = AliasSystem( |
| 119 | + Sa=Alias(above, name="above", sep="/", size=2), |
| 120 | + Sb=Alias(below, name="below", sep="/", size=2), |
| 121 | + Si=Alias(between, name="between", sep="/", size=3, ndim=2), |
| 122 | + Sr=Alias(replace, name="replace", sep="/", size=2, ndim=2), |
| 123 | + ).merge(kwargs) |
121 | 124 |
|
122 | 125 | with Session() as lib:
|
123 | 126 | with (
|
124 | 127 | lib.virtualfile_in(check_kind="raster", data=grid) as vingrd,
|
125 | 128 | lib.virtualfile_out(kind="grid", fname=outgrid) as voutgrd,
|
126 | 129 | ):
|
127 |
| - kwargs["G"] = voutgrd |
| 130 | + aliasdict["G"] = voutgrd |
128 | 131 | lib.call_module(
|
129 |
| - module="grdclip", args=build_arg_list(kwargs, infile=vingrd) |
| 132 | + module="grdclip", args=build_arg_list(aliasdict, infile=vingrd) |
130 | 133 | )
|
131 | 134 | return lib.virtualfile_to_raster(vfname=voutgrd, outgrid=outgrid)
|
0 commit comments