Skip to content
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

GMT_Put_Vector: Fix a bug when passing longitude/latitude strings #8600

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

seisman
Copy link
Member

@seisman seisman commented Oct 15, 2024

Here is the PyGMT script to reproduce the issue. The expected output is [-25.5, -12.5], but the actual output is [334.5, 347.5].

In [1]: import pygmt

In [2]: pygmt.info([["12:30S"], ["25:30S"]], per_column=True)
Out[2]: array([334.5, 347.5])

The bug exists in the GMT_Put_Vector function. In this function, GMT checks if the last character of a text string is one of E, N, S, W, to determine if the strings should be parsed as longitude/latitudes.

Here, L is the length of the first string so text[L-1] should be the last character of the string, but GMT incorrectly checks text[L]. This PR fixes the bug, and after the fix it's correct:

In [1]: import pygmt

In [2]: pygmt.info([["12:30S"], ["25:30S"]], per_column=True)
Out[2]: array([-25.5, -12.5])

@seisman seisman merged commit 1173862 into master Oct 15, 2024
14 of 18 checks passed
@seisman seisman deleted the fix/put-vector branch October 15, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants