Skip to content

Commit a4955b9

Browse files
committed
Updates
1 parent f34a297 commit a4955b9

File tree

1 file changed

+49
-32
lines changed

1 file changed

+49
-32
lines changed

pygmt/src/clip.py

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,41 @@ def dcw(self, code: str | Sequence[str], **kwargs):
228228
_code = ",".join(code) if is_nonstr_iter(code) else code
229229
return _ClipDcw(self._figure, dcw=f"{_code}+c", **kwargs)
230230

231+
def solar(self, **kwargs):
232+
"""
233+
Clip the data to the solar terminator.
234+
235+
Must be used as a context manager. Any plotting operations within the context
236+
manager will be clipped to the solar terminator.
237+
238+
Parameters
239+
----------
240+
kwargs
241+
Additional keyword arguments passed to :meth:`pygmt.Figure.solar`. Not all
242+
parameters make sense in this context.
243+
244+
Examples
245+
--------
246+
>>> from pygmt import Figure
247+
>>> from pygmt.datasets import load_earth_relief
248+
>>>
249+
>>> grid = load_earth_relief()
250+
>>> fig = Figure()
251+
>>> fig.basemap(region="g", projection="W15c", frame=True)
252+
>>> with fig.clip.solar(terminator="civil"):
253+
... fig.grdimage(grid, cmap="geo")
254+
>>> fig.show()
255+
"""
256+
return _ClipSolar(self._figure, **kwargs)
257+
231258
@fmt_docstring
232259
@use_alias(
233260
A="straight_line",
234261
B="frame",
235-
R="region",
236262
J="projection",
237-
V="verbose",
238263
N="invert",
264+
R="region",
265+
V="verbose",
239266
W="pen",
240267
)
241268
@kwargs_to_strings(R="sequence")
@@ -251,9 +278,9 @@ def polygon(self, data=None, x=None, y=None, **kwargs):
251278
Parameters
252279
----------
253280
data
254-
Coordinates of polygon.
281+
Either a file name to an ASCII data table, a 2-D {table-classes}.
255282
x/y
256-
Coordinates of polygon.
283+
X and Y coordinates of the polygon.
257284
{frame}
258285
{region}
259286
{projection}
@@ -304,39 +331,29 @@ def polygon(self, data=None, x=None, y=None, **kwargs):
304331
"""
305332
return _ClipPolygon(self._figure, data=data, x=x, y=y, **kwargs)
306333

307-
def solar(self, **kwargs):
334+
@fmt_docstring
335+
@use_alias(
336+
I="spacing",
337+
N="invert",
338+
S="radius",
339+
)
340+
@kwargs_to_strings(R="sequence")
341+
def mask(self, data=None, x=None, y=None, **kwargs):
308342
"""
309-
Clip the data to the solar terminator.
343+
Clip the data to a mask.
310344
311345
Must be used as a context manager. Any plotting operations within the context
312-
manager will be clipped to the solar terminator.
346+
manager will be clipped to the mask.
313347
314348
Parameters
315349
----------
316-
kwargs
317-
Additional keyword arguments passed to :meth:`pygmt.Figure.solar`. Not all
318-
parameters make sense in this context.
319-
320-
Examples
321-
--------
322-
>>> from pygmt import Figure
323-
>>> from pygmt.datasets import load_earth_relief
324-
>>>
325-
>>> grid = load_earth_relief()
326-
>>> fig = Figure()
327-
>>> fig.basemap(region="g", projection="W15c", frame=True)
328-
>>> with fig.clip.solar(terminator="civil"):
329-
... fig.grdimage(grid, cmap="geo")
330-
>>> fig.show()
331-
"""
332-
return _ClipSolar(self._figure, **kwargs)
333-
334-
def mask(self, x, y, spacing, radius=None):
335-
"""
336-
Clip the data to a mask.
337-
338-
Must be used as a context manager. Any plotting operations within the context
339-
manager will be clipped to the mask.
350+
data
351+
Either a file name to an ASCII data table, a 2-D {table-classes}.
352+
x/y
353+
X and Y coordinates of the mask.
354+
{spacing}
355+
invert
356+
Invert the sense of what is inside and outside.
340357
341358
Examples
342359
--------
@@ -353,4 +370,4 @@ def mask(self, x, y, spacing, radius=None):
353370
... fig.grdimage(grid, cmap="geo")
354371
>>> fig.show()
355372
"""
356-
return _ClipMask(self._figure, data={"x": x, "y": y}, I=spacing, S=radius)
373+
return _ClipMask(self._figure, data=data, x=x, y=y, **kwargs)

0 commit comments

Comments
 (0)