Qubit Spectroscopy does not fit dips
Currently the qubit spectroscopy analysis only fits peaks.
It can however occur that the feature in the data is a dip. Hence it would be useful to have compatibility with both scenarios.
diff --git a/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py b/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py
index bc73312f..c8a554e6 100644
--- a/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py
+++ b/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py
@@ -543,7 +543,7 @@ class UHFQC(zibase.ZI_base_instrument, DIO.CalInterface):
         self.auxins_0_averaging(8)
 
     def acquisition_arm(self, single=True) -> None:
-        time.sleep(0.01)
+        # time.sleep(0.01)
         self.awgs_0_single(single)
         self.start()
 
@@ -1717,33 +1717,54 @@ setTrigger(0);
         log.info(f"{self.devname}: Calibrating DIO protocol")
         self.assure_ext_clock()
 
-        for awg in [0]:
-            if not self._ensure_activity(awg, mask_value=dio_mask):
-                raise ziUHFQCDIOActivityError('No or insufficient activity found on the DIO bits associated with AWG {}'.format(awg))
-
-        valid_delays = self._find_valid_delays(awg, mask_value=dio_mask)
-        if len(valid_delays) == 0:
-            raise ziUHFQCDIOCalibrationError('DIO calibration failed! No valid delays found')
-
-        # Find center of first valid region
-        subseq = [[]]
-        for e in valid_delays:
-            if not subseq[-1] or subseq[-1][-1] == e - 1:
-                subseq[-1].append(e)
-            else:
-                subseq.append([e])
-
-        subseq = max(subseq, key=len)
-        delay = len(subseq)//2 + subseq[0]
-
-        # Print information
-        log.info(f"{self.devname}: Valid delays are {valid_delays}")
-
-        # And configure the delays
-        self._set_dio_calibration_delay(delay)
-
-        # Clear all detected errors (caused by DIO timing calibration)
-        self.check_errors(errors_to_ignore=['AWGDIOTIMING'])
+        # Get the integration length and result enable settings to be able to
+        # restore them later
+        integration_length = self.get('qas_0_integration_length')
+        result_enable = self.get('qas_0_result_enable')
+        monitor_enable = self.get('qas_0_monitor_enable')
+        awg_enable = self.get('awgs_0_enable')
+
+        try:
+          self.set('qas_0_integration_length', 4)
+          self.set('qas_0_result_enable', 0)
+          self.set('qas_0_monitor_enable', 0)
+          self.set('awgs_0_enable', 0)
+          
+          for awg in [0]:
+              if not self._ensure_activity(awg, mask_value=dio_mask):
+                  raise ziUHFQCDIOActivityError('No or insufficient activity found on the DIO bits associated with AWG {}'.format(awg))
+
+          valid_delays = self._find_valid_delays(awg, mask_value=dio_mask)
+          if len(valid_delays) == 0:
+              raise ziUHFQCDIOCalibrationError('DIO calibration failed! No valid delays found')
+
+          # Find center of first valid region
+          subseq = [[]]
+          for e in valid_delays:
+              if not subseq[-1] or subseq[-1][-1] == e - 1:
+                  subseq[-1].append(e)
+              else:
+                  subseq.append([e])
+
+          subseq = max(subseq, key=len)
+          delay = len(subseq)//2 + subseq[0]
+
+          # Print information
+          log.info(f"{self.devname}: Valid delays are {valid_delays}")
+
+          # And configure the delays
+          self._set_dio_calibration_delay(delay)
+
+          # Clear all detected errors (caused by DIO timing calibration)
+          self.check_errors(errors_to_ignore=['AWGDIOTIMING'])
+        
+        finally:
+          # Restore settings either in case of an exception or if the DIO
+          # routine finishes correctly
+          self.set('qas_0_integration_length', integration_length)
+          self.set('qas_0_result_enable', result_enable)
+          self.set('qas_0_monitor_enable', monitor_enable)
+          self.set('awgs_0_enable', awg_enable)
 
     ##########################################################################
     # DIO calibration functions for *CC*
['pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py']