Skip to content

Commit f8d2837

Browse files
committed
Merge branch 'main' into feature/direction_rose
2 parents 6f9153c + 1669d51 commit f8d2837

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+752
-220
lines changed

doc/techref/common_parameters.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
``verbose``
2323
Select verbosity level, which modulates the messages written to stderr.
2424
25-
Choose among 7 levels of verbosity [Default is ``"w"``]:
25+
Choose among 7 levels of verbosity [Default is ``"warning"``]:
2626
27-
- ``"q"``: Quiet, not even fatal error messages are produced
28-
- ``"e"``: Error messages only
29-
- ``"w"``: Warnings [Default]
30-
- ``"t"``: Timings (report runtimes for time-intensive algorithms)
31-
- ``"i"``: Informational messages (same as ``verbose=True``)
32-
- ``"c"``: Compatibility warnings
33-
- ``"d"``: Debugging messages
27+
- ``"quiet"``: Quiet, not even fatal error messages are produced
28+
- ``"error"``: Error messages only
29+
- ``"warning"``: Warnings [Default]
30+
- ``"timing"``: Timings (report runtimes for time-intensive algorithms)
31+
- ``"info"``: Informational messages (same as ``verbose=True``)
32+
- ``"compat"``: Compatibility warnings
33+
- ``"debug"``: Debugging messages
3434
```

pygmt/alias.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,14 @@ class AliasSystem(UserDict):
217217
>>> from pygmt.helpers import build_arg_list
218218
>>>
219219
>>> def func(
220-
... par0, par1=None, par2=None, frame=False, repeat=None, panel=None, **kwargs
220+
... par0,
221+
... par1=None,
222+
... par2=None,
223+
... frame=False,
224+
... repeat=None,
225+
... panel=None,
226+
... verbose=None,
227+
... **kwargs,
221228
... ):
222229
... aliasdict = AliasSystem(
223230
... A=[
@@ -227,6 +234,7 @@ class AliasSystem(UserDict):
227234
... B=Alias(frame, name="frame"),
228235
... D=Alias(repeat, name="repeat"),
229236
... ).add_common(
237+
... V=verbose,
230238
... c=panel,
231239
... )
232240
... aliasdict.merge(kwargs)
@@ -238,9 +246,10 @@ class AliasSystem(UserDict):
238246
... frame=True,
239247
... repeat=[1, 2, 3],
240248
... panel=(1, 2),
249+
... verbose="debug",
241250
... J="X10c/10c",
242251
... )
243-
['-Amytext+o12/12', '-B', '-D1', '-D2', '-D3', '-JX10c/10c', '-c1,2']
252+
['-Amytext+o12/12', '-B', '-D1', '-D2', '-D3', '-JX10c/10c', '-Vd', '-c1,2']
244253
"""
245254

246255
def __init__(self, **kwargs):
@@ -276,10 +285,26 @@ def add_common(self, **kwargs):
276285
"""
277286
for key, value in kwargs.items():
278287
match key:
288+
case "V":
289+
alias = Alias(
290+
value,
291+
name="verbose",
292+
mapping={
293+
"quiet": "q",
294+
"error": "e",
295+
"warning": "w",
296+
"timing": "t",
297+
"info": "i",
298+
"compat": "c",
299+
"debug": "d",
300+
},
301+
)
279302
case "J":
280303
alias = Alias(value, name="projection")
281304
case "c":
282305
alias = Alias(value, name="panel", sep=",", size=2)
306+
case "t":
307+
alias = Alias(value, name="transparency")
283308
case _:
284309
raise GMTValueError(key, description="common parameter")
285310
self.aliasdict[key] = alias

pygmt/src/basemap.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import warnings
6+
from typing import Literal
67

78
from pygmt.alias import AliasSystem
89
from pygmt.clib import Session
@@ -19,14 +20,18 @@
1920
F="box",
2021
Td="rose",
2122
Tm="compass",
22-
V="verbose",
2323
f="coltypes",
2424
p="perspective",
25-
t="transparency",
2625
)
2726
@kwargs_to_strings(R="sequence", p="sequence")
2827
def basemap(
29-
self, projection=None, panel: int | tuple[int, int] | bool = False, **kwargs
28+
self,
29+
projection=None,
30+
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
31+
| bool = False,
32+
panel: int | tuple[int, int] | bool = False,
33+
transparency: float | None = None,
34+
**kwargs,
3035
):
3136
r"""
3237
Plot base maps and frames.
@@ -43,7 +48,9 @@ def basemap(
4348
4449
{aliases}
4550
- J = projection
51+
- V = verbose
4652
- c = panel
53+
- t = transparency
4754
4855
Parameters
4956
----------
@@ -102,7 +109,9 @@ def basemap(
102109

103110
aliasdict = AliasSystem().add_common(
104111
J=projection,
112+
V=verbose,
105113
c=panel,
114+
t=transparency,
106115
)
107116
aliasdict.merge(kwargs)
108117

pygmt/src/binstats.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
N="normalize",
1919
R="region",
2020
S="search_radius",
21-
V="verbose",
2221
W="weight",
2322
a="aspatial",
2423
b="binary",
@@ -49,6 +48,8 @@ def binstats(
4948
"sum",
5049
] = "number",
5150
quantile_value: float = 50,
51+
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
52+
| bool = False,
5253
**kwargs,
5354
) -> xr.DataArray | None:
5455
r"""
@@ -66,6 +67,7 @@ def binstats(
6667
6768
{aliases}
6869
- C = statistic
70+
- V = verbose
6971
7072
Parameters
7173
----------
@@ -151,7 +153,10 @@ def binstats(
151153
"sum": "z",
152154
},
153155
),
154-
).merge(kwargs)
156+
).add_common(
157+
V=verbose,
158+
)
159+
aliasdict.merge(kwargs)
155160
if statistic == "quantile":
156161
aliasdict["C"] += f"{quantile_value}"
157162

pygmt/src/blockm.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import numpy as np
88
import pandas as pd
99
from pygmt._typing import PathLike, TableLike
10+
from pygmt.alias import AliasSystem
1011
from pygmt.clib import Session
1112
from pygmt.helpers import (
1213
build_arg_list,
@@ -74,7 +75,6 @@ def _blockm(
7475
I="spacing",
7576
R="region",
7677
S="summary",
77-
V="verbose",
7878
a="aspatial",
7979
b="binary",
8080
d="nodata",
@@ -94,6 +94,8 @@ def blockmean(
9494
z=None,
9595
output_type: Literal["pandas", "numpy", "file"] = "pandas",
9696
outfile: PathLike | None = None,
97+
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
98+
| bool = False,
9799
**kwargs,
98100
) -> pd.DataFrame | np.ndarray | None:
99101
r"""
@@ -111,6 +113,7 @@ def blockmean(
111113
Full GMT docs at :gmt-docs:`blockmean.html`.
112114
113115
{aliases}
116+
- V = verbose
114117
115118
Parameters
116119
----------
@@ -162,6 +165,11 @@ def blockmean(
162165
>>> # Calculate block mean values within 5 by 5 arc-minute bins
163166
>>> data_bmean = pygmt.blockmean(data=data, region=[245, 255, 20, 30], spacing="5m")
164167
"""
168+
aliasdict = AliasSystem().add_common(
169+
V=verbose,
170+
)
171+
aliasdict.merge(kwargs)
172+
165173
return _blockm(
166174
block_method="blockmean",
167175
data=data,
@@ -170,15 +178,14 @@ def blockmean(
170178
z=z,
171179
output_type=output_type,
172180
outfile=outfile,
173-
**kwargs,
181+
**aliasdict,
174182
)
175183

176184

177185
@fmt_docstring
178186
@use_alias(
179187
I="spacing",
180188
R="region",
181-
V="verbose",
182189
a="aspatial",
183190
b="binary",
184191
d="nodata",
@@ -198,6 +205,8 @@ def blockmedian(
198205
z=None,
199206
output_type: Literal["pandas", "numpy", "file"] = "pandas",
200207
outfile: PathLike | None = None,
208+
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
209+
| bool = False,
201210
**kwargs,
202211
) -> pd.DataFrame | np.ndarray | None:
203212
r"""
@@ -215,6 +224,7 @@ def blockmedian(
215224
Full GMT docs at :gmt-docs:`blockmedian.html`.
216225
217226
{aliases}
227+
- V = verbose
218228
219229
Parameters
220230
----------
@@ -260,6 +270,11 @@ def blockmedian(
260270
... data=data, region=[245, 255, 20, 30], spacing="5m"
261271
... )
262272
"""
273+
aliasdict = AliasSystem().add_common(
274+
V=verbose,
275+
)
276+
aliasdict.merge(kwargs)
277+
263278
return _blockm(
264279
block_method="blockmedian",
265280
data=data,
@@ -268,15 +283,14 @@ def blockmedian(
268283
z=z,
269284
output_type=output_type,
270285
outfile=outfile,
271-
**kwargs,
286+
**aliasdict,
272287
)
273288

274289

275290
@fmt_docstring
276291
@use_alias(
277292
I="spacing",
278293
R="region",
279-
V="verbose",
280294
a="aspatial",
281295
b="binary",
282296
d="nodata",
@@ -296,6 +310,8 @@ def blockmode(
296310
z=None,
297311
output_type: Literal["pandas", "numpy", "file"] = "pandas",
298312
outfile: PathLike | None = None,
313+
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
314+
| bool = False,
299315
**kwargs,
300316
) -> pd.DataFrame | np.ndarray | None:
301317
r"""
@@ -313,6 +329,7 @@ def blockmode(
313329
Full GMT docs at :gmt-docs:`blockmode.html`.
314330
315331
{aliases}
332+
- V = verbose
316333
317334
Parameters
318335
----------
@@ -356,6 +373,11 @@ def blockmode(
356373
>>> # Calculate block mode values within 5 by 5 arc-minute bins
357374
>>> data_bmode = pygmt.blockmode(data=data, region=[245, 255, 20, 30], spacing="5m")
358375
"""
376+
aliasdict = AliasSystem().add_common(
377+
V=verbose,
378+
)
379+
aliasdict.merge(kwargs)
380+
359381
return _blockm(
360382
block_method="blockmode",
361383
data=data,
@@ -364,5 +386,5 @@ def blockmode(
364386
z=z,
365387
output_type=output_type,
366388
outfile=outfile,
367-
**kwargs,
389+
**aliasdict,
368390
)

pygmt/src/coast.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
N="borders",
3232
R="region",
3333
S="water",
34-
V="verbose",
3534
W="shorelines",
3635
p="perspective",
37-
t="transparency",
3836
)
3937
@kwargs_to_strings(R="sequence", p="sequence")
4038
def coast(
@@ -43,7 +41,10 @@ def coast(
4341
resolution: Literal[
4442
"auto", "full", "high", "intermediate", "low", "crude", None
4543
] = None,
44+
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
45+
| bool = False,
4646
panel: int | tuple[int, int] | bool = False,
47+
transparency: float | None = None,
4748
**kwargs,
4849
):
4950
r"""
@@ -68,7 +69,9 @@ def coast(
6869
{aliases}
6970
- D = resolution
7071
- J = projection
72+
- V = verbose
7173
- c = panel
74+
- t = transparency
7275
7376
Parameters
7477
----------
@@ -229,7 +232,9 @@ def coast(
229232
),
230233
).add_common(
231234
J=projection,
235+
V=verbose,
232236
c=panel,
237+
t=transparency,
233238
)
234239
aliasdict.merge(kwargs)
235240

0 commit comments

Comments
 (0)