Repository navigation
Running info on vector memory inputs return UNIX timestamps instead of ISO datetimes #4241
Copy link
Copy link
Closed
Description
Description of the problem
UNIX timestamps (e.g. 1577836800) are returned instead of ISO datetimes (e.g. 2020-01-01T00:00:00) when running info on virtual tables. Originally noticed at GenericMappingTools/pygmt#619 (comment), check also #3396 where datetime inputs were originally accepted into GMT_Put_Vector.
Full script that generated the error
Sorry that I can't write C code, but given an input like so:
z time
10 2020-01-01T00:00:00
13 2020-01-02T00:00:00
12 2020-01-03T00:00:00
15 2020-01-04T00:00:00
14 2020-01-05T00:00:00
and then running info from PyGMT from the branch at GenericMappingTools/pygmt#619 (each column is passed into C API using GMT_Put_Vector)
import pygmt
# create data array 'table' and pass it into `info`
pygmt.info(table=table, V="d")Full error message
gmtinfo [INFORMATION]: Processing input table data
gmtinfo [DEBUG]: gmtapi_init_import: Passed family = Data Table and geometry = Point|Line|Poly
gmtinfo (gmtapi_init_import): tried to free unallocated memory
gmtinfo [DEBUG]: gmtapi_init_import: Added 1 new sources
gmtinfo [DEBUG]: GMT_Init_IO: Returned first Input object ID = 0
gmtinfo [DEBUG]: gmtapi_init_export: Passed family = Data Table and geometry = Point|Line|Poly
gmtinfo [DEBUG]: Object ID 1 : Registered Data Table File /tmp/pygmt-gykf5n3t.txt as an Output resource with geometry Point|Line|Poly [n_objects = 2]
gmtinfo [DEBUG]: gmtapi_init_export: Added 1 new destination
gmtinfo [DEBUG]: GMT_Init_IO: Returned first Output object ID = 1
gmtinfo [DEBUG]: GMT_Begin_IO: Mode value 1 not considered (ignored)
gmtinfo [DEBUG]: GMT_Begin_IO: Initialize record-by-record access for Input
gmtinfo [DEBUG]: gmtapi_next_io_source: Selected object 0
gmtinfo [INFORMATION]: Reading Data Table from Input memory location via vector
gmtinfo [DEBUG]: GMT_Begin_IO: Input resource access is now enabled [record-by-record]
gmtinfo [DEBUG]: GMT_Begin_IO: Initialize record-by-record access for Output
gmtinfo [DEBUG]: gmtapi_next_io_source: Selected object 1
gmtinfo [INFORMATION]: Writing Data Table to file /tmp/pygmt-gykf5n3t.txt
gmtinfo [DEBUG]: GMT_Begin_IO: Output resource access is now enabled [record-by-record]
gmtinfo [DEBUG]: Number of numerical output columns has been set to 0
gmtinfo [DEBUG]: GMT_End_IO: Input resource access is now disabled
gmtinfo [DEBUG]: GMT_End_IO: Output resource access is now disabled
gmtinfo (GMT_gmtinfo): tried to free unallocated memory
gmtinfo (GMT_gmtinfo): tried to free unallocated memory
gmtinfo [DEBUG]: gmtlib_unregister_io: Unregistering object no 1 [n_objects = 1]
gmtinfo (gmtlib_free_tmp_arrays): tried to free unallocated memory
Actual outcome
<vector memory>: N = 5 <10/15> <1577836800/1578182400>
Expected outcome
<vector memory>: N = 5 <10/15> <2020-01-01T00:00:00/2020-01-05T00:00:00>
System information
- Operating system: Linux
- GMT version (
gmt --version): 6.1.1
Metadata
Metadata
Assignees
Labels
No labels
Activity
PaulWessel commentedon Sep 20, 2020
Hm, yes since what is returned is a text record I agree there is no good reason it should not be formatted as you expect here. If -C was used then you would get a numerical record and it would have UNIX time of course, but here it is text. I will try to have a look as to why it is not doing the formatting.
PaulWessel commentedon Sep 20, 2020
I would like to add another section to the DEVELOPER RESOURCES sidebar on debugging, for how to debug pyGMT via Xcode on macOS. Been a month since last time and cannot find all the step that @seisman helped with. Since I am a complete python rookie there is not much mental memory on even the most basics, so I need that recipe, which also had some issues with setting shared-dir and possibly library paths for all to work. Maybe @seisman could resurrect his instructions and I can turn it into a section in the developer RST?
PaulWessel commentedon Sep 20, 2020
And @joa-quim has given similar instructions for setting up GMT.jl so I can debug cases he finds directly in Xcode as well?
weiji14 commentedon Sep 20, 2020
Issue is at #3778. I should probably start to learn C too at some point 😆
seisman commentedon Sep 20, 2020
The steps to debug PyGMT via Xcode was discussed in #3829.
Here is a summary:
GMT_LIBRARY_PATHjoa-quim commentedon Sep 20, 2020
Please, please join the Force.
Debugging from any of the environments (Matlab, Julia, Python) should all the same procedure.
RETURNseisman commentedon Sep 20, 2020
@weiji14 Perhaps we should merge GenericMappingTools/pygmt#619 first (mark the tests as
xfail) and provide a minimal Python script to reproduce the issue. Your example above is incomplete, and @PaulWessel will need to rewrite a working script before debugging.joa-quim commentedon Sep 20, 2020
Ofc, on Unix everything is more complicated 😈
weiji14 commentedon Sep 20, 2020
http://www.nooooooooooooooo.com/
Yeah, I'm on Linux which doesn't seem to have Xcode 🤷
Yep, give me a few minutes to finish up that PR.
PaulWessel commentedon Sep 20, 2020
Yes, it would be great if a snipped of Python code demonstrating the problem is submitted since that is not something I will know how to do. Same with Julia of course and @joa-quim usually posts a Julia command or mex command. We just want to lower the threshold for all of us to do these things. Even C-novices should be able to step in the the C library and at least detect where a crash happens - often that is enough of a clue for the C-team to figure things out.
joa-quim commentedon Sep 20, 2020
Good question for Linux. I guess that
gccshould have an equivalent mechanism to Attach to process ID and from that on, the doing should be the same ... except that usinggdbis an act of masochism.PaulWessel commentedon Sep 20, 2020
On Linux, I have done lots of debugging using ddd, and even on macOS before Apple switched to clang and it became a bit harder (and I have not paid too much attention). But I dont know if you can connect to the process in ddd the same way we do in Xcode or Visual Studio.
PaulWessel commentedon Sep 20, 2020
ddd is just a graphical front-end to gdb which I assume can connect to other processes.
PaulWessel commentedon Sep 21, 2020
@joa-quim, do you mind posting the usual setup for a newbie to install GMT.jl from the developer version, including installing julia. I know you have some of that on your site but it would help me put the docs together if you can (like @seisman) cut/paste in here while I am thinking about this.
weiji14 commentedon Sep 21, 2020
Ok, GenericMappingTools/pygmt#619 has been merged, and I'm starting to have a go at debugging using gdbgui (installed via
pip install gdbgui). Will see if I can figure this out. Below is the Python code to run after following PyGMT installation instructions (pip install https://github.com/GenericMappingTools/pygmt/archive/master.zip), and launching Python:27 remaining items
stale commentedon Jan 23, 2021
This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions.
Let pygmt.info load datetime columns into a str dtype array
Let pygmt.info load datetime columns into a str dtype array (#960)
maxrjones commentedon Mar 14, 2021
@weiji14 the output appears as you wanted it - is this because of workarounds implemented in PyGMT? Would you be able to provide an example that still demonstrates the bug for debugging purposes?
weiji14 commentedon Mar 14, 2021
Hmm, you might be right! I see that the these two units tests at https://github.com/GenericMappingTools/pygmt/blob/v0.3.1/pygmt/tests/test_info.py#L67-L107 are passing on GMT master (i.e. 6.2.0) now at the GMT Latest tests (https://github.com/GenericMappingTools/pygmt/runs/2104362367?check_suite_focus=true#step:14:324). Not sure when this got fixed 😅
Just to double check, could you try this example out (passing in only one datetime column from a numpy array).
maxrjones commentedon Mar 14, 2021
Output looks good, I think:
weiji14 commentedon Mar 14, 2021
Nice, I'll close this issue then and wait for GMT 6.2.0 to be released. Thanks everyone!
maxrjones commentedon Mar 14, 2021
Fixed by #4849
Let pygmt.info load datetime columns into a str dtype array (GenericM…