diff --git a/src/NanoVNASaver/About.py b/src/NanoVNASaver/About.py index 8625a96d..7fe05f3c 100644 --- a/src/NanoVNASaver/About.py +++ b/src/NanoVNASaver/About.py @@ -19,7 +19,7 @@ from setuptools_scm import get_version try: - version = get_version(root='..', relative_to=__file__) + version = get_version(root='../..', relative_to=__file__) except LookupError: from NanoVNASaver._version import version diff --git a/src/NanoVNASaver/Windows/TDR.py b/src/NanoVNASaver/Windows/TDR.py index a8c03049..1f57e132 100644 --- a/src/NanoVNASaver/Windows/TDR.py +++ b/src/NanoVNASaver/Windows/TDR.py @@ -138,14 +138,23 @@ def updateTDR(self): return s11 = [complex(d.re, d.im) for d in self.app.data.s11] - window = np.blackman(len(self.app.data.s11)) + s11 = np.array(s11) + s11 = np.concatenate([s11, np.conj(s11[-1:0:-1])]) # Include negative frequencies + s11 = np.fft.fftshift(s11) + + window = np.blackman(len(s11)) + windowed_s11 = window * s11 # Now windowing eliminates higher frequencies while leaving low frequencies untouched + + pad_points = (FFT_POINTS - len(windowed_s11)) // 2 + windowed_s11 = np.pad(windowed_s11, [pad_points + 1, pad_points]) # Pad array to length FFT_POINTS + windowed_s11 = np.fft.ifftshift(windowed_s11) + + td = np.fft.ifft(windowed_s11) - windowed_s11 = window * s11 - td = np.abs(np.fft.ifft(windowed_s11, FFT_POINTS)) step = np.ones(FFT_POINTS) step_response = convolve(td, step) - self.step_response_Z = 50 * (1 + step_response) / (1 - step_response) + self.step_response_Z = np.abs(50 * (1 + step_response) / (1 - step_response)) #Can plot impedance in terms of real and imaginary too time_axis = np.linspace(0, 1 / step_size, FFT_POINTS) self.distance_axis = time_axis * v * speed_of_light