Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7e4ee2f
Migrate the parameter 'verbose' to the new alias system
seisman Jul 31, 2025
1da83f1
AliasSystem: Add the add_common method for common parameters
seisman Aug 8, 2025
08f83af
Figure.basemap: Migrate the 'verbose' parameter to the new .add_commo…
seisman Aug 8, 2025
0b24680
Fix a typo [skip ci]
seisman Aug 8, 2025
482a132
Fix value to key
seisman Aug 8, 2025
e3b531e
Merge branch 'main' into AliasSystem/verbose
seisman Aug 10, 2025
c87a9d6
Reformat the docstring
seisman Aug 10, 2025
d5b095d
Merge branch 'main' into AliasSystem/verbose
seisman Aug 10, 2025
07097e3
Migrate verbose in coast
seisman Aug 10, 2025
f688d7e
Merge branch 'main' into AliasSystem/verbose
seisman Aug 18, 2025
1858135
Merge branch 'main' into AliasSystem/verbose
seisman Aug 19, 2025
6ca8aa7
Remove V from coast aliases
seisman Aug 19, 2025
cccf373
Update more modules
seisman Aug 19, 2025
d945817
Merge branch 'main' into AliasSystem/verbose
seisman Aug 20, 2025
c843379
Merge branch 'main' into AliasSystem/verbose
seisman Aug 22, 2025
86b629b
Add a test for the verbose parameter
seisman Aug 22, 2025
c25df2a
Fix test name
seisman Aug 22, 2025
e89fe7e
Rename information->info and compatibility->compat
seisman Aug 22, 2025
ad81056
Update docs
seisman Aug 22, 2025
1998522
Minor fixes
seisman Aug 22, 2025
3ab0c22
Merge branch 'main' into AliasSystem/verbose
seisman Aug 23, 2025
261ed7f
Fix a typo
seisman Aug 23, 2025
f94f235
Use long names for verbose in tests
seisman Aug 23, 2025
4ea8967
Fix a typo
seisman Aug 23, 2025
6474049
Add the mssing alias to grdgradient
seisman Aug 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions doc/techref/common_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
``verbose``
Select verbosity level, which modulates the messages written to stderr.

Choose among 7 levels of verbosity [Default is ``"w"``]:
Choose among 7 levels of verbosity [Default is ``"warning"``]:

