[An update is added at the end of the post after receiving first response]
I have an algorithm which is very sensitive to phase shifts. It works with signal sampled at 40MHz (it's a neural network so actually the sampling rate is not very flexible)
I have a data sampled at 21.818e6 MHz and I resample it to ~40 MHz by:
sample_cnt = len(test_data) Fs_org = 21.818e6 Fr = 40e6 resam_cnt = np.floor(Fr * sample_cnt / Fs_org) test_data_re = scipy.signal.resample(test_data, resam_cnt.astype(int), axis=0)
test_data is sensor data with 1704 sample numbers so (1704,1).
When I look at frequency spectrum and phase response of the resampled data the frequency spectrum matches original signal (it's a bandpass signal with center frequency of 5MHz) but phase response for higher frequencies is flat (see image).
pyolt.figure() pyplt.phase_spectrum(test_data_re, Fr, fc=5e6) pyplt.phase_spectrum(test_data, Fs_org, fc=5e6)
Blue line is corresponded to the phase response of resampled data and orange line is corresponded to original data which is overlapped on the resampled data.
1- Is this resampling correct?
2- Is there a solution to create any kind of corresponding phase information for higher frequencies?
I resampled same data with Matlab:
Then saved the data, loaded in python and compared two resampled signal (see image)
The blue one is the python resampled data and the orange one is the matlab resampled data
I do agree with @Hilmar that "When you re-sample you extend the frequency range, but the energy at these new frequencies (between 11 MHz and 20 MHz) is close to or exactly zero. That's the whole point of a "good" interpolation: make sure you don't add stuff that wasn't there before.
That means the phase at the new frequencies is either undefined or doesn't really matter since there is no relevant energy. If the magnitude is zero, it doesn't matter what the phase is"
Now it rises this question that how come Matlab is creating phase information in those frequencies?