-
Notifications
You must be signed in to change notification settings - Fork 224
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
beachball offsetting doesn't work for pandas/dict/ndarray input #2016
Comments
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct. |
The
After installing the PyGMT dev version, you'll see that it still doesn't work as expected, but at least setting |
Hi, I upgraded to v0.7.0 . I am not sure that I understand you correctly. I don't mind reading in the file in separately, I only mind that I cannot offset the beachballs. If that also will not work in the dev-version, I'd rather stick to the normal version, or does it? (It does not seem to work in v0.7.0, either.) |
The following script works for me with both PyGMT v0.7.0 and the dev version:
The output image is: |
OK, great, thanks! It now works for me in v0.7.0 as well as long as I directly read the file using meca and not go via pandas. |
I think the same problem occurs when passing a dictionary (dict) to import pygmt
#------------------------------------------------------------------------------
# set up dictonary
dict_meca = {
"longitude": 1,
"latitude": 52,
"depth": 10,
"strike": 100,
"dip": 50,
"rake": 20,
"magnitude": 5,
"plot_longitude": 1,
"plot_latitude": 53,
}
#------------------------------------------------------------------------------
# create figure object
fig = pygmt.Figure()
fig.coast(
region="-2/2/51/55",
projection="M15c",
land="lightgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
)
fig.meca(
spec=dict_meca,
convention="aki",
scale="2c",
G="red",
offset=True,
)
fig.show() The beachball should be offset to latitude 53, but is plotted at latitude 52, which is the event latitude: |
As a workaround for PyGMT v0.7.0, if you can set your dict_meca = {
"longitude": 1,
"latitude": 52,
"depth": 10,
"strike": 100,
"dip": 50,
"rake": 20,
"magnitude": 5,
"plot_longitude": "1",
"plot_latitude": "53",
} should give: Notice how the beachball is now at 53N instead of 52N. For those using This will be fixed properly in #2202 (so that numeric int/float inputs will work) and should be available in the upcoming PyGMT v0.8.0. Thanks @seisman for identifying the issue! |
For me stetting the arguments for Example script import pygmt
# use dictonary to provided focal mechanism data (aki convention)
dict_meca = {
"longitude": 0,
"latitude": 0,
"depth": 12,
"strike": 330,
"dip": 30,
"rake": 90,
"magnitude": 5,
# "plot_longitude": 2,
# "plot_latitude": 2,
"plot_longitude": "2", # trick use string input
"plot_latitude": "2",
}
fig = pygmt.Figure()
fig.basemap(
region=[-5, 5, -5, 5],
projection="X10c",
frame="afg",
)
fig.meca(
spec=dict_meca,
convention="aki",
scale="1c",
offset=True,
)
fig.show() Error message
Output of pygmt.show_versions()
|
An other aspect is, that the line and the small circle are not plotted or modified via the Example script import pygmt
#------------------------------------------------------------------------------
# (I) read focal mechanism data from input file (aki convention)
fig = pygmt.Figure()
fig.basemap(
region=[-5, 5, -5, 5],
projection="X10c",
frame="afg",
)
fig.meca(
spec="gmt_meca_doc.txt",
scale="1c",
offset="+p1p,green+s0.5c", # line thickness and color, size of circle
convention="aki",
)
fig.show()
# fig.savefig(fname="meca_offset_line_file.png")
# ------------------------------------------------------------------------------
# (II) use dictionary to provided focal mechanism data (aki convention)
dict_meca = {
"longitude": 0,
"latitude": 0,
"depth": 12,
"strike": 330,
"dip": 30,
"rake": 90,
"magnitude": 5,
"plot_longitude": 2,
"plot_latitude": 2,
}
fig = pygmt.Figure()
fig.basemap(
region=[-5, 5, -5, 5],
projection="X10c",
frame="afg",
)
fig.meca(
spec=dict_meca,
convention="aki",
scale="1c",
offset="+p1p,green+s0.5c", # line thickness and color, size of circle
)
fig.show()
# fig.savefig(fname="meca_offset_line_dict.png") Output figure for (I) reading a txt file (expectation) Output figure for (II) using a dictionary Output of pygmt.show_versions()
|
Yes, the source code of the
I can confirm that this is a bug caused by Line 299 in b22495d
You can make a fix if you want. |
Done via PR #2226. |
Thanks! I see the updated issue title. Hm, then bump this back to v0.9.0 🙂? |
I'll see if I can finish it before v0.8.0. |
I'm bumping this issue to v0.9.0 because beachball offsetting for ndarray input is more tricky than I initially thought so I can't finish it soon. |
Do you have time to work on this before end of March 2023? Or should we bump this to PyGMT v0.10.0? |
I'll give it another try in the following week. |
I am trying to plot focal mechanisms on a map with an offset. I’ve tried to follow the tips given here:
[ PyGMT: How to offset focal mechanism beachballs?]
but still cannot get it to work, the two beachballs in the southeast are still plotted on top of each other, although there is no error message.
My file contains the columns
longitude latitude depth strike dip rake magnitude plot_longitude plot_latitude
and columns are separated by tabs:
|longitude|latitude|depth|strike|dip|rake|magnitude|plot_longitude|plot_latitude|
|1.4421|51.2819|15.5|47.28|32.05|112.09|4.5|1.4421|52|
|1.3884|51.3337|17|69.84|25.88|151.52|4.5|0.75|51.3337|
|-0.055|53.648|19.3|21.33|84.92|-19.37|4.1|-0.055|53.648|
|-1.314|54.594|4.6|102.1|84.1|-162|3.1|-1.314|54.594|
FM_ISC_exampleplot.txt
I reported that issue on the GMT community forum
[Pygmt psmeca beachball - no offset despite following tips from previous post]
Full code that generated the error
Full error message
System information
Please paste the output of
python -c "import pygmt; pygmt.show_versions()"
:The text was updated successfully, but these errors were encountered: