here's current file. i think i'd like to change the test data to be a low frequency square wave. then it is easy to debug by inspection; and it may already work fine, the issues stemming only from high-magnitude high-frequency data that is not recorded for long enough. import numpy as np signal_bufsize = 1024 * 1024 recording_bufsize = signal_bufsize original_signal = np.random.random(signal_bufsize) recording = np.empty(recording_bufsize) period_length = len(original_signal) // recording_bufsize ** 0.5 * np.random.random() for out_idx in range(recording_bufsize): # using a loop because i am confused in_idx = int(out_idx * signal_bufsize / period_length) % signal_bufsize recording[out_idx] = original_signal[in_idx] recording_fft = np.fft.rfft(recording) # now take fft with np.fft.rfft # then select only upper portion of 1 + bandwidth equal to period_length # note: am guessing that period_in_recording = recording_bufsize / rfft_idx # so, solving for rfft_idx # rfft_idx = recording_bufsize / period_in_recording # and, if right, that would be the index in the rfft output of the period's peak # so further data on it would be to the right, at higher frequencies import pdb; pdb.set_trace() period_fft_idx = recording_bufsize / period_length fft_subregion = np.concatenate((recording_fft[:1],recording_fft[int(period_fft_idx):])) # then reconstruct using irfft [curious: is this complex output? what do the angles look like?] # then downsample original_signal to the bandwidth using averaging # then compare real values # NOTE: failure is expected AT FIRST. then, identify the mistake, and improve it. reconstructed_fft = fft_subregion original_fft = np.fft.rfft(original_signal) reconstructed_rfftsize = min(len(reconstructed_fft), len(original_fft)) // 2 reconstructed_from_reconstructed = np.fft.irfft(abs(reconstructed_fft[:reconstructed_rfftsize])) reconstructed_from_original = np.fft.irfft(abs(original_fft[:reconstructed_rfftsize]))