mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-12-22 16:27:48 +00:00
Merge branch 'main' of github.com:nqrduck/nqrduck-spectrometer
This commit is contained in:
commit
0d7524107c
5 changed files with 70 additions and 6 deletions
|
@ -28,8 +28,6 @@ class BaseSpectrometerModel(ModuleModel):
|
||||||
|
|
||||||
def get_setting(self):
|
def get_setting(self):
|
||||||
return float(self.value)
|
return float(self.value)
|
||||||
|
|
||||||
|
|
||||||
class PulseParameter:
|
class PulseParameter:
|
||||||
"""A pulse parameter is a value that can be different for each event in a pulse sequence.
|
"""A pulse parameter is a value that can be different for each event in a pulse sequence.
|
||||||
E.g. the transmit pulse power or the phase of the transmit pulse.
|
E.g. the transmit pulse power or the phase of the transmit pulse.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import numpy as np
|
||||||
from nqrduck.helpers.signalprocessing import SignalProcessing as sp
|
from nqrduck.helpers.signalprocessing import SignalProcessing as sp
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -13,15 +14,39 @@ class Measurement():
|
||||||
tdy (np.array): Time axis for the y axis of the measurement data.
|
tdy (np.array): Time axis for the y axis of the measurement data.
|
||||||
target_frequency (float): Target frequency of the measurement.
|
target_frequency (float): Target frequency of the measurement.
|
||||||
frequency_shift (float): Frequency shift of the measurement.
|
frequency_shift (float): Frequency shift of the measurement.
|
||||||
|
IF_frequency (float): Intermediate frequency of the measurement.
|
||||||
xf (np.array): Frequency axis for the x axis of the measurement data.
|
xf (np.array): Frequency axis for the x axis of the measurement data.
|
||||||
yf (np.array): Frequency axis for the y axis of the measurement data.
|
yf (np.array): Frequency axis for the y axis of the measurement data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, tdx, tdy, target_frequency, frequency_shift : float = 0) -> None:
|
def __init__(self, tdx, tdy, target_frequency, frequency_shift : float = 0, IF_frequency : float = 0) -> None:
|
||||||
self.tdx = tdx
|
self.tdx = tdx
|
||||||
self.tdy = tdy
|
self.tdy = tdy
|
||||||
self.target_frequency = target_frequency
|
self.target_frequency = target_frequency
|
||||||
self.fdx, self.fdy = sp.fft(tdx, tdy, frequency_shift)
|
self.fdx, self.fdy = sp.fft(tdx, tdy, frequency_shift)
|
||||||
|
self.IF_frequency = IF_frequency
|
||||||
|
|
||||||
|
# Data saving and loading
|
||||||
|
|
||||||
|
def to_json(self):
|
||||||
|
"""Converts the measurement to a json-compatible format."""
|
||||||
|
return {
|
||||||
|
"tdx": self.tdx.tolist(),
|
||||||
|
"tdy": [[x.real, x.imag] for x in self.tdy], # Convert complex numbers to list
|
||||||
|
"target_frequency": self.target_frequency,
|
||||||
|
"IF_frequency": self.IF_frequency
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""Converts the json format to a measurement."""
|
||||||
|
tdy = np.array([complex(y[0], y[1]) for y in json["tdy"]])
|
||||||
|
return cls(
|
||||||
|
np.array(json["tdx"]),
|
||||||
|
tdy,
|
||||||
|
target_frequency = json["target_frequency"],
|
||||||
|
IF_frequency = json["IF_frequency"]
|
||||||
|
)
|
||||||
|
|
||||||
# Measurement data
|
# Measurement data
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -24,6 +24,9 @@ class SpectrometerModel(ModuleModel):
|
||||||
def active_spectrometer(self, value):
|
def active_spectrometer(self, value):
|
||||||
self._active_spectrometer = value
|
self._active_spectrometer = value
|
||||||
self.active_spectrometer_changed.emit(value)
|
self.active_spectrometer_changed.emit(value)
|
||||||
|
spectrometer_module_name = value.model.toolbar_name
|
||||||
|
logger.debug("Active spectrometer changed to %s", spectrometer_module_name)
|
||||||
|
self.module.nqrduck_signal.emit("active_spectrometer_changed", spectrometer_module_name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_spectrometers(self):
|
def available_spectrometers(self):
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Function:
|
||||||
td = self.get_time_points(pulse_length)
|
td = self.get_time_points(pulse_length)
|
||||||
yd = self.evaluate(pulse_length)
|
yd = self.evaluate(pulse_length)
|
||||||
xdf, ydf = sp.fft(td, yd)
|
xdf, ydf = sp.fft(td, yd)
|
||||||
mpl_widget.canvas.ax.plot(xdf, ydf)
|
mpl_widget.canvas.ax.plot(xdf, abs(ydf))
|
||||||
mpl_widget.canvas.ax.set_xlabel("Frequency in Hz")
|
mpl_widget.canvas.ax.set_xlabel("Frequency in Hz")
|
||||||
mpl_widget.canvas.ax.set_ylabel("Magnitude")
|
mpl_widget.canvas.ax.set_ylabel("Magnitude")
|
||||||
mpl_widget.canvas.ax.grid(True)
|
mpl_widget.canvas.ax.grid(True)
|
||||||
|
|
|
@ -127,9 +127,47 @@ class PulseSequence:
|
||||||
On execution of the pulse sequence the event duration will be set to the first value in the list.
|
On execution of the pulse sequence the event duration will be set to the first value in the list.
|
||||||
Then the pulse sequence will be executed with the second value of the list. This is repeated until the pulse sequence has
|
Then the pulse sequence will be executed with the second value of the list. This is repeated until the pulse sequence has
|
||||||
been executed with all values in the list."""
|
been executed with all values in the list."""
|
||||||
pass
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, name : str):
|
||||||
|
if not isinstance(name, str):
|
||||||
|
raise TypeError("Name needs to be a string")
|
||||||
|
self._name = name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def values(self):
|
||||||
|
return self._values
|
||||||
|
|
||||||
|
@values.setter
|
||||||
|
def values(self, values : list):
|
||||||
|
if not isinstance(values, list):
|
||||||
|
raise TypeError("Values needs to be a list")
|
||||||
|
self._values = values
|
||||||
|
|
||||||
class VariableGroup:
|
class VariableGroup:
|
||||||
""" Variables can be grouped together.
|
""" Variables can be grouped together.
|
||||||
If we have groups a and b the pulse sequence will be executed for all combinations of variables in a and b."""
|
If we have groups a and b the pulse sequence will be executed for all combinations of variables in a and b."""
|
||||||
pass
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, name : str):
|
||||||
|
if not isinstance(name, str):
|
||||||
|
raise TypeError("Name needs to be a string")
|
||||||
|
self._name = name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def variables(self):
|
||||||
|
return self._variables
|
||||||
|
|
||||||
|
@variables.setter
|
||||||
|
def variables(self, variables : list):
|
||||||
|
if not isinstance(variables, list):
|
||||||
|
raise TypeError("Variables needs to be a list")
|
||||||
|
self._variables = variables
|
Loading…
Reference in a new issue