Added check for valid event duration.

This commit is contained in:
jupfi 2023-07-29 16:56:16 +02:00
parent a1bf3df72c
commit 05e8812204
2 changed files with 19 additions and 0 deletions

View file

@ -60,6 +60,7 @@ class Function:
mpl_widget.canvas.ax.plot(xdf, ydf)
mpl_widget.canvas.ax.set_xlabel("Frequency in Hz")
mpl_widget.canvas.ax.set_ylabel("Magnitude")
mpl_widget.canvas.ax.grid(True)
return mpl_widget
def time_domain_plot(self, pulse_length: float) -> MplWidget:
@ -68,6 +69,7 @@ class Function:
mpl_widget.canvas.ax.plot(td, self.evaluate(pulse_length))
mpl_widget.canvas.ax.set_xlabel("Time in s")
mpl_widget.canvas.ax.set_ylabel("Magnitude")
mpl_widget.canvas.ax.grid(True)
return mpl_widget
def get_pulse_amplitude(self, pulse_length: float) -> np.array:

View file

@ -63,6 +63,23 @@ class PulseSequence:
return obj
@property
def duration(self):
return self._duration
@duration.setter
def duration(self, duration : float):
# Duration needs to be a positive number
try:
duration = float(duration)
except ValueError:
raise ValueError("Duration needs to be a number")
if duration < 0:
raise ValueError("Duration needs to be a positive number")
self._duration = duration
def to_json(self):
"""Returns a dict with all the data in the pulse sequence