x2sys_cross: Refactor to get rid of temporary files and have consistent table-like output behavior #3160
Labels
maintenance
Boring but important stuff for the core devs
Milestone
Originally posted by @weiji14 in #2730 (comment)
I had a look at refactoring
x2sys_cross
to use virtualfiles instead of temporary files, but it's a little tricky because:Input: Cannot pass in virtualfiles as input as mentioned at Wrap x2sys_init and x2sys_cross #546 (comment) and Passing in virtual files into the supplementary x2sys modules gmt#3717, since GMT doesn't support virtualfiles to X2SYS modules
Output: The
virtualfile_to_dataset
method from clib: Add virtualfile_to_dataset method for converting virtualfile to a dataset #3083 was able to produce apandas.DataFrame
output, but the column names were missing. The logic for handlingx2sys_cross
's output is actually complicated:pygmt/pygmt/src/x2sys_cross.py
Lines 231 to 250 in bcbbcad
Important things to handle are:
datetime64
dtypex2sys_cross
may output multi-segment parts (see https://docs.generic-mapping-tools.org/6.5/supplements/x2sys/x2sys_cross.html#remarks) when multiple tracks are passed in and-Qe
(external COEs) is selected. Unsure how this is handled in GMT virtualfiles (note that we actually just merge all the multi-segments into one table when pandas.DataFrame output is selected, output to file will preserve the segments though).z_X
/z_M
orz_1
/z_2
depending on whether trackvalues/-Z
argument is set.It should be possible to handle 1 and 3 somehow, but I'm not so sure about 2 since it will involve checking how GMT outputs virtualfiles in
x2sys_cross
. We'll need to do some careful checking to ensure the refactoring doesn't modify the output and makes it incorrect.The text was updated successfully, but these errors were encountered: