Simu:8.1 Phase Delay finally working

This commit is contained in:
Eric Teunis de Boone 2022-08-04 20:33:59 +02:00
parent 657d1d1870
commit 95e3af3d94
2 changed files with 478 additions and 3 deletions

View file

@ -47,13 +47,20 @@ def time2phase(time, frequency=1):
def phase2time(phase, frequency=1): def phase2time(phase, frequency=1):
return phase/(2*np.pi*frequency) return phase/(2*np.pi*frequency)
def time_roll(a, samplerate, time_shift, *roll_args, int_func=lambda x: np.rint(x).astype(int), **roll_kwargs): def phase_modulo(phase, low=np.pi):
"""
Modulo phase such that it falls within the
interval $[-low, 2\pi - low)$.
"""
return (phase + low) % (2*np.pi) - low
def time_roll(a, samplerate, time_shift, sample_shift=0, int_func=lambda x: np.rint(x).astype(int), **roll_kwargs):
""" """
Like np.roll, but use samplerate and time_shift to approximate Like np.roll, but use samplerate and time_shift to approximate
the offset to roll. the offset to roll.
""" """
shift = int_func(time_shift*samplerate) shift = int_func(time_shift*samplerate + sample_shift)
return np.roll(a, shift, *roll_args, **roll_kwargs) return np.roll(a, shift, **roll_kwargs)
### signal generation ### signal generation
def fft_bandpass(signal, band, samplerate): def fft_bandpass(signal, band, samplerate):

File diff suppressed because one or more lines are too long