Skip to content

Commit 1256d15

Browse files
Figure.meca: Improve documentation (#3517)
1 parent 5babf22 commit 1256d15

File tree

1 file changed

+94
-118
lines changed

1 file changed

+94
-118
lines changed

pygmt/src/meca.py

+94-118
Original file line numberDiff line numberDiff line change
@@ -227,169 +227,145 @@ def meca( # noqa: PLR0912, PLR0913, PLR0915
227227
228228
Parameters
229229
----------
230-
spec : str, 1-D array, 2-D array, dict, or :class:`pandas.DataFrame`
230+
spec : str, 1-D numpy array, 2-D numpy array, dict, or pandas.DataFrame
231231
Data that contain focal mechanism parameters.
232232
233233
``spec`` can be specified in either of the following types:
234234
235-
- *str*: a file name containing focal mechanism parameters as
236-
columns. The meaning of each column is:
235+
- *str*: a file name containing focal mechanism parameters as columns. The
236+
meaning of each column is:
237237
238238
- Columns 1 and 2: event longitude and latitude
239-
- Column 3: event depth (in km)
240-
- Columns 4 to 3+n: focal mechanism parameters. The number of columns
241-
*n* depends on the choice of ``convention``, which will be
242-
described below.
243-
- Columns 4+n and 5+n: longitude, latitude at which to place
244-
beachball. Using ``0 0`` will plot the beachball at the longitude,
245-
latitude given in columns 1 and 2. [optional and requires
246-
``offset=True`` to take effect].
247-
- Text string to appear near the beachball [optional].
248-
249-
- *1-D array*: focal mechanism parameters of a single event.
239+
- Column 3: event depth (in kilometers)
240+
- Columns 4 to 3+n: focal mechanism parameters. The number of columns *n*
241+
depends on the choice of ``convention``, which is described below.
242+
- Columns 4+n and 5+n: longitude and latitude at which to place the
243+
beachball. ``0 0`` plots the beachball at the longitude and latitude
244+
given in the columns 1 and 2. [optional; requires ``offset=True``].
245+
- Last Column: text string to appear near the beachball [optional].
246+
247+
- *1-D np.array*: focal mechanism parameters of a single event.
250248
The meanings of columns are the same as above.
251-
- *2-D array*: focal mechanism parameters of multiple events.
249+
- *2-D np.array*: focal mechanism parameters of multiple events.
252250
The meanings of columns are the same as above.
253-
- *dictionary or :class:`pandas.DataFrame`*: The dictionary keys or
251+
- *dict* or :class:`pandas.DataFrame`: The dict keys or
254252
:class:`pandas.DataFrame` column names determine the focal mechanism
255-
convention. For different conventions, the following combination of
256-
keys are allowed:
257-
258-
- ``"aki"``: *strike, dip, rake, magnitude*
259-
- ``"gcmt"``: *strike1, dip1, rake1, strike2, dip2, rake2, mantissa,*
260-
*exponent*
261-
- ``"mt"``: *mrr, mtt, mff, mrt, mrf, mtf, exponent*
262-
- ``"partial"``: *strike1, dip1, strike2, fault_type, magnitude*
263-
- ``"principal_axis"``: *t_value, t_azimuth, t_plunge, n_value,
264-
n_azimuth, n_plunge, p_value, p_azimuth, p_plunge, exponent*
265-
266-
A dictionary may contain values for a single focal mechanism or
267-
lists of values for multiple focal mechanisms.
268-
269-
Both dictionary and :class:`pandas.DataFrame` may optionally contain
270-
keys/column names: ``latitude``, ``longitude``, ``depth``,
271-
``plot_longitude``, ``plot_latitude``, and/or ``event_name``.
272-
273-
If ``spec`` is either a str, a 1-D array or a 2-D array, the
274-
``convention`` parameter is required so we know how to interpret the
275-
columns. If ``spec`` is a dictionary or a :class:`pandas.DataFrame`,
276-
``convention`` is not needed and is ignored if specified.
253+
convention. For the different conventions, the following combination of
254+
keys / column names are required:
255+
256+
- ``"aki"``: *strike*, *dip*, *rake*, *magnitude*
257+
- ``"gcmt"``: *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*,
258+
*mantissa*, *exponent*
259+
- ``"mt"``: *mrr*, *mtt*, *mff*, *mrt*, *mrf*, *mtf*, *exponent*
260+
- ``"partial"``: *strike1*, *dip1*, *strike2*, *fault_type*, *magnitude*
261+
- ``"principal_axis"``: *t_value*, *t_azimuth*, *t_plunge*, *n_value*,
262+
*n_azimuth*, *n_plunge*, *p_value*, *p_azimuth*, *p_plunge*, *exponent*
263+
264+
A dict may contain values for a single focal mechanism or lists of
265+
values for multiple focal mechanisms.
266+
267+
Both dict and :class:`pandas.DataFrame` may optionally contain the keys /
268+
column names: ``latitude``, ``longitude``, ``depth``, ``plot_longitude``,
269+
``plot_latitude``, and/or ``event_name``.
270+
271+
If ``spec`` is either a str or a 1-D or 2-D numpy array, the ``convention``
272+
parameter is required to interpret the columns. If ``spec`` is a dict or
273+
a :class:`pandas.DataFrame`, ``convention`` is not needed and ignored if
274+
specified.
277275
scale : float or str
278276
*scale*\ [**+a**\ *angle*][**+f**\ *font*][**+j**\ *justify*]\
279277
[**+l**][**+m**][**+o**\ *dx*\ [/\ *dy*]][**+s**\ *reference*].
280-
Adjust scaling of the radius of the beachball, which is
281-
proportional to the magnitude. By default, *scale* defines the
282-
size for magnitude = 5 (i.e., scalar seismic moment
283-
M0 = 4.0E23 dynes-cm). If **+l** is used the radius will be
284-
proportional to the seismic moment instead. Use **+s** and give
285-
a *reference* to change the reference magnitude (or moment), and
286-
use **+m** to plot all beachballs with the same size. A text
287-
string can be specified to appear near the beachball
288-
(corresponding to column or parameter ``event_name``).
289-
Append **+a**\ *angle* to change the angle of the text string;
290-
append **+f**\ *font* to change its font (size,fontname,color);
291-
append **+j**\ *justify* to change the text location relative
292-
to the beachball [Default is ``"TC"``, i.e., Top Center];
293-
append **+o** to offset the text string by *dx*\ /*dy*.
278+
Adjust scaling of the radius of the beachball, which is proportional to the
279+
magnitude. By default, *scale* defines the size for magnitude = 5 (i.e., scalar
280+
seismic moment M0 = 4.0E23 dynes-cm). If **+l** is used the radius will be
281+
proportional to the seismic moment instead. Use **+s** and give a *reference*
282+
to change the reference magnitude (or moment), and use **+m** to plot all
283+
beachballs with the same size. A text string can be specified to appear near
284+
the beachball (corresponding to column or parameter ``event_name``). Append
285+
**+a**\ *angle* to change the angle of the text string; append **+f**\ *font*
286+
to change its font (size,fontname,color); append **+j**\ *justify* to change
287+
the text location relative to the beachball [Default is ``"TC"``, i.e., Top
288+
Center]; append **+o** to offset the text string by *dx*\ /*dy*.
294289
convention : str
295290
Focal mechanism convention. Choose from:
296291
297-
- ``"aki"`` (Aki & Richards)
292+
- ``"aki"`` (Aki and Richards)
298293
- ``"gcmt"`` (global CMT)
299294
- ``"mt"`` (seismic moment tensor)
300295
- ``"partial"`` (partial focal mechanism)
301296
- ``"principal_axis"`` (principal axis)
302297
303-
Ignored if ``spec`` is a dictionary or :class:`pandas.DataFrame`.
298+
Ignored if ``spec`` is a dict or :class:`pandas.DataFrame`.
304299
component : str
305300
The component of the seismic moment tensor to plot.
306301
307302
- ``"full"``: the full seismic moment tensor
308-
- ``"dc"``: the closest double couple defined from the moment tensor
309-
(zero trace and zero determinant)
303+
- ``"dc"``: the closest double couple defined from the moment tensor (zero
304+
trace and zero determinant)
310305
- ``"deviatoric"``: deviatoric part of the moment tensor (zero trace)
311-
longitude : float, list, or 1-D numpy array
312-
Longitude(s) of event location(s). Must be the same length as the
313-
number of events. Will override the ``longitude`` values
314-
in ``spec`` if ``spec`` is a dictionary or :class:`pandas.DataFrame`.
315-
latitude : float, list, or 1-D numpy array
316-
Latitude(s) of event location(s). Must be the same length as the
317-
number of events. Will override the ``latitude`` values
318-
in ``spec`` if ``spec`` is a dictionary or :class:`pandas.DataFrame`.
319-
depth : float, list, or 1-D numpy array
320-
Depth(s) of event location(s) in kilometers. Must be the same length
321-
as the number of events. Will override the ``depth`` values in ``spec``
322-
if ``spec`` is a dictionary or :class:`pandas.DataFrame`.
323-
plot_longitude : float, str, list, or 1-D numpy array
324-
Longitude(s) at which to place beachball(s). Must be the same length
325-
as the number of events. Will override the ``plot_longitude`` values
326-
in ``spec`` if ``spec`` is a dictionary or :class:`pandas.DataFrame`.
327-
plot_latitude : float, str, list, or 1-D numpy array
328-
Latitude(s) at which to place beachball(s). List must be the same
329-
length as the number of events. Will override the ``plot_latitude``
330-
values in ``spec`` if ``spec`` is a dictionary or :class:`pandas.DataFrame`.
306+
longitude/latitude/depth : float, list, or 1-D numpy array
307+
Longitude(s) / latitude(s) / depth(s) of the event(s). Length must match the
308+
number of events. Overrides the ``longitude`` / ``latitude`` / ``depth`` values
309+
in ``spec`` if ``spec`` is a dict or :class:`pandas.DataFrame`.
310+
plot_longitude/plot_latitude : float, str, list, or 1-D numpy array
311+
Longitude(s) / Latitude(s) at which to place the beachball(s). Length must match
312+
the number of events. Overrides the ``plot_longitude`` / ``plot_latitude``
313+
values in ``spec`` if ``spec`` is a dict or :class:`pandas.DataFrame`.
331314
event_name : str, list of str, or 1-D numpy array
332-
Text string(s), e.g., event name(s) to appear near the beachball(s).
333-
List must be the same length as the number of events. Will override
334-
the ``event_name`` labels in ``spec`` if ``spec`` is a dictionary
335-
or :class:`pandas.DataFrame`.
315+
Text string(s), e.g., event name(s) to appear near the beachball(s). Length
316+
must match the number of events. Overrides the ``event_name`` labels in ``spec``
317+
if ``spec`` is a dict or :class:`pandas.DataFrame`.
336318
labelbox : bool or str
337319
[*fill*].
338-
Draw a box behind the label if given. Use *fill* to give a fill color
339-
[Default is ``"white"``].
320+
Draw a box behind the label if given via ``event_name``. Use *fill* to give a
321+
fill color [Default is ``"white"``].
340322
offset : bool or str
341323
[**+p**\ *pen*][**+s**\ *size*].
342-
Offset beachball(s) to longitude(s) and latitude(s) specified in the
343-
the last two columns of the input file or array, or by
344-
``plot_longitude`` and ``plot_latitude`` if provided. A small circle
345-
is plotted at the initial location and a line connects the beachball
346-
to the circle. Use **+s**\ *size* to set the diameter of the circle
347-
[Default is no circle]. Use **+p**\ *pen* to set the pen attributes
348-
for this feature [Default is set via ``pen``]. The fill of the
349-
circle is set via ``compressionfill`` or ``cmap``, i.e.,
350-
corresponds to the fill of the compressive quadrants.
324+
Offset beachball(s) to the longitude(s) and latitude(s) specified in the last
325+
two columns of the input file or array, or by ``plot_longitude`` and
326+
``plot_latitude`` if provided. A line from the beachball to the inital location
327+
is drawn. Use **+s**\ *size* to plot a small circle at the initial location and
328+
to set the diameter of this circle [Default is no circle]. Use **+p**\ *pen* to
329+
set the pen attributes for this feature [Default is set via ``pen``]. The fill
330+
of the circle is set via ``compressionfill`` or ``cmap``, i.e., corresponds to
331+
the fill of the compressive quadrants.
351332
compressionfill : str
352-
Set color or pattern for filling compressive quadrants
353-
[Default is ``"black"``]. This setting also applies to the fill of
354-
the circle defined via ``offset``.
333+
Set color or pattern for filling compressive quadrants [Default is ``"black"``].
334+
This setting also applies to the fill of the circle defined via ``offset``.
355335
extensionfill : str
356-
Set color or pattern for filling extensive quadrants
357-
[Default is ``"white"``].
336+
Set color or pattern for filling extensive quadrants [Default is ``"white"``].
358337
pen : str
359-
Set pen attributes for all lines related to beachball [Default is
360-
``"0.25p,black,solid"``]. This setting applies to ``outline``,
361-
``nodal``, and ``offset``, unless overruled by arguments passed to
362-
those parameters. Draws circumference of beachball.
338+
Set (default) pen attributes for all lines related to the beachball [Default is
339+
``"0.25p,black,solid"``]. This setting applies to ``outline``, ``nodal``, and
340+
``offset``, unless overruled by arguments passed to those parameters. Draws the
341+
circumference of the beachball.
363342
outline : bool or str
364343
[*pen*].
365-
Draw circumference and nodal planes of beachball. Use *pen* to set
366-
the pen attributes for this feature [Default is set via ``pen``].
344+
Draw circumference and nodal planes of the beachball. Use *pen* to set the pen
345+
attributes for this feature [Default is set via ``pen``].
367346
nodal : bool, int, or str
368347
[*nplane*][/*pen*].
369-
Plot the nodal planes and outline the bubble which is transparent.
370-
If *nplane* is
348+
Plot the nodal planes and outline the bubble which is transparent. If *nplane*
349+
is
371350
372351
- ``0`` or ``True``: both nodal planes are plotted [Default].
373352
- ``1``: only the first nodal plane is plotted.
374353
- ``2``: only the second nodal plane is plotted.
375354
376-
Use /*pen* to set the pen attributes for this feature [Default is
377-
set via ``pen``].
378-
For double couple mechanisms, ``nodal`` renders the beachball
379-
transparent by drawing only the nodal planes and the circumference.
380-
For non-double couple mechanisms, ``nodal=0`` overlays best
381-
double couple transparently.
355+
Use /*pen* to set the pen attributes for this feature [Default is set via
356+
``pen``].
357+
For double couple mechanisms, ``nodal`` renders the beachball transparent by
358+
drawing only the nodal planes and the circumference. For non-double couple
359+
mechanisms, ``nodal=0`` overlays best double couple transparently.
382360
cmap : str
383361
File name of a CPT file or a series of comma-separated colors (e.g.,
384-
*color1,color2,color3*) to build a linear continuous CPT from those
385-
colors automatically. The color of the compressive quadrants is
386-
determined by the z-value (i.e., event depth or the third column for
387-
an input file). This setting also applies to the fill of the circle
388-
defined via ``offset``.
362+
*color1,color2,color3*) to build a linear continuous CPT from those colors
363+
automatically. The color of the compressive quadrants is determined by the
364+
z-value (i.e., event depth or the third column for an input file). This setting
365+
also applies to the fill of the circle defined via ``offset``.
389366
no_clip : bool
390-
Do **not** skip symbols that fall outside the frame boundaries
391-
[Default is ``False``, i.e., plot symbols inside the frame
392-
boundaries only].
367+
Do **not** skip symbols that fall outside the frame boundaries [Default is
368+
``False``, i.e., plot symbols inside the frame boundaries only].
393369
{projection}
394370
{region}
395371
{frame}

0 commit comments

Comments
 (0)