From d09ab02201676c47d8b2bfa117f45b8ffe4f4613 Mon Sep 17 00:00:00 2001 From: Mauro Gaioni Date: Wed, 5 Jan 2022 16:19:32 +0100 Subject: [PATCH 01/22] Add shebang and make nanovna-saver.py executable --- nanovna-saver.py | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 nanovna-saver.py diff --git a/nanovna-saver.py b/nanovna-saver.py old mode 100644 new mode 100755 index 4ae2ec64..f76c875b --- a/nanovna-saver.py +++ b/nanovna-saver.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 # NanoVNASaver - a python program to view and export Touchstone data from a NanoVNA # Copyright (C) 2019. Rune B. Broberg # From 28fd7e5478c571155bbf1990b694f14844f7fae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Sun, 9 Jan 2022 15:24:04 +0100 Subject: [PATCH 02/22] fix bug #455 vswr of datapoint now returns inf instead of going negative --- NanoVNASaver/About.py | 6 +- NanoVNASaver/Charts/VSWR.py | 12 +- NanoVNASaver/RFTools.py | 6 +- test/data/bug_455.s1p | 506 ++++++++++++++++++++++++++++++++++++ test/test_rftools.py | 8 +- 5 files changed, 527 insertions(+), 11 deletions(-) create mode 100644 test/data/bug_455.s1p diff --git a/NanoVNASaver/About.py b/NanoVNASaver/About.py index 39130f15..4f09aa73 100644 --- a/NanoVNASaver/About.py +++ b/NanoVNASaver/About.py @@ -2,7 +2,7 @@ # # A python program to view and export Touchstone data from a NanoVNA # Copyright (C) 2019, 2020 Rune B. Broberg -# Copyright (C) 2020,2021 NanoVNA-Saver Authors +# Copyright (C) 2020ff NanoVNA-Saver Authors # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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.3.10" +VERSION = "0.3.11-pre" VERSION_URL = ( "https://raw.githubusercontent.com/" "NanoVNA-Saver/nanovna-saver/master/NanoVNASaver/About.py") @@ -26,7 +26,7 @@ INFO = f"""NanoVNASaver {VERSION} Copyright (C) 2019, 2020 Rune B. Broberg -Copyright (C) 2020, 2021 NanoVNA-Saver Authors +Copyright (C) 2020ff NanoVNA-Saver Authors This program comes with ABSOLUTELY NO WARRANTY This program is licensed under the GNU General Public License version 3 diff --git a/NanoVNASaver/Charts/VSWR.py b/NanoVNASaver/Charts/VSWR.py index de394630..56d3d4cc 100644 --- a/NanoVNASaver/Charts/VSWR.py +++ b/NanoVNASaver/Charts/VSWR.py @@ -2,7 +2,7 @@ # # A python program to view and export Touchstone data from a NanoVNA # Copyright (C) 2019, 2020 Rune B. Broberg -# Copyright (C) 2020,2021 NanoVNA-Saver Authors +# Copyright (C) 2020ff NanoVNA-Saver Authors # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -73,7 +73,10 @@ def drawValues(self, qp: QtGui.QPainter): vswr = d.vswr if vswr > maxVSWR: maxVSWR = vswr - maxVSWR = min(self.maxDisplayValue, math.ceil(maxVSWR)) + try: + maxVSWR = min(self.maxDisplayValue, math.ceil(maxVSWR)) + except OverflowError: + maxVSWR = self.maxDisplayValue self.maxVSWR = maxVSWR span = maxVSWR-minVSWR if span == 0: @@ -152,7 +155,10 @@ def getYPositionFromValue(self, vswr) -> int: return ( self.topMargin + round((math.log(self.maxVSWR) - math.log(vswr)) / span * self.dim.height)) - return self.topMargin + round((self.maxVSWR - vswr) / self.span * self.dim.height) + try: + return self.topMargin + round((self.maxVSWR - vswr) / self.span * self.dim.height) + except OverflowError: + return self.topMargin def getYPosition(self, d: Datapoint) -> int: return self.getYPositionFromValue(d.vswr) diff --git a/NanoVNASaver/RFTools.py b/NanoVNASaver/RFTools.py index f52ac57e..6084b6f0 100644 --- a/NanoVNASaver/RFTools.py +++ b/NanoVNASaver/RFTools.py @@ -2,7 +2,7 @@ # # A python program to view and export Touchstone data from a NanoVNA # Copyright (C) 2019, 2020 Rune B. Broberg -# Copyright (C) 2020,2021 NanoVNA-Saver Authors +# Copyright (C) 2020ff NanoVNA-Saver Authors # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -52,8 +52,8 @@ def gain(self) -> float: @property def vswr(self) -> float: mag = abs(self.z) - if mag == 1: - return 1 + if mag >= 1: + return math.inf return (1 + mag) / (1 - mag) @property diff --git a/test/data/bug_455.s1p b/test/data/bug_455.s1p new file mode 100644 index 00000000..65598a8e --- /dev/null +++ b/test/data/bug_455.s1p @@ -0,0 +1,506 @@ +# HZ S RI R 50 +3000000 0.999217553111198 -0.026006368969073507 +3053571 0.9990760221063897 -0.02616960062678943 +3107142 0.9998695060207428 -0.026357512648392707 +3160713 0.9995727813137307 -0.02673165514964476 +3214284 0.9998422477178924 -0.02735950932172737 +3267855 0.9992611599648574 -0.027695043887267765 +3321426 0.9994153446168698 -0.028142851063794546 +3374997 0.9990529877500746 -0.028286796941760946 +3428568 0.9986411771882968 -0.028610573575896612 +3482139 0.9990422044445644 -0.029103037543726586 +3535710 0.9998870883448377 -0.03042064735916487 +3589281 0.9993909514556742 -0.030752615461112468 +3642852 0.9992750532005389 -0.030726426761521205 +3696423 0.9994514905449735 -0.03131507200742467 +3749994 0.999263188100151 -0.03158895487413982 +3803565 0.9996532960089962 -0.03311019159545953 +3857136 0.9992885427124021 -0.03274728504326098 +3910707 0.9994867939820941 -0.03293395194432181 +3964278 1.00007193448788 -0.03361517261152925 +4017849 0.9992341700208589 -0.03430241320216032 +4071420 0.9995507363224189 -0.03495942236583878 +4124991 0.999101837821369 -0.03488121307307324 +4178562 0.9987138904444818 -0.03563963741382877 +4232133 0.99909831864041 -0.03593625933515065 +4285704 0.9995754802936503 -0.036282659258283924 +4339275 0.9994219560558821 -0.037170443866862315 +4392846 0.9995884262219273 -0.03708491483338213 +4446417 0.9994087230431894 -0.03789548756507887 +4499988 0.9989947999631904 -0.038963552047948165 +4553559 0.9992350368131363 -0.03913296865027929 +4607130 0.9985395452304222 -0.03934442925188224 +4660701 0.9988533265643139 -0.04022992413835943 +4714272 0.9989698599614594 -0.040891436280646364 +4767843 0.9989441374133053 -0.0413372370064415 +4821414 0.9986446332579819 -0.041569626302144315 +4874985 0.9985293357884746 -0.04226826839680791 +4928556 0.9988838351966212 -0.04213246797235339 +4982127 0.9990690474733765 -0.042538626139672235 +5035698 0.9987066280195313 -0.04329459239161214 +5089269 0.9985539273776957 -0.04387481827325034 +5142840 0.9987135180537664 -0.04443010725776021 +5196411 0.9991203509337917 -0.044671590411386616 +5249982 0.9986886024185128 -0.04550748885579783 +5303553 0.9987642117234306 -0.04571848923732077 +5357124 0.9984274098828113 -0.046217899148703154 +5410695 0.9982925420349229 -0.04623039431391896 +5464266 0.9980937151025986 -0.04733881693829932 +5517837 0.9986541555578448 -0.04780273660918467 +5571408 0.9981784234133837 -0.04844531477376229 +5624979 0.9985273242820556 -0.04877996506365952 +5678550 0.9986155071402917 -0.04875073938353244 +5732121 0.9980065463580129 -0.0497291849156147 +5785692 0.9982718494439847 -0.05001180474236919 +5839263 0.9982502829418478 -0.05067211147403429 +5892834 0.9979626665068084 -0.05104249007597819 +5946405 0.9982619604911992 -0.052305545471160696 +5999976 0.998351583642194 -0.052145521195233316 +6053547 0.9981895993737917 -0.052691799972200005 +6107118 0.9980332589845721 -0.05301959154019422 +6160689 0.9982704227300877 -0.053595225549902155 +6214260 0.9977368098625427 -0.054337218800012944 +6267831 0.9983212746688003 -0.054214537479295506 +6321402 0.9978268780223202 -0.055404363363811264 +6374973 0.9976686859421983 -0.05613910369325602 +6428544 0.9981633435625159 -0.056262117916763145 +6482115 0.9978697525444725 -0.056704971601716454 +6535686 0.9980015254775774 -0.05687714019266079 +6589257 0.9976072213130828 -0.05805238929849655 +6642828 0.9979318058436628 -0.0586717693668304 +6696399 0.9977840152059427 -0.058639751278584965 +6749970 0.9974156523924141 -0.05937616354214651 +6803541 0.9984292523191397 -0.060218988241132095 +6857112 0.9971438181556471 -0.06014241394752362 +6910683 0.9977984547372281 -0.06073570548346518 +6964254 0.9974257895060054 -0.06126633650162547 +7017825 0.9972246698519285 -0.06214302921191344 +7071396 0.9975264840075736 -0.06258094912060302 +7124967 0.9971553157492249 -0.06281630628536014 +7178538 0.9970689589782636 -0.06359869782216586 +7232109 0.9972973854797345 -0.06394477705074199 +7285680 0.9969437115248685 -0.064295457851317 +7339251 0.9975481259238336 -0.06503960564010633 +7392822 0.9969888868277865 -0.06563786925161066 +7446393 0.9974343303826327 -0.06653233209201131 +7499964 0.9969938272246118 -0.06727448430206931 +7553535 0.9967090627903945 -0.06739626542994442 +7607106 0.9971038728278822 -0.0679480698628891 +7660677 0.9967852967780516 -0.06845720326596402 +7714248 0.9966596116946268 -0.06942311618377062 +7767819 0.9972270772208484 -0.06948656420601551 +7821390 0.9969254678319468 -0.0706330303102574 +7874961 0.9969266003724869 -0.07086250492797655 +7928532 0.9970959280465449 -0.0720000932406417 +7982103 0.9966266146875772 -0.07202748646898359 +8035674 0.9964565880619184 -0.07318431949910283 +8089245 0.9964621854905252 -0.07336217599531261 +8142816 0.996191552125491 -0.07406750790103851 +8196387 0.9962782793465949 -0.07483426249522236 +8249958 0.9956473842889764 -0.07530948508603715 +8303529 0.9960449823177318 -0.0759801653243026 +8357100 0.9957919642398791 -0.07681700466728256 +8410671 0.9962415298945388 -0.0772336642098874 +8464242 0.9962432566197986 -0.07783723409082723 +8517813 0.9960078176658733 -0.07881499521755564 +8571384 0.9957366556751558 -0.07975240208529898 +8624955 0.9963184018278428 -0.0808928792770033 +8678526 0.9958822197881233 -0.08120856404492596 +8732097 0.9959759871485439 -0.08113924960926543 +8785668 0.9952893351186954 -0.0826432005581572 +8839239 0.9957748362168557 -0.08324511032412386 +8892810 0.9960055353152465 -0.08401131476674972 +8946381 0.9957058858158947 -0.08534594589502703 +8999952 0.9954151966840431 -0.08593115508064662 +9053523 0.994933013892916 -0.08656382256392237 +9107094 0.9950275177421993 -0.08819771167443084 +9160665 0.995166910046771 -0.08867918483070554 +9214236 0.99486848465088 -0.08916126736665639 +9267807 0.9946435835794071 -0.08975067083338593 +9321378 0.9944830292843686 -0.09121910573808438 +9374949 0.994385050595363 -0.09274251283523469 +9428520 0.9946963244299659 -0.09356927418123756 +9482091 0.9943157240640157 -0.09500421387559732 +9535662 0.9940508116943455 -0.09568568665908211 +9589233 0.9940450411963871 -0.09713708014620673 +9642804 0.9934968379815106 -0.09842307044556774 +9696375 0.9934671608440254 -0.10016028418167966 +9749946 0.9934878915145678 -0.10177492682370778 +9803517 0.9930148217076515 -0.10338106656781151 +9857088 0.9922562503340756 -0.10542467120204209 +9910659 0.9927410967744271 -0.10684051342906756 +9964230 0.9921779764907653 -0.10925062578857385 +10017801 0.9917651177146568 -0.1110799970588746 +10071372 0.991051461538982 -0.11386141699594096 +10124943 0.9906060843604803 -0.11704614355743145 +10178514 0.9898161454198454 -0.12003403561390104 +10232085 0.9889622882211591 -0.12381576852971819 +10285656 0.9879253265034385 -0.12797749641641623 +10339227 0.9866146844409356 -0.13266460309989245 +10392798 0.9849082343563721 -0.1387135558783785 +10446369 0.982275995990684 -0.14600317717689362 +10499940 0.9789114087112528 -0.15485894519985277 +10553511 0.9735567730372985 -0.16516490428832958 +10607082 0.9662069577836061 -0.18034531793264558 +10660653 0.9536561543693347 -0.19992249079955696 +10714224 0.9307260800309157 -0.22832348542452136 +10767795 0.8806502928255087 -0.2673632787008138 +10821366 0.7556308850836485 -0.29779483776178206 +10874937 0.5409649961797074 -0.1299898244378607 +10928508 0.6987982899699381 0.15526429366423256 +10982079 0.8778317958106712 0.13532188128599096 +11035650 0.9418533175847232 0.0821384644275875 +11089221 0.9680167120719122 0.044315197389293105 +11142792 0.9799277351396609 0.018772892651826644 +11196363 0.9855705364642934 0.001164818678567531 +11249934 0.9894125174946842 -0.011666522821093255 +11303505 0.9918418976727778 -0.022192740801678133 +11357076 0.9932724363980111 -0.030330412030535943 +11410647 0.9940801611974754 -0.03630455447393354 +11464218 0.9945389141847601 -0.04222380837374977 +11517789 0.9949149408440415 -0.0470442204210176 +11571360 0.9950633018760501 -0.05069544178272652 +11624931 0.9954988690991742 -0.05405343924700162 +11678502 0.9956642778061069 -0.05725025438268397 +11732073 0.9956363149831066 -0.060118705279462066 +11785644 0.9957183227032212 -0.062389809119893724 +11839215 0.995384154617556 -0.06461575693120411 +11892786 0.9953129528474888 -0.06658065613190652 +11946357 0.995770582685312 -0.06839755801823888 +11999928 0.9949785264704428 -0.07035982622108607 +12053499 0.9952211692942226 -0.0713251421583897 +12107070 0.9954874531050608 -0.07307900473961773 +12160641 0.9955243463319715 -0.07426995305668209 +12214212 0.994786830876783 -0.07597966848283173 +12267783 0.9951194869029178 -0.0773347786201788 +12321354 0.9951366861036643 -0.07811384326357043 +12374925 0.994982512502683 -0.07955337643088722 +12428496 0.9948303914869228 -0.080943929400787 +12482067 0.9953569005228897 -0.08203923723873678 +12535638 0.9954630045916847 -0.0828083996899234 +12589209 0.9950394397500968 -0.08379474650406775 +12642780 0.9950292188947644 -0.08482657082515668 +12696351 0.9946766267419829 -0.08536259589365124 +12749922 0.994358884912829 -0.086570247330051 +12803493 0.9944963395689184 -0.08734226547805125 +12857064 0.9939357354355413 -0.0882398085243126 +12910635 0.9945284317298411 -0.0893814424480011 +12964206 0.9941126016314422 -0.0898955048016864 +13017777 0.9942985066125885 -0.0904185546931862 +13071348 0.9942337753796533 -0.09095865914997683 +13124919 0.9935774273906016 -0.0919400304008933 +13178490 0.9941425091550781 -0.0928463767758405 +13232061 0.9941131136996637 -0.09401272269588964 +13285632 0.9937182336652576 -0.09414337222213953 +13339203 0.9935149875364977 -0.09513807959118802 +13392774 0.9937669857731929 -0.09551257856781561 +13446345 0.9936614776949069 -0.09582399966938478 +13499916 0.9942756478839512 -0.09677632342908475 +13553487 0.9935828623498284 -0.09739944800051517 +13607058 0.9937794765653759 -0.09777977629894408 +13660629 0.9937180893463432 -0.0983921032528617 +13714200 0.993340511106815 -0.09945921777296451 +13767771 0.9933407235724354 -0.09999858372867791 +13821342 0.9930472801767287 -0.10072025019354662 +13874913 0.9928723727132504 -0.10122116291659056 +13928484 0.9926350068783647 -0.10180282468968216 +13982055 0.9925955232556638 -0.10269218806448324 +14035626 0.9930210083267031 -0.10336916636961702 +14089197 0.9924852657077348 -0.10334044645372793 +14142768 0.9928426256036582 -0.10393088277450345 +14196339 0.9924793772813422 -0.10461680076771009 +14249910 0.9925784881503651 -0.10498582449193614 +14303481 0.9921499468800375 -0.10603408015407349 +14357052 0.9921495256310014 -0.10672618840363164 +14410623 0.9922878289228158 -0.10717991175743231 +14464194 0.9927660622297558 -0.10798878864877968 +14517765 0.9921520987067775 -0.1078591801036691 +14571336 0.9916293633632522 -0.1083971083040472 +14624907 0.9918830528569798 -0.10911349347402269 +14678478 0.9919057941887367 -0.1097314426646818 +14732049 0.9918902655047204 -0.11039848980875035 +14785620 0.9916102484996948 -0.11067434506609254 +14839191 0.9920597385813671 -0.11073904485787368 +14892762 0.9912874363969549 -0.11142357137515811 +14946333 0.9916205840860174 -0.11232644038632808 +14999904 0.9915235871824334 -0.1125817128335612 +15053475 0.9912996482340988 -0.11276691373408815 +15107046 0.9910687703862893 -0.11391519053895907 +15160617 0.9912742691235508 -0.11435304014180557 +15214188 0.9910775752754512 -0.1151345242586019 +15267759 0.9907653484148902 -0.11501352843505369 +15321330 0.9914897729873433 -0.11568950983113162 +15374901 0.9904839017364158 -0.11622936790759496 +15428472 0.9906096493532274 -0.1174526300651569 +15482043 0.9906233598107956 -0.11720875742453334 +15535614 0.9907459268756187 -0.11762005349063027 +15589185 0.9904585671571969 -0.11778435752378964 +15642756 0.9900302731878331 -0.11852343154406011 +15696327 0.9903959438987728 -0.11938728319587442 +15749898 0.9897086390844093 -0.12001251834667126 +15803469 0.989896291297618 -0.12004432535867703 +15857040 0.9895270897512793 -0.1203063629024269 +15910611 0.9901049949266408 -0.12123727182181228 +15964182 0.9901076450652431 -0.1215358778200787 +16017753 0.9898880435565007 -0.12206922178779658 +16071324 0.990177740619253 -0.12250286025709717 +16124895 0.9894561622255955 -0.12319614743609304 +16178466 0.9895923695640564 -0.1235320809231777 +16232037 0.9897944538732346 -0.12359557584283609 +16285608 0.9897151016516871 -0.12451580990914524 +16339179 0.9893008783099903 -0.12485166960831685 +16392750 0.9891352805447597 -0.12539262858928246 +16446321 0.9891334841814782 -0.12580656248474523 +16499892 0.989197898940479 -0.12636624749031622 +16553463 0.9901237892861766 -0.12638106057687648 +16607034 0.9897650976033056 -0.12659658082702935 +16660605 0.9892432748486709 -0.1275870270995953 +16714176 0.9887425601906308 -0.12806801418957278 +16767747 0.9889323123598704 -0.12832252309884093 +16821318 0.988866474624152 -0.12877228314718875 +16874889 0.9889551925980418 -0.1295347546597515 +16928460 0.9890147398303677 -0.12976495067709826 +16982031 0.9888253584663943 -0.1301782971145535 +17035602 0.9886808739871272 -0.13059900693074472 +17089173 0.9890404959105649 -0.13130336667167475 +17142744 0.9884118803790904 -0.13126214354204793 +17196315 0.9886516969511405 -0.13233572968595717 +17249886 0.9886989702121985 -0.1324668558826104 +17303457 0.989108485765365 -0.13261541454627718 +17357028 0.9888931431141009 -0.1335115841876147 +17410599 0.9885615590386486 -0.13399923509980957 +17464170 0.9881814991719462 -0.1340753333484648 +17517741 0.98832714326702 -0.13477427381472018 +17571312 0.9884159103983137 -0.1354004567701287 +17624883 0.9884305638289235 -0.1360246046509931 +17678454 0.9890395672987313 -0.13606492328637257 +17732025 0.988713617493704 -0.1367923946533187 +17785596 0.9883609505549893 -0.1369481234203866 +17839167 0.9882334736685265 -0.13702367212456082 +17892738 0.9893692753426045 -0.1382609015618997 +17946309 0.9882262175182731 -0.13895722636824825 +17999880 0.988280235632101 -0.13862121838393335 +18053451 0.9885573066462229 -0.13950313723898577 +18107022 0.9881151516059664 -0.14012865362856847 +18160593 0.9881625190100778 -0.14022167926479454 +18214164 0.9881350871471172 -0.1411393878609674 +18267735 0.9878702523812258 -0.14096364950612228 +18321306 0.9879510488671214 -0.1420070357613215 +18374877 0.9878662161413214 -0.1424580905478906 +18428448 0.9875309915393673 -0.14302546855042983 +18482019 0.9877745217849085 -0.14298338982496528 +18535590 0.9877590631631599 -0.1438555946477478 +18589161 0.9872782486263697 -0.1443430328273233 +18642732 0.9879145046026822 -0.14458182612940235 +18696303 0.9876749611934554 -0.1451532794562831 +18749874 0.9876043815260809 -0.14558576080965355 +18803445 0.9873839945209708 -0.14596259386924518 +18857016 0.9869390718929465 -0.14610450039055944 +18910587 0.9875372678417568 -0.14708599486041862 +18964158 0.987254854973979 -0.14762654213544973 +19017729 0.9867120546811328 -0.1481631610368824 +19071300 0.9870210682211021 -0.14900199087679247 +19124871 0.9865396496690785 -0.14952492805435885 +19178442 0.9875954737983618 -0.14966077183478874 +19232013 0.9870445753067475 -0.1505484846426606 +19285584 0.9871155869938094 -0.1503690860656906 +19339155 0.9868356427840828 -0.1513609644230029 +19392726 0.9865673638550525 -0.15158341708483578 +19446297 0.9868009720890412 -0.15209403589526757 +19499868 0.9863587421191387 -0.15231126999391395 +19553439 0.9863576277415801 -0.15320272179237748 +19607010 0.986769836784581 -0.1537070032408587 +19660581 0.9865791259087955 -0.15397463962553634 +19714152 0.9860647251213305 -0.15442256739757876 +19767723 0.9862810575110382 -0.1547935930430274 +19821294 0.9860663248353245 -0.15562245269556896 +19874865 0.9862143271510841 -0.1557284027810921 +19928436 0.9866389204150298 -0.15698734721404242 +19982007 0.9859122778017916 -0.15672197433718907 +20035578 0.9858298561865042 -0.15740995586316453 +20089149 0.9854565081673328 -0.15786635930679954 +20142720 0.9859779679256885 -0.15888032979983505 +20196291 0.9851667784895008 -0.1586828891146613 +20249862 0.9851614537623359 -0.1595280055117806 +20303433 0.9851557792116729 -0.16042387350690038 +20357004 0.9852997569303226 -0.16049817836811053 +20410575 0.9849122643616139 -0.1605000669236301 +20464146 0.9842152815737197 -0.1610357707184645 +20517717 0.9846696159904078 -0.16151500444678205 +20571288 0.984387695349332 -0.16212126838003976 +20624859 0.9840464772529336 -0.16219808755490728 +20678430 0.984628371282301 -0.16348367751916815 +20732001 0.9843287402763705 -0.16259925243420204 +20785572 0.9841965514822271 -0.1639482526823632 +20839143 0.9833517461261025 -0.16471728094014695 +20892714 0.983336563370358 -0.16451535605446013 +20946285 0.983369321348119 -0.1647191942592931 +20999856 0.9836088471264368 -0.16566655453438553 +21053427 0.983516397668322 -0.16647158091362826 +21106998 0.9835093564815073 -0.16676568405667444 +21160569 0.9830388511807129 -0.16621486983867162 +21214140 0.9828230327833031 -0.16754049939277596 +21267711 0.9824302535997427 -0.1678613256896772 +21321282 0.9829065914532821 -0.16812860935311721 +21374853 0.9825001439160739 -0.16834157486906476 +21428424 0.9833719526024379 -0.16900085535902143 +21481995 0.9822099617243415 -0.16935890883642685 +21535566 0.9822300794153903 -0.16945300697014554 +21589137 0.9823504480084657 -0.17035131159585495 +21642708 0.9821462222175426 -0.17061465587971347 +21696279 0.9819870530811937 -0.17077925593240945 +21749850 0.9823104109175569 -0.17164375830177822 +21803421 0.9819164434995913 -0.1720819193782311 +21856992 0.9816711805940526 -0.17234151813364554 +21910563 0.981734968285003 -0.1724844973742192 +21964134 0.9819669765276886 -0.17302058888128474 +22017705 0.9819081915554242 -0.17350107090747438 +22071276 0.9814633560441453 -0.17379375234283198 +22124847 0.9819768122578423 -0.17433897299333423 +22178418 0.9812371364650782 -0.17452547021009956 +22231989 0.9817367480642806 -0.17552187018902435 +22285560 0.9812764060060191 -0.17558827126313228 +22339131 0.9810726387254673 -0.17634051339224457 +22392702 0.9814463404433088 -0.17677181473342374 +22446273 0.9808137410135314 -0.17644969458291368 +22499844 0.980892605654481 -0.17734219368893744 +22553415 0.9812726778060378 -0.17774140754850065 +22606986 0.9802150680141831 -0.17852957347329632 +22660557 0.9808062148850352 -0.17924732709855642 +22714128 0.9808351751070951 -0.17922944623803325 +22767699 0.9806925953099329 -0.1795878256033152 +22821270 0.9808136298205348 -0.1794271049657436 +22874841 0.980518725197183 -0.18090077774673932 +22928412 0.9809612928808759 -0.18075675793997778 +22981983 0.9800212506768312 -0.18115362126329437 +23035554 0.9811098667429702 -0.18202100858635564 +23089125 0.9805968436077559 -0.1827118761709168 +23142696 0.9804563464185784 -0.18270987831198174 +23196267 0.9802458602847129 -0.1832791318290017 +23249838 0.9805288943144301 -0.1840167085961144 +23303409 0.9801418266017299 -0.18422756457342293 +23356980 0.9797250277453007 -0.18492735628916565 +23410551 0.9794873396546807 -0.18524132274206984 +23464122 0.9804275222454805 -0.18532977831977296 +23517693 0.9803010514784931 -0.18592039809336114 +23571264 0.9799321855604852 -0.1863182452797298 +23624835 0.979231102576443 -0.18614106507921513 +23678406 0.9793886184962745 -0.18742450829896234 +23731977 0.979588824804823 -0.18760403529310413 +23785548 0.9792923548401016 -0.1879919213724168 +23839119 0.9788777730609183 -0.18818868834000818 +23892690 0.9792705085500207 -0.1884836956966114 +23946261 0.9794202006170766 -0.18978367609804123 +23999832 0.9789180642242916 -0.18998091141463613 +24053403 0.9789739131786338 -0.1896572421365202 +24106974 0.9788220052736787 -0.19029688734076827 +24160545 0.9784252940899901 -0.19130931671499588 +24214116 0.9785585299819073 -0.19106199395079093 +24267687 0.9787364603946404 -0.19166758412233478 +24321258 0.9784107828244768 -0.1921151279015836 +24374829 0.9785579777533544 -0.19263615339971207 +24428400 0.9776059332101786 -0.1936401581503578 +24481971 0.977840555159449 -0.19336163433298964 +24535542 0.9776706255641624 -0.19395381200181996 +24589113 0.9777425490215689 -0.19414580367495224 +24642684 0.9773503874334812 -0.1950991381016746 +24696255 0.9767130371743208 -0.19548094556647927 +24749826 0.977296396186032 -0.1962352983489903 +24803397 0.9773830358375917 -0.19633542542177324 +24856968 0.9767219413249234 -0.19672547512197794 +24910539 0.9769705778937239 -0.19746325580162657 +24964110 0.9768354777507623 -0.19770662795456156 +25017681 0.976179291372085 -0.19812146435386924 +25071252 0.9770270808115145 -0.19813676015699522 +25124823 0.9765917974277334 -0.19899396845239134 +25178394 0.97663599989675 -0.19924753932728587 +25231965 0.9766250276638195 -0.19972791263357023 +25285536 0.9762465966111962 -0.20002187639920055 +25339107 0.9759529418006039 -0.20038495817440313 +25392678 0.9757864514506046 -0.20086218330915692 +25446249 0.9766910086446187 -0.2011334160905251 +25499820 0.9755363407725041 -0.20189455402873951 +25553391 0.9760591768947167 -0.2020221326529233 +25606962 0.9765188932100465 -0.203047271400522 +25660533 0.9758416238636678 -0.20280803493568886 +25714104 0.9757979892883083 -0.20277953652363334 +25767675 0.9752593529676297 -0.2036865200237142 +25821246 0.9755746442576719 -0.2043421693161996 +25874817 0.975496704932979 -0.2041487695409564 +25928388 0.9756824715032787 -0.2045287115334498 +25981959 0.9753091664844671 -0.20546644409521905 +26035530 0.9753066415958195 -0.20581460781542812 +26089101 0.9752879659082208 -0.20615557942766377 +26142672 0.9750837407070778 -0.20616498952662893 +26196243 0.9757364279757187 -0.20693139694612012 +26249814 0.9748245640922626 -0.20777547017574421 +26303385 0.9753700857281873 -0.20762032427907065 +26356956 0.9753457049409419 -0.20841428158279984 +26410527 0.9748957836479486 -0.20860245714073425 +26464098 0.9745689476734108 -0.20927815624531856 +26517669 0.975046408363662 -0.20844054553493233 +26571240 0.9747924779987089 -0.21013085720952443 +26624811 0.974660512336377 -0.21028374264276978 +26678382 0.9748316154912648 -0.21068879622624326 +26731953 0.9750649251496954 -0.21096338064725403 +26785524 0.9748150902335366 -0.21091564524777454 +26839095 0.9751222606886436 -0.2122685138326751 +26892666 0.9745665424711661 -0.21271834681963855 +26946237 0.9744583034185428 -0.21284347471991347 +26999808 0.9742452079106152 -0.21344383787723661 +27053379 0.9746522812301087 -0.2135449206645421 +27106950 0.9748847999921183 -0.21468131173045904 +27160521 0.9743516533586608 -0.2149299293294192 +27214092 0.9738659114872381 -0.21558366570897072 +27267663 0.9742435780793909 -0.2160760147452772 +27321234 0.9745629411429392 -0.2165164730765642 +27374805 0.9737420697075901 -0.21684297601866526 +27428376 0.9737595671167263 -0.21723227078222435 +27481947 0.9737589172994865 -0.21749384577247707 +27535518 0.9736762358003322 -0.21811966091887866 +27589089 0.9738354167125122 -0.21915271390588684 +27642660 0.9737948619437679 -0.21877164389400258 +27696231 0.9740881490243009 -0.2193667134130943 +27749802 0.9732555401139915 -0.21998209689896545 +27803373 0.9732362292712964 -0.220571760670072 +27856944 0.9734478658037116 -0.22108324838816296 +27910515 0.973703611149113 -0.2212894754854785 +27964086 0.9736683669780059 -0.2216066403908327 +28017657 0.9728592292769881 -0.22221759307604025 +28071228 0.973211959414166 -0.22253074326958924 +28124799 0.9732102121813986 -0.22290335503945627 +28178370 0.9726493193869898 -0.22362557889751528 +28231941 0.9728574156091847 -0.2240741918173055 +28285512 0.9721990416963512 -0.22519725515711134 +28339083 0.9725806091845351 -0.22491033192994572 +28392654 0.9723717834164394 -0.225474819224442 +28446225 0.9726248900990087 -0.2262551066052174 +28499796 0.9724778870193509 -0.22691237064198444 +28553367 0.9720351205681644 -0.22657892830485685 +28606938 0.9724466588588184 -0.22768987704033075 +28660509 0.9716325574178216 -0.22742037906704324 +28714080 0.9722170002266404 -0.22850646875324024 +28767651 0.9721312695589477 -0.2293208699157244 +28821222 0.9719828298696898 -0.22898370228664214 +28874793 0.9713515769519546 -0.23045887216827343 +28928364 0.9715125806909315 -0.23028344732060868 +28981935 0.970657504457702 -0.23055520888247913 +29035506 0.9711760546712243 -0.23140338330015592 +29089077 0.9712548422946026 -0.23121954223962865 +29142648 0.9705335340773523 -0.2325776293454353 +29196219 0.9707452054805266 -0.23251059986823783 +29249790 0.9711096048030685 -0.2330809725190042 +29303361 0.9703610689764776 -0.23344549066443043 +29356932 0.9711254135417211 -0.2341226638914314 +29410503 0.9702062598083376 -0.2337056589938312 +29464074 0.9702207712176436 -0.2350939863464158 +29517645 0.9702577871704774 -0.2355903281329962 +29571216 0.969884342860187 -0.23571067060229775 +29624787 0.9704204660141642 -0.23633554756874378 +29678358 0.9699116298578333 -0.2366006620321404 +29731929 0.9705276795139067 -0.23709076715664346 +29785500 0.9702213067948415 -0.23798907372184097 +29839071 0.9699452545302005 -0.23745301714784228 +29892642 0.9699740633238594 -0.23909820438257073 +29946213 0.9690471433601371 -0.23879115058697287 +29999784 0.9693706885722901 -0.23926560820846976 diff --git a/test/test_rftools.py b/test/test_rftools.py index f2ece9ba..abd9dc4d 100644 --- a/test/test_rftools.py +++ b/test/test_rftools.py @@ -2,7 +2,7 @@ # # A python program to view and export Touchstone data from a NanoVNA # Copyright (C) 2019, 2020 Rune B. Broberg -# Copyright (C) 2020,2021 NanoVNA-Saver Authors +# Copyright (C) 2020ff NanoVNA-Saver Authors # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -143,6 +143,7 @@ def setUp(self): self.dp50 = Datapoint(100000, 1, 0) self.dp75 = Datapoint(100000, 0.2, 0) self.dp_im50 = Datapoint(100000, 0, 1) + self.dp_ill = Datapoint(100000, 1.1, 0) def test_properties(self): self.assertEqual(self.dp.z, complex(0.1091, 0.3118)) @@ -150,7 +151,10 @@ def test_properties(self): self.assertAlmostEqual(self.dp.phase, 1.23420722) self.assertEqual(self.dp0.gain, -math.inf) self.assertAlmostEqual(self.dp.gain, -9.6208748) - self.assertEqual(self.dp50.vswr, 1.0) + self.assertEqual(self.dp50.vswr, math.inf) + self.assertEqual(self.dp_im50.vswr, math.inf) + self.assertEqual(self.dp_ill.vswr, math.inf) + self.assertEqual(self.dp0.vswr, 1) self.assertAlmostEqual(self.dp.vswr, 1.9865736) self.assertAlmostEqual(self.dp.impedance(), complex(49.997525, 34.9974501)) From 8208563ff346ee9adb588d0f5f9826819bf56075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Mon, 10 Jan 2022 16:49:25 +0100 Subject: [PATCH 03/22] Modified deps/workflows - setup.cfg should now work flowlessly with fedoro 36 (#456) - github actions are updated to use more current software versions --- .github/workflows/release_linux.yml | 6 +++--- .github/workflows/release_macos.yml | 6 +++--- .github/workflows/release_win.yml | 6 +++--- requirements.txt | 8 ++++---- setup.cfg | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index b3665edb..697b56ad 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -15,12 +15,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies and pyinstall run: | - python -m pip install --upgrade pip setuptools + python -m pip install pip==21.3.1 setuptools==60.5.0 pip install -r requirements.txt - pip install PyInstaller==4.5.1 + pip install PyInstaller==4.8 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver nanovna-saver.py diff --git a/.github/workflows/release_macos.yml b/.github/workflows/release_macos.yml index 83a59765..34ba7a65 100644 --- a/.github/workflows/release_macos.yml +++ b/.github/workflows/release_macos.yml @@ -15,12 +15,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies and pyinstall run: | - python -m pip install --upgrade pip setuptools + python -m pip install pip==21.3.1 setuptools==60.5.0 pip install -r requirements.txt - pip install PyInstaller==4.5.1 + pip install PyInstaller==4.8 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver nanovna-saver.py diff --git a/.github/workflows/release_win.yml b/.github/workflows/release_win.yml index 7dd7daaf..04229c70 100644 --- a/.github/workflows/release_win.yml +++ b/.github/workflows/release_win.yml @@ -18,13 +18,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: 3.10 architecture: ${{ matrix.arch }} - name: Install dependencies and pyinstall run: | - python -m pip install --upgrade pip setuptools + python -m pip install pip==21.3.1 setuptools==60.5.0 pip install -r requirements.txt - pip install PyInstaller==4.7 + pip install PyInstaller==4.8 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver.exe nanovna-saver.py diff --git a/requirements.txt b/requirements.txt index 1c49ba0c..e8f4bce9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ pyserial==3.5 -PyQt5==5.15.4 -numpy==1.21.1 -scipy==1.7.1 -cython==0.29.24 +PyQt5==5.15.6 +numpy==1.22.0 +scipy==1.7.3 +Cython==0.29.26 diff --git a/setup.cfg b/setup.cfg index 646e60b8..c534321f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,11 +15,11 @@ version = attr: NanoVNASaver.About.VERSION [options] packages = find_namespace: install_requires= - pyserial==3.5 - PyQt5==5.15.4 - numpy==1.21.1 - scipy==1.7.1 - cython==0.29.24 + pyserial>=3.5 + PyQt5>=5.15.0 + numpy>=1.21.1 + scipy>=1.7.1 + Cython>=0.29.24 python_requires = >=3.8, <4 [options.entry_points] From 3e78b490e9c9cb0a0e608799ce97ae7f2dc0d0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Mon, 10 Jan 2022 16:55:50 +0100 Subject: [PATCH 04/22] linux workflows just knows python 3.9 --- .github/workflows/release_linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index 697b56ad..a2fb5338 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10 + python-version: 3.9 - name: Install dependencies and pyinstall run: | python -m pip install pip==21.3.1 setuptools==60.5.0 From 0c179388d33f979de0e83263b9c9b2c333aaea57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Tue, 11 Jan 2022 17:22:33 +0100 Subject: [PATCH 05/22] Pyinstaller and numpy version fixes for binary builds --- .github/workflows/release_linux.yml | 2 +- .github/workflows/release_macos.yml | 4 ++-- .github/workflows/release_win.yml | 4 ++-- _config.yml | 1 - requirements.txt | 2 +- setup.cfg | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 _config.yml diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index a2fb5338..30e2cf06 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -20,7 +20,7 @@ jobs: run: | python -m pip install pip==21.3.1 setuptools==60.5.0 pip install -r requirements.txt - pip install PyInstaller==4.8 + pip install PyInstaller==4.7 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver nanovna-saver.py diff --git a/.github/workflows/release_macos.yml b/.github/workflows/release_macos.yml index 34ba7a65..4ae5df78 100644 --- a/.github/workflows/release_macos.yml +++ b/.github/workflows/release_macos.yml @@ -15,12 +15,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10 + python-version: 3.9 - name: Install dependencies and pyinstall run: | python -m pip install pip==21.3.1 setuptools==60.5.0 pip install -r requirements.txt - pip install PyInstaller==4.8 + pip install PyInstaller==4.7 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver nanovna-saver.py diff --git a/.github/workflows/release_win.yml b/.github/workflows/release_win.yml index 04229c70..e4adf467 100644 --- a/.github/workflows/release_win.yml +++ b/.github/workflows/release_win.yml @@ -18,13 +18,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10 + python-version: 3.9 architecture: ${{ matrix.arch }} - name: Install dependencies and pyinstall run: | python -m pip install pip==21.3.1 setuptools==60.5.0 pip install -r requirements.txt - pip install PyInstaller==4.8 + pip install PyInstaller==4.7 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver.exe nanovna-saver.py diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 9da9a029..00000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-dinky \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e8f4bce9..85c80a25 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ pyserial==3.5 PyQt5==5.15.6 -numpy==1.22.0 +numpy==1.21.5 scipy==1.7.3 Cython==0.29.26 diff --git a/setup.cfg b/setup.cfg index c534321f..1dde2fd2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,7 +17,7 @@ packages = find_namespace: install_requires= pyserial>=3.5 PyQt5>=5.15.0 - numpy>=1.21.1 + numpy>=1.21.1,<1.22.0 scipy>=1.7.1 Cython>=0.29.24 python_requires = >=3.8, <4 From 209a2e326b303cbcfe4369a8d28ad017442157fe Mon Sep 17 00:00:00 2001 From: Randmental <{ID}+{randmental}@users.noreply.github.com> Date: Wed, 12 Jan 2022 16:09:15 +0200 Subject: [PATCH 06/22] self.sweep_control.progress_bar.setValue() needs an int value, percentage sweep is not always guaranteed to be an int --- NanoVNASaver/NanoVNASaver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NanoVNASaver/NanoVNASaver.py b/NanoVNASaver/NanoVNASaver.py index 6818f5b0..0948cbfe 100644 --- a/NanoVNASaver/NanoVNASaver.py +++ b/NanoVNASaver/NanoVNASaver.py @@ -493,7 +493,7 @@ def dataUpdated(self): for c in self.combinedCharts: c.setCombinedData(s11, s21) - self.sweep_control.progress_bar.setValue(self.worker.percentage) + self.sweep_control.progress_bar.setValue(int(self.worker.percentage)) # add int() RM 12-01-2022 self.windows["tdr"].updateTDR() if s11: From 915da14ac1abc7af4da8dd92b3c7c3aa386c68cf Mon Sep 17 00:00:00 2001 From: Galileo Date: Sun, 16 Jan 2022 21:37:20 +0100 Subject: [PATCH 07/22] PA0JOZ Enhanced Response Correction --- NanoVNASaver/Calibration.py | 64 +++++++++++++++++---- NanoVNASaver/SweepWorker.py | 11 ++-- NanoVNASaver/Windows/CalibrationSettings.py | 3 +- 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/NanoVNASaver/Calibration.py b/NanoVNASaver/Calibration.py index c9e88ad8..f7b70813 100644 --- a/NanoVNASaver/Calibration.py +++ b/NanoVNASaver/Calibration.py @@ -34,6 +34,7 @@ (?P[-0-9Ee.]+) \s+ (?P[-0-9Ee.]+) \s+ (?P[-0-9Ee.]+) \s+ (?P[-0-9Ee.]+)(?: \s (?P[-0-9Ee.]+) \s+ (?P[-0-9Ee.]+) \s+ + (?P[-0-9Ee.]+) \s+ (?P[-0-9Ee.]+) \s+ (?P[-0-9Ee.]+) \s+ (?P[-0-9Ee.]+) )? """, re.VERBOSE) @@ -55,16 +56,19 @@ def __init__(self): "open": None, "load": None, "through": None, + "thrurefl": None, "isolation": None, # the frequence "freq": 0, # 1 Port "e00": 0.0, # Directivity - "e11": 0.0, # Port match + "e11": 0.0, # Port1 match "delta_e": 0.0, # Tracking + "e10e01": 0.0, # Forward Reflection Tracking # 2 port - "e30": 0.0, # Port match - "e10e32": 0.0, # Transmission + "e30": 0.0, # Forward isolation + "e22": 0.0, # Port2 match + "e10e32": 0.0, # Forward transmission } super().__init__(data) @@ -76,6 +80,7 @@ def __str__(self): f' {d["load"].re} {d["load"].im}') if d["through"] is not None: s += (f' {d["through"].re} {d["through"].im}' + f' {d["thrurefl"].re} {d["thrurefl"].im}' f' {d["isolation"].re} {d["isolation"].im}') return s @@ -115,14 +120,14 @@ def complete1port(self) -> bool: def complete2port(self) -> bool: for val in self.data.values(): - for name in ("short", "open", "load", "through", "isolation"): + for name in ("short", "open", "load", "through", "thrurefl", "isolation"): if val[name] is None: return False return any(self.data) class Calibration: - CAL_NAMES = ("short", "open", "load", "through", "isolation",) + CAL_NAMES = ("short", "open", "load", "through", "thrurefl", "isolation",) IDEAL_SHORT = complex(-1, 0) IDEAL_OPEN = complex(1, 0) IDEAL_LOAD = complex(0, 0) @@ -222,10 +227,18 @@ def calc_corrections(self): if self.isValid2Port(): caldata["e30"] = caldata["isolation"].z - gt = self.gamma_through(freq) - caldata["e10e32"] = (caldata["through"].z / gt - caldata["e30"] - ) * (1 - caldata["e11"]**2) + gm4 = caldata["through"].z + gm5 = caldata["thrurefl"].z + gm6 = caldata["isolation"].z + + caldata["e10e01"] = caldata["e00"] * caldata["e11"] - caldata["delta_e"] + gm7 = gm5 - caldata["e00"] + caldata["e22"] = gm7 /(gm7*caldata["e11"]*gt**2+caldata["e10e01"]*gt**2) + caldata["e10e32"] = (gm4-gm6)*(1-caldata["e11"]*caldata["e22"]*gt**2)/gt + + + self.gen_interpolation() self.isCalculated = True @@ -280,7 +293,9 @@ def gen_interpolation(self): e00 = [] e11 = [] delta_e = [] + e10e01 = [] e30 = [] + e22 = [] e10e32 = [] for caldata in self.dataset.values(): @@ -288,7 +303,9 @@ def gen_interpolation(self): e00.append(caldata["e00"]) e11.append(caldata["e11"]) delta_e.append(caldata["delta_e"]) + e10e01.append(caldata["e10e01"]) e30.append(caldata["e30"]) + e22.append(caldata["e22"]) e10e32.append(caldata["e10e32"]) self.interp = { @@ -301,9 +318,15 @@ def gen_interpolation(self): "delta_e": interp1d(freq, delta_e, kind="slinear", bounds_error=False, fill_value=(delta_e[0], delta_e[-1])), + "e10e01": interp1d(freq, e10e01, + kind="slinear", bounds_error=False, + fill_value=(e10e01[0], e10e01[-1])), "e30": interp1d(freq, e30, kind="slinear", bounds_error=False, fill_value=(e30[0], e30[-1])), + "e22": interp1d(freq, e22, + kind="slinear", bounds_error=False, + fill_value=(e22[0], e22[-1])), "e10e32": interp1d(freq, e10e32, kind="slinear", bounds_error=False, fill_value=(e10e32[0], e10e32[-1])), @@ -315,11 +338,28 @@ def correct11(self, dp: Datapoint): (dp.z * i["e11"](dp.freq)) - i["delta_e"](dp.freq)) return Datapoint(dp.freq, s11.real, s11.imag) - def correct21(self, dp: Datapoint): + def correct21(self, dp: Datapoint, dp11: Datapoint): i = self.interp s21 = (dp.z - i["e30"](dp.freq)) / i["e10e32"](dp.freq) + s21 = s21 * (i["e10e01"](dp.freq)/(i["e11"](dp.freq)*dp11.z-i["delta_e"](dp.freq))) return Datapoint(dp.freq, s21.real, s21.imag) + def dump_correct(self, dp: Datapoint, dp11: Datapoint): + i = self.interp + if dp.freq == 2520000000 or dp.freq == 2600000000: + print("freq: ", dp.freq) + print("z11: ", dp11.z) + print("z21: ", dp.z) + print("e00: ", i["e00"](dp.freq)) + print("e11: ", i["e11"](dp.freq)) + print("delta_e: ", i["delta_e"](dp.freq)) + print("e10e01: ", i["e10e01"](dp.freq)) + print("e30: ", i["e30"](dp.freq)) + print("e22: ", i["e22"](dp.freq)) + print("e10e32: ", i["e10e32"](dp.freq)) + + + # TODO: implement tests def save(self, filename: str): # Save the calibration data to file @@ -331,7 +371,7 @@ def save(self, filename: str): calfile.write(f"! {note}\n") calfile.write( "# Hz ShortR ShortI OpenR OpenI LoadR LoadI" - " ThroughR ThroughI IsolationR IsolationI\n") + " ThroughR ThroughI ThrureflR ThrureflI IsolationR IsolationI\n") for freq in self.dataset.frequencies(): calfile.write(f"{self.dataset.get(freq)}\n") @@ -353,7 +393,7 @@ def load(self, filename): if line.startswith("#"): if not parsed_header and line == ( "# Hz ShortR ShortI OpenR OpenI LoadR LoadI" - " ThroughR ThroughI IsolationR IsolationI"): + " ThroughR ThroughI ThrureflR ThrureflI IsolationR IsolationI"): parsed_header = True continue if not parsed_header: @@ -367,7 +407,7 @@ def load(self, filename): logger.warning("Illegal data in cal file. Line %i", i) cal = m.groupdict() - nr_cals = 5 if cal["throughr"] else 3 + nr_cals = 6 if cal["throughr"] else 3 for name in Calibration.CAL_NAMES[:nr_cals]: self.dataset.insert( name, diff --git a/NanoVNASaver/SweepWorker.py b/NanoVNASaver/SweepWorker.py index 602d7580..f01f7cea 100644 --- a/NanoVNASaver/SweepWorker.py +++ b/NanoVNASaver/SweepWorker.py @@ -199,11 +199,12 @@ def applyCalibration(self, else: data11 = raw_data11.copy() - if self.app.calibration.isValid2Port(): - for dp in raw_data21: - data21.append(self.app.calibration.correct21(dp)) - else: - data21 = raw_data21.copy() + if self.app.calibration.isValid2Port(): + for counter, dp in enumerate(raw_data21): + dp11 = raw_data11[counter] + data21.append(self.app.calibration.correct21(dp, dp11)) + else: + data21 = raw_data21 if self.offsetDelay != 0: data11 = [correct_delay(dp, self.offsetDelay, reflect=True) for dp in data11] diff --git a/NanoVNASaver/Windows/CalibrationSettings.py b/NanoVNASaver/Windows/CalibrationSettings.py index f990cb73..4df6f1a5 100644 --- a/NanoVNASaver/Windows/CalibrationSettings.py +++ b/NanoVNASaver/Windows/CalibrationSettings.py @@ -592,7 +592,7 @@ def loadCalibration(self): if not self.app.calibration.isValid1Port(): return for i, name in enumerate( - ("short", "open", "load", "through", "isolation")): + ("short", "open", "load", "through", "isolation", "thrurefl")): self.cal_label[name].setText( _format_cal_label(self.app.calibration.data_size(name), "Loaded")) if i == 2 and not self.app.calibration.isValid2Port(): @@ -812,6 +812,7 @@ def automaticCalibrationStep(self): if self.nextStep == 4: # Done + self.cal_save("thrurefl") self.cal_save("through") apply_step = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Information, From 55b7c4e42c37a8ed90545e7701dc6eae08ea0a87 Mon Sep 17 00:00:00 2001 From: Galileo Date: Mon, 17 Jan 2022 01:15:25 +0100 Subject: [PATCH 08/22] fix for issue #458 --- NanoVNASaver/Hardware/VNA.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/NanoVNASaver/Hardware/VNA.py b/NanoVNASaver/Hardware/VNA.py index ae749b46..9d608252 100644 --- a/NanoVNASaver/Hardware/VNA.py +++ b/NanoVNASaver/Hardware/VNA.py @@ -29,12 +29,17 @@ logger = logging.getLogger(__name__) DISLORD_BW = OrderedDict(( - (10, 181), - (33, 58), - (100, 19), - (333, 5), - (1000, 1), - (2000, 0), + (10, 363), + (33, 117), + (50, 78), + (100, 39), + (200, 19), + (250, 15), + (333, 11), + (500, 7), + (1000, 3), + (2000, 1), + (4000, 0), )) WAIT = 0.05 From 55d86acec155a15ab916981360cfb88909b69ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Mon, 17 Jan 2022 08:50:04 +0100 Subject: [PATCH 09/22] Update NanoVNASaver/NanoVNASaver.py --- NanoVNASaver/NanoVNASaver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NanoVNASaver/NanoVNASaver.py b/NanoVNASaver/NanoVNASaver.py index 0948cbfe..a56e82bc 100644 --- a/NanoVNASaver/NanoVNASaver.py +++ b/NanoVNASaver/NanoVNASaver.py @@ -493,7 +493,7 @@ def dataUpdated(self): for c in self.combinedCharts: c.setCombinedData(s11, s21) - self.sweep_control.progress_bar.setValue(int(self.worker.percentage)) # add int() RM 12-01-2022 + self.sweep_control.progress_bar.setValue(int(self.worker.percentage)) self.windows["tdr"].updateTDR() if s11: From 1c8477f1a968f332a0fa986a78e88d91a5760c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 18 Feb 2022 19:31:54 +0100 Subject: [PATCH 10/22] Linting and refactoring --- NanoVNASaver/Calibration.py | 95 ++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 53 deletions(-) diff --git a/NanoVNASaver/Calibration.py b/NanoVNASaver/Calibration.py index f7b70813..5c592d64 100644 --- a/NanoVNASaver/Calibration.py +++ b/NanoVNASaver/Calibration.py @@ -185,6 +185,43 @@ def isValid1Port(self) -> bool: def isValid2Port(self) -> bool: return self.dataset.complete2port() + def _calc_port_1(self, freq: int, cal: CalData): + g1 = self.gamma_short(freq) + g2 = self.gamma_open(freq) + g3 = self.gamma_load(freq) + + gm1 = cal["short"].z + gm2 = cal["open"].z + gm3 = cal["load"].z + + denominator = (g1 * (g2 - g3) * gm1 + + g2 * g3 * gm2 - g2 * g3 * gm3 - + (g2 * gm2 - g3 * gm3) * g1) + cal["e00"] = - ((g2 * gm3 - g3 * gm3) * g1 * gm2 - + (g2 * g3 * gm2 - g2 * g3 * gm3 - + (g3 * gm2 - g2 * gm3) * g1) * gm1 + ) / denominator + cal["e11"] = ((g2 - g3) * gm1 - g1 * (gm2 - gm3) + + g3 * gm2 - g2 * gm3) / denominator + cal["delta_e"] = - ((g1 * (gm2 - gm3) - g2 * gm2 + g3 * + gm3) * gm1 + (g2 * gm3 - g3 * gm3) * + gm2) / denominator + + def _calc_port_2(self, freq: int, cal: CalData): + gt = self.gamma_through(freq) + + gm4 = cal["through"].z + gm5 = cal["thrurefl"].z + gm6 = cal["isolation"].z + gm7 = gm5 - cal["e00"] + + cal["e30"] = cal["isolation"].z + cal["e10e01"] = cal["e00"] * cal["e11"] - cal["delta_e"] + cal["e22"] = gm7 / ( + gm7 * cal["e11"] * gt**2 + cal["e10e01"] * gt**2) + cal["e10e32"] = (gm4 - gm6) * ( + 1 - cal["e11"] * cal["e22"] *gt**2) / gt + def calc_corrections(self): if not self.isValid1Port(): logger.warning( @@ -195,27 +232,10 @@ def calc_corrections(self): logger.debug("Calculating calibration for %d points.", self.size()) for freq, caldata in self.dataset.items(): - g1 = self.gamma_short(freq) - g2 = self.gamma_open(freq) - g3 = self.gamma_load(freq) - - gm1 = caldata["short"].z - gm2 = caldata["open"].z - gm3 = caldata["load"].z - try: - denominator = (g1 * (g2 - g3) * gm1 + - g2 * g3 * gm2 - g2 * g3 * gm3 - - (g2 * gm2 - g3 * gm3) * g1) - caldata["e00"] = - ((g2 * gm3 - g3 * gm3) * g1 * gm2 - - (g2 * g3 * gm2 - g2 * g3 * gm3 - - (g3 * gm2 - g2 * gm3) * g1) * gm1 - ) / denominator - caldata["e11"] = ((g2 - g3) * gm1 - g1 * (gm2 - gm3) + - g3 * gm2 - g2 * gm3) / denominator - caldata["delta_e"] = - ((g1 * (gm2 - gm3) - g2 * gm2 + g3 * - gm3) * gm1 + (g2 * gm3 - g3 * gm3) * - gm2) / denominator + self._calc_port_1(freq, caldata) + if self.isValid2Port(): + self._calc_port_2(freq, caldata) except ZeroDivisionError as exc: self.isCalculated = False logger.error( @@ -225,21 +245,6 @@ def calc_corrections(self): f"Two of short, open and load returned the same" f" values at frequency {freq}Hz.") from exc - if self.isValid2Port(): - caldata["e30"] = caldata["isolation"].z - gt = self.gamma_through(freq) - gm4 = caldata["through"].z - gm5 = caldata["thrurefl"].z - gm6 = caldata["isolation"].z - - caldata["e10e01"] = caldata["e00"] * caldata["e11"] - caldata["delta_e"] - gm7 = gm5 - caldata["e00"] - caldata["e22"] = gm7 /(gm7*caldata["e11"]*gt**2+caldata["e10e01"]*gt**2) - caldata["e10e32"] = (gm4-gm6)*(1-caldata["e11"]*caldata["e22"]*gt**2)/gt - - - - self.gen_interpolation() self.isCalculated = True logger.debug("Calibration correctly calculated.") @@ -344,28 +349,12 @@ def correct21(self, dp: Datapoint, dp11: Datapoint): s21 = s21 * (i["e10e01"](dp.freq)/(i["e11"](dp.freq)*dp11.z-i["delta_e"](dp.freq))) return Datapoint(dp.freq, s21.real, s21.imag) - def dump_correct(self, dp: Datapoint, dp11: Datapoint): - i = self.interp - if dp.freq == 2520000000 or dp.freq == 2600000000: - print("freq: ", dp.freq) - print("z11: ", dp11.z) - print("z21: ", dp.z) - print("e00: ", i["e00"](dp.freq)) - print("e11: ", i["e11"](dp.freq)) - print("delta_e: ", i["delta_e"](dp.freq)) - print("e10e01: ", i["e10e01"](dp.freq)) - print("e30: ", i["e30"](dp.freq)) - print("e22: ", i["e22"](dp.freq)) - print("e10e32: ", i["e10e32"](dp.freq)) - - - # TODO: implement tests def save(self, filename: str): # Save the calibration data to file if not self.isValid1Port(): raise ValueError("Not a valid 1-Port calibration") - with open(f"{filename}", "w") as calfile: + with open(filename, mode="w", encoding='utf-8') as calfile: calfile.write("# Calibration data for NanoVNA-Saver\n") for note in self.notes: calfile.write(f"! {note}\n") @@ -383,7 +372,7 @@ def load(self, filename): self.notes = [] parsed_header = False - with open(filename) as calfile: + with open(filename, encoding='utf-8') as calfile: for i, line in enumerate(calfile): line = line.strip() if line.startswith("!"): From f613ee1a5a69be0c9667c066ca413be6f978d283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 18 Feb 2022 19:32:43 +0100 Subject: [PATCH 11/22] Version Bump --- NanoVNASaver/About.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NanoVNASaver/About.py b/NanoVNASaver/About.py index 4f09aa73..ca304ca8 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.3.11-pre" +VERSION = "0.4.0-pre" VERSION_URL = ( "https://raw.githubusercontent.com/" "NanoVNA-Saver/nanovna-saver/master/NanoVNASaver/About.py") From 884207d910210d20ea4d3c8f7cb7e313d7ac048f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 18 Feb 2022 19:36:56 +0100 Subject: [PATCH 12/22] updated pyinstaller --- .github/workflows/release_linux.yml | 4 ++-- .github/workflows/release_macos.yml | 4 ++-- .github/workflows/release_win.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index 30e2cf06..fd31cfb2 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -18,9 +18,9 @@ jobs: python-version: 3.9 - name: Install dependencies and pyinstall run: | - python -m pip install pip==21.3.1 setuptools==60.5.0 + python -m pip install pip==22.0.3 setuptools==60.9.3 pip install -r requirements.txt - pip install PyInstaller==4.7 + pip install PyInstaller==4.9 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver nanovna-saver.py diff --git a/.github/workflows/release_macos.yml b/.github/workflows/release_macos.yml index 4ae5df78..1caa915b 100644 --- a/.github/workflows/release_macos.yml +++ b/.github/workflows/release_macos.yml @@ -18,9 +18,9 @@ jobs: python-version: 3.9 - name: Install dependencies and pyinstall run: | - python -m pip install pip==21.3.1 setuptools==60.5.0 + python -m pip install pip==22.0.3 setuptools==60.9.3 pip install -r requirements.txt - pip install PyInstaller==4.7 + pip install PyInstaller==4.9 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver nanovna-saver.py diff --git a/.github/workflows/release_win.yml b/.github/workflows/release_win.yml index e4adf467..01a547a6 100644 --- a/.github/workflows/release_win.yml +++ b/.github/workflows/release_win.yml @@ -22,9 +22,9 @@ jobs: architecture: ${{ matrix.arch }} - name: Install dependencies and pyinstall run: | - python -m pip install pip==21.3.1 setuptools==60.5.0 + python -m pip install pip==22.0.3 setuptools==60.9.3 pip install -r requirements.txt - pip install PyInstaller==4.7 + pip install PyInstaller==4.9 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver.exe nanovna-saver.py From 8432dcfbd3cba6db72d6aaf95409bac8f57a3395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 18 Feb 2022 20:16:44 +0100 Subject: [PATCH 13/22] use older setuptools for pyinstaller --- .github/workflows/release_linux.yml | 2 +- .github/workflows/release_macos.yml | 2 +- .github/workflows/release_win.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index fd31cfb2..e2082243 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -18,7 +18,7 @@ jobs: python-version: 3.9 - name: Install dependencies and pyinstall run: | - python -m pip install pip==22.0.3 setuptools==60.9.3 + python -m pip install pip==22.0.3 setuptools==60.7.1 pip install -r requirements.txt pip install PyInstaller==4.9 - name: Build binary diff --git a/.github/workflows/release_macos.yml b/.github/workflows/release_macos.yml index 1caa915b..28015901 100644 --- a/.github/workflows/release_macos.yml +++ b/.github/workflows/release_macos.yml @@ -18,7 +18,7 @@ jobs: python-version: 3.9 - name: Install dependencies and pyinstall run: | - python -m pip install pip==22.0.3 setuptools==60.9.3 + python -m pip install pip==22.0.3 setuptools==60.7.1 pip install -r requirements.txt pip install PyInstaller==4.9 - name: Build binary diff --git a/.github/workflows/release_win.yml b/.github/workflows/release_win.yml index 01a547a6..0ffe0031 100644 --- a/.github/workflows/release_win.yml +++ b/.github/workflows/release_win.yml @@ -22,7 +22,7 @@ jobs: architecture: ${{ matrix.arch }} - name: Install dependencies and pyinstall run: | - python -m pip install pip==22.0.3 setuptools==60.9.3 + python -m pip install pip==22.0.3 setuptools==60.7.1 pip install -r requirements.txt pip install PyInstaller==4.9 - name: Build binary From d596ba7661bf082bdcc93535c64120d567a9c3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 18 Feb 2022 20:31:09 +0100 Subject: [PATCH 14/22] test build with python 3.10 --- .github/workflows/release_linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index e2082243..5c6f5d5d 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies and pyinstall run: | python -m pip install pip==22.0.3 setuptools==60.7.1 From 982dbe26abf4c6a6ca1204c976474bb28dfc55a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 18 Feb 2022 20:33:23 +0100 Subject: [PATCH 15/22] version in workflow as string --- .github/workflows/release_linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index 5c6f5d5d..b11711e5 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10 + python-version: '3.10' - name: Install dependencies and pyinstall run: | python -m pip install pip==22.0.3 setuptools==60.7.1 From ca97287fc47f0683de9cec8a7cfa89e204df2899 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Mon, 7 Mar 2022 14:51:51 +0100 Subject: [PATCH 16/22] Version: avoid infinite recursion The comparison operators (<, >, etc.) are not translated 1:1 to customisation methods (__lt__, __gt__, ...) in Python. Instead the type of the operands plays a role in determining on which of the two sides the customisation method is invoked (see Python Language Reference section 3.3.1 [1]). This means 'a > b' can end up invoking b.__lt__(a) rather than a.__gt__(b). This behaviour can causes infinite recursion in Version.__lt__(): 2022-03-07 13:47:52,087 - NanoVNASaver.Hardware.NanoVNA_V2 - ERROR - Timeout reading version registers Traceback (most recent call last): File "/home/sascha/nanovna-saver/NanoVNASaver/Controls/SerialControl.py", line 73, in serialButtonClick self.connect_device() File "/home/sascha/nanovna-saver/NanoVNASaver/Controls/SerialControl.py", line 93, in connect_device self.app.vna = get_VNA(self.interface) File "/home/sascha/nanovna-saver/NanoVNASaver/Hardware/Hardware.py", line 101, in get_VNA return NAME2DEVICE[iface.comment](iface) File "/home/sascha/nanovna-saver/NanoVNASaver/Hardware/NanoVNA_V2.py", line 76, in __init__ super().__init__(iface) File "/home/sascha/nanovna-saver/NanoVNASaver/Hardware/VNA.py", line 71, in __init__ self.read_features() File "/home/sascha/nanovna-saver/NanoVNASaver/Hardware/NanoVNA_V2.py", line 107, in read_features if self.board_revision >= Version("2.0.4"): File "/home/sascha/nanovna-saver/NanoVNASaver/Version.py", line 63, in __le__ return self < other or self == other File "/home/sascha/nanovna-saver/NanoVNASaver/Version.py", line 57, in __lt__ return other > self File "/home/sascha/nanovna-saver/NanoVNASaver/Version.py", line 57, in __lt__ return other > self File "/home/sascha/nanovna-saver/NanoVNASaver/Version.py", line 57, in __lt__ return other > self [Previous line repeated 491 more times] RecursionError: maximum recursion depth exceeded in comparison Fix it by explicitly invoking the customisation methods we expect. [1] https://docs.python.org/3/reference/datamodel.html#object.__lt__ --- NanoVNASaver/Version.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NanoVNASaver/Version.py b/NanoVNASaver/Version.py index 1df6233f..01fe5caa 100644 --- a/NanoVNASaver/Version.py +++ b/NanoVNASaver/Version.py @@ -54,13 +54,13 @@ def __gt__(self, other: "Version") -> bool: return False def __lt__(self, other: "Version") -> bool: - return other > self + return other.__gt__(self) def __ge__(self, other: "Version") -> bool: - return self > other or self == other + return self.__gt__(other) or self.__eq__(other) def __le__(self, other: "Version") -> bool: - return self < other or self == other + return other.__gt__(self) or self.__eq__(other) def __eq__(self, other: "Version") -> bool: return self.data == other.data From 630d6fafc36355c37bfa824bb32042b96f0ba7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Thu, 17 Mar 2022 17:54:52 +0100 Subject: [PATCH 17/22] linting --- NanoVNASaver/Formatting.py | 8 ++------ NanoVNASaver/Hardware/TinySA.py | 8 +------- NanoVNASaver/Hardware/VNA.py | 5 ++--- NanoVNASaver/Settings/Bands.py | 17 ++++++++--------- NanoVNASaver/Settings/Sweep.py | 12 +++++++----- NanoVNASaver/Windows/About.py | 2 +- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/NanoVNASaver/Formatting.py b/NanoVNASaver/Formatting.py index 17b4a9cc..7fdf05c2 100644 --- a/NanoVNASaver/Formatting.py +++ b/NanoVNASaver/Formatting.py @@ -115,17 +115,13 @@ def format_complex_adm(z: complex, allow_negative: bool = False) -> str: return "- S" adm = 1/z - fmt_re = FMT_COMPLEX - if allow_negative: - fmt_re = FMT_COMPLEX_NEG + fmt_re = FMT_COMPLEX_NEG if allow_negative else FMT_COMPLEX re = SITools.Value(adm.real, fmt=fmt_re) im = SITools.Value(abs(adm.imag), fmt=FMT_COMPLEX) return f"{re}{'-' if adm.imag < 0 else '+'}j{im} S" def format_complex_imp(z: complex, allow_negative: bool = False) -> str: - fmt_re = FMT_COMPLEX - if allow_negative: - fmt_re = FMT_COMPLEX_NEG + fmt_re = FMT_COMPLEX_NEG if allow_negative else FMT_COMPLEX re = SITools.Value(z.real, fmt=fmt_re) im = SITools.Value(abs(z.imag), fmt=FMT_COMPLEX) return f"{re}{'-' if z.imag < 0 else '+'}j{im} ""\N{OHM SIGN}" diff --git a/NanoVNASaver/Hardware/TinySA.py b/NanoVNASaver/Hardware/TinySA.py index cff4e6a5..19af3bb0 100644 --- a/NanoVNASaver/Hardware/TinySA.py +++ b/NanoVNASaver/Hardware/TinySA.py @@ -114,11 +114,5 @@ def readFrequencies(self) -> List[int]: def readValues(self, value) -> List[str]: logger.debug("Read: %s", value) if value == "data 0": - self._sweepdata = [] - for line in self.exec_command("data"): - self._sweepdata.append(f"0 {line.strip()}") + self._sweepdata = [f"0 {line.strip()}" for line in self.exec_command("data")] return self._sweepdata - if value == "data 0": - return [x[0] for x in self._sweepdata] - if value == "data 1": - return [x[0] for x in self._sweepdata] diff --git a/NanoVNASaver/Hardware/VNA.py b/NanoVNASaver/Hardware/VNA.py index 9d608252..f72f82ef 100644 --- a/NanoVNASaver/Hardware/VNA.py +++ b/NanoVNASaver/Hardware/VNA.py @@ -141,9 +141,8 @@ def get_bandwidths(self) -> List[int]: return [1000, ] def set_bandwidth(self, bandwidth: int): - bw_val = bandwidth - if self.bw_method == "dislord": - bw_val = DISLORD_BW[bandwidth] + bw_val = DISLORD_BW[bandwidth] \ + if self.bw_method == "dislord" else bandwidth result = " ".join(self.exec_command(f"bandwidth {bw_val}")) if self.bw_method == "ttrftech" and result: raise IOError(f"set_bandwith({bandwidth}: {result}") diff --git a/NanoVNASaver/Settings/Bands.py b/NanoVNASaver/Settings/Bands.py index ac897056..3c6844d2 100644 --- a/NanoVNASaver/Settings/Bands.py +++ b/NanoVNASaver/Settings/Bands.py @@ -62,10 +62,10 @@ def __init__(self): self.settings.setIniCodec("UTF-8") self.enabled = self.settings.value("ShowBands", False, bool) - self.bands = [] - - for band in self.settings.value("bands", _DEFAULT_BANDS): - self.bands.append(band.split(";")) + self.bands = [ + band.split(";") + for band in self.settings.value("bands", _DEFAULT_BANDS) + ] def saveSettings(self): self.settings.setValue( @@ -74,9 +74,7 @@ def saveSettings(self): self.settings.sync() def resetBands(self): - self.bands = [] - for band in _DEFAULT_BANDS: - self.bands.append(band.split(";")) + self.bands = [band.split(";") for band in _DEFAULT_BANDS] self.layoutChanged.emit() self.saveSettings() @@ -87,8 +85,9 @@ def rowCount(self, _) -> int: return len(self.bands) def data(self, index: QModelIndex, role: int = ...) -> QtCore.QVariant: - if (role == QtCore.Qt.DisplayRole or - role == QtCore.Qt.ItemDataRole or role == QtCore.Qt.EditRole): + if role in [ + QtCore.Qt.DisplayRole, QtCore.Qt.ItemDataRole, QtCore.Qt.EditRole, + ]: return QtCore.QVariant(self.bands[index.row()][index.column()]) if role == QtCore.Qt.TextAlignmentRole: if index.column() == 0: diff --git a/NanoVNASaver/Settings/Sweep.py b/NanoVNASaver/Settings/Sweep.py index ec0d7f64..edcad2b6 100644 --- a/NanoVNASaver/Settings/Sweep.py +++ b/NanoVNASaver/Settings/Sweep.py @@ -85,11 +85,13 @@ def stepsize(self) -> int: return round(self.span / (self.points * self.segments - 1)) def check(self): - if not(self.segments > 0 and - self.points > 0 and - self.start > 0 and - self.end > 0 and - self.stepsize >= 1): + if ( + self.segments <= 0 + or self.points <= 0 + or self.start <= 0 + or self.end <= 0 + or self.stepsize < 1 + ): raise ValueError(f"Illegal sweep settings: {self}") def _exp_factor(self, index: int) -> float: diff --git a/NanoVNASaver/Windows/About.py b/NanoVNASaver/Windows/About.py index 6b3b5d5d..f269a962 100644 --- a/NanoVNASaver/Windows/About.py +++ b/NanoVNASaver/Windows/About.py @@ -154,7 +154,7 @@ def findUpdates(self, automatic=False): latest_url = "" try: req = request.Request(VERSION_URL) - req.add_header('User-Agent', "NanoVNA-Saver/" + self.app.version) + req.add_header('User-Agent', f'NanoVNA-Saver/{self.app.version}') for line in request.urlopen(req, timeout=3): line = line.decode("utf-8") if line.startswith("VERSION ="): From 747184e85fa6af3c34879ae749e14a1214627456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Thu, 17 Mar 2022 18:04:34 +0100 Subject: [PATCH 18/22] use pyinstaller 4.10 --- .github/workflows/release_linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index b11711e5..c532812f 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -18,9 +18,9 @@ jobs: python-version: '3.10' - name: Install dependencies and pyinstall run: | - python -m pip install pip==22.0.3 setuptools==60.7.1 + python -m pip install pip==22.0.4 setuptools==60.10.0 pip install -r requirements.txt - pip install PyInstaller==4.9 + pip install PyInstaller==4.10 - name: Build binary run: | pyinstaller --onefile -n nanovna-saver nanovna-saver.py From ed48c85e8e6104bf840d38729f2dd36d366a5dff Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 26 Mar 2022 09:03:03 -0400 Subject: [PATCH 19/22] Fix command-line formatting in README.md Add additional indentation to force code formatting of command lines. (Could use triple-backticks instead.) --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7e902f2f..7536d508 100644 --- a/README.md +++ b/README.md @@ -96,34 +96,34 @@ The downloadable executable runs directly, and requires no installation. 1. Clone repo and cd into the directory - git clone https://github.com/NanoVNA-Saver/nanovna-saver - cd nanovna-saver + git clone https://github.com/NanoVNA-Saver/nanovna-saver + cd nanovna-saver 2. Run the pip installation - pip3 install . + pip3 install . 3. Once completed run with the following command - NanoVNASaver + NanoVNASaver #### Ubuntu 20.04 1. Install python3.8 and pip - sudo apt install python3.8 python3-pip - python3 -m venv ~/.venv_nano - . ~/.venv_nano/bin/activate - pip install -U pip + sudo apt install python3.8 python3-pip + python3 -m venv ~/.venv_nano + . ~/.venv_nano/bin/activate + pip install -U pip 2. Clone repo and cd into the directory - git clone https://github.com/NanoVNA-Saver/nanovna-saver - cd nanovna-saver + git clone https://github.com/NanoVNA-Saver/nanovna-saver + cd nanovna-saver 3. Update pip and run the pip installation - python3 -m pip install . + python3 -m pip install . (You may need to install the additional packages python3-distutils, python3-setuptools and python3-wheel for this command to work on some @@ -131,8 +131,8 @@ The downloadable executable runs directly, and requires no installation. 4. Once completed run with the following command - . ~/.venv_nano/bin/activate - python3 nanovna-saver.py + . ~/.venv_nano/bin/activate + python3 nanovna-saver.py #### MacPorts From 02de5a16507e7a84625fb2719ef005970089b864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Sat, 26 Mar 2022 20:11:33 +0100 Subject: [PATCH 20/22] Fix linux binary build --- .github/workflows/release_linux.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index c532812f..6434aeba 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -11,20 +11,25 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.10' + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install python + run: | + sudo apt-get update + sudo apt install -y python3.9 python3-pip python3.9-venv \ + python3.9-dev \ + python3-pyqt5 - name: Install dependencies and pyinstall run: | + python3.9 -m venv build + . build/bin/activate python -m pip install pip==22.0.4 setuptools==60.10.0 pip install -r requirements.txt pip install PyInstaller==4.10 - name: Build binary run: | + . build/bin/activate pyinstaller --onefile -n nanovna-saver nanovna-saver.py - - name: Archive production artifacts uses: actions/upload-artifact@v1 with: From f68d3c2fb779a5015ef8f47096bcac1d0f1c3d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 1 Apr 2022 16:29:19 +0200 Subject: [PATCH 21/22] Version 0.4.0 Allow 2 digit versions. Fixes #483 --- NanoVNASaver/About.py | 2 +- NanoVNASaver/Version.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NanoVNASaver/About.py b/NanoVNASaver/About.py index ca304ca8..94e0c143 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.4.0-pre" +VERSION = "0.4.0" VERSION_URL = ( "https://raw.githubusercontent.com/" "NanoVNA-Saver/nanovna-saver/master/NanoVNASaver/About.py") diff --git a/NanoVNASaver/Version.py b/NanoVNASaver/Version.py index 01fe5caa..3ab85249 100644 --- a/NanoVNASaver/Version.py +++ b/NanoVNASaver/Version.py @@ -15,8 +15,10 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from lib2to3.pytree import type_repr import logging import re +from typing import Type logger = logging.getLogger(__name__) @@ -25,8 +27,8 @@ class Version: RXP = re.compile(r"""^ \D* (?P\d+)\. - (?P\d+)\. - (?P\d+) + (?P\d+)\.? + (?P\d+)? (?P.*) $""", re.VERBOSE) @@ -41,6 +43,8 @@ def __init__(self, vstring: str = "0.0.0"): self.data = Version.RXP.search(vstring).groupdict() for name in ("major", "minor", "revision"): self.data[name] = int(self.data[name]) + except TypeError: + self.data["revision"] = 0 except AttributeError: logger.error("Unable to parse version: %s", vstring) From 6c82ff6ee384f3af1e4d64ee576861eac9977cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20M=C3=BCller?= Date: Fri, 1 Apr 2022 16:44:54 +0200 Subject: [PATCH 22/22] Updated documentation for 0.4.0 --- CHANGELOG.md | 7 +++++++ README.md | 12 ++++++++++-- setup.cfg | 6 +----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a974da2..55825609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +0.4.0 +----- + + - PA0JOZ Enhanced Response Correction + - Fix linux binary build + - Many bugfixes + v0.3.10 ------ diff --git a/README.md b/README.md index 7536d508..0e277a6e 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,19 @@ sweep frequency spans in segments to gain more than 101 data points, and generally display and analyze the resulting data. - Copyright 2019, 2020 Rune B. Broberg -- Copyright 2020, 2021 NanoVNA-Saver Authors +- Copyright 2020ff NanoVNA-Saver Authors Latest Changes -------------- +### Changes in 0.4.0 + + - PA0JOZ Enhanced Response Correction + This is the reason vor minor version increase as older callibration data shouldn't + be use. + - Fix linux binary build + - Many bugfixes + ### Changes in v0.3.10 - Default Band ranges for 5 and 9cm @@ -73,7 +81,7 @@ Running the application The software was written in Python on Windows, using Pycharm, and the modules PyQT5, numpy, scipy and pyserial. -Main development is currently done on Linux (Ubuntu 21.04) +Main development is currently done on Linux (Mint 20.3 Cinnamon) ### Binary releases diff --git a/setup.cfg b/setup.cfg index 1dde2fd2..dbeb32d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,11 +3,7 @@ name = NanoVNASaver author = Rune B. Broberg license = GNU GPL V3 license_file = LICENSE -description = - A multiplatform tool to save Touchstone files from the - NanoVNA, sweep frequency spans in segments to gain more - data points, and generally display and analyze the - resulting data. +description = A Qt GUI for the NanoVNA and derivates long_description = file: README.md url = https://github.com/NanoVNA-Saver/nanovna-saver version = attr: NanoVNASaver.About.VERSION