Added visualization of S11 value. Fixed display of real imaginary and magnitude plots.
This commit is contained in:
parent
1eae6bf38f
commit
b1da9f48e7
3 changed files with 40 additions and 5 deletions
|
@ -42,6 +42,10 @@ class BroadbandController(ModuleController):
|
|||
|
||||
elif key == "confirm_tune_and_match" and self.module.model.waiting_for_tune_and_match:
|
||||
logger.debug("Confirmed tune and match.")
|
||||
reflection = value
|
||||
logger.debug("Reflection: " + str(reflection))
|
||||
if reflection is not None:
|
||||
self.module.model.current_broadband_measurement.add_tune_and_match(reflection)
|
||||
self.module.nqrduck_signal.emit("start_measurement", None)
|
||||
self.module.model.waiting_for_tune_and_match = False
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ class BroadbandModel(ModuleModel):
|
|||
self._single_frequency_measurements[frequency] = None
|
||||
|
||||
self.frequency_step = frequency_step
|
||||
self.reflection = {}
|
||||
|
||||
def add_measurement(self, measurement : "Measurement") -> None:
|
||||
"""This method adds a single measurement to the broadband measurement.
|
||||
|
@ -188,7 +189,16 @@ class BroadbandModel(ModuleModel):
|
|||
|
||||
self.broadband_data_fdx = fdx_assembled.flatten()
|
||||
self.broadband_data_fdy = fdy_assembled.flatten()
|
||||
|
||||
|
||||
def add_tune_and_match(self, magnitude) -> None:
|
||||
"""This method adds the tune and match values to the last completed measurement.
|
||||
|
||||
Args:
|
||||
magnitude (float): The magnitude of the tune and match values."""
|
||||
logger.debug("Adding tune and match values toat next measurement frequency")
|
||||
next_measurement_frequency = self.get_next_measurement_frequency()
|
||||
self.reflection[next_measurement_frequency] = magnitude
|
||||
|
||||
|
||||
def find_nearest(self, array, value) -> int:
|
||||
array = np.asarray(array)
|
||||
|
|
|
@ -132,11 +132,16 @@ class BroadbandView(ModuleView):
|
|||
|
||||
def set_broadband_labels(self) -> None:
|
||||
"""Set the labels of the broadband plot."""
|
||||
self._ui_form.broadbandPlot.canvas.ax.set_title("Broadband Spectrum")
|
||||
self._ui_form.broadbandPlot.canvas.ax.set_title("Magnitude Plot")
|
||||
self._ui_form.broadbandPlot.canvas.ax.set_xlabel("Frequency in MHz")
|
||||
self._ui_form.broadbandPlot.canvas.ax.set_ylabel("Amplitude a.u.")
|
||||
self._ui_form.broadbandPlot.canvas.ax.set_ylabel("Magnitude a.u.")
|
||||
self._ui_form.broadbandPlot.canvas.ax.grid()
|
||||
|
||||
# Make second axis for S11 value
|
||||
self._ui_form.broadbandPlot.canvas.ax2 = self._ui_form.broadbandPlot.canvas.ax.twinx()
|
||||
self._ui_form.broadbandPlot.canvas.ax2.set_ylabel("S11 in dB")
|
||||
self._ui_form.broadbandPlot.canvas.ax2.set_ylim([-40, 0])
|
||||
|
||||
@pyqtSlot(float)
|
||||
def on_start_frequency_change(self, start_frequency: float) -> None:
|
||||
"""This method is called when the start frequency is changed.
|
||||
|
@ -221,13 +226,29 @@ class BroadbandView(ModuleView):
|
|||
fd_plotter.clear()
|
||||
broadband_plotter.clear()
|
||||
|
||||
td_plotter.plot(measurement.tdx, measurement.tdy)
|
||||
fd_plotter.plot(measurement.fdx * 1e-6, measurement.fdy * 1e-6)
|
||||
td_plotter.plot(measurement.tdx, measurement.tdy.real, label="Real", linestyle="-", alpha=0.35, color="red")
|
||||
td_plotter.plot(measurement.tdx, measurement.tdy.imag, label="Imaginary", linestyle="-", alpha=0.35, color="green")
|
||||
td_plotter.plot(measurement.tdx, abs(measurement.tdy), label="Magnitude", color="blue")
|
||||
td_plotter.legend()
|
||||
|
||||
fd_plotter.plot(measurement.fdx * 1e-6, measurement.fdy.real, label="Real", linestyle="-", alpha=0.35, color="red")
|
||||
fd_plotter.plot(measurement.fdx * 1e-6, measurement.fdy.imag, label="Imaginary", linestyle="-", alpha=0.35, color="green")
|
||||
fd_plotter.plot(measurement.fdx * 1e-6, abs(measurement.fdy), label="Magnitude", color="blue")
|
||||
fd_plotter.legend()
|
||||
|
||||
# Plot real and imag part again here in time and frequency domain
|
||||
broadband_plotter.plot(
|
||||
self.module.model.current_broadband_measurement.broadband_data_fdx,
|
||||
self.module.model.current_broadband_measurement.broadband_data_fdy,
|
||||
)
|
||||
|
||||
# Plot S11 values on the twin axis of the broadband plot
|
||||
frequencies = self.module.model.current_broadband_measurement.reflection.keys()
|
||||
frequencies = [frequency * 1e-6 for frequency in frequencies]
|
||||
reflection_values = self.module.model.current_broadband_measurement.reflection.values()
|
||||
S11plotter = self._ui_form.broadbandPlot.canvas.ax2
|
||||
S11plotter.plot(frequencies, reflection_values, color="red", marker="x", linestyle="None")
|
||||
|
||||
self.set_timedomain_labels()
|
||||
self.set_frequencydomain_labels()
|
||||
self.set_broadband_labels()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue