-
Notifications
You must be signed in to change notification settings - Fork 218
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
base: main
Are you sure you want to change the base?
Conversation
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? |
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
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() 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. |
Hm, yeah, I needed a moment to sort all these flags... and made a rough overview (probably not perfect):
The argumente passed to Fa can be confusing because there is no slash (/") between the two symbol codes (e.g., Besides these parameters, there are
|
Thanks for your example. It seems In my opinion, a more Pythonic parameter is:
but I feel most of us don't like the dictionary in #1082. |
Description of proposed changes
This PR adds aliases for the GMT flags used for plotting the P and T axes for
Figure.meca
:pt_axes
t_axisfill
p_axisfill
t_axispen
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
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash command is:
/format
: automatically format and lint the code