Skip to content

Commit 01e1245

Browse files
authored
Figure.meca: Add type hints and improve docstrings of some parameters (#3842)
* Figure.meca: Add type hints and improve docstrings of some parameters * fix
1 parent d399e74 commit 01e1245

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

pygmt/src/meca.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
meca - Plot focal mechanisms.
33
"""
44

5+
from collections.abc import Sequence
6+
from typing import Literal
7+
58
import numpy as np
69
import pandas as pd
710
from pygmt.clib import Session
@@ -131,14 +134,14 @@ def meca( # noqa: PLR0913
131134
self,
132135
spec,
133136
scale,
134-
convention=None,
135-
component="full",
136-
longitude=None,
137-
latitude=None,
138-
depth=None,
139-
plot_longitude=None,
140-
plot_latitude=None,
141-
event_name=None,
137+
convention: Literal["aki", "gcmt", "mt", "partial", "principal_axis"] | None = None,
138+
component: Literal["full", "dc", "deviatoric"] = "full",
139+
longitude: float | Sequence[float] | None = None,
140+
latitude: float | Sequence[float] | None = None,
141+
depth: float | Sequence[float] | None = None,
142+
plot_longitude: float | Sequence[float] | None = None,
143+
plot_latitude: float | Sequence[float] | None = None,
144+
event_name: str | Sequence[str] | None = None,
142145
**kwargs,
143146
):
144147
r"""
@@ -248,28 +251,32 @@ def meca( # noqa: PLR0913
248251
to change its font (size,fontname,color); append **+j**\ *justify* to change
249252
the text location relative to the beachball [Default is ``"TC"``, i.e., Top
250253
Center]; append **+o** to offset the text string by *dx*\ /*dy*.
251-
convention : str
252-
Focal mechanism convention. See the table above for the supported conventions.
253-
Ignored if ``spec`` is a dict or :class:`pandas.DataFrame`.
254-
component : str
255-
The component of the seismic moment tensor to plot.
254+
convention
255+
Specify the focal mechanism convention of the input data. Ignored if ``spec`` is
256+
a dict or :class:`pandas.DataFrame`. See the table above for the supported
257+
conventions.
258+
component
259+
The component of the seismic moment tensor to plot. Valid values are:
256260
257261
- ``"full"``: the full seismic moment tensor
258-
- ``"dc"``: the closest double couple defined from the moment tensor (zero
259-
trace and zero determinant)
262+
- ``"dc"``: the closest double couple defined from the moment tensor (zero trace
263+
and zero determinant)
260264
- ``"deviatoric"``: deviatoric part of the moment tensor (zero trace)
261-
longitude/latitude/depth : float, list, or 1-D numpy array
262-
Longitude(s) / latitude(s) / depth(s) of the event(s). Length must match the
263-
number of events. Overrides the ``longitude`` / ``latitude`` / ``depth`` values
264-
in ``spec`` if ``spec`` is a dict or :class:`pandas.DataFrame`.
265-
plot_longitude/plot_latitude : float, str, list, or 1-D numpy array
266-
Longitude(s) / Latitude(s) at which to place the beachball(s). Length must match
267-
the number of events. Overrides the ``plot_longitude`` / ``plot_latitude``
268-
values in ``spec`` if ``spec`` is a dict or :class:`pandas.DataFrame`.
269-
event_name : str, list of str, or 1-D numpy array
270-
Text string(s), e.g., event name(s) to appear near the beachball(s). Length
271-
must match the number of events. Overrides the ``event_name`` labels in ``spec``
272-
if ``spec`` is a dict or :class:`pandas.DataFrame`.
265+
longitude/latitude/depth
266+
Longitude(s), latitude(s), and depth(s) of the event(s). The length of each must
267+
match the number of events. These parameters are only used if ``spec`` is a
268+
dictionary or a :class:`pandas.DataFrame`, and they override any existing
269+
``longitude``, ``latitude``, or ``depth`` values in ``spec``.
270+
plot_longitude/plot_latitude
271+
Longitude(s) and latitude(s) at which to place the beachball(s). The length of
272+
each must match the number of events. These parameters are only used if ``spec``
273+
is a dictionary or a :class:`pandas.DataFrame`, and they override any existing
274+
``plot_longitude`` or ``plot_latitude`` values in ``spec``.
275+
event_name
276+
Text string(s), such as event name(s), to appear near the beachball(s). The
277+
length must match the number of events. This parameter is only used if ``spec``
278+
is a dictionary or a :class:`pandas.DataFrame`, and it overrides any existing
279+
``event_name`` labels in ``spec``.
273280
labelbox : bool or str
274281
[*fill*].
275282
Draw a box behind the label if given via ``event_name``. Use *fill* to give a

0 commit comments

Comments
 (0)