2
2
dimfilter - Directional filtering of grids in the space domain.
3
3
"""
4
4
5
+ from pygmt .alias import Alias , AliasSystem
5
6
from pygmt .clib import Session
6
7
from pygmt .exceptions import GMTInvalidInput
7
- from pygmt .helpers import build_arg_list , fmt_docstring , kwargs_to_strings , use_alias
8
+ from pygmt .helpers import build_arg_list , fmt_docstring
8
9
9
10
__doctest_skip__ = ["dimfilter" ]
10
11
11
12
12
13
@fmt_docstring
13
- @use_alias (
14
- D = "distance" ,
15
- F = "filter" ,
16
- I = "spacing" ,
17
- N = "sectors" ,
18
- R = "region" ,
19
- V = "verbose" ,
20
- )
21
- @kwargs_to_strings (I = "sequence" , R = "sequence" )
22
14
def dimfilter (grid , outgrid : str | None = None , ** kwargs ):
23
15
r"""
24
16
Filter a grid by dividing the filter circle.
@@ -41,8 +33,6 @@ def dimfilter(grid, outgrid: str | None = None, **kwargs):
41
33
42
34
Full option list at :gmt-docs:`dimfilter.html`
43
35
44
- {aliases}
45
-
46
36
Parameters
47
37
----------
48
38
{grid}
@@ -135,19 +125,34 @@ def dimfilter(grid, outgrid: str | None = None, **kwargs):
135
125
... region=[-55, -51, -24, -19],
136
126
... )
137
127
"""
138
- if not all (arg in kwargs for arg in ["D" , "F" , "N" ]) and "Q" not in kwargs :
128
+ alias = AliasSystem (
129
+ D = Alias ("distance" ),
130
+ G = Alias ("outgrid" ),
131
+ F = Alias ("filter" ),
132
+ I = Alias ("spacing" , separator = "/" ),
133
+ N = Alias ("sectors" ),
134
+ R = Alias ("region" , separator = "/" ),
135
+ V = Alias ("verbose" ),
136
+ )
137
+
138
+ if (
139
+ not all (arg in kwargs for arg in ["distance" , "filter" , "sectors" ])
140
+ and "Q" not in kwargs
141
+ ):
139
142
raise GMTInvalidInput (
140
143
"""At least one of the following parameters must be specified:
141
- distance, filters , or sectors."""
144
+ distance, filter , or sectors."""
142
145
)
143
146
147
+ kwdict = alias .kwdict
144
148
with Session () as lib :
145
149
with (
146
150
lib .virtualfile_in (check_kind = "raster" , data = grid ) as vingrd ,
147
151
lib .virtualfile_out (kind = "grid" , fname = outgrid ) as voutgrd ,
148
152
):
149
- kwargs ["G" ] = voutgrd
153
+ kwdict ["G" ] = voutgrd
150
154
lib .call_module (
151
- module = "dimfilter" , args = build_arg_list (kwargs , infile = vingrd )
155
+ module = "dimfilter" ,
156
+ args = build_arg_list (kwdict , infile = vingrd ),
152
157
)
153
158
return lib .virtualfile_to_raster (vfname = voutgrd , outgrid = outgrid )
0 commit comments