proper way to upsample/interpolate a wave given 2 time waves?
Tue, 02/12/2019 - 05:27 am
I currently have 2 sets of waves: number, number_time, and areax, area_time where
numpnts(areax) == numpnts(area_time)
numpnts(area_time) > numpnts(number_time)
currently I am using these as waveform, I think? Unfortunately, (number_time[i] - number_time[i-1]) is not necessarily uniform over the length of the wave (same for area_time). If I understand correctly, this prevents me from using the XY pairs form of data?
I would like to interpolate number to the higher time resolution of area_time such that
numpnts(number_interp) == numpnts(area_time)
I've tried something like
wave data, data_time, interp_time
j = floor(binarysearchinterp(data_time,interp_time[i]))
k = floor(BinarySearchinterp(data_time, interp_time[i+1]))
k = ceil(BinarySearchinterp(data_time, interp_time[i+1]))
x0 = data_time[j]
x1 = data_time[k] //obviously almost all of this for loop can be condensed to 1 line
y0 = data[j] //writing it all out for debugging purposes
y1 = data[k]
a = interp_time[i]
b = y0 + (a-x0) * (y1 - y0)/(x1-x0)
data_interp[i] = b
but this creates a lot of ringing and stepwise behavior that doesn't exist in the number wave.
I've also tried more simply just using BinarySearchInterp but it's apparently the exact same thing as what I wrote out above.
I have tried using the same data in R and I can get at least the correct shape of the curve using the approx function
e.g. number_interp <- approx(number[,"number_Time"], data[,"number_tot"], method = "linear")
is there a good way to do this in igor?