Skip to content

Commit 9e0a868

Browse files
authored
Add common alias cores (x) for grdimage and other multi-threaded modules (#625)
Used for setting the number of cores to be used in any OpenMP-enabled multi-threaded algorithms. See also https://docs.generic-mapping-tools.org/6.1/cookbook/options.html#selecting-number-of-cpu-cores-the-x-option.
1 parent 7785566 commit 9e0a868

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pygmt/base_plotting.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ def grdcontour(self, grid, **kwargs):
310310
I="shading",
311311
C="cmap",
312312
t="transparency",
313+
x="cores",
313314
)
314315
@kwargs_to_strings(R="sequence")
315316
def grdimage(self, grid, **kwargs):
@@ -327,6 +328,7 @@ def grdimage(self, grid, **kwargs):
327328
grid : str or xarray.DataArray
328329
The file name of the input grid or the grid loaded as a DataArray.
329330
{t}
331+
{x}
330332
331333
"""
332334
kwargs = self._preprocess(**kwargs)

pygmt/helpers/decorators.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@
8989
Only visible when PDF or raster format output is selected.
9090
Only the PNG format selection adds a transparency layer
9191
in the image (for further processing). """,
92+
"x": """\
93+
cores : int
94+
``[[-]n]``.
95+
Limit the number of cores to be used in any OpenMP-enabled
96+
multi-threaded algorithms. By default we try to use all available
97+
cores. Set a number *n* to only use n cores (if too large it will
98+
be truncated to the maximum cores available). Finally, give a
99+
negative number *-n* to select (all - n) cores (or at least 1 if
100+
n equals or exceeds all).
101+
""",
92102
}
93103

94104

0 commit comments

Comments
 (0)