Sample1d: don't eliminate duplicate values

Hi all,

I recently updated to gmt 6.2.0 from 6.1.0 and am having trouble with one of the updates to sample1d. Originally, if I had a look-up table (lookup.xy) like this:

0 00
1 10
2 20

And sampled it at these points (sample.x):

0.5
1.5
1.9
1.5

Using “gmt sample1d -Fl -Tsample.x lookup.xy” would return:

0.5 5
1.5 15
1.9 19
1.5 15

But the updated version gives:

sample1d [WARNING]: Eliminated 1 duplicate values from the sorted array
0.5 5
1.5 15
1.9 19

I understand from this thread (Sample1d on gmt6.1 and gmt6.2) why this update was made, but is there a way to not skip the duplicates? Often I am stripping columns from a data file, using sample1d to find a corresponding value, and pasting things back together, which now doesn’t work when there happen to be duplicate values due to the rows no longer corresponding. Or am I using the wrong tool for the job?

Also, has a sorting procedure been added, such that the points are not necessarily returned in their original order?

Thanks a lot for your help!

Hm, yes I agree there really should not be any reason to ban duplicate points given via -T. Once the spline is defined by lookup.xy then you should be able to sample at any value and repeatedly. So not quite what the other thread was all about but I will need to check things as I do not want to break something we have fixed. I will have a look.

Hi Paul,

I was just wondering if this got fixed at some point? Or whether anyone came up with a workaround? I tried it in 6.3.0 with the same result.

Cheers!

Works fine in master so either build from github or wait for 6.4 (< 1 month):

gmt sample1d -Fl -Tlookup.xy sample.x
0.5 5
1.5 15
1.9 19
1.5 15

Thanks a lot! Much appreciated