Updated pulse resolution.

This commit is contained in:
jupfi 2023-08-24 10:07:30 +02:00
parent 3882be0054
commit a1a631b544
2 changed files with 9 additions and 5 deletions

View file

@ -41,16 +41,19 @@ class Function:
t = np.linspace(0, float(pulse_length), n)
return t
def evaluate(self, pulse_length: Decimal) -> np.ndarray:
def evaluate(self, pulse_length: Decimal, resolution : Decimal = None) -> np.ndarray:
"""Evaluates the function for the given pulse length.
Args:
pulse_length (Decimal): The pulse length in seconds.
resolution (Decimal, optional): The resolution of the function in seconds. Defaults to None.
Returns:
np.ndarray: The evaluated function.
"""
n = int(pulse_length / self.resolution)
if resolution is None:
resolution = self.resolution
n = int(pulse_length / resolution)
t = np.linspace(self.start_x, self.end_x, n)
x = sympy.symbols("x")
@ -117,16 +120,17 @@ class Function:
mpl_widget.canvas.ax.grid(True)
return mpl_widget
def get_pulse_amplitude(self, pulse_length: Decimal) -> np.array:
def get_pulse_amplitude(self, pulse_length: Decimal, resolution : Decimal = None) -> np.array:
"""Returns the pulse amplitude in the time domain.
Args:
pulse_length (Decimal): The pulse length in seconds.
resolution (Decimal, optional): The resolution of the function in seconds. Defaults to None.
Returns:
np.array: The pulse amplitude.
"""
return self.evaluate(pulse_length)
return self.evaluate(pulse_length, resolution=resolution)
def add_parameter(self, parameter: "Function.Parameter") -> None:
"""Adds a parameter to the function.

View file

@ -115,7 +115,7 @@ class SpectrometerView(ModuleView):
last_added_action = self._actions[list(self._actions.keys())[-1]]
last_added_action.setChecked(True)
self.add_menubar_item.emit("Hardware", list(self._actions.values()))
self.add_menubar_item.emit("Spectrometer", list(self._actions.values()))
@pyqtSlot(str)
def on_menu_button_clicked(self, spectrometer_name):