Hello again! I am attempting to plot focal mechanism beach-balls and offset them from their point of origin so they don’t overlap, but so far I have been unable to get them to offset. I am aware that a similar issue was reported in March, but am not sure if this is that bug, a different one, or if I’m simply doing it wrong. At present I am attempting to follow the documentation, putting the offset coordinates as the last two columns in the dataframe. However, the beach-balls do not offset from their point of origin.
@hazardgoat I saw your private message about deleting the post, but I believe the post is good and I think it was accidentally flagged as inappropriate.
Back to your question: yes, it’s a bug of the PyGMT “meca” wrapper, and currently you have to write the mechanism information into a file, and then pass the file the spec, i.e., the following code should work:
Thank you @seisman. I tried using the file directly instead of a dataframe and when I did no focal mechanisms were plotted at all. I’ve attached the table I’m using for the focal mechanismsselected_focal_mechanisms.txt (397 Bytes) .
I really do appreciate you helping me with this. I have reordered and renamed my table and while it now plots the focal mechanisms, they still do not offset from their point of origin. The offset column values are just printed above each focal mechanism. I’ve attached my updated table file.selected_focal_mechanisms.txt (418 Bytes)
You’ll want to use this code for the fig.meca function if you’re attempting to plot focal mechanisms using the ‘aki’ format and coloring the beach-balls by depth:
SomeDataFrame = pd.read_csv(SomeDataFile, sep='\t')
pygmt.makecpt(
cmap = 'magma', # sets the cpt to one of the named built-in ones
reverse = True, # reverse the color scale of the cpt
series = [SomeDataFrame.SomeColumn.min(), SomeDataFrame.SomeColumn.max()] # sets the value range by which to assign colors. In this case, by using the min and max values of a column from some dataframe
)
fig.meca(
spec = SomeDataFile, # tab separated csv file
convention = 'aki', # convention for columns (strike, dip, rake, magnitude)
scale = '1.0c', # size scale in centimeters for the focal mechanism beach-balls
C = True, # sets cmap for coloring beach-balls by some column to true
offset = True, # sets function to read from the offset columns in the data file
)
The data file must be a tab separated csv file if you want to offset the focal mechanism beach-balls. For the ‘aki’ convention, the column format needs to be in the order of longitude, latitude, depth, strike, dip, rake, magnitude, offset_longitude, offset_latitude, label. You don’t need a label column, but if you choose to have one it will plot the text above each beach-ball. There is however another quirk/bug where the column labels are printed in the very bottom left corner of the map. Removing the column names from the csv file solves this issue.
Thank you for the response. I use PyGMT 0.5.0. Finally, I made it. I used the data in .dat format, and it worked very well. But can you help me to make a text for the beachball?