From f340caabd7bd67ad7dd774647fb50103ccb09e40 Mon Sep 17 00:00:00 2001
From: sldesnoo-Delft <s.l.desnoo@tudelft.nl>
Date: Thu, 19 Jan 2023 11:03:16 +0100
Subject: [PATCH] Changed iq_modes abs->amplitude, angle->phase

---
 pulse_lib/acquisition/iq_modes.py             |  8 +--
 .../acquisition/measurement_converter.py      |  4 +-
 pulse_lib/fast_scan/qblox_fast_scans.py       | 18 +++----
 pulse_lib/sequencer.py                        | 54 ++++++++++++-------
 4 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/pulse_lib/acquisition/iq_modes.py b/pulse_lib/acquisition/iq_modes.py
index 224af7a8..05c65bf2 100644
--- a/pulse_lib/acquisition/iq_modes.py
+++ b/pulse_lib/acquisition/iq_modes.py
@@ -10,12 +10,12 @@ def iq_mode2func(iq_mode):
         'Complex': lambda x:x,
         'I': np.real,
         'Q': np.imag,
-        'abs': np.abs,
-        'angle': np.angle,
+        'amplitude': np.abs,
+        'phase': np.angle,
         'I+Q': [('_I', np.real), ('_Q', np.imag)],
-        'abs+angle': [('_abs', np.abs), ('_angle', np.angle)],
+        'amplitude+phase': [('_amp', np.abs), ('_phase', np.angle)],
         }
     try:
         return func_map[iq_mode]
     except KeyError:
-        raise Exception(f'Unknown iq_mode f{iq_mode}')
+        raise Exception(f'Unknown iq_mode {iq_mode}')
diff --git a/pulse_lib/acquisition/measurement_converter.py b/pulse_lib/acquisition/measurement_converter.py
index d1d905cb..e4269fff 100644
--- a/pulse_lib/acquisition/measurement_converter.py
+++ b/pulse_lib/acquisition/measurement_converter.py
@@ -338,11 +338,11 @@ class MeasurementConverter:
                     funcs = iq_mode2func(selection.iq_mode)
                     if isinstance(funcs, list):
                         for postfix,_ in funcs:
-                            unit = 'rad' if postfix == '_angle' else  'mV'
+                            unit = 'rad' if postfix == '_phase' else  'mV'
                             sp_new = sp.with_attributes(name=sp.name+postfix, unit=unit)
                             sp_list.append(sp_new)
                     else:
-                        if selection.iq_mode == 'angle':
+                        if selection.iq_mode == 'phase':
                             sp_new = sp.with_attributes(unit='rad')
                             sp_list.append(sp_new)
                         else:
