Allow GMT_Put_Vector to convert other text items than datetime - #4849
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).
commented
Feb 24, 2021
|
Just built this branch and ran the full PyGMT tests, the GMT_DATETIME implementation works like before. |
commented
Feb 24, 2021
|
Great, maybe @weiji14 could test Lon lat inputs |
commented
Feb 24, 2021
|
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., |
commented
Feb 24, 2021
|
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 |
commented
Feb 24, 2021
|
@seisman, this PR is now more align with your suggestion. |
commented
Feb 26, 2021
|
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 <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
commented
Feb 28, 2021
|
@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. |
commented
Feb 28, 2021
|
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.