In the fourier transform, the theorised signals are sampled at their peaks. The def signal(x) function above provides a signal that is +1 at the 0 sample, and -1 and the 1 sample. Multiplying this by the fourier signal gives +1 and +1 at each sample:
signal(np.array([0,1])) * np.exp(np.array([0,1]) * 2j * np.pi * freqs[1]) array([1.+0.j, 1.+0.j])
If the signal is offset, then these products give the phase of the offset:
signal(np.array([0.1,1.1])) * np.exp(np.array([0,1]) * 2j * np.pi * freqs[1]) array([0.95105652+0.30901699j, 0.95105652+0.30901699j]) abs(0.95105652+0.30901699j), np.angle(0.95105652+0.30901699j) * 180 // np.pi (1.0000000021715851, 17.0)
Offseting by 0.1 samples here makes a phase offset of 17 degrees. The output has a magnitude of 1.0 and a constant phase, at both samples. - So, if we have a scaled wave, that is not aligned with the samples, and we want to extract it precisely, we're going to be sampling it points other than its peaks. It will be sampled at a different point in its wave, each time. -> A transform that undoes the results of that product at non-peaks, and outputs a vector of units with constant angles, seems like it would be very useful there. It seems likely to me such a transform could recover the data precisely. <-