diff --git a/pulse_lib/fast_scan/qblox_fast_scans.py b/pulse_lib/fast_scan/qblox_fast_scans.py
index c792c3e6..7b152c69 100644
--- a/pulse_lib/fast_scan/qblox_fast_scans.py
+++ b/pulse_lib/fast_scan/qblox_fast_scans.py
@@ -46,13 +46,12 @@ def fast_scan1D_param(pulse_lib, gate, swing, n_pt, t_step,
                 'Complex': return IQ data as complex value.
                 'I': return only I value.
                 'Q': return only Q value.
-                'abs': return absolute value (amplitude).
-                'angle:' return angle (phase) in radians,
+                'amplitude': return amplitude.
+                'phase:' return phase [radians],
                 'I+Q', return I and Q using channel name postfixes '_I', '_Q'.
-                'abs+angle'. return absolute value and angle using channel name postfixes '_abs', '_angle'.
+                'amplitude+phase'. return amplitude and phase using channel name postfixes '_amp', '_phase'.
         iq_complex (bool):
-            If True return IQ data as complex value in 1 value, otherwise return IQ data
-            in two values with suffixes '_I' and '_Q'.
+            If False this is equivalent to `iq_mode='I+Q'`
 
     Returns:
         Parameter (QCODES multiparameter) : parameter that can be used as input in a conversional scan function.
@@ -172,13 +171,12 @@ def fast_scan2D_param(pulse_lib, gate1, swing1, n_pt1, gate2, swing2, n_pt2, t_s
                 'Complex': return IQ data as complex value.
                 'I': return only I value.
                 'Q': return only Q value.
-                'abs': return absolute value (amplitude).
-                'angle:' return angle (phase) in radians,
+                'amplitude': return amplitude.
+                'phase:' return phase [radians],
                 'I+Q', return I and Q using channel name postfixes '_I', '_Q'.
-                'abs+angle'. return absolute value and angle using channel name postfixes '_abs', '_angle'.
+                'amplitude+phase'. return amplitude and phase using channel name postfixes '_amp', '_phase'.
         iq_complex (bool):
-            If True return IQ data as complex value in 1 value, otherwise return IQ data
-            in two values with suffixes '_I' and '_Q'.
+            If False this is equivalent to `iq_mode='I+Q'`
 
     Returns:
         Parameter (QCODES multiparameter) : parameter that can be used as input in a conversional scan function.
diff --git a/pulse_lib/sequencer.py b/pulse_lib/sequencer.py
index 98b10a0f..5030d94b 100644
--- a/pulse_lib/sequencer.py
+++ b/pulse_lib/sequencer.py
@@ -390,19 +390,19 @@ class sequencer():
                 then the data contains time traces in a 2D array indexed
                 [index_repetition][time_step].
                 Only present when channel contains no IQ data or
-                when `iq_complex=True` or `iq_mode in['Complex','I','Q','abs','angle']`.
+                when `iq_complex=True` or `iq_mode in['Complex','I','Q','amplitude','phase']`.
             "{name}_I":
                 Similar to "{name}", but contains I component of IQ.
                 Only present when channel contains IQ data and `iq_mode='I+Q'`.
             "{name}_Q":
                 Similar to "{name}", but contains Q component of IQ.
                 Only present when channel contains IQ data and `iq_mode='I+Q'`.
-            "{name}_abs":
-                Similar to "{name}", but contains absolute value (amplitude) of IQ.
-                Only present when channel contains IQ data and `iq_mode='abs+angle'`.
-            "{name}_angle":
-                Similar to "{name}", but contains angle (phase) of IQ.
-                Only present when channel contains IQ data and `iq_mode='abs+angle'`.
+            "{name}_amp":
+                Similar to "{name}", but contains amplitude of IQ.
+                Only present when channel contains IQ data and `iq_mode='amplitude+phase'`.
+            "{name}_phase":
+                Similar to "{name}", but contains phase of IQ.
+                Only present when channel contains IQ data and `iq_mode='amplitude+phase'`.
             "{name}_state":
                 Qubit states in 1 D array.
                 Only present when `states=True`, threshold is set,
@@ -418,7 +418,6 @@ class sequencer():
                 condition returned in a 1D array.
                 Only present when `selectors=True`, threshold is set,
                 and accept_if is set.
-
             "total_selected":
                 The number of accepted sequence shots.
                 A shot is accepted when all selectors have the required value.
@@ -445,8 +444,18 @@ class sequencer():
                 A shot is accepted when all selectors have the required value.
             accept_mask (bool):
                 If True returns per shot whether it is accepted or not.
+            iq_mode (str):
+                when channel contains IQ data, i.e. iq_input=True or frequency is not None,
+                then this parameter specifies how the complex I/Q value should be returned:
+                    'Complex': return IQ data as complex value.
+                    'I': return only I value.
+                    'Q': return only Q value.
+                    'amplitude': return amplitude.
+                    'phase:' return phase [radians],
+                    'I+Q', return I and Q using channel name postfixes '_I', '_Q'.
+                    'amplitude+phase'. return amplitude and phase using channel name postfixes '_amp', '_phase'.
             iq_complex (bool):
-                If True return IQ data as complex value in raw data.
+                If False this is equivalent to `iq_mode='I+Q'`
 
         '''
         if not self.configure_digitizer:
@@ -573,7 +582,7 @@ class sequencer():
                 then the data contains time traces in a 2D array indexed
                 [index_repetition][time_step].
                 Only present when channel contains no IQ data or
-                when `iq_complex=True` or `iq_mode in['Complex','I','Q','abs','angle']`.
+                when `iq_complex=True` or `iq_mode in['Complex','I','Q','amplitude','phase']`.
             "{name}_I":
                 Similar to "{name}", but contains I component of IQ.
                 Only present when channel contains IQ data,
@@ -582,14 +591,14 @@ class sequencer():
                 Similar to "{name}", but contains Q component of IQ.
                 Only present when channel contains IQ data,
                 `raw=True`, and `iq_mode='I+Q'`.
-            "{name}_abs":
-                Similar to "{name}", but contains absolute value (amplitude) of IQ.
+            "{name}_amp":
+                Similar to "{name}", but contains amplitude of IQ.
                 Only present when channel contains IQ data,
-                `raw=True`, and `iq_mode='abs+angle'`.
-            "{name}_angle":
-                Similar to "{name}", but contains angle (phase) of IQ.
+                `raw=True`, and `iq_mode='amplitude+phase'`.
+            "{name}_phase":
+                Similar to "{name}", but contains phase of IQ.
                 Only present when channel contains IQ data,
-                `raw=True`, and `iq_mode='abs+angle'`.
+                `raw=True`, and ``iq_mode='amplitude+phase'`.
             "{name}_state":
                 Qubit states in 1 D array.
                 Only present when `states=True`, threshold is set,
@@ -605,7 +614,6 @@ class sequencer():
                 condition returned in a 1D array.
                 Only present when `selectors=True`, threshold is set,
                 and accept_if is set.
-
             "total_selected":
                 The number of accepted sequence shots.
                 A shot is accepted when all selectors have the required value.
@@ -633,8 +641,18 @@ class sequencer():
                 A shot is accepted when all selectors have the required value.
             accept_mask (bool):
                 If True returns per shot whether it is accepted or not.
+            iq_mode (str):
+                when channel contains IQ data, i.e. iq_input=True or frequency is not None,
+                then this parameter specifies how the complex I/Q value should be returned:
+                    'Complex': return IQ data as complex value.
+                    'I': return only I value.
+                    'Q': return only Q value.
+                    'amplitude': return amplitude.
+                    'phase:' return phase [radians],
+                    'I+Q', return I and Q using channel name postfixes '_I', '_Q'.
+                    'amplitude+phase'. return amplitude and phase using channel name postfixes '_amp', '_phase'.
             iq_complex (bool):
-                If True return IQ data as complex value in raw data.
+                If False this is equivalent to `iq_mode='I+Q'`
 
         '''
         if index is None:
-- 
GitLab