proper way to upsample/interpolate a wave given 2 time waves?

I currently have 2 sets of waves:  number, number_time, and areax, area_time  where

numpnts(number) == numpnts(number_time)
and
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

Function line_interp2(data,data_time,interp_time)

    wave data, data_time, interp_time
   
    variable a,b,x0,x1,y0,y1,i,j,k
   
    make/O/d/N=(numpnts(interp_time)) data_interp
   
    for(i=128;i<numpnts(data_time);i+=1)
    j = floor(binarysearchinterp(data_time,interp_time[i]))
    k = floor(BinarySearchinterp(data_time, interp_time[i+1]))
    if(j==k)
        k = ceil(BinarySearchinterp(data_time, interp_time[i+1]))
    endif
    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
   
    endfor

End

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?

 

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?

The other way around, I believe. Waveform means equal spacing in x, hence x data are not needed. You have unequally spaced x (in the wave number_time).

If you wish to interpolate, a good starting point is to select Interpolate from the Analysis menu and use the dialog to obtain the interpolation you desire. The interpolate command will be generated for you and can be used as a template for your own code.

After you have experimented with the user-friendly dialog, take a look at

displayHelpTopic "interpolate2"

You could resample to create waveform data, or you could create new X-Y pairs to match the sampling you have in area_time.