Skip to content

Commit c74e4af

Browse files
seismanweiji14
andauthored
pygmt.grdsample: Migrate the 'translate' parameter to the new alias system (#4185)
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
1 parent 25f2656 commit c74e4af

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

pygmt/src/grdsample.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,20 @@
77

88
import xarray as xr
99
from pygmt._typing import PathLike
10-
from pygmt.alias import AliasSystem
10+
from pygmt.alias import Alias, AliasSystem
1111
from pygmt.clib import Session
1212
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
1313

1414
__doctest_skip__ = ["grdsample"]
1515

1616

1717
@fmt_docstring
18-
@use_alias(
19-
I="spacing",
20-
T="translate",
21-
f="coltypes",
22-
n="interpolation",
23-
r="registration",
24-
)
18+
@use_alias(I="spacing", f="coltypes", n="interpolation", r="registration")
2519
@kwargs_to_strings(I="sequence")
2620
def grdsample(
2721
grid: PathLike | xr.DataArray,
2822
outgrid: PathLike | None = None,
23+
translate: bool = False,
2924
region: Sequence[float | str] | str | None = None,
3025
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
3126
| bool = False,
@@ -61,9 +56,10 @@ def grdsample(
6156
{outgrid}
6257
{spacing}
6358
{region}
64-
translate : bool
65-
Translate between grid and pixel registration; if the input is
66-
grid-registered, the output will be pixel-registered and vice-versa.
59+
translate
60+
Translate between grid and pixel registration; if the input is grid-registered,
61+
the output will be pixel-registered and vice-versa. This is a *destructive* grid
62+
change; see :gmt-docs:`reference/options.html#switch-registrations`.
6763
registration : str or bool
6864
[**g**\|\ **p**\ ].
6965
Set registration to **g**\ ridline or **p**\ ixel.
@@ -93,7 +89,9 @@ def grdsample(
9389
>>> # and set both x- and y-spacings to 0.5 arc-degrees
9490
>>> new_grid = pygmt.grdsample(grid=grid, translate=True, spacing=[0.5, 0.5])
9591
"""
96-
aliasdict = AliasSystem().add_common(
92+
aliasdict = AliasSystem(
93+
T=Alias(translate, name="translate"),
94+
).add_common(
9795
R=region,
9896
V=verbose,
9997
x=cores,

0 commit comments

Comments
 (0)