pasqal-io / Pulser

Library for pulse-level/analog control of neutral atom devices. Emulator with QuTiP.
Apache License 2.0
159 stars 57 forks source link

Confusion over the definition of RampWaveform #645

Closed a-corni closed 4 months ago

a-corni commented 4 months ago

In pulser, waveforms are defined over integer time-steps, that is, it is a mapping between a list of times between [0, 1, ..., duration -1] and a list of values [waveform(0), waveform(1), ..., waveform(duration - 1)].

When defining a RampWaveform, we define a duration, a start value and an end value. Usually, users think that the RampWaveform is defined over [0; duration[, such that $start = waveform(0)$ and $end=waveform(duration)$. In practice, when we sample the waveform, $end=waveform(duration - 1)$. This is coherent with the definition of the waveforms defined above.

However, the slope property of RampWaveform is not coherent with the definition above, since it is $\frac{end-start}{duration}$. It should rather be $\frac{end-start}{duration + 1}$.

I suggest to modify the definition of the slope property, and to clarify the behaviour of the RampWaveform in the documentation. Otherwise, to be closer to user experience, the other option is to modify the samples (which is a way bigger change in terms of importance) such that we use linspace to make an interpolation of the ramp defined over [0; duration[, by setting np.linspace(start, stop, num=duration + 1, endpoint=False)

a-corni commented 4 months ago

Originally raised by @sgrava