Skip to content

Commit e5ffb83

Browse files
committed
removed dc offset
1 parent 0b89f79 commit e5ffb83

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python_hackrf/pyhackrf_tools/pyhackrf_sweep.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ cpdef int sweep_callback(c_pyhackrf.PyHackrfDevice device, cnp.ndarray[cnp.int8_
117117
cdef uint64_t start_frequency = device_data['start_frequency']
118118

119119
cdef cnp.ndarray fftOut
120+
cdef cnp.ndarray raw_iq
120121
cdef cnp.ndarray pwr
121122

122123
cdef uint32_t fft_1_start = 1 + (fft_size * 5) // 8
@@ -160,7 +161,9 @@ cpdef int sweep_callback(c_pyhackrf.PyHackrfDevice device, cnp.ndarray[cnp.int8_
160161

161162
index += (pyhackrf.PY_BYTES_PER_BLOCK - data_length)
162163

163-
fftOut = fft((buffer[index:index + data_length:2] / 128 + 1j * buffer[index + 1:index + data_length:2] / 128) * window)
164+
raw_iq = buffer[index:index + data_length:2] / 128 + 1j * buffer[index + 1:index + data_length:2] / 128
165+
raw_iq -= raw_iq.mean()
166+
fftOut = fft(raw_iq * window)
164167
pwr = np.log10(np.abs(fftOut * norm_factor) ** 2) * 10.0
165168

166169
if sweep_style == pyhackrf.py_sweep_style.LINEAR:

0 commit comments

Comments
 (0)