I have two sensors measuring the same thing over time. They don't sample at the same rate and one of them samples at irregular times. The start times recorded by the sensors are also not the same (their clocks aren't in sync.. and I can't change that). Still, they sample often enough that it's obviously the same function and the human eye has no trouble aligning them.
I want to align the data, which involves some combination of stretching and shifting the arrays (something in scipy.signal?). I'm totally fine with using a solver to do this.. I'm just not sure how to do it.
I found a few posts where people had just shifted the data or simply resampled time series data that's taken at regular intervals. But I can't find a problem that's as much of a mess as mine, unfortunately. I'm not entirely sure that this is possible without resampling the irregularly sampled data to make it regular and then doing the stretch/shift... but I'm not sure how to do any of those three things. This seems like a signal processing problem that people have surely run across before. Is there a canonical answer to this?
Here's an example of the sort of data:
x = np.arange(-2,2,0.01)
def f(x):
return x**2
# Now find a bunch of random indices to represent the irregular sampling by one sensor
x1 = np.sort((np.array((np.random.random(20)*4-2)*100).astype(int))/100)
# sample this one at regular intervals
x2 = x[::19]
fig,ax = plt.subplots(1,3,figsize=(8,3))
ax[0].plot(x,f(x))
ax[1].scatter(x1,f(x1),color=[0,0,1,0.5])
ax[1].plot(x1,f(x1),color=[0,0,0,0.2])
ax[2].scatter(x2,f(x2),lw=1,color=[0,.5,.5,.5])
ax[2].plot(x2,f(x2),color=[0,0,0,0.2]);