diff --git a/pygmt/alias.py b/pygmt/alias.py index 472653d09a5..35f64f8b610 100644 --- a/pygmt/alias.py +++ b/pygmt/alias.py @@ -300,6 +300,10 @@ def add_common(self, **kwargs): """ for key, value in kwargs.items(): match key: + case "J": + alias = Alias(value, name="projection") + case "R": + alias = Alias(value, name="region", sep="/", size=(4, 6)) case "V": alias = Alias( value, @@ -314,8 +318,6 @@ def add_common(self, **kwargs): "debug": "d", }, ) - case "J": - alias = Alias(value, name="projection") case "c": alias = Alias(value, name="panel", sep=",", size=2) case "t": diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index b7753893319..6ec874fdbe4 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -2,6 +2,7 @@ basemap - Plot base maps and frames. """ +from collections.abc import Sequence from typing import Literal from pygmt.alias import AliasSystem @@ -11,7 +12,6 @@ @fmt_docstring @use_alias( - R="region", Jz="zscale", JZ="zsize", B="frame", @@ -22,10 +22,11 @@ f="coltypes", p="perspective", ) -@kwargs_to_strings(R="sequence", p="sequence") +@kwargs_to_strings(p="sequence") def basemap( self, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -47,6 +48,7 @@ def basemap( {aliases} - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -97,6 +99,7 @@ def basemap( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/binstats.py b/pygmt/src/binstats.py index f20ceff111b..256b71eea8e 100644 --- a/pygmt/src/binstats.py +++ b/pygmt/src/binstats.py @@ -2,6 +2,7 @@ binstats - Bin spatial data and determine statistics per bin. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -16,7 +17,6 @@ E="empty", I="spacing", N="normalize", - R="region", S="search_radius", W="weight", a="aspatial", @@ -25,7 +25,7 @@ i="incols", r="registration", ) -@kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma") +@kwargs_to_strings(I="sequence", i="sequence_comma") def binstats( data: PathLike | TableLike, outgrid: PathLike | None = None, @@ -48,6 +48,7 @@ def binstats( "sum", ] = "number", quantile_value: float = 50, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -67,6 +68,7 @@ def binstats( {aliases} - C = statistic + - R = region - V = verbose Parameters @@ -154,6 +156,7 @@ def binstats( }, ), ).add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/blockm.py b/pygmt/src/blockm.py index 6f2920f7591..9aa593df3e1 100644 --- a/pygmt/src/blockm.py +++ b/pygmt/src/blockm.py @@ -2,6 +2,7 @@ blockm - Block average (x, y, z) data tables by mean, median, or mode estimation. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -73,7 +74,6 @@ def _blockm( @fmt_docstring @use_alias( I="spacing", - R="region", S="summary", a="aspatial", b="binary", @@ -86,7 +86,7 @@ def _blockm( r="registration", w="wrap", ) -@kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma", o="sequence_comma") +@kwargs_to_strings(I="sequence", i="sequence_comma", o="sequence_comma") def blockmean( data: PathLike | TableLike | None = None, x=None, @@ -94,6 +94,7 @@ def blockmean( z=None, output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -113,6 +114,7 @@ def blockmean( Full GMT docs at :gmt-docs:`blockmean.html`. {aliases} + - R = region - V = verbose Parameters @@ -166,6 +168,7 @@ def blockmean( >>> data_bmean = pygmt.blockmean(data=data, region=[245, 255, 20, 30], spacing="5m") """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) @@ -185,7 +188,6 @@ def blockmean( @fmt_docstring @use_alias( I="spacing", - R="region", a="aspatial", b="binary", d="nodata", @@ -197,7 +199,7 @@ def blockmean( r="registration", w="wrap", ) -@kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma", o="sequence_comma") +@kwargs_to_strings(I="sequence", i="sequence_comma", o="sequence_comma") def blockmedian( data: PathLike | TableLike | None = None, x=None, @@ -205,6 +207,7 @@ def blockmedian( z=None, output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -224,6 +227,7 @@ def blockmedian( Full GMT docs at :gmt-docs:`blockmedian.html`. {aliases} + - R = region - V = verbose Parameters @@ -271,6 +275,7 @@ def blockmedian( ... ) """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) @@ -290,7 +295,6 @@ def blockmedian( @fmt_docstring @use_alias( I="spacing", - R="region", a="aspatial", b="binary", d="nodata", @@ -302,7 +306,7 @@ def blockmedian( r="registration", w="wrap", ) -@kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma", o="sequence_comma") +@kwargs_to_strings(I="sequence", i="sequence_comma", o="sequence_comma") def blockmode( data: PathLike | TableLike | None = None, x=None, @@ -310,6 +314,7 @@ def blockmode( z=None, output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -329,6 +334,7 @@ def blockmode( Full GMT docs at :gmt-docs:`blockmode.html`. {aliases} + - R = region - V = verbose Parameters @@ -374,6 +380,7 @@ def blockmode( >>> data_bmode = pygmt.blockmode(data=data, region=[245, 255, 20, 30], spacing="5m") """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index 5a82482a8aa..730e3dab404 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -2,6 +2,7 @@ coast - Plot continents, countries, shorelines, rivers, and borders. """ +from collections.abc import Sequence from typing import Literal from pygmt.alias import Alias, AliasSystem @@ -29,12 +30,11 @@ I="rivers", L="map_scale", N="borders", - R="region", S="water", W="shorelines", p="perspective", ) -@kwargs_to_strings(R="sequence", p="sequence") +@kwargs_to_strings(p="sequence") def coast( self, projection: str | None = None, @@ -42,6 +42,7 @@ def coast( "auto", "full", "high", "intermediate", "low", "crude", None ] = None, box: Box | bool = False, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -71,6 +72,7 @@ def coast( - D = resolution - F = box - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -222,6 +224,7 @@ def coast( F=Alias(box, name="box"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index 857f0712e8e..00271c65878 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -2,6 +2,7 @@ colorbar - Plot gray scale or color scale bar. """ +from collections.abc import Sequence from typing import Literal from pygmt.alias import Alias, AliasSystem @@ -21,16 +22,16 @@ I="shading", L="equalsize", Q="log", - R="region", W="scale", Z="zfile", p="perspective", ) -@kwargs_to_strings(R="sequence", G="sequence", I="sequence", p="sequence") +@kwargs_to_strings(G="sequence", I="sequence", p="sequence") def colorbar( self, projection: str | None = None, box: Box | bool = False, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -53,6 +54,7 @@ def colorbar( {aliases} - F = box - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -151,6 +153,7 @@ def colorbar( F=Alias(box, name="box"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index fc08179d79e..f85434543f6 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -2,6 +2,7 @@ contour - Contour table data by direct triangulation. """ +from collections.abc import Sequence from typing import Literal from pygmt._typing import PathLike, TableLike @@ -23,7 +24,6 @@ C="levels", G="label_placement", L="triangular_mesh_pen", - R="region", S="skip", W="pen", b="binary", @@ -35,8 +35,8 @@ l="label", p="perspective", ) -@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence") -def contour( +@kwargs_to_strings(i="sequence_comma", p="sequence") +def contour( # noqa: PLR0913 self, data: PathLike | TableLike | None = None, x=None, @@ -44,6 +44,7 @@ def contour( z=None, no_clip: bool = False, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -63,6 +64,7 @@ def contour( {aliases} - J = projection - N = no_clip + - R = region - V = verbose - c = panel - t = transparency @@ -164,6 +166,7 @@ def contour( N=Alias(no_clip, name="no_clip"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/dimfilter.py b/pygmt/src/dimfilter.py index a95a5d6e7bc..f70b6ea12a6 100644 --- a/pygmt/src/dimfilter.py +++ b/pygmt/src/dimfilter.py @@ -2,6 +2,7 @@ dimfilter - Directional filtering of grids in the space domain. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -15,17 +16,12 @@ @fmt_docstring -@use_alias( - D="distance", - F="filter", - I="spacing", - N="sectors", - R="region", -) -@kwargs_to_strings(I="sequence", R="sequence") +@use_alias(D="distance", F="filter", I="spacing", N="sectors") +@kwargs_to_strings(I="sequence") def dimfilter( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -52,6 +48,7 @@ def dimfilter( Full GMT docs at :gmt-docs:`dimfilter.html`. {aliases} + - R = region - V = verbose Parameters @@ -152,6 +149,7 @@ def dimfilter( raise GMTInvalidInput(msg) aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grd2cpt.py b/pygmt/src/grd2cpt.py index c85dd7f9a4e..9535ba874ca 100644 --- a/pygmt/src/grd2cpt.py +++ b/pygmt/src/grd2cpt.py @@ -2,6 +2,7 @@ grd2cpt - Make linear or histogram-equalized color palette table from grid. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -24,12 +25,11 @@ H="output", I="reverse", L="limit", - R="region", T="series", W="categorical", Ww="cyclic", ) -@kwargs_to_strings(L="sequence", R="sequence", T="sequence") +@kwargs_to_strings(L="sequence", T="sequence") def grd2cpt( grid: PathLike | xr.DataArray, truncate: tuple[float, float] | None = None, @@ -37,6 +37,7 @@ def grd2cpt( no_bg: bool = False, log: bool = False, continuous: bool = False, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -89,6 +90,7 @@ def grd2cpt( - M = overrule_bg - N = no_bg - Q = log + - R = region - Z = continuous - V = verbose @@ -210,6 +212,7 @@ def grd2cpt( Q=Alias(log, name="log"), Z=Alias(continuous, name="continuous"), ).add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grd2xyz.py b/pygmt/src/grd2xyz.py index 67cad34e2b6..662fe228c81 100644 --- a/pygmt/src/grd2xyz.py +++ b/pygmt/src/grd2xyz.py @@ -2,6 +2,7 @@ grd2xyz - Convert grid to data table. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -25,7 +26,6 @@ @fmt_docstring @use_alias( C="cstyle", - R="region", W="weight", Z="convention", b="binary", @@ -35,11 +35,12 @@ o="outcols", s="skiprows", ) -@kwargs_to_strings(R="sequence", o="sequence_comma") +@kwargs_to_strings(o="sequence_comma") def grd2xyz( grid: PathLike | xr.DataArray, output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -53,6 +54,7 @@ def grd2xyz( Full GMT docs at :gmt-docs:`grd2xyz.html`. {aliases} + - R = region - V = verbose Parameters @@ -161,6 +163,7 @@ def grd2xyz( column_names = [str(grid.dims[1]), str(grid.dims[0]), str(grid.name)] aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdclip.py b/pygmt/src/grdclip.py index e79f1560daa..021550036d2 100644 --- a/pygmt/src/grdclip.py +++ b/pygmt/src/grdclip.py @@ -10,13 +10,7 @@ from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput -from pygmt.helpers import ( - build_arg_list, - deprecate_parameter, - fmt_docstring, - kwargs_to_strings, - use_alias, -) +from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring __doctest_skip__ = ["grdclip"] @@ -24,8 +18,6 @@ # TODO(PyGMT>=0.19.0): Remove the deprecated "new" parameter. @fmt_docstring @deprecate_parameter("new", "replace", "v0.15.0", remove_version="v0.19.0") -@use_alias(R="region") -@kwargs_to_strings(R="sequence") def grdclip( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, @@ -33,6 +25,7 @@ def grdclip( below: Sequence[float] | None = None, between: Sequence[float] | Sequence[Sequence[float]] | None = None, replace: Sequence[float] | Sequence[Sequence[float]] | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -54,7 +47,11 @@ def grdclip( Full GMT docs at :gmt-docs:`grdclip.html`. - {aliases} + **Aliases:** + .. hlist:: + :columns: 3 + + - R = region - Sa = above - Sb = below - Si = between @@ -125,6 +122,7 @@ def grdclip( Si=Alias(between, name="between", sep="/", size=3, ndim=2), Sr=Alias(replace, name="replace", sep="/", size=2, ndim=2), ).add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index d363bf15d27..000eefa95b6 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -2,6 +2,7 @@ grdcontour - Make contour map using a grid. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -29,18 +30,18 @@ G="label_placement", L="limit", Q="cut", - R="region", S="resample", W="pen", l="label", f="coltypes", p="perspective", ) -@kwargs_to_strings(R="sequence", L="sequence", p="sequence") +@kwargs_to_strings(L="sequence", p="sequence") def grdcontour( self, grid: PathLike | xr.DataArray, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -56,6 +57,7 @@ def grdcontour( {aliases} - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -165,6 +167,7 @@ def grdcontour( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/grdcut.py b/pygmt/src/grdcut.py index 4ae0ff0ff01..cf198d9dc74 100644 --- a/pygmt/src/grdcut.py +++ b/pygmt/src/grdcut.py @@ -2,6 +2,7 @@ grdcut - Extract subregion from a grid or image or a slice from a cube. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -13,7 +14,6 @@ build_arg_list, data_kind, fmt_docstring, - kwargs_to_strings, use_alias, ) @@ -21,19 +21,13 @@ @fmt_docstring -@use_alias( - R="region", - N="extend", - S="circ_subregion", - Z="z_subregion", - f="coltypes", -) -@kwargs_to_strings(R="sequence") +@use_alias(N="extend", S="circ_subregion", Z="z_subregion", f="coltypes") def grdcut( grid: PathLike | xr.DataArray, kind: Literal["grid", "image"] = "grid", outgrid: PathLike | None = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -54,6 +48,7 @@ def grdcut( {aliases} - J = projection + - R = region - V = verbose Parameters @@ -130,6 +125,7 @@ def grdcut( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdfill.py b/pygmt/src/grdfill.py index 97c27855720..11dd368caf5 100644 --- a/pygmt/src/grdfill.py +++ b/pygmt/src/grdfill.py @@ -3,6 +3,7 @@ """ import warnings +from collections.abc import Sequence from typing import Literal import numpy as np @@ -11,13 +12,7 @@ from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput -from pygmt.helpers import ( - build_arg_list, - deprecate_parameter, - fmt_docstring, - kwargs_to_strings, - use_alias, -) +from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring, use_alias __doctest_skip__ = ["grdfill"] @@ -77,9 +72,8 @@ def _validate_params( # TODO(PyGMT>=0.19.0): Remove the deprecated 'no_data' parameter. # TODO(PyGMT>=0.19.0): Remove the deprecated 'mode' parameter. @deprecate_parameter("no_data", "hole", "v0.15.0", remove_version="v0.19.0") -@use_alias(R="region", f="coltypes") -@kwargs_to_strings(R="sequence") -def grdfill( +@use_alias(f="coltypes") +def grdfill( # noqa: PLR0913 grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, constantfill: float | None = None, @@ -89,6 +83,7 @@ def grdfill( inquire: bool = False, hole: float | None = None, mode: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -111,6 +106,7 @@ def grdfill( - As = splinefill - L = inquire - N = hole + - R = region - V = verbose Parameters @@ -191,6 +187,7 @@ def grdfill( L=Alias(inquire, name="inquire"), N=Alias(hole, name="hole"), ).add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdfilter.py b/pygmt/src/grdfilter.py index 060f07d593a..4347df7d995 100644 --- a/pygmt/src/grdfilter.py +++ b/pygmt/src/grdfilter.py @@ -2,6 +2,7 @@ grdfilter - Filter a grid in the space (or time) domain. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -17,15 +18,15 @@ F="filter", I="spacing", N="nans", - R="region", T="toggle", f="coltypes", r="registration", ) -@kwargs_to_strings(I="sequence", R="sequence") +@kwargs_to_strings(I="sequence") def grdfilter( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, cores: int | bool = False, @@ -47,6 +48,7 @@ def grdfilter( Full GMT docs at :gmt-docs:`grdfilter.html`. {aliases} + - R = region - V = verbose - x = cores @@ -137,6 +139,7 @@ def grdfilter( >>> smooth_field = pygmt.grdfilter(grid=grid, filter="g600", distance="4") """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, x=cores, ) diff --git a/pygmt/src/grdgradient.py b/pygmt/src/grdgradient.py index f0862ee276e..c10784a0391 100644 --- a/pygmt/src/grdgradient.py +++ b/pygmt/src/grdgradient.py @@ -2,6 +2,7 @@ grdgradient - Compute directional gradients from a grid. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -27,15 +28,15 @@ E="radiance", N="normalize", Q="tiles", - R="region", S="slope_file", f="coltypes", n="interpolation", ) -@kwargs_to_strings(A="sequence", E="sequence", R="sequence") +@kwargs_to_strings(A="sequence", E="sequence") def grdgradient( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -49,6 +50,7 @@ def grdgradient( Full GMT docs at :gmt-docs:`grdgradient.html`. {aliases} + - R = region - V = verbose Parameters @@ -156,7 +158,6 @@ def grdgradient( - ``None`` if ``outgrid`` is set (grid output will be stored in the file set by ``outgrid``) - Example ------- >>> import pygmt @@ -179,6 +180,7 @@ def grdgradient( raise GMTInvalidInput(msg) aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdhisteq.py b/pygmt/src/grdhisteq.py index 77b86a15df5..a877ab69198 100644 --- a/pygmt/src/grdhisteq.py +++ b/pygmt/src/grdhisteq.py @@ -2,6 +2,7 @@ grdhisteq - Perform histogram equalization for a grid. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -14,7 +15,6 @@ from pygmt.helpers import ( build_arg_list, fmt_docstring, - kwargs_to_strings, use_alias, validate_output_table_type, ) @@ -55,17 +55,11 @@ class grdhisteq: # noqa: N801 @staticmethod @fmt_docstring - @use_alias( - C="divisions", - R="region", - N="gaussian", - Q="quadratic", - h="header", - ) - @kwargs_to_strings(R="sequence") + @use_alias(C="divisions", N="gaussian", Q="quadratic", h="header") def equalize_grid( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal[ "quiet", "error", "warning", "timing", "info", "compat", "debug" ] @@ -84,6 +78,7 @@ def equalize_grid( Full GMT docs at :gmt-docs:`grdhisteq.html`. {aliases} + - R = region - V = verbose Parameters @@ -131,6 +126,7 @@ def equalize_grid( grids to account for node area varying with latitude. """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) @@ -148,18 +144,12 @@ def equalize_grid( @staticmethod @fmt_docstring - @use_alias( - C="divisions", - R="region", - N="gaussian", - Q="quadratic", - h="header", - ) - @kwargs_to_strings(R="sequence") + @use_alias(C="divisions", N="gaussian", Q="quadratic", h="header") def compute_bins( grid: PathLike | xr.DataArray, output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal[ "quiet", "error", "warning", "timing", "info", "compat", "debug" ] @@ -186,6 +176,7 @@ def compute_bins( Full GMT docs at :gmt-docs:`grdhisteq.html`. {aliases} + - R = region - V = verbose Parameters @@ -247,6 +238,7 @@ def compute_bins( raise GMTInvalidInput(msg) aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index d27d5472252..ca64d550373 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -2,6 +2,7 @@ grdimage - Project and plot grids or images. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -22,18 +23,18 @@ G="bitcolor", I="shading", Q="nan_transparent", - R="region", n="interpolation", f="coltypes", p="perspective", ) -@kwargs_to_strings(R="sequence", p="sequence") +@kwargs_to_strings(p="sequence") def grdimage( self, grid: PathLike | xr.DataArray, monochrome: bool = False, no_clip: bool = False, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -78,6 +79,7 @@ def grdimage( - J = projection - M = monochrome - N = no_clip + - R = region - V = verbose - c = panel - t = transparency @@ -180,6 +182,7 @@ def grdimage( N=Alias(no_clip, name="no_clip"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/grdinfo.py b/pygmt/src/grdinfo.py index ec09317023e..cd7195f58d2 100644 --- a/pygmt/src/grdinfo.py +++ b/pygmt/src/grdinfo.py @@ -2,6 +2,7 @@ grdinfo - Extract information from 2-D grids or 3-D cubes. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -25,13 +26,13 @@ I="spacing", L="force_scan", M="minmax_pos", - R="region", T="nearest_multiple", f="coltypes", ) -@kwargs_to_strings(D="sequence", I="sequence", R="sequence") +@kwargs_to_strings(D="sequence", I="sequence") def grdinfo( grid: PathLike | xr.DataArray, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -44,6 +45,7 @@ def grdinfo( Full GMT docs at :gmt-docs:`grdinfo.html`. {aliases} + - R = region - V = verbose Parameters @@ -121,6 +123,7 @@ def grdinfo( A string with information about the grid. """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 6f8f0111b8e..30a3738f537 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -16,13 +16,8 @@ @fmt_docstring -@use_alias( - A="area_thresh", - I="spacing", - R="region", - r="registration", -) -@kwargs_to_strings(I="sequence", R="sequence") +@use_alias(A="area_thresh", I="spacing", r="registration") +@kwargs_to_strings(I="sequence") def grdlandmask( outgrid: PathLike | None = None, maskvalues: Sequence[float] | None = None, @@ -30,6 +25,7 @@ def grdlandmask( resolution: Literal[ "auto", "full", "high", "intermediate", "low", "crude", None ] = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, cores: int | bool = False, @@ -50,6 +46,7 @@ def grdlandmask( - D = resolution - E = bordervalues - N = maskvalues + - R = region - V = verbose - x = cores @@ -111,7 +108,7 @@ def grdlandmask( >>> # latitude range of 30° N to 35° N, and a grid spacing of 1 arc-degree >>> landmask = pygmt.grdlandmask(spacing=1, region=[125, 130, 30, 35]) """ - if kwargs.get("I") is None or kwargs.get("R") is None: + if kwargs.get("I") is None or kwargs.get("R", region) is None: msg = "Both 'region' and 'spacing' must be specified." raise GMTInvalidInput(msg) @@ -131,6 +128,7 @@ def grdlandmask( N=Alias(maskvalues, name="maskvalues", sep="/", size=(2, 5)), E=Alias(bordervalues, name="bordervalues", sep="/", size=4), ).add_common( + R=region, V=verbose, x=cores, ) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index afd8e4e975a..97910ab7061 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -2,6 +2,7 @@ grdproject - Forward and inverse map transformation of grids. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -22,15 +23,15 @@ F="scaling", I="inverse", M="unit", - R="region", n="interpolation", r="registration", ) -@kwargs_to_strings(C="sequence", D="sequence", R="sequence") +@kwargs_to_strings(C="sequence", D="sequence") def grdproject( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -57,6 +58,7 @@ def grdproject( {aliases} - J = projection + - R = region - V = verbose Parameters @@ -119,6 +121,7 @@ def grdproject( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdsample.py b/pygmt/src/grdsample.py index 1af517380c2..0ab0b46e354 100644 --- a/pygmt/src/grdsample.py +++ b/pygmt/src/grdsample.py @@ -2,6 +2,7 @@ grdsample - Resample a grid onto a new lattice. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -16,16 +17,16 @@ @fmt_docstring @use_alias( I="spacing", - R="region", T="translate", f="coltypes", n="interpolation", r="registration", ) -@kwargs_to_strings(I="sequence", R="sequence") +@kwargs_to_strings(I="sequence") def grdsample( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, cores: int | bool = False, @@ -50,6 +51,7 @@ def grdsample( Full GMT docs at :gmt-docs:`grdsample.html`. {aliases} + - R = region - V = verbose - x = cores @@ -92,6 +94,7 @@ def grdsample( >>> new_grid = pygmt.grdsample(grid=grid, translate=True, spacing=[0.5, 0.5]) """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, x=cores, ) diff --git a/pygmt/src/grdtrack.py b/pygmt/src/grdtrack.py index 973125ebf48..fd0631de1fc 100644 --- a/pygmt/src/grdtrack.py +++ b/pygmt/src/grdtrack.py @@ -2,6 +2,7 @@ grdtrack - Sample one or more grids at specified locations. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -29,7 +30,6 @@ D="dfile", E="profile", F="critical", - R="region", N="no_skip", S="stack", T="radius", @@ -48,13 +48,14 @@ s="skiprows", w="wrap", ) -@kwargs_to_strings(R="sequence", S="sequence", i="sequence_comma", o="sequence_comma") +@kwargs_to_strings(S="sequence", i="sequence_comma", o="sequence_comma") def grdtrack( grid: PathLike | xr.DataArray, points: PathLike | TableLike | None = None, output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, newcolname=None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -79,6 +80,7 @@ def grdtrack( Full GMT docs at :gmt-docs:`grdtrack.html`. {aliases} + - R = region - V = verbose Parameters @@ -313,6 +315,7 @@ def grdtrack( column_names = [*points.columns.to_list(), newcolname] aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 52268299e52..8835cca7cf2 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -2,6 +2,7 @@ grdview - Create 3-D perspective image or surface mesh from a grid. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -15,7 +16,6 @@ @fmt_docstring @use_alias( - R="region", Jz="zscale", JZ="zsize", B="frame", @@ -31,11 +31,12 @@ n="interpolation", p="perspective", ) -@kwargs_to_strings(R="sequence", p="sequence") +@kwargs_to_strings(p="sequence") def grdview( self, grid: PathLike | xr.DataArray, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -55,6 +56,7 @@ def grdview( {aliases} - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -156,6 +158,7 @@ def grdview( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index 986b4d4c7a3..1f97f12994d 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -2,6 +2,7 @@ grdvolume - Calculate grid volume and area constrained by a contour. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -22,12 +23,13 @@ @fmt_docstring -@use_alias(C="contour", R="region", S="unit") -@kwargs_to_strings(C="sequence", R="sequence") +@use_alias(C="contour", S="unit") +@kwargs_to_strings(C="sequence") def grdvolume( grid: PathLike | xr.DataArray, output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -44,6 +46,7 @@ def grdvolume( Full GMT docs at :gmt-docs:`grdvolume.html`. {aliases} + - R = region - V = verbose Parameters @@ -104,6 +107,7 @@ def grdvolume( output_type = validate_output_table_type(output_type, outfile=outfile) aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 357d1b55391..5fa11cacc21 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -2,6 +2,7 @@ Histogram - Calculate and plot histograms. """ +from collections.abc import Sequence from typing import Literal from pygmt._typing import PathLike, TableLike @@ -22,7 +23,6 @@ L="extreme", N="distribution", Q="cumulative", - R="region", S="stairs", T="series", W="pen", @@ -36,11 +36,12 @@ p="perspective", w="wrap", ) -@kwargs_to_strings(R="sequence", T="sequence", i="sequence_comma", p="sequence") +@kwargs_to_strings(T="sequence", i="sequence_comma", p="sequence") def histogram( self, data: PathLike | TableLike, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -54,6 +55,7 @@ def histogram( {aliases} - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -149,6 +151,7 @@ def histogram( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/image.py b/pygmt/src/image.py index 1ef00b887c7..78a19ad9edd 100644 --- a/pygmt/src/image.py +++ b/pygmt/src/image.py @@ -2,6 +2,7 @@ image - Plot raster or EPS images. """ +from collections.abc import Sequence from typing import Literal from pygmt._typing import PathLike @@ -12,12 +13,13 @@ @fmt_docstring -@use_alias(D="position", G="bitcolor", R="region", p="perspective") -@kwargs_to_strings(R="sequence", p="sequence") +@use_alias(D="position", G="bitcolor", p="perspective") +@kwargs_to_strings(p="sequence") def image( self, imagefile: PathLike, projection: str | None = None, + region: Sequence[float | str] | str | None = None, box: Box | bool = False, monochrome: bool = False, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] @@ -48,6 +50,7 @@ def image( - F = box - J = projection - M = monochrome + - R = region - V = verbose - c = panel - t = transparency @@ -93,6 +96,7 @@ def image( M=Alias(monochrome, name="monochrome"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/inset.py b/pygmt/src/inset.py index 617bb36a274..30b5d316e0b 100644 --- a/pygmt/src/inset.py +++ b/pygmt/src/inset.py @@ -3,6 +3,7 @@ """ import contextlib +from collections.abc import Sequence from typing import Literal from pygmt.alias import Alias, AliasSystem @@ -15,11 +16,12 @@ @fmt_docstring @contextlib.contextmanager -@use_alias(D="position", M="margin", R="region") -@kwargs_to_strings(D="sequence", M="sequence", R="sequence") +@use_alias(D="position", M="margin") +@kwargs_to_strings(D="sequence", M="sequence") def inset( self, projection: str | None = None, + region: Sequence[float | str] | str | None = None, box: Box | bool = False, no_clip: bool = False, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] @@ -39,6 +41,7 @@ def inset( - F = box - J = projection - N = no_clip + - R = region - V = verbose Parameters @@ -135,6 +138,7 @@ def inset( N=Alias(no_clip, name="no_clip"), ).add_common( J=projection, + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/legend.py b/pygmt/src/legend.py index 8e299bf401c..ad3022a9711 100644 --- a/pygmt/src/legend.py +++ b/pygmt/src/legend.py @@ -3,6 +3,7 @@ """ import io +from collections.abc import Sequence from typing import Literal from pygmt._typing import PathLike @@ -21,12 +22,13 @@ @fmt_docstring -@use_alias(R="region", D="position", p="perspective") -@kwargs_to_strings(R="sequence", p="sequence") +@use_alias(D="position", p="perspective") +@kwargs_to_strings(p="sequence") def legend( self, spec: PathLike | io.StringIO | None = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, position="JTR+jTR+o0.2c", box: Box | bool = False, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] @@ -49,6 +51,7 @@ def legend( {aliases} - F = box - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -104,6 +107,7 @@ def legend( F=Alias(box, name="box"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/logo.py b/pygmt/src/logo.py index c74ee2dea2b..61a648a6c12 100644 --- a/pygmt/src/logo.py +++ b/pygmt/src/logo.py @@ -2,6 +2,7 @@ logo - Plot the GMT logo. """ +from collections.abc import Sequence from typing import Literal from pygmt.alias import Alias, AliasSystem @@ -11,11 +12,12 @@ @fmt_docstring -@use_alias(R="region", D="position") -@kwargs_to_strings(R="sequence", p="sequence") +@use_alias(D="position") +@kwargs_to_strings(p="sequence") def logo( self, projection: str | None = None, + region: Sequence[float | str] | str | None = None, style: Literal["standard", "url", "no_label"] = "standard", box: Box | bool = False, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] @@ -37,6 +39,7 @@ def logo( {aliases} - F = box - J = projection + - R = region - S = style - V = verbose - c = panel @@ -74,6 +77,7 @@ def logo( ), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/meca.py b/pygmt/src/meca.py index 335496d0acf..6969f41f40a 100644 --- a/pygmt/src/meca.py +++ b/pygmt/src/meca.py @@ -124,12 +124,11 @@ def _auto_offset(spec) -> bool: Fr="labelbox", G="compressionfill", L="outline", - R="region", T="nodal", W="pen", p="perspective", ) -@kwargs_to_strings(R="sequence", p="sequence") +@kwargs_to_strings(p="sequence") def meca( # noqa: PLR0913 self, spec: PathLike | TableLike, @@ -144,6 +143,7 @@ def meca( # noqa: PLR0913 event_name: str | Sequence[str] | None = None, no_clip: bool = False, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -204,6 +204,7 @@ def meca( # noqa: PLR0913 {aliases} - J = projection - N = no_clip + - R = region - S = scale/convention/component - V = verbose - c = panel @@ -374,6 +375,7 @@ def meca( # noqa: PLR0913 N=Alias(no_clip, name="no_clip"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/nearneighbor.py b/pygmt/src/nearneighbor.py index 48c6610e775..8f7d0466d93 100644 --- a/pygmt/src/nearneighbor.py +++ b/pygmt/src/nearneighbor.py @@ -2,6 +2,7 @@ nearneighbor - Grid table data using a "Nearest neighbor" algorithm. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -18,7 +19,6 @@ E="empty", I="spacing", N="sectors", - R="region", S="search_radius", a="aspatial", b="binary", @@ -31,13 +31,14 @@ r="registration", w="wrap", ) -@kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma") +@kwargs_to_strings(I="sequence", i="sequence_comma") def nearneighbor( data: PathLike | TableLike | None = None, x=None, y=None, z=None, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -79,6 +80,7 @@ def nearneighbor( Full GMT docs at :gmt-docs:`nearneighbor.html`. {aliases} + - R = region - V = verbose Parameters @@ -150,6 +152,7 @@ def nearneighbor( ... ) """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index 1f54088c6e4..0c5142c7828 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -31,7 +31,6 @@ I="intensity", L="close", N="no_clip", - R="region", S="style", W="pen", Z="zvalue", @@ -47,7 +46,7 @@ p="perspective", w="wrap", ) -@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma", p="sequence") def plot( # noqa: PLR0912, PLR0913 self, data: PathLike | TableLike | None = None, @@ -58,6 +57,7 @@ def plot( # noqa: PLR0912, PLR0913 direction=None, straight_line: bool | Literal["x", "y"] = False, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -90,6 +90,7 @@ def plot( # noqa: PLR0912, PLR0913 {aliases} - A = straight_line - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -293,6 +294,7 @@ def plot( # noqa: PLR0912, PLR0913 aliasdict = AliasSystem( A=Alias(straight_line, name="straight_line"), ).add_common( + R=region, J=projection, V=verbose, c=panel, diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index cc3e123a345..6601d39ca2b 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -32,7 +32,6 @@ L="close", N="no_clip", Q="no_sort", - R="region", S="style", W="pen", Z="zvalue", @@ -48,7 +47,7 @@ p="perspective", w="wrap", ) -@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma", p="sequence") def plot3d( # noqa: PLR0912, PLR0913 self, data: PathLike | TableLike | None = None, @@ -60,6 +59,7 @@ def plot3d( # noqa: PLR0912, PLR0913 direction=None, straight_line: bool | Literal["x", "y"] = False, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -92,6 +92,7 @@ def plot3d( # noqa: PLR0912, PLR0913 {aliases} - A = straight_line - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -273,6 +274,7 @@ def plot3d( # noqa: PLR0912, PLR0913 A=Alias(straight_line, name="straight_line"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/rose.py b/pygmt/src/rose.py index b573d84ef51..685c196c494 100644 --- a/pygmt/src/rose.py +++ b/pygmt/src/rose.py @@ -2,6 +2,7 @@ rose - Plot a polar histogram (rose, sector, windrose diagrams). """ +from collections.abc import Sequence from typing import Literal from pygmt._typing import PathLike, TableLike @@ -24,7 +25,6 @@ L="labels", M="vector_params", Q="alpha", - R="region", S="norm", T="orientation", W="pen", @@ -37,12 +37,13 @@ p="perspective", w="wrap", ) -@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma", p="sequence") def rose( self, data: PathLike | TableLike | None = None, length=None, azimuth=None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -65,6 +66,7 @@ def rose( Full GMT docs at :gmt-docs:`rose.html`. {aliases} + - R = region - V = verbose - c = panel - t = transparency @@ -208,6 +210,7 @@ def rose( self._activate_figure() aliasdict = AliasSystem().add_common( + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/select.py b/pygmt/src/select.py index 15fbcd1d79d..c9ff73c35d7 100644 --- a/pygmt/src/select.py +++ b/pygmt/src/select.py @@ -2,6 +2,7 @@ select - Select data table subsets based on multiple spatial criteria. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -29,7 +30,6 @@ I="reverse", L="dist2line", N="mask", - R="region", Z="z_subregion", b="binary", d="nodata", @@ -42,7 +42,7 @@ s="skiprows", w="wrap", ) -@kwargs_to_strings(N="sequence", R="sequence", i="sequence_comma", o="sequence_comma") +@kwargs_to_strings(N="sequence", i="sequence_comma", o="sequence_comma") def select( data: PathLike | TableLike | None = None, output_type: Literal["pandas", "numpy", "file"] = "pandas", @@ -51,6 +51,7 @@ def select( "auto", "full", "high", "intermediate", "low", "crude", None ] = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -79,6 +80,7 @@ def select( {aliases} - D = resolution - J = projection + - R = region - V = verbose Parameters @@ -233,6 +235,7 @@ def select( ), ).add_common( J=projection, + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index 6641961d0b8..dea8d7d4d21 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -2,6 +2,7 @@ solar - Plot day-night terminators and other sunlight parameters. """ +from collections.abc import Sequence from typing import Literal import pandas as pd @@ -14,8 +15,8 @@ @fmt_docstring -@use_alias(B="frame", R="region", p="perspective") -@kwargs_to_strings(R="sequence", p="sequence") +@use_alias(B="frame", p="perspective") +@kwargs_to_strings(p="sequence") def solar( self, terminator: Literal["astronomical", "civil", "day_night", "nautical"] = "day_night", @@ -23,6 +24,7 @@ def solar( fill: str | None = None, pen: str | None = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -40,6 +42,7 @@ def solar( {aliases} - G = fill - J = projection + - R = region - T = terminator, **+d**/**+z**: terminator_datetime - V = verbose - W = pen @@ -137,6 +140,7 @@ def solar( W=Alias(pen, name="pen"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/sph2grd.py b/pygmt/src/sph2grd.py index 9887292c20c..3446c65d3a6 100644 --- a/pygmt/src/sph2grd.py +++ b/pygmt/src/sph2grd.py @@ -2,6 +2,7 @@ sph2grd - Compute grid from spherical harmonic coefficients. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -16,16 +17,16 @@ @fmt_docstring @use_alias( I="spacing", - R="region", b="binary", h="header", i="incols", r="registration", ) -@kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma") +@kwargs_to_strings(I="sequence", i="sequence_comma") def sph2grd( data: PathLike | TableLike, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, cores: int | bool = False, @@ -41,6 +42,7 @@ def sph2grd( Full GMT docs at :gmt-docs:`sph2grd.html`. {aliases} + - R = region - V = verbose - x = cores @@ -77,6 +79,7 @@ def sph2grd( >>> new_grid = pygmt.sph2grd(data="@EGM96_to_36.txt", spacing=1, region="g") """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, x=cores, ) diff --git a/pygmt/src/sphdistance.py b/pygmt/src/sphdistance.py index 243968e3249..ba185a7a665 100644 --- a/pygmt/src/sphdistance.py +++ b/pygmt/src/sphdistance.py @@ -3,6 +3,7 @@ sphere. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -24,14 +25,14 @@ L="unit", N="node_table", Q="voronoi", - R="region", ) -@kwargs_to_strings(I="sequence", R="sequence") +@kwargs_to_strings(I="sequence") def sphdistance( data: PathLike | TableLike | None = None, x=None, y=None, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -47,6 +48,7 @@ def sphdistance( Full GMT docs at :gmt-docs:`sphdistance.html`. {aliases} + - R = region - V = verbose Parameters @@ -119,11 +121,12 @@ def sphdistance( ... data=coords_array, spacing=[1, 2], region=[82, 87, 22, 24] ... ) """ - if kwargs.get("I") is None or kwargs.get("R") is None: + if kwargs.get("I") is None or kwargs.get("R", region) is None: msg = "Both 'region' and 'spacing' must be specified." raise GMTInvalidInput(msg) aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/sphinterpolate.py b/pygmt/src/sphinterpolate.py index 3aad5e760ae..1c82c741dfc 100644 --- a/pygmt/src/sphinterpolate.py +++ b/pygmt/src/sphinterpolate.py @@ -2,6 +2,7 @@ sphinterpolate - Spherical gridding in tension of data on a sphere. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -14,11 +15,12 @@ @fmt_docstring -@use_alias(I="spacing", R="region") -@kwargs_to_strings(I="sequence", R="sequence") +@use_alias(I="spacing") +@kwargs_to_strings(I="sequence") def sphinterpolate( data: PathLike | TableLike, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -35,6 +37,7 @@ def sphinterpolate( Full GMT docs at :gmt-docs:`sphinterpolate.html`. {aliases} + - R = region - V = verbose Parameters @@ -67,6 +70,7 @@ def sphinterpolate( >>> grid = pygmt.sphinterpolate(data=mars_shape, spacing=1, region="g") """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index f80d8a2f538..e8f20c8286d 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -3,6 +3,7 @@ """ import contextlib +from collections.abc import Sequence from typing import Literal from pygmt.alias import AliasSystem @@ -25,17 +26,17 @@ B="frame", C="clearance", M="margins", - R="region", SC="sharex", SR="sharey", T="title", ) -@kwargs_to_strings(Ff="sequence", Fs="sequence", M="sequence", R="sequence") +@kwargs_to_strings(Ff="sequence", Fs="sequence", M="sequence") def subplot( self, nrows=1, ncols=1, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -53,6 +54,7 @@ def subplot( {aliases} - J = projection + - R = region - V = verbose Parameters @@ -171,6 +173,7 @@ def subplot( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index cc351e9d875..fb772cf77c2 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -2,6 +2,7 @@ surface - Grid table data using adjustable tension continuous curvature splines. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -20,7 +21,6 @@ Ll="lower", Lu="upper", M="maxradius", - R="region", T="tension", a="aspatial", b="binary", @@ -32,13 +32,14 @@ r="registration", w="wrap", ) -@kwargs_to_strings(I="sequence", R="sequence") +@kwargs_to_strings(I="sequence") def surface( data: PathLike | TableLike | None = None, x=None, y=None, z=None, outgrid: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -76,6 +77,7 @@ def surface( Full GMT docs at :gmt-docs:`surface.html`. {aliases} + - R = region - V = verbose Parameters @@ -164,6 +166,7 @@ def surface( >>> grid = pygmt.surface(data=topography, spacing=1, region=[0, 4, 0, 8]) """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/ternary.py b/pygmt/src/ternary.py index c58138c0e85..50d7e8f69d9 100644 --- a/pygmt/src/ternary.py +++ b/pygmt/src/ternary.py @@ -2,6 +2,7 @@ ternary - Plot data on ternary diagrams. """ +from collections.abc import Sequence from typing import Literal import pandas as pd @@ -18,18 +19,18 @@ C="cmap", G="fill", JX="width", - R="region", S="style", W="pen", p="perspective", ) -@kwargs_to_strings(R="sequence", p="sequence") +@kwargs_to_strings(p="sequence") def ternary( self, data: PathLike | TableLike, alabel: str | None = None, blabel: str | None = None, clabel: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -51,6 +52,7 @@ def ternary( {aliases} - L = alabel/blabel/clabel + - R = region - V = verbose - c = panel - t = transparency @@ -98,6 +100,7 @@ def ternary( aliasdict = AliasSystem( L=Alias(labels, name="alabel/blabel/clabel", sep="/", size=3), ).add_common( + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 5ed30087c56..07027e10f5e 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -24,7 +24,6 @@ @fmt_docstring @use_alias( - R="region", B="frame", C="clearance", D="offset", @@ -38,7 +37,7 @@ p="perspective", w="wrap", ) -@kwargs_to_strings(R="sequence", p="sequence") +@kwargs_to_strings(p="sequence") def text_( # noqa: PLR0912, PLR0913, PLR0915 self, textfiles: PathLike | TableLike | None = None, @@ -51,6 +50,7 @@ def text_( # noqa: PLR0912, PLR0913, PLR0915 justify: bool | None | AnchorCode | Sequence[AnchorCode] = None, no_clip: bool = False, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -77,6 +77,7 @@ def text_( # noqa: PLR0912, PLR0913, PLR0915 - F = **+a**: angle, **+c**: position, **+j**: justify, **+f**: font - J = projection - N = no_clip + - R = region - V = verbose - c = panel - t = transparency @@ -275,6 +276,7 @@ def text_( # noqa: PLR0912, PLR0913, PLR0915 N=Alias(no_clip, name="no_clip"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/tilemap.py b/pygmt/src/tilemap.py index e6afb6ae0c1..5fa03cfc727 100644 --- a/pygmt/src/tilemap.py +++ b/pygmt/src/tilemap.py @@ -2,6 +2,7 @@ tilemap - Plot XYZ tile maps. """ +from collections.abc import Sequence from typing import Literal from pygmt.alias import Alias, AliasSystem @@ -22,13 +23,12 @@ E="dpi", I="shading", Q="nan_transparent", - # R="region", p="perspective", ) -@kwargs_to_strings(p="sequence") # R="sequence", +@kwargs_to_strings(p="sequence") def tilemap( # noqa: PLR0913 self, - region: list, + region: Sequence[float], zoom: int | Literal["auto"] = "auto", source: TileProvider | str | None = None, lonlat: bool = True, @@ -128,16 +128,17 @@ def tilemap( # noqa: PLR0913 if lonlat: raster.gmt.gtype = GridType.GEOGRAPHIC - # Only set region if no_clip is None or False, so that plot is clipped to exact - # bounding box region - if kwargs.get("N", no_clip) in {None, False}: - kwargs["R"] = "/".join(str(coordinate) for coordinate in region) + # If no_clip is not True, set region to None so that plot is clipped to exact + # bounding box region. + if kwargs.get("N", no_clip) not in {None, False}: + region = None # type: ignore[assignment] aliasdict = AliasSystem( M=Alias(monochrome, name="monochrome"), N=Alias(no_clip, name="no_clip"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/triangulate.py b/pygmt/src/triangulate.py index d0f67488b6a..917b17ee0cf 100644 --- a/pygmt/src/triangulate.py +++ b/pygmt/src/triangulate.py @@ -3,6 +3,7 @@ data. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -52,7 +53,6 @@ class triangulate: # noqa: N801 @fmt_docstring @use_alias( I="spacing", - R="region", b="binary", d="nodata", e="find", @@ -63,7 +63,7 @@ class triangulate: # noqa: N801 s="skiprows", w="wrap", ) - @kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma") + @kwargs_to_strings(I="sequence", i="sequence_comma") def regular_grid( data: PathLike | TableLike | None = None, x=None, @@ -71,6 +71,7 @@ def regular_grid( z=None, outgrid: PathLike | None = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal[ "quiet", "error", "warning", "timing", "info", "compat", "debug" ] @@ -102,6 +103,7 @@ def regular_grid( {aliases} - J = projection + - R = region - V = verbose Parameters @@ -148,6 +150,7 @@ def regular_grid( unaware of periodic or polar boundary conditions. """ aliasdict = AliasSystem().add_common( + R=region, J=projection, V=verbose, ) @@ -170,7 +173,6 @@ def regular_grid( @fmt_docstring @use_alias( I="spacing", - R="region", b="binary", d="nodata", e="find", @@ -181,7 +183,7 @@ def regular_grid( s="skiprows", w="wrap", ) - @kwargs_to_strings(I="sequence", R="sequence", i="sequence_comma") + @kwargs_to_strings(I="sequence", i="sequence_comma") def delaunay_triples( data: PathLike | TableLike | None = None, x=None, @@ -191,6 +193,7 @@ def delaunay_triples( output_type: Literal["pandas", "numpy", "file"] = "pandas", outfile: PathLike | None = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal[ "quiet", "error", "warning", "timing", "info", "compat", "debug" ] @@ -215,6 +218,7 @@ def delaunay_triples( {aliases} - J = projection + - R = region - V = verbose Parameters @@ -260,6 +264,7 @@ def delaunay_triples( aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/velo.py b/pygmt/src/velo.py index 56e4f46559e..f4fe41d8a7f 100644 --- a/pygmt/src/velo.py +++ b/pygmt/src/velo.py @@ -2,6 +2,7 @@ velo - Plot velocity vectors, crosses, anisotropy bars, and wedges. """ +from collections.abc import Sequence from typing import Literal import numpy as np @@ -24,7 +25,6 @@ H="scale", I="shading", L="line", - R="region", S="spec", W="pen", Z="zvalue", @@ -34,12 +34,13 @@ i="incols", p="perspective", ) -@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma", p="sequence") def velo( self, data: PathLike | TableLike | None = None, no_clip: bool = False, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -63,6 +64,7 @@ def velo( {aliases} - J = projection - N = no_clip + - R = region - V = verbose - c = panel - t = transparency @@ -267,6 +269,7 @@ def velo( N=Alias(no_clip, name="no_clip"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 57521001f97..b0d145a3687 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -2,6 +2,7 @@ wiggle - Plot z=f(x,y) anomalies along tracks. """ +from collections.abc import Sequence from typing import Literal from pygmt._typing import PathLike, TableLike @@ -41,7 +42,6 @@ def _parse_fills(fillpositive, fillnegative): @use_alias( B="frame", D="position", - R="region", T="track", W="pen", Z="scale", @@ -55,7 +55,7 @@ def _parse_fills(fillpositive, fillnegative): p="perspective", w="wrap", ) -@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma", p="sequence") def wiggle( # noqa: PLR0913 self, data: PathLike | TableLike | None = None, @@ -65,6 +65,7 @@ def wiggle( # noqa: PLR0913 fillpositive=None, fillnegative=None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, panel: int | tuple[int, int] | bool = False, @@ -84,6 +85,7 @@ def wiggle( # noqa: PLR0913 {aliases} - G = **+p**: fillpositive, **+n**: fillnegative - J = projection + - R = region - V = verbose - c = panel - t = transparency @@ -140,6 +142,7 @@ def wiggle( # noqa: PLR0913 G=Alias(_fills, name="fillpositive/fillnegative"), ).add_common( J=projection, + R=region, V=verbose, c=panel, t=transparency, diff --git a/pygmt/src/x2sys_cross.py b/pygmt/src/x2sys_cross.py index 355b8a34f21..50f47b36c42 100644 --- a/pygmt/src/x2sys_cross.py +++ b/pygmt/src/x2sys_cross.py @@ -4,6 +4,7 @@ import contextlib import os +from collections.abc import Sequence from pathlib import Path from typing import Any, Literal @@ -16,7 +17,6 @@ build_arg_list, data_kind, fmt_docstring, - kwargs_to_strings, unique_name, use_alias, ) @@ -63,17 +63,16 @@ def tempfile_from_dftrack(track, suffix): C="runtimes", D="override", I="interpolation", - R="region", S="speed", T="tag", Q="coe", W="numpoints", Z="trackvalues", ) -@kwargs_to_strings(R="sequence") def x2sys_cross( tracks=None, outfile: PathLike | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -92,6 +91,7 @@ def x2sys_cross( Full GMT docs at :gmt-docs:`supplements/x2sys/x2sys_cross.html`. {aliases} + - R = region - V = verbose Parameters @@ -219,6 +219,7 @@ def x2sys_cross( raise GMTTypeError(type(track)) aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/x2sys_init.py b/pygmt/src/x2sys_init.py index ff9711eb479..4313ed5e033 100644 --- a/pygmt/src/x2sys_init.py +++ b/pygmt/src/x2sys_init.py @@ -2,6 +2,7 @@ x2sys_init - Initialize a new x2sys track database. """ +from collections.abc import Sequence from typing import Literal from pygmt.alias import AliasSystem @@ -17,13 +18,13 @@ G="discontinuity", I="spacing", N="units", - R="region", W="gap", j="distcalc", ) -@kwargs_to_strings(I="sequence", R="sequence") +@kwargs_to_strings(I="sequence") def x2sys_init( tag, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -44,6 +45,7 @@ def x2sys_init( Full GMT docs at :gmt-docs:`supplements/x2sys/x2sys_init.html`. {aliases} + - R = region - V = verbose Parameters @@ -119,6 +121,7 @@ def x2sys_init( {distcalc} """ aliasdict = AliasSystem().add_common( + R=region, V=verbose, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 15a0fa7920b..b73f3c0b566 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -2,6 +2,7 @@ xyz2grd - Convert data table to a grid. """ +from collections.abc import Sequence from typing import Literal import xarray as xr @@ -18,7 +19,6 @@ @use_alias( A="duplicate", I="spacing", - R="region", Z="convention", b="binary", d="nodata", @@ -29,7 +29,7 @@ r="registration", w="wrap", ) -@kwargs_to_strings(I="sequence", R="sequence") +@kwargs_to_strings(I="sequence") def xyz2grd( data: PathLike | TableLike | None = None, x=None, @@ -37,6 +37,7 @@ def xyz2grd( z=None, outgrid: PathLike | None = None, projection: str | None = None, + region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, **kwargs, @@ -54,6 +55,7 @@ def xyz2grd( {aliases} - J = projection + - R = region - V = verbose Parameters @@ -154,12 +156,13 @@ def xyz2grd( ... x=xx, y=yy, z=zz, spacing=(1.0, 0.5), region=[0, 3, 10, 13] ... ) """ - if kwargs.get("I") is None or kwargs.get("R") is None: + if kwargs.get("I") is None or kwargs.get("R", region) is None: msg = "Both 'region' and 'spacing' must be specified." raise GMTInvalidInput(msg) aliasdict = AliasSystem().add_common( J=projection, + R=region, V=verbose, ) aliasdict.merge(kwargs)