From 3562d50f996457b515c523ad2a4d92d5fe6ea628 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:20:44 +0100 Subject: [PATCH 1/5] POC: Add common docstrings for meca/coupe --- pygmt/helpers/decorators.py | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 3c4f9dd5510..8092778fa09 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -355,6 +355,45 @@ **Note**: If ``region=grdfile`` is used then the grid spacing and the registration have already been initialized; use ``spacing`` and ``registration`` to override these values.""", + "spec": r""" + spec : str, 1-D numpy array, 2-D numpy array, dict, or pandas.DataFrame + Data that contain focal mechanism parameters. + + ``spec`` can be specified in either of the following types: + + - *str*: a file name containing focal mechanism parameters as columns. The + meaning of each column is: + + - Columns 1 and 2: event longitude and latitude + - Column 3: event depth (in kilometers) + - Columns 4 to 3+n: focal mechanism parameters. The number of columns *n* + depends on the choice of ``convention`` (see the table above for the + supported conventions). + - Columns 4+n and 5+n: longitude and latitude at which to place the + beachball. ``0 0`` plots the beachball at the longitude and latitude + given in the columns 1 and 2. [optional; requires ``offset=True``]. + - Last Column: text string to appear near the beachball [optional]. + + - *1-D np.array*: focal mechanism parameters of a single event. + The meanings of columns are the same as above. + - *2-D np.array*: focal mechanism parameters of multiple events. + The meanings of columns are the same as above. + - *dict* or :class:`pandas.DataFrame`: The dict keys or + :class:`pandas.DataFrame` column names determine the focal mechanism + convention. For the different conventions, the combination of keys / + column names as given in the table above are required. + + A dict may contain values for a single focal mechanism or lists of + values for multiple focal mechanisms. + + Both dict and :class:`pandas.DataFrame` may optionally contain the keys / + column names: ``latitude``, ``longitude``, ``depth``, ``plot_longitude``, + ``plot_latitude``, and/or ``event_name``. + + If ``spec`` is either a str or a 1-D or 2-D numpy array, the ``convention`` + parameter is required to interpret the columns. If ``spec`` is a dict or + a :class:`pandas.DataFrame`, ``convention`` is not needed and ignored if + specified. "transparency": r""" transparency : float Set transparency level, in [0-100] percent range From 249c027a511fbb7accbd893e6dbb11f4985fffa4 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:22:25 +0100 Subject: [PATCH 2/5] Update meca.py --- pygmt/src/meca.py | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/pygmt/src/meca.py b/pygmt/src/meca.py index 2fb9638e8e7..98b535c3c97 100644 --- a/pygmt/src/meca.py +++ b/pygmt/src/meca.py @@ -99,44 +99,6 @@ def meca( # noqa: PLR0912, PLR0913 Parameters ---------- - spec : str, 1-D numpy array, 2-D numpy array, dict, or pandas.DataFrame - Data that contain focal mechanism parameters. - - ``spec`` can be specified in either of the following types: - - - *str*: a file name containing focal mechanism parameters as columns. The - meaning of each column is: - - - Columns 1 and 2: event longitude and latitude - - Column 3: event depth (in kilometers) - - Columns 4 to 3+n: focal mechanism parameters. The number of columns *n* - depends on the choice of ``convention`` (see the table above for the - supported conventions). - - Columns 4+n and 5+n: longitude and latitude at which to place the - beachball. ``0 0`` plots the beachball at the longitude and latitude - given in the columns 1 and 2. [optional; requires ``offset=True``]. - - Last Column: text string to appear near the beachball [optional]. - - - *1-D np.array*: focal mechanism parameters of a single event. - The meanings of columns are the same as above. - - *2-D np.array*: focal mechanism parameters of multiple events. - The meanings of columns are the same as above. - - *dict* or :class:`pandas.DataFrame`: The dict keys or - :class:`pandas.DataFrame` column names determine the focal mechanism - convention. For the different conventions, the combination of keys / - column names as given in the table above are required. - - A dict may contain values for a single focal mechanism or lists of - values for multiple focal mechanisms. - - Both dict and :class:`pandas.DataFrame` may optionally contain the keys / - column names: ``latitude``, ``longitude``, ``depth``, ``plot_longitude``, - ``plot_latitude``, and/or ``event_name``. - - If ``spec`` is either a str or a 1-D or 2-D numpy array, the ``convention`` - parameter is required to interpret the columns. If ``spec`` is a dict or - a :class:`pandas.DataFrame`, ``convention`` is not needed and ignored if - specified. scale : float or str *scale*\ [**+a**\ *angle*][**+f**\ *font*][**+j**\ *justify*]\ [**+l**][**+m**][**+o**\ *dx*\ [/\ *dy*]][**+s**\ *reference*]. @@ -230,6 +192,7 @@ def meca( # noqa: PLR0912, PLR0913 {verbose} {panel} {perspective} + {spec} {transparency} """ kwargs = self._preprocess(**kwargs) From 25a9ddb0b81628ad2ef255a7158a759613a3b6f8 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:27:49 +0100 Subject: [PATCH 3/5] Update decorators.py --- pygmt/helpers/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 8092778fa09..836a4c02392 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -393,7 +393,7 @@ If ``spec`` is either a str or a 1-D or 2-D numpy array, the ``convention`` parameter is required to interpret the columns. If ``spec`` is a dict or a :class:`pandas.DataFrame`, ``convention`` is not needed and ignored if - specified. + specified. """, "transparency": r""" transparency : float Set transparency level, in [0-100] percent range From 375c364e74ae0bc11f25f64dc58d710a7c6d5a88 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:30:36 +0100 Subject: [PATCH 4/5] rm white spaces --- pygmt/helpers/decorators.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 836a4c02392..d86bb909f43 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -358,12 +358,12 @@ "spec": r""" spec : str, 1-D numpy array, 2-D numpy array, dict, or pandas.DataFrame Data that contain focal mechanism parameters. - + ``spec`` can be specified in either of the following types: - + - *str*: a file name containing focal mechanism parameters as columns. The meaning of each column is: - + - Columns 1 and 2: event longitude and latitude - Column 3: event depth (in kilometers) - Columns 4 to 3+n: focal mechanism parameters. The number of columns *n* @@ -373,7 +373,7 @@ beachball. ``0 0`` plots the beachball at the longitude and latitude given in the columns 1 and 2. [optional; requires ``offset=True``]. - Last Column: text string to appear near the beachball [optional]. - + - *1-D np.array*: focal mechanism parameters of a single event. The meanings of columns are the same as above. - *2-D np.array*: focal mechanism parameters of multiple events. @@ -382,14 +382,14 @@ :class:`pandas.DataFrame` column names determine the focal mechanism convention. For the different conventions, the combination of keys / column names as given in the table above are required. - + A dict may contain values for a single focal mechanism or lists of values for multiple focal mechanisms. - + Both dict and :class:`pandas.DataFrame` may optionally contain the keys / column names: ``latitude``, ``longitude``, ``depth``, ``plot_longitude``, ``plot_latitude``, and/or ``event_name``. - + If ``spec`` is either a str or a 1-D or 2-D numpy array, the ``convention`` parameter is required to interpret the columns. If ``spec`` is a dict or a :class:`pandas.DataFrame`, ``convention`` is not needed and ignored if From 8cb7a9a0ac963315f3b8ea9eba1e8a4e27d203e6 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:37:17 +0100 Subject: [PATCH 5/5] put spec on top of list --- pygmt/src/meca.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/meca.py b/pygmt/src/meca.py index 98b535c3c97..526397409d6 100644 --- a/pygmt/src/meca.py +++ b/pygmt/src/meca.py @@ -99,6 +99,7 @@ def meca( # noqa: PLR0912, PLR0913 Parameters ---------- + {spec} scale : float or str *scale*\ [**+a**\ *angle*][**+f**\ *font*][**+j**\ *justify*]\ [**+l**][**+m**][**+o**\ *dx*\ [/\ *dy*]][**+s**\ *reference*]. @@ -192,7 +193,6 @@ def meca( # noqa: PLR0912, PLR0913 {verbose} {panel} {perspective} - {spec} {transparency} """ kwargs = self._preprocess(**kwargs)