gui working with real data
This commit is contained in:
parent
18a1b2faa3
commit
0202163f08
|
@ -162,7 +162,7 @@ class MainWindow(QMainWindow):
|
||||||
self.config_path = None
|
self.config_path = None
|
||||||
self._frequency = np.linspace(1e9, 2e9, 101) # TODO: read frequency from config
|
self._frequency = np.linspace(1e9, 2e9, 101) # TODO: read frequency from config
|
||||||
|
|
||||||
# self.device = Charon("ip:192.168.3.1", frequency=DEFAULT_CONFIG["frequency"])
|
self.vna = Charon("ip:192.168.3.1", frequency=DEFAULT_CONFIG["frequency"])
|
||||||
|
|
||||||
mpl.use("QtAgg")
|
mpl.use("QtAgg")
|
||||||
|
|
||||||
|
@ -194,6 +194,10 @@ class MainWindow(QMainWindow):
|
||||||
action_set_power = QAction("&Power", self)
|
action_set_power = QAction("&Power", self)
|
||||||
menu_stimulus.addAction(action_set_power)
|
menu_stimulus.addAction(action_set_power)
|
||||||
# action_set_power.triggered.connect(self.set_power)
|
# action_set_power.triggered.connect(self.set_power)
|
||||||
|
action_trigger = QAction("&Trigger", self)
|
||||||
|
action_trigger.triggered.connect(self.capture)
|
||||||
|
action_trigger.setShortcut("Ctrl+T")
|
||||||
|
menu_stimulus.addAction(action_trigger)
|
||||||
|
|
||||||
menu_calibration = QMenu("&Calibration")
|
menu_calibration = QMenu("&Calibration")
|
||||||
menubar.addMenu(menu_calibration)
|
menubar.addMenu(menu_calibration)
|
||||||
|
@ -215,6 +219,7 @@ class MainWindow(QMainWindow):
|
||||||
# prog_sweep.setTextVisible(False)
|
# prog_sweep.setTextVisible(False)
|
||||||
prog_sweep.setValue(50)
|
prog_sweep.setValue(50)
|
||||||
window_layout.addWidget(prog_sweep)
|
window_layout.addWidget(prog_sweep)
|
||||||
|
self.prog_sweep = prog_sweep
|
||||||
|
|
||||||
# window_widget.se
|
# window_widget.se
|
||||||
plot_layout = QVBoxLayout()
|
plot_layout = QVBoxLayout()
|
||||||
|
@ -277,6 +282,26 @@ class MainWindow(QMainWindow):
|
||||||
print(f"Loading config from {path}...")
|
print(f"Loading config from {path}...")
|
||||||
# TODO: load config
|
# TODO: load config
|
||||||
|
|
||||||
|
def capture(self) -> None:
|
||||||
|
def callback(done: int, total: int):
|
||||||
|
self.prog_sweep.setMaximum(total)
|
||||||
|
self.prog_sweep.setValue(done)
|
||||||
|
|
||||||
|
s = self.vna.vna_capture(self._frequency, callback)
|
||||||
|
|
||||||
|
data = xr.DataArray(
|
||||||
|
[[s]],
|
||||||
|
dims=["m", "n", "frequency"],
|
||||||
|
coords=dict(
|
||||||
|
frequency=s.coords["frequency"],
|
||||||
|
m=[1],
|
||||||
|
n=[1],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
for plot in self.plots:
|
||||||
|
plot.update_plot(data)
|
||||||
|
|
||||||
def generate_sim_data(self) -> None:
|
def generate_sim_data(self) -> None:
|
||||||
coords = {"frequency": self._frequency, "m": [1], "n": [1]}
|
coords = {"frequency": self._frequency, "m": [1], "n": [1]}
|
||||||
shape = tuple(len(v) for v in coords.values())
|
shape = tuple(len(v) for v in coords.values())
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# %% imports
|
# %% imports
|
||||||
import copy
|
import copy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Tuple
|
from typing import Any, Callable, Dict, Tuple
|
||||||
|
|
||||||
import adi
|
import adi
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Charon:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
uri: str,
|
uri: str = "192.168.2.1",
|
||||||
frequency: npt.ArrayLike = np.linspace(1e9, 2e9, 3),
|
frequency: npt.ArrayLike = np.linspace(1e9, 2e9, 3),
|
||||||
ports: Tuple[int] = (1,),
|
ports: Tuple[int] = (1,),
|
||||||
):
|
):
|
||||||
|
@ -207,7 +207,7 @@ class Charon:
|
||||||
s.loc[dict(frequency=frequency)] = self.get_b_over_a(frequency=frequency)
|
s.loc[dict(frequency=frequency)] = self.get_b_over_a(frequency=frequency)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def vna_capture(self, frequency: npt.ArrayLike):
|
def vna_capture(self, frequency: npt.ArrayLike, callback: Callable[int, int] | None):
|
||||||
s = xr.DataArray(
|
s = xr.DataArray(
|
||||||
np.empty(len(frequency), dtype=np.complex128),
|
np.empty(len(frequency), dtype=np.complex128),
|
||||||
dims=["frequency"],
|
dims=["frequency"],
|
||||||
|
@ -215,7 +215,9 @@ class Charon:
|
||||||
frequency=frequency,
|
frequency=frequency,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
for freq in s.frequency.data:
|
for ff, freq in enumerate(s.frequency.data):
|
||||||
|
if callback is not None:
|
||||||
|
callback(ff, len(s.frequency))
|
||||||
self.set_output(frequency=freq, power=-5)
|
self.set_output(frequency=freq, power=-5)
|
||||||
self.sdr.rx_destroy_buffer()
|
self.sdr.rx_destroy_buffer()
|
||||||
self.sdr.rx_lo = int(freq)
|
self.sdr.rx_lo = int(freq)
|
||||||
|
@ -226,6 +228,8 @@ class Charon:
|
||||||
self.sdr.rx_hardwaregain_chan1 = 40
|
self.sdr.rx_hardwaregain_chan1 = 40
|
||||||
rx = self.sdr.rx()
|
rx = self.sdr.rx()
|
||||||
s.loc[dict(frequency=freq)] = np.mean(rx[1] / rx[0])
|
s.loc[dict(frequency=freq)] = np.mean(rx[1] / rx[0])
|
||||||
|
if callback is not None:
|
||||||
|
callback(len(s.frequency), len(s.frequency))
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user