Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure.meca: Add aliases for "Fa", "Fe", "Fg", "Ft", "Fp" #3526

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

yvonnefroehlich
Copy link
Member

@yvonnefroehlich yvonnefroehlich commented Oct 16, 2024

Description of proposed changes

This PR adds aliases for the GMT flags used for plotting the P and T axes for Figure.meca:

GMT flag PyGMT alias
Fa pt_axes
Fe t_axisfill
Fg p_axisfill
Ft t_axispen
Fp p_axispen

The docstrings are orientated on the upstream GMT documentation at https://docs.generic-mapping-tools.org/dev/supplements/seis/meca.html#f.

Preview: https://pygmt-dev--3526.org.readthedocs.build/en/3526/api/generated/pygmt.Figure.meca.html

Fixes #

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@yvonnefroehlich yvonnefroehlich added documentation Improvements or additions to documentation enhancement Improving an existing feature labels Oct 16, 2024
@yvonnefroehlich yvonnefroehlich added this to the 0.14.0 milestone Oct 16, 2024
@yvonnefroehlich yvonnefroehlich self-assigned this Oct 16, 2024
@yvonnefroehlich yvonnefroehlich changed the title Figure.meca: Add aliases for "-Fa", "-Fe", "-Fg", "-Ft", "-Fp" Figure.meca: Add aliases for "Fa", "Fe", "Fg", "Ft", "Fp" Oct 16, 2024
@seisman
Copy link
Member

seisman commented Oct 19, 2024

I'm wondering if we can make these parameters more Pythonic. Could you please provide a minimal example so that anyone interested can play with these parameters?

@yvonnefroehlich
Copy link
Member Author

yvonnefroehlich commented Oct 19, 2024

First of all, I have never used this feature my own yet, and this PR was mainly motivated by a question on the GMT forum xD

Could you please provide a minimal example so that anyone interested can play with these parameters?

The following example is modified from the example I posted on the GMT forum (https://forum.generic-mapping-tools.org/t/add-p-t-axis-to-focal-mechanism/5464/2?u=yvonnefroehlich) and is based on my current understanding of the upstream GMT docs:

import pygmt
import numpy as np

size = 5

fig = pygmt.Figure()
fig.basemap(region=[-size, size] * 2, projection=f"X{size}c", frame=0)

fig.meca(
    spec=np.array([0, 0, 0,  35, 42, 70, 5]),  # lon, lat, dep,  strike, dip, rake, magnitude
    scale="4c+m",
    convention="aki",
    Fa="0.5c/cd",  # Compute and plot P and T axes with symbols, Adjust size and symbols
    Fe="pink",  # Adjust fill of T axis symbol
    Fg="cyan",  # Adjust fill of P axis symbol
    Ft="2p,red",  # Add and adjust outline of T axis symbol
    Fp="2p,blue",  # Add and adjust  of P axis symbol
)

fig.show()

meca_pt_axes

Furthermore, an modified version can be found currently in the draft version of the focal mechanisms tutorial at https://pygmt-dev--2550.org.readthedocs.build/en/2550/tutorials/advanced/focal_mechanisms.html#plotting-the-p-and-t-axes.

@yvonnefroehlich
Copy link
Member Author

yvonnefroehlich commented Oct 19, 2024

I'm wondering if we can make these parameters more Pythonic

Hm, yeah, I needed a moment to sort all these flags... and made a rough overview (probably not perfect):

  • W -> pen (adjust circumference, set default for all lines)
  • Fa -> pt_axes (add and set size and symbols for P and T axes)
quadrants (aliases existing) axes (aliases added in this PR)
G -> compressionfill [Default is "black"] Fg -> p_axisfill [Default is G]
E -> extensionfill [Default is "white"] Fe -> t_axisfill [Default is E]
L -> outline [Default is W] Fp -> p_axispen [Default is W]
T -> nodal [Default is W] Ft -> t_axispen [Default is W]

The argumente passed to Fa can be confusing because there is no slash (/") between the two symbol codes (e.g., "0.5c/cd").

Besides these parameters, there are

  • A -> offset [Default for the line is W, Default for the fill is G or C]
  • Fr -> labelbox [Default for the fill is "white"]

@seisman
Copy link
Member

seisman commented Oct 21, 2024

Thanks for your example. It seems -Fe/-Fg/-Ft/-Fp only take effects if -Fa is set to True or a string.

In my opinion, a more Pythonic parameter is:

pt_axes = {
    "size": "0.5c",
    "p_symbol": "c",
    "t_symbol": "d",
    "p_outline": "2p,blue",
    "t_outline": "2p,red",
    "p_fill": "cyan",
    "t_fill": "pink"
}

but I feel most of us don't like the dictionary in #1082.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants