-
Notifications
You must be signed in to change notification settings - Fork 381
Allow GMT_Put_Vector to convert other text items than datetime #4849
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
Conversation
While we already support a type of GMT_DATETIME, this PR adds support for incoming text strings via GMT_TEXTLON, GMT_TEXTLAT, and GMT_TEXT (Cartesian values).
Just built this branch and ran the full PyGMT tests, the GMT_DATETIME implementation works like before. |
Great, maybe @weiji14 could test Lon lat inputs |
As for the new data types, GMT_TEXTLON, GMT_TEXTLAT, and GMT_TEXT, does it mean that PyGMT has to know the data types before passing to GMT? For example, if the string is I'm wondering if we can simply pass any strings (e.g., |
We could automatically determine type and give an error if more than one, e.g., both time and latitude since a column must only have one type |
@seisman, this PR is now more align with your suggestion. |
It works well with a simple test (see GenericMappingTools/pygmt#975 for the example script and output). Need to do more testing later. So please keep the PR open for a few more days. |
Co-authored-by: Dongdong Tian <[email protected]>
Co-authored-by: Dongdong Tian <[email protected]>
Co-authored-by: Dongdong Tian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@weiji14 Could you please bump the GMT dev version again in the conda-forge channel, so that we can better test the new GMT_TEXT data type. |
Ok, I'll do that in a bit |
See this post for background. While we added support for GMT_DATETIME last year, this PR generalizes the conversion from text to numbers via the type GMT_TEXT. The strings may be either Cartesian numbers, datetime, longitude, or latitude, and we also allow these to be converted to other internal representations than GMT_DOUBLE (e.g., GMT_FLOAT, GMT_LONG, etc.) via logical addition (e.g., pass type as GMT_TEXT|GMT_FLOAT).
I have left the prior scheme of GMT_DATETIME for datetime so we are backwards compatible, but one now only needs to select GMT_TEXT and GMT figures out what you passed, hopefully. We assume each column has the same type and there is no error checking if you pass both time and longitude as part of a single column. I added testapi_putvector.c and calling script apiputvector.sh which demonstrates that it works.
I think a quick test and this can be approved and merged.