From b155e49ccbcb395b05da53e7f046651e3c758bc3 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 11 Nov 2025 13:33:25 +0800 Subject: [PATCH 1/3] pygmt.grdproject: Migrate the 'center' parameter to the alias system --- pygmt/src/grdproject.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index 2bf82e83dc6..e7e02b63398 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -7,7 +7,7 @@ import xarray as xr from pygmt._typing import PathLike -from pygmt.alias import AliasSystem +from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias @@ -17,7 +17,6 @@ @fmt_docstring @use_alias( - C="center", D="spacing", E="dpi", F="scaling", @@ -25,10 +24,11 @@ M="unit", n="interpolation", ) -@kwargs_to_strings(C="sequence", D="sequence") +@kwargs_to_strings(D="sequence") def grdproject( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, + center: Sequence[float | str] | bool = False, projection: str | None = None, region: Sequence[float | str] | str | None = None, registration: Literal["gridline", "pixel"] | bool = False, @@ -57,6 +57,7 @@ def grdproject( Full GMT docs at :gmt-docs:`grdproject.html`. {aliases} + - C = center - J = projection - R = region - V = verbose @@ -71,13 +72,12 @@ def grdproject( [Default is ``False``]. {projection} {region} - center : str or list - [*dx*, *dy*]. - Let projected coordinates be relative to projection center [Default - is relative to lower left corner]. Optionally, add offsets in the - projected units to be added (or subtracted when ``inverse`` is set) to - (from) the projected coordinates, such as false eastings and - northings for particular projection zones [Default is ``[0, 0]``]. + center + If ``True``, let projected coordinates be relative to projection center [Default + is relative to lower left corner]. Optionally, set offsets (*dx*, *dy*) in the + projected units to be added (or subtracted when ``inverse`` is set) to (from) + the projected coordinates, such as false eastings and northings for particular + projection zones [Default is ``(0, 0)``]. {spacing} dpi : int Set the resolution for the new grid in dots per inch. @@ -120,7 +120,9 @@ def grdproject( msg = "Parameter 'projection' must be specified." raise GMTInvalidInput(msg) - aliasdict = AliasSystem().add_common( + aliasdict = AliasSystem( + C=Alias(center, name="center", sep="/", size=2), + ).add_common( J=projection, R=region, V=verbose, From e2c0eb2989486e51ec7e3e46b14a23ef854e6494 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 11 Nov 2025 16:21:14 +0800 Subject: [PATCH 2/3] Update pygmt/src/grdproject.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/grdproject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index e7e02b63398..a65fea23e23 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -73,8 +73,8 @@ def grdproject( {projection} {region} center - If ``True``, let projected coordinates be relative to projection center [Default - is relative to lower left corner]. Optionally, set offsets (*dx*, *dy*) in the + If ``True``, let the projected coordinates be relative to the projection center [Default + is relative to the lower left corner]. Optionally, set offsets (*dx*, *dy*) in the projected units to be added (or subtracted when ``inverse`` is set) to (from) the projected coordinates, such as false eastings and northings for particular projection zones [Default is ``(0, 0)``]. From 57463a2ff0eeea6f74eb2f910fd29b004a85b8db Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 11 Nov 2025 16:23:49 +0800 Subject: [PATCH 3/3] Fix styling --- pygmt/src/grdproject.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index a65fea23e23..7678ab42d63 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -73,11 +73,11 @@ def grdproject( {projection} {region} center - If ``True``, let the projected coordinates be relative to the projection center [Default - is relative to the lower left corner]. Optionally, set offsets (*dx*, *dy*) in the - projected units to be added (or subtracted when ``inverse`` is set) to (from) - the projected coordinates, such as false eastings and northings for particular - projection zones [Default is ``(0, 0)``]. + If ``True``, let the projected coordinates be relative to the projection center + [Default is relative to the lower left corner]. Optionally, set offsets + (*dx*, *dy*) in the projected units to be added (or subtracted when ``inverse`` + is set) to (from) the projected coordinates, such as false eastings and + northings for particular projection zones [Default is ``(0, 0)``]. {spacing} dpi : int Set the resolution for the new grid in dots per inch.