Repository: DiCarloLab-Delft/PycQED_py3

Issue:
Instruments contained in meta instrument as parameter
I've been experimenting with a better way to have instruments referenced in meta instruments (such as the qubit object. Currently the instruments need to be given upon initialization of the instrument and are an attribute of the instrument that is not logged and cannot easily be changed. 

On the starmon and nanowire branch I have introduced a new parameter called an `instrument_parameter` that contains the name of an instrument and a special get_instr function. By using this it is possible to refer to other instruments as a parameter. This is better because it significantly simplifies the init and reloading of instruments and it also logs how instruments are connected in the datafiles. 

I'm making this issue as this needs to be merged relatively soon to prevent diverging branches


Discussion:

Patch:
diff --git a/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py b/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py
index c8a554e6..569d17e2 100644
--- a/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py
+++ b/pycqed/instrument_drivers/physical_instruments/ZurichInstruments/UHFQuantumController.py
@@ -955,6 +955,14 @@ class UHFQC(zibase.ZI_base_instrument, DIO.CalInterface):
             'of the codewords. The valid range is 0 to 15.',
             vals=validators.Ints())
 
+        self.add_parameter(
+            'minimum_holdoff',
+            get_cmd=self._get_minimum_holdoff,
+            unit='s',
+            label='Minimum hold-off',
+            docstring='Returns the minimum allowed hold-off between two readout operations.',
+            vals=validators.Numbers())
+
     def _codeword_table_preamble(self, awg_nr) -> str:
         """
         Defines a snippet of code to use in the beginning of an AWG program in order to define the waveforms.
@@ -1074,6 +1082,14 @@ class UHFQC(zibase.ZI_base_instrument, DIO.CalInterface):
     def _get_dio_calibration_delay(self):
         return self._dio_calibration_delay
 
+    def _get_minimum_holdoff(self):
+        if self.qas_0_result_averages() == 1:
+            holdoff = np.max((800, self.qas_0_integration_length(), self.qas_0_delay()+16))/self.clock_freq()
+        else:
+            holdoff = np.max((2560, self.qas_0_integration_length(), self.qas_0_delay()+16))/self.clock_freq()
+
+        return holdoff
+
     def _set_wait_dly(self, value) -> None:
         self.set('awgs_0_userregs_{}'.format(UHFQC.USER_REG_WAIT_DLY), value)
 


Test patch:
diff --git a/pycqed/tests/instrument_drivers/physical_instruments/test_UHFQC.py b/pycqed/tests/instrument_drivers/physical_instruments/test_UHFQC.py
index e8da5ab4..31295904 100644
--- a/pycqed/tests/instrument_drivers/physical_instruments/test_UHFQC.py
+++ b/pycqed/tests/instrument_drivers/physical_instruments/test_UHFQC.py
@@ -120,6 +120,27 @@ class Test_UHFQC(unittest.TestCase):
     def test_print_overview(self):
         self.uhf.print_overview()
 
+    def test_minimum_holdoff(self):
+        # Test without averaging
+        self.uhf.qas_0_integration_length(128)
+        self.uhf.qas_0_result_averages(1)
+        self.uhf.qas_0_delay(0)
+        assert self.uhf.minimum_holdoff() == 800/1.8e9
+        self.uhf.qas_0_delay(896)
+        assert self.uhf.minimum_holdoff() == (896+16)/1.8e9
+        self.uhf.qas_0_integration_length(2048)
+        assert self.uhf.minimum_holdoff() == (2048)/1.8e9
+
+        # Test with averaging
+        self.uhf.qas_0_result_averages(16)
+        self.uhf.qas_0_delay(0)
+        self.uhf.qas_0_integration_length(128)
+        assert self.uhf.minimum_holdoff() == 2560/1.8e9
+        self.uhf.qas_0_delay(896)
+        assert self.uhf.minimum_holdoff() == 2560/1.8e9
+        self.uhf.qas_0_integration_length(4096)
+        assert self.uhf.minimum_holdoff() == 4096/1.8e9
+
     def test_reset_acquisition_params(self):
         self.uhf.awgs_0_userregs_0(100)
         self.uhf.awgs_0_userregs_15(153)