thinking fft
This commit is contained in:
@ -513,14 +513,45 @@ class ProcessingTests(unittest.TestCase):
|
||||
bins = 8
|
||||
axis = compute_distance_axis(freqs, bins, mode="positive_only_exact")
|
||||
|
||||
df_hz = 1e9
|
||||
n_shift = int(np.arange(-6.0, 6.0 + 0.5, 1.0, dtype=np.float64).size)
|
||||
# With a small bins budget the exact-mode grid is downsampled so
|
||||
# internal IFFT length does not exceed visible bins.
|
||||
df_hz = 2e9
|
||||
n_shift = int(np.arange(-6.0, 6.0 + 1.0, 2.0, dtype=np.float64).size)
|
||||
expected_step = C_M_S / (2.0 * n_shift * df_hz)
|
||||
expected = np.arange(bins, dtype=np.float64) * expected_step
|
||||
|
||||
self.assertEqual(axis.shape, (bins,))
|
||||
self.assertTrue(np.allclose(axis, expected))
|
||||
|
||||
def test_positive_only_exact_mode_remains_stable_when_input_points_double(self):
|
||||
bins = FFT_LEN // 2 + 1
|
||||
tau_s = 45e-9
|
||||
|
||||
freqs_400 = np.linspace(3.3, 14.3, 400, dtype=np.float64)
|
||||
freqs_800 = np.linspace(3.3, 14.3, 800, dtype=np.float64)
|
||||
sweep_400 = np.exp(-1j * 2.0 * np.pi * freqs_400 * 1e9 * tau_s).astype(np.complex64)
|
||||
sweep_800 = np.exp(-1j * 2.0 * np.pi * freqs_800 * 1e9 * tau_s).astype(np.complex64)
|
||||
|
||||
mag_400 = compute_fft_mag_row(sweep_400, freqs_400, bins, mode="positive_only_exact")
|
||||
mag_800 = compute_fft_mag_row(sweep_800, freqs_800, bins, mode="positive_only_exact")
|
||||
|
||||
self.assertEqual(mag_400.shape, mag_800.shape)
|
||||
finite = np.isfinite(mag_400) & np.isfinite(mag_800)
|
||||
self.assertGreater(int(np.count_nonzero(finite)), int(0.95 * bins))
|
||||
|
||||
idx_400 = int(np.nanargmax(mag_400))
|
||||
idx_800 = int(np.nanargmax(mag_800))
|
||||
peak_400 = float(np.nanmax(mag_400))
|
||||
peak_800 = float(np.nanmax(mag_800))
|
||||
|
||||
self.assertLess(abs(idx_400 - idx_800), 64)
|
||||
self.assertGreater(idx_400, 8)
|
||||
self.assertGreater(idx_800, 8)
|
||||
self.assertLess(idx_400, bins - 8)
|
||||
self.assertLess(idx_800, bins - 8)
|
||||
self.assertGreater(peak_400, 0.05)
|
||||
self.assertGreater(peak_800, 0.05)
|
||||
|
||||
def test_resolve_visible_fft_curves_handles_complex_mode(self):
|
||||
complex_row = np.asarray([1.0 + 2.0j, -3.0 + 4.0j], dtype=np.complex64)
|
||||
mag = np.abs(complex_row).astype(np.float32)
|
||||
|
||||
Reference in New Issue
Block a user