-
Waveform — Base class for waveforms.
-
CompositeWaveform — Base class for composite waveforms.
qoolqit.waveforms.base_waveforms
module
qoolqit.waveforms.base_waveforms
Classes
class
Waveform
(duration: float, *args: float, **kwargs: float)
Bases : ABC
Base class for waveforms.
A Waveform is a function of time for t >= 0. Custom waveforms can be defined by
inheriting from the base class and overriding the function
method corresponding
to the function f(t) that returns the value of the waveform evaluated at time t.
A waveform is always a 1D function, so if it includes other parameters, these should be
passed and saved at initialization for usage within the function
method.
Initializes the Waveform.
Parameters
-
duration : float — the total duration of the waveform.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float] — Dictonary of parameters used by the waveform.
Methods
property
duration
: float
Returns the duration of the waveform.
property
params
: dict[str, float]
Dictonary of parameters used by the waveform.
method
function
(t: float) → float
Evaluates the waveform function at a given time t.
method
max
() → float
Get the approximate maximum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the maximum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
method
min
() → float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
method
draw
(n_points: int = N_POINTS, return_fig: bool = False, **kwargs: Any) → plt.Figure | None
class
CompositeWaveform
(*waveforms: Waveform)
Bases : Waveform
Base class for composite waveforms.
A CompositeWaveform stores a sequence of waveforms occuring one after the other by the order given. When it is evaluated at time t, the corresponding waveform from the sequence is identified depending on the duration of each one, and it is then evaluated for a time t' = t minus the duration of all previous waveforms.
Initializes the CompositeWaveform.
Parameters
-
waveforms : Waveform — an iterator over waveforms.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float] — Dictonary of parameters used by the waveform.
-
durations : list[float] — Returns the list of durations of each individual waveform.
-
times : list[float] — Returns the list of times when each individual waveform starts.
-
waveforms : list[Waveform] — Returns a list of the individual waveforms.
-
n_waveforms : int — Returns the number of waveforms.
Methods
property
durations
: list[float]
Returns the list of durations of each individual waveform.
property
times
: list[float]
Returns the list of times when each individual waveform starts.
property
waveforms
: list[Waveform]
Returns a list of the individual waveforms.
property
n_waveforms
: int
Returns the number of waveforms.
method
function
(t: float) → float
Identifies the right waveform in the composition and evaluates it at time t.
method
max
() → float
Get the maximum value of the waveform.