Experiment.set_phase(): normalize negative phases to [0, 360)

The phase was passed to the backend job file verbatim, so negative
values (e.g. from rf_pulse(phase=-90)) reached the backend unchanged.
set_phase(), set_frequency() and thus rf_pulse() now write the phase
normalized with phase % 360. Add unittests for the normalization.
This commit is contained in:
markusro committed 2026-10-16 11:31:37 +02:00
1 parent 8d7d241ec7
commit ef11824f8b
2 files changed
+51 -3

No files matched your search

+4 -3
View File
@@ -402,10 +402,10 @@ class Experiment:
The state length is 2 µs. Stabilisation time depends on RF source.
:param float frequency: frequency to set in Hz
:param float phase: phase to set
:param float phase: phase to set, normalized to the range [0, 360)
:param int ttls: default=0, additional ttl lines to set (integer)
"""
s_content = '<analogout id="0" f="%f" phase="%f"/>' % (frequency, phase)
s_content = '<analogout id="0" f="%f" phase="%f"/>' % (frequency, phase % 360)
if ttls != 0:
s_content += '<ttlout value="0x%06x"/>' % ttls
self.state_list.append(StateSimple(2e-6, s_content))
@@ -580,8 +580,9 @@ class Experiment:
- The state length for this command is 0.5 µs.
- The stabilization time for the phase change is RF source dependent. A typical value for PTS310 is 2 µs.
- The phase is relative to the initial phase set at start of the experiment.
- Negative phases are normalized to the range [0, 360) before writing the job file.
"""
s_content = '<analogout phase="%f" />' % (phase)
s_content = '<analogout phase="%f" />' % (phase % 360)
if ttls!=0:
s_content += '<ttlout value="%d"/>' % ttls
self.state_list.append(StateSimple(0.5e-6, s_content))