- ``"q"``: Quiet, not even fatal error messages are produced
- ``"e"``: Error messages only
- ``"w"``: Warnings [Default]
- ``"t"``: Timings (report runtimes for time-intensive algorithms)
- ``"i"``: Informational messages (same as ``verbose=True``)
- ``"c"``: Compatibility warnings
- ``"d"``: Debugging messages
- ``"quiet"``: Quiet, not even fatal error messages are produced
- ``"error"``: Error messages only
- ``"warning"``: Warnings [Default]
- ``"timing"``: Timings (report runtimes for time-intensive algorithms)
- ``"info"``: Informational messages (same as ``verbose=True``)
- ``"compat"``: Compatibility warnings
- ``"debug"``: Debugging messages
```
27 changes: 25 additions & 2 deletions pygmt/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,14 @@ class AliasSystem(UserDict):
>>> from pygmt.helpers import build_arg_list
>>>
>>> def func(
... par0, par1=None, par2=None, frame=False, repeat=None, panel=None, **kwargs
... par0,
... par1=None,
... par2=None,
... frame=False,
... repeat=None,
... panel=None,
... verbose=None,
... **kwargs,
... ):
... aliasdict = AliasSystem(
... A=[
Expand All @@ -227,6 +234,7 @@ class AliasSystem(UserDict):
... B=Alias(frame, name="frame"),
... D=Alias(repeat, name="repeat"),
... ).add_common(
... V=verbose,
... c=panel,
... )
... aliasdict.merge(kwargs)
Expand All @@ -238,9 +246,10 @@ class AliasSystem(UserDict):
... frame=True,
... repeat=[1, 2, 3],
... panel=(1, 2),
... verbose="debug",
... J="X10c/10c",
... )
['-Amytext+o12/12', '-B', '-D1', '-D2', '-D3', '-JX10c/10c', '-c1,2']
['-Amytext+o12/12', '-B', '-D1', '-D2', '-D3', '-JX10c/10c', '-Vd', '-c1,2']
"""

def __init__(self, **kwargs):
Expand Down Expand Up @@ -276,6 +285,20 @@ def add_common(self, **kwargs):
"""
for key, value in kwargs.items():
match key:
case "V":
alias = Alias(
value,
name="verbose",
mapping={
"quiet": "q",
"error": "e",
"warning": "w",
"timing": "t",
"info": "i",
"compat": "c",
"debug": "d",
},
)
case "J":
alias = Alias(value, name="projection")
case "c":
Expand Down
12 changes: 10 additions & 2 deletions pygmt/src/basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
basemap - Plot base maps and frames.
"""

from typing import Literal

from pygmt.alias import AliasSystem
from pygmt.clib import Session
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
Expand All @@ -17,14 +19,18 @@
F="box",
Td="rose",
Tm="compass",
V="verbose",
f="coltypes",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
def basemap(
self, projection=None, panel: int | tuple[int, int] | bool = False, **kwargs
self,
projection=None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
**kwargs,
):
r"""
Plot base maps and frames.
Expand All @@ -41,6 +47,7 @@ def basemap(

{aliases}
- J = projection
- V = verbose
- c = panel

Parameters
Expand Down Expand Up @@ -89,6 +96,7 @@ def basemap(

aliasdict = AliasSystem().add_common(
J=projection,
V=verbose,
c=panel,
)
aliasdict.merge(kwargs)
Expand Down
9 changes: 7 additions & 2 deletions pygmt/src/binstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
N="normalize",
R="region",
S="search_radius",
V="verbose",
W="weight",
a="aspatial",
b="binary",
Expand Down Expand Up @@ -49,6 +48,8 @@ def binstats(
"sum",
] = "number",
quantile_value: float = 50,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
**kwargs,
) -> xr.DataArray | None:
r"""
Expand All @@ -66,6 +67,7 @@ def binstats(

{aliases}
- C = statistic
- V = verbose

Parameters
----------
Expand Down Expand Up @@ -151,7 +153,10 @@ def binstats(
"sum": "z",
},
),
).merge(kwargs)
).add_common(
V=verbose,
)
aliasdict.merge(kwargs)
if statistic == "quantile":
aliasdict["C"] += f"{quantile_value}"

Expand Down
34 changes: 28 additions & 6 deletions pygmt/src/blockm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import pandas as pd
from pygmt._typing import PathLike, TableLike
from pygmt.alias import AliasSystem
from pygmt.clib import Session
from pygmt.helpers import (
build_arg_list,
Expand Down Expand Up @@ -74,7 +75,6 @@ def _blockm(
I="spacing",
R="region",
S="summary",
V="verbose",
a="aspatial",
b="binary",
d="nodata",
Expand All @@ -94,6 +94,8 @@ def blockmean(
z=None,
output_type: Literal["pandas", "numpy", "file"] = "pandas",
outfile: PathLike | None = None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
**kwargs,
) -> pd.DataFrame | np.ndarray | None:
r"""
Expand All @@ -111,6 +113,7 @@ def blockmean(
Full GMT docs at :gmt-docs:`blockmean.html`.

{aliases}
- V = verbose

Parameters
----------
Expand Down Expand Up @@ -162,6 +165,11 @@ def blockmean(
>>> # Calculate block mean values within 5 by 5 arc-minute bins
>>> data_bmean = pygmt.blockmean(data=data, region=[245, 255, 20, 30], spacing="5m")
"""
aliasdict = AliasSystem().add_common(
V=verbose,
)
aliasdict.merge(kwargs)

return _blockm(
block_method="blockmean",
data=data,
Expand All @@ -170,15 +178,14 @@ def blockmean(
z=z,
output_type=output_type,
outfile=outfile,
**kwargs,
**aliasdict,
)


@fmt_docstring
@use_alias(
I="spacing",
R="region",
V="verbose",
a="aspatial",
b="binary",
d="nodata",
Expand All @@ -198,6 +205,8 @@ def blockmedian(
z=None,
output_type: Literal["pandas", "numpy", "file"] = "pandas",
outfile: PathLike | None = None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
**kwargs,
) -> pd.DataFrame | np.ndarray | None:
r"""
Expand All @@ -215,6 +224,7 @@ def blockmedian(
Full GMT docs at :gmt-docs:`blockmedian.html`.

{aliases}
- V = verbose

Parameters
----------
Expand Down Expand Up @@ -260,6 +270,11 @@ def blockmedian(
... data=data, region=[245, 255, 20, 30], spacing="5m"
... )
"""
aliasdict = AliasSystem().add_common(
V=verbose,
)
aliasdict.merge(kwargs)

return _blockm(
block_method="blockmedian",
data=data,
Expand All @@ -268,15 +283,14 @@ def blockmedian(
z=z,
output_type=output_type,
outfile=outfile,
**kwargs,
**aliasdict,
)


@fmt_docstring
@use_alias(
I="spacing",
R="region",
V="verbose",
a="aspatial",
b="binary",
d="nodata",
Expand All @@ -296,6 +310,8 @@ def blockmode(
z=None,
output_type: Literal["pandas", "numpy", "file"] = "pandas",
outfile: PathLike | None = None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
**kwargs,
) -> pd.DataFrame | np.ndarray | None:
r"""
Expand All @@ -313,6 +329,7 @@ def blockmode(
Full GMT docs at :gmt-docs:`blockmode.html`.

{aliases}
- V = verbose

Parameters
----------
Expand Down Expand Up @@ -356,6 +373,11 @@ def blockmode(
>>> # Calculate block mode values within 5 by 5 arc-minute bins
>>> data_bmode = pygmt.blockmode(data=data, region=[245, 255, 20, 30], spacing="5m")
"""
aliasdict = AliasSystem().add_common(
V=verbose,
)
aliasdict.merge(kwargs)

return _blockm(
block_method="blockmode",
data=data,
Expand All @@ -364,5 +386,5 @@ def blockmode(
z=z,
output_type=output_type,
outfile=outfile,
**kwargs,
**aliasdict,
)
5 changes: 4 additions & 1 deletion pygmt/src/coast.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
N="borders",
R="region",
S="water",
V="verbose",
W="shorelines",
p="perspective",
t="transparency",
Expand All @@ -43,6 +42,8 @@ def coast(
resolution: Literal[
"auto", "full", "high", "intermediate", "low", "crude", None
] = None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
**kwargs,
):
Expand All @@ -68,6 +69,7 @@ def coast(
{aliases}
- D = resolution
- J = projection
- V = verbose
- c = panel

Parameters
Expand Down Expand Up @@ -229,6 +231,7 @@ def coast(
),
).add_common(
J=projection,
V=verbose,
c=panel,
)
aliasdict.merge(kwargs)
Expand Down
12 changes: 10 additions & 2 deletions pygmt/src/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
colorbar - Plot gray scale or color scale bar.
"""

from typing import Literal

from pygmt.alias import AliasSystem
from pygmt.clib import Session
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
Expand All @@ -20,15 +22,19 @@
L="equalsize",
Q="log",
R="region",
V="verbose",
W="scale",
Z="zfile",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", G="sequence", I="sequence", p="sequence")
def colorbar(
self, projection=None, panel: int | tuple[int, int] | bool = False, **kwargs
self,
projection=None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
**kwargs,
):
r"""
Plot gray scale or color scale bar.
Expand All @@ -45,6 +51,7 @@ def colorbar(

{aliases}
- J = projection
- V = verbose
- c = panel

Parameters
Expand Down Expand Up @@ -149,6 +156,7 @@ def colorbar(

aliasdict = AliasSystem().add_common(
J=projection,
V=verbose,
c=panel,
)
aliasdict.merge(kwargs)
Expand Down
Loading
Loading