From d8b1a56c99395b21cf78bbd7342f077524a4701a Mon Sep 17 00:00:00 2001 From: Brendan Haines Date: Sat, 12 Apr 2025 22:35:04 -0600 Subject: [PATCH] rename config path --- README.md | 4 ++++ charon_vna/config_default.py | 8 ++++---- charon_vna/gui.py | 12 ++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bd896db..94489d9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # Charon VNA + + + + Named after [Pluto's moon](https://en.wikipedia.org/wiki/Charon_(moon)), Charon uses the [ADI Pluto SDR](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/adalm-pluto.html) as a vector network analyzer. The basic usage is as a 1 port VNA but this can be extended to arbitrarily many ports with the addition of a couple RF switches. diff --git a/charon_vna/config_default.py b/charon_vna/config_default.py index f38cdfb..2058cec 100644 --- a/charon_vna/config_default.py +++ b/charon_vna/config_default.py @@ -3,14 +3,14 @@ import subprocess import numpy as np -from charon_vna.gui import DEFAULT_CONFIG +from charon_vna.gui import PATH_CONFIG_DEFAULT config = dict( frequency=np.linspace(80e6, 500e6, 500).tolist(), power=-5, ) -with open(DEFAULT_CONFIG, "w") as f: +with open(PATH_CONFIG_DEFAULT, "w") as f: json.dump(config, f) # autoformat @@ -19,7 +19,7 @@ subprocess.run( "python", "-m", "json.tool", - DEFAULT_CONFIG.resolve().as_posix(), - DEFAULT_CONFIG.resolve().as_posix(), + PATH_CONFIG_DEFAULT.resolve().as_posix(), + PATH_CONFIG_DEFAULT.resolve().as_posix(), ] ) diff --git a/charon_vna/gui.py b/charon_vna/gui.py index 996d7b4..524c6e1 100644 --- a/charon_vna/gui.py +++ b/charon_vna/gui.py @@ -14,7 +14,6 @@ from numpy import typing as npt from PySide6.QtGui import QAction, QKeySequence from PySide6.QtWidgets import ( QApplication, - QDialogButtonBox, QFileDialog, QInputDialog, QLineEdit, @@ -31,7 +30,7 @@ from charon_vna.util import net2s, s2net from charon_vna.vna import Charon # %% -DEFAULT_CONFIG = Path(__file__).parent / "config_default.json" +PATH_CONFIG_DEFAULT = Path(__file__).parent / "config_default.json" CONFIG_SUFFIX = ".json" @@ -44,7 +43,7 @@ class MainWindow(QMainWindow): def __init__(self, ip: str | None = None): super().__init__() - self.config_path = DEFAULT_CONFIG + self.config_path = PATH_CONFIG_DEFAULT with open(self.config_path, "r") as f: config = json.load(f) self._frequency = config["frequency"] @@ -129,6 +128,7 @@ class MainWindow(QMainWindow): def saveas_config(self) -> None: print("Prompting for save path...") dialog = QFileDialog(self) + dialog.setNameFilter(f"*{CONFIG_SUFFIX}") dialog.setDefaultSuffix(CONFIG_SUFFIX) dialog.setAcceptMode(QFileDialog.AcceptMode.AcceptSave) if dialog.exec(): @@ -137,8 +137,8 @@ class MainWindow(QMainWindow): raise ValueError( f"{config_path.name} is not a valid configuration file. Must have extension {CONFIG_SUFFIX}" ) - if config_path == DEFAULT_CONFIG: - raise ValueError(f"Cannot overwrite default configuration file at {DEFAULT_CONFIG}") + if config_path == PATH_CONFIG_DEFAULT: + raise ValueError(f"Cannot overwrite default configuration file at {PATH_CONFIG_DEFAULT}") self.config_path = config_path print(f"Config path is now {self.config_path.resolve()}") @@ -162,7 +162,7 @@ class MainWindow(QMainWindow): self.load_config(self.config_path) def save_config(self) -> None: - if self.config_path == DEFAULT_CONFIG: + if self.config_path == PATH_CONFIG_DEFAULT: self.saveas_config() else: print(f"Saving config to {self.config_path.resolve()}")