Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix About.py bug and fix math for TDR #715

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/NanoVNASaver/About.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 13 additions & 4 deletions src/NanoVNASaver/Windows/TDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading