-
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
Segmentation fault if a grid has zero increments #1483
Segmentation fault if a grid has zero increments #1483
Comments
There is something wrong with your x and y coords. Printing the
as you can see, x and y coords are all zeros. |
That's true, I didn't notice. It's because of the way I'm building the |
I agree, but I'm not sure if the error should be done by PyGMT or by GMT. Ping @meghanrjones |
I think ideally it should be caught by both so that PyGMT users have a more readable call stack and other wrappers do not get the same problem. If the same grid is a actual file rather than a remote file, GMT catches the read error properly which suggests it is an API bug. We could pretty easily add a check for this case in the code section below. I cannot find this documented, but I think that GMT expects monotonically increasing, evenly spaced grids even though COARDS compliant grids can be monotonically increasing or decreasing. If this is the case, we could raise pygmt/pygmt/clib/conversion.py Lines 93 to 102 in d01da5a
|
I'll add the error. |
actually, GMT is handling well monotonically decreasing grid when passing with see example X, Y = np.meshgrid(np.linspace(0, -10, 10), np.linspace(0, -10, 10))
Z = X ** 2 + Y ** 2
da = xr.DataArray(
data=Z,
dims=['y', 'x'],
coords=dict(
x=(['x'], X[0, :]),
y=(['y'], Y[:, 0])
)
)
fig = pygmt.Figure()
fig.basemap(
frame='a',
projection=f"X10",
region=[-10, 0, -10, 0]
)
fig.grdimage(da)
fig.show() get us the following so maybe we should allow it and only raise an error when |
Sounds good. |
I'm reopening the issue because a similar fix should be done in the upstream GMT code. @PaulWessel @meghanrjones I think the problem is the API function |
Thanks for the information. @PaulWessel, I would like to work on fixing this issue. I'll submit a PR in the GMT repository for your feedback and ping if help is needed. We should remember to run gmt.jl tests before merging anything. |
grdimage
throwing a segmentation fault insted of some proper error when mistakenly swappingxarray
y and x coordination.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: