-
Notifications
You must be signed in to change notification settings - Fork 213
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
plot crashes when plotting arrows #406
Comments
I can reproduce the same crash, with GMT 6.0 on Linux and using the pygmt master branch. The corresponding code in GMT works though: gmt begin test png
gmt basemap -JX15c/10c -R400/600/5/8 -B
gmt plot -W1p,black+ve0.2c << EOF
530.0 6.0
530.0 7.0
EOF
gmt plot -W1p,black+ve0.2c << EOF
570.0 6.0
570.0 7.0
EOF
gmt end show produces: Not much of a clue as to why it's crashing though 🤷♂️ |
Also crushes on the second plot, but import pygmt
import numpy as np
fig = pygmt.Figure()
fig.basemap(projection="X15c/10c", region="400/600/5/8", frame=True)
fig.plot(x=[530, 530], y=[6.0, 7.0], pen='1p,black+ve0.2c')
fig.plot(x=[570, 570], y=[6.0, 7.0], pen='1p,black+ve0.2c')
fig.savefig("map.pdf") works fine fig.plot(x=[530, 530], y=[6.0, 7.0], pen='1p,black+ve0.2c')
fig.plot(x=[570.0, 570.0], y=[6.0, 7.0], pen='1p,black+ve0.2c') also works fine fig.plot(x=[530.0, 530.0], y=[6.0, 7.0], pen='1p,black+ve0.2c')
fig.plot(x=[570, 570], y=[6.0, 7.0], pen='1p,black+ve0.2c') does not work Seems like the issue is related to floating point numbers, |
I might have found a solution: import pygmt
import numpy as np
fig = pygmt.Figure()
fig.basemap(projection="X15c/10c", region="400/600/5/8", frame=True)
fig.plot(x=[np.float32(530.0), np.float32(530.0)], y=[6.0, 7.0], pen='1p,black+ve0.2c')
fig.plot(x=[np.float32(570.0), np.float32(570.0)], y=[6.0, 7.0], pen='1p,black+ve0.2c')
fig.savefig("map.pdf") Could it be that GMT does not have good support for float64 and uses float32 by default? |
External programs like PyGMT can pass dataset/momory to GMT. By default, GMT can read, modify and free the momery, which sometimes can cause crashes. Issue #406 reports an example in which PyGMT crashes. The issue was reported to the upstream (see GenericMappingTools/gmt#3515 and GenericMappingTools/gmt#3528). It turns out to be a API user error (i.e., a PyGMT bug). As per the explanation of Paul, external programs like PyGMT should always use `GMT_IN|GMT_IS_REFERENCE` to tell GMT that the data is read-only, so that GMT won't try to change and free the memory. This PR makes the change from `GMT_IN` to `GMT_IN|GMT_IS_REFERENCE` in the `Session.open_virtual_file()` function, updates a few docstrings, and also adds the script in #406 as a test.
External programs like PyGMT can pass dataset/momory to GMT. By default, GMT can read, modify and free the momery, which sometimes can cause crashes. Issue #406 reports an example in which PyGMT crashes. The issue was reported to the upstream (see GenericMappingTools/gmt#3515 and GenericMappingTools/gmt#3528). It turns out to be a API user error (i.e., a PyGMT bug). As per the explanation of Paul, external programs like PyGMT should always use `GMT_IN|GMT_IS_REFERENCE` to tell GMT that the data is read-only, so that GMT won't try to change and free the memory. This PR makes the change from `GMT_IN` to `GMT_IN|GMT_IS_REFERENCE` in the `Session.open_virtual_file()` function, updates a few docstrings, and also adds the script in #406 as a test.
Description of the problem
I'm trying to plot two vectors using the following script. It works well if pen is set to
1p,black
(i.e. a simple line), but crashes if set to1p,black+ve0.2c
. Actually, the first plot works, but the second one crashes.Full code that generated the error
Full error message
System information
conda list
below:output of conda list
The text was updated successfully, but these errors were encountered: