Skip to content

Commit cf93a77

Browse files
pygmt.grdproject: Migrate the 'center' parameter to the alias system (#4199)
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
1 parent 80c4f50 commit cf93a77

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pygmt/src/grdproject.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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.exceptions import GMTInvalidInput
1313
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
@@ -17,18 +17,18 @@
1717

1818
@fmt_docstring
1919
@use_alias(
20-
C="center",
2120
D="spacing",
2221
E="dpi",
2322
F="scaling",
2423
I="inverse",
2524
M="unit",
2625
n="interpolation",
2726
)
28-
@kwargs_to_strings(C="sequence", D="sequence")
27+
@kwargs_to_strings(D="sequence")
2928
def grdproject(
3029
grid: PathLike | xr.DataArray,
3130
outgrid: PathLike | None = None,
31+
center: Sequence[float | str] | bool = False,
3232
projection: str | None = None,
3333
region: Sequence[float | str] | str | None = None,
3434
registration: Literal["gridline", "pixel"] | bool = False,
@@ -57,6 +57,7 @@ def grdproject(
5757
Full GMT docs at :gmt-docs:`grdproject.html`.
5858
5959
{aliases}
60+
- C = center
6061
- J = projection
6162
- R = region
6263
- V = verbose
@@ -71,13 +72,12 @@ def grdproject(
7172
[Default is ``False``].
7273
{projection}
7374
{region}
74-
center : str or list
75-
[*dx*, *dy*].
76-
Let projected coordinates be relative to projection center [Default
77-
is relative to lower left corner]. Optionally, add offsets in the
78-
projected units to be added (or subtracted when ``inverse`` is set) to
79-
(from) the projected coordinates, such as false eastings and
80-
northings for particular projection zones [Default is ``[0, 0]``].
75+
center
76+
If ``True``, let the projected coordinates be relative to the projection center
77+
[Default is relative to the lower left corner]. Optionally, set offsets
78+
(*dx*, *dy*) in the projected units to be added (or subtracted when ``inverse``
79+
is set) to (from) the projected coordinates, such as false eastings and
80+
northings for particular projection zones [Default is ``(0, 0)``].
8181
{spacing}
8282
dpi : int
8383
Set the resolution for the new grid in dots per inch.
@@ -120,7 +120,9 @@ def grdproject(
120120
msg = "Parameter 'projection' must be specified."
121121
raise GMTInvalidInput(msg)
122122

123-
aliasdict = AliasSystem().add_common(
123+
aliasdict = AliasSystem(
124+
C=Alias(center, name="center", sep="/", size=2),
125+
).add_common(
124126
J=projection,
125127
R=region,
126128
V=verbose,

0 commit comments

Comments
 (0)