From 0f7c397a8a024d5bf93cea5222c7bdd0d5ac74de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Sun, 31 Jan 2021 13:18:31 +0100 Subject: [PATCH] Bugfix 2xthru --- Software/PC_Application/VNA/Deembedding/twothru.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Software/PC_Application/VNA/Deembedding/twothru.cpp b/Software/PC_Application/VNA/Deembedding/twothru.cpp index 7bd510c..2dce573 100644 --- a/Software/PC_Application/VNA/Deembedding/twothru.cpp +++ b/Software/PC_Application/VNA/Deembedding/twothru.cpp @@ -80,7 +80,8 @@ void TwoThru::transformDatapoint(Protocol::Datapoint &p) partial_sum(t212x.begin(), t212x.end(), t212x.begin()); // find the midpoint of the trace - auto mid = lower_bound(t212x.begin(), t212x.end(), 0.5, [](complex p, double c) -> bool { + double threshold = 0.5*real(t212x.back()); + auto mid = lower_bound(t212x.begin(), t212x.end(), threshold, [](complex p, double c) -> bool { return real(p) < c; }) - t212x.begin(); @@ -135,7 +136,8 @@ void TwoThru::transformDatapoint(Protocol::Datapoint &p) partial_sum(t212x.begin(), t212x.end(), t212x.begin()); // find the midpoint of the trace - auto mid = lower_bound(t212x.begin(), t212x.end(), 0.5, [](complex p, double c) -> bool { + double threshold = 0.5*real(t212x.back()); + auto mid = lower_bound(t212x.begin(), t212x.end(), threshold, [](complex p, double c) -> bool { return real(p) < c; }) - t212x.begin(); @@ -167,7 +169,7 @@ void TwoThru::transformDatapoint(Protocol::Datapoint &p) // create S parameter errorbox for(unsigned int i=1;i<=n;i++) { - data_side2.push_back(Sparam(p111x[i], p211x[i], p211x[i], data_side1[i-1].m22)); + data_side2.push_back(Sparam(data_side1[i-1].m22, p211x[i], p211x[i], p111x[i])); data_side1[i-1].m22 = p221x[i]; } }