22dimfilter - Directional filtering of grids in the space domain.
33"""
44
5+ from pygmt .alias import Alias , AliasSystem
56from pygmt .clib import Session
67from 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
89
910__doctest_skip__ = ["dimfilter" ]
1011
1112
1213@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" )
2214def dimfilter (grid , outgrid : str | None = None , ** kwargs ):
2315 r"""
2416 Filter a grid by dividing the filter circle.
@@ -41,8 +33,6 @@ def dimfilter(grid, outgrid: str | None = None, **kwargs):
4133
4234 Full option list at :gmt-docs:`dimfilter.html`
4335
44- {aliases}
45-
4636 Parameters
4737 ----------
4838 {grid}
@@ -135,19 +125,34 @@ def dimfilter(grid, outgrid: str | None = None, **kwargs):
135125 ... region=[-55, -51, -24, -19],
136126 ... )
137127 """
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+ ):
139142 raise GMTInvalidInput (
140143 """At least one of the following parameters must be specified:
141- distance, filters , or sectors."""
144+ distance, filter , or sectors."""
142145 )
143146
147+ kwdict = alias .kwdict
144148 with Session () as lib :
145149 with (
146150 lib .virtualfile_in (check_kind = "raster" , data = grid ) as vingrd ,
147151 lib .virtualfile_out (kind = "grid" , fname = outgrid ) as voutgrd ,
148152 ):
149- kwargs ["G" ] = voutgrd
153+ kwdict ["G" ] = voutgrd
150154 lib .call_module (
151- module = "dimfilter" , args = build_arg_list (kwargs , infile = vingrd )
155+ module = "dimfilter" ,
156+ args = build_arg_list (kwdict , infile = vingrd ),
152157 )
153158 return lib .virtualfile_to_raster (vfname = voutgrd , outgrid = outgrid )
0 commit comments