From 41a307485c2ccfa4d29545a5c44c1d23fb504f27 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 24 Apr 2023 18:59:58 +0200 Subject: [PATCH] my development version 0.5.5, fix #608 Signed-off-by: Martin --- NanoVNASaver/About.py | 2 +- NanoVNASaver/Analysis/EFHWAnalysis.py | 2 +- NanoVNASaver/Analysis/ResonanceAnalysis.py | 37 ++++++++-------------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/NanoVNASaver/About.py b/NanoVNASaver/About.py index 29c20eac..b56babbf 100644 --- a/NanoVNASaver/About.py +++ b/NanoVNASaver/About.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -VERSION = "0.5.5" +VERSION = "0.5.5-horo" VERSION_URL = ( "https://raw.githubusercontent.com/" "NanoVNA-Saver/nanovna-saver/master/NanoVNASaver/About.py") diff --git a/NanoVNASaver/Analysis/EFHWAnalysis.py b/NanoVNASaver/Analysis/EFHWAnalysis.py index e0b9126a..2eca1b97 100644 --- a/NanoVNASaver/Analysis/EFHWAnalysis.py +++ b/NanoVNASaver/Analysis/EFHWAnalysis.py @@ -47,7 +47,7 @@ def do_resonance_analysis(self): threshold=500)) extended_data = {} logger.info("TO DO: find near data") - for lowest in self.crossing: + for lowest in self.crossings: my_data = self._get_data(lowest) if lowest in extended_data: extended_data[lowest].update(my_data) diff --git a/NanoVNASaver/Analysis/ResonanceAnalysis.py b/NanoVNASaver/Analysis/ResonanceAnalysis.py index f75613fb..2084d7ec 100644 --- a/NanoVNASaver/Analysis/ResonanceAnalysis.py +++ b/NanoVNASaver/Analysis/ResonanceAnalysis.py @@ -47,7 +47,7 @@ class ResonanceAnalysis(Analysis): def __init__(self, app): super().__init__(app) - self.crossing: List[int] = [] + self.crossings: list[int] = [] self.filename = "" self._widget = QtWidgets.QWidget() self.layout = QtWidgets.QFormLayout() @@ -94,10 +94,10 @@ def runAnalysis(self): for _ in range(results_header, self.layout.rowCount()): self.layout.removeRow(self.layout.rowCount() - 1) - self.crossing = at.zero_crossings([d.phase for d in self.app.data.s11]) + self.crossings = at.zero_crossings([d.phase for d in self.app.data.s11]) logger.debug("Found %d sections ", - len(self.crossing)) - if not self.crossing: + len(self.crossings)) + if not self.crossings: self.layout.addRow(QtWidgets.QLabel( "No resonance found")) return @@ -106,29 +106,20 @@ def runAnalysis(self): def do_resonance_analysis(self): extended_data = [] - for m in self.crossing: - start, lowest, end = m - my_data = self._get_data(lowest) - s11_low = self.app.data.s11[lowest] - extended_data.append(my_data) - if start != end: - logger.debug( - "Section from %d to %d, lowest at %d", - start, end, lowest) - self.layout.addRow( - "Resonance", - QtWidgets.QLabel( - f"{format_frequency(s11_low.freq)}" - f" ({format_complex_imp(s11_low.impedance())})")) - else: - self.layout.addRow("Resonance", QtWidgets.QLabel( - format_frequency(self.app.data.s11[lowest].freq))) - self.layout.addWidget(QHLine()) + for crossing in self.crossings: + extended_data.append(self._get_data(crossing)) + self.layout.addRow( + "Resonance", + QtWidgets.QLabel( + format_frequency(self.app.data.s11[crossing].freq) + ), + ) + self.layout.addWidget(QHLine()) # Remove the final separator line self.layout.removeRow(self.layout.rowCount() - 1) if self.filename and extended_data: with open( - self.filename, 'w', encoding='utf-8', newline='' + self.filename, "w", encoding="utf-8", newline="" ) as csvfile: fieldnames = extended_data[0].keys() writer = csv.DictWriter(csvfile, fieldnames=fieldnames)