Exemple #1
0
    def test_scan1D(self, verbose=0):
        p = Parameter('p', set_cmd=None)
        q = Parameter('q', set_cmd=None)
        r = VoltageDivider(p, 4)
        _ = MultiParameter(instrumentName('multi_param'), [p, q])

        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        if verbose:
            print('test_scan1D: running scan1D')
        scanjob = scanjob_t({'sweepdata': dict(
            {'param': p, 'start': 0, 'end': 10, 'step': 2, 'wait_time': 0.}), 'minstrument': [r]})
        _ = scan1D(station, scanjob, liveplotwindow=False, verbose=0)

        scanjob = scanjob_t({'sweepdata': dict(
            {'param': p, 'start': 0, 'end': 10, 'step': 2, 'wait_time': 0.}), 'minstrument': [q, r]})
        _ = scan1D(station, scanjob, liveplotwindow=False, verbose=0)

        scanjob = scanjob_t({'sweepdata': dict(
            {'param': 'dac1', 'start': 0, 'end': 10, 'step': 2}), 'minstrument': [r]})
        _ = scan1D(station, scanjob, liveplotwindow=False, verbose=0)

        scanjob = scanjob_t({'sweepdata': dict(
            {'param': {'dac1': 1}, 'start': 0, 'range': 10, 'step': 2}), 'minstrument': [r]})
        data = scan1D(station, scanjob, liveplotwindow=False, verbose=0, extra_metadata={'hi': 'world'})
        self.assertTrue('hi' in data.metadata)
        gates.close()
Exemple #2
0
class TestVirtualGates(TestCase):
    def setUp(self):
        gate_map = {
            'T': (0, 15),
            'P1': (0, 3),
            'P2': (0, 4),
            'L': (0, 5),
            'D1': (0, 6),
            'R': (0, 7)
        }

        self.ivvi = VirtualIVVI(qtt.measurements.scans.instrumentName('ivvi'),
                                model=None)
        self.gates = virtual_gates(
            qtt.measurements.scans.instrumentName('gates'),
            instruments=[self.ivvi],
            gate_map=gate_map)

    def tearDown(self):
        self.gates.close()
        self.ivvi.close()

    def test_gates(self):
        self.gates.R.set(100)
        self.assertEqual(self.gates.R.get(), 100)
Exemple #3
0
    def setUp(self):
        gate_map = {
            'T': (0, 15), 'P1': (0, 3), 'P2': (0, 4),
            'L': (0, 5), 'D1': (0, 6), 'R': (0, 7)}

        self.ivvi = VirtualIVVI(instrumentName('ivvi'), model=None)
        self.gates = VirtualDAC(instrumentName('gates'), instruments=[self.ivvi], gate_map=gate_map)
Exemple #4
0
class TestVirtualDAC(TestCase):

    def setUp(self):
        gate_map = {
            'T': (0, 15), 'P1': (0, 3), 'P2': (0, 4),
            'L': (0, 5), 'D1': (0, 6), 'R': (0, 7)}

        self.ivvi = VirtualIVVI(qtt.measurements.scans.instrumentName('ivvi'), model=None)
        self.gates = VirtualDAC(qtt.measurements.scans.instrumentName('gates'),
                                instruments=[self.ivvi], gate_map=gate_map)

    def tearDown(self):
        self.gates.close()
        self.ivvi.close()

    def test_gates_get_set(self):
        expected_value = 100.
        self.gates.R.set(expected_value)
        self.assertEqual(self.gates.R.get(), expected_value)

    def test_named_instruments(self):
        gate_map = {'P1': (0, 1), 'P2': (0, 2), 'P1named': (self.ivvi.name, 1)}

        gates = VirtualDAC(qtt.measurements.scans.instrumentName('gates'), instruments=[self.ivvi], gate_map=gate_map)

        expected_value = 20.
        gates.P1.set(expected_value)
        self.assertEqual(gates.P1named.get(), expected_value)
        gates.close()
Exemple #5
0
    def test_convert_scanjob_vec_regression(self):
        station = qcodes.Station()
        ivvi = VirtualIVVI(name='ivvi', model=None)
        gates = qtt.instrument_drivers.gates.VirtualDAC('gates',
                                                        instruments=[ivvi],
                                                        gate_map={
                                                            'P1': (0, 1),
                                                            'P2': (0, 2)
                                                        })
        station.add_component(gates)
        num = 566
        scanjob = scanjob_t({
            'minstrument': [1],
            'minstrumenthandle': ('m4i', [1]),
            'wait_time_startscan': 0.04,
            'stepdata': {
                'wait_time': 0.2
            },
            'Naverage': 2000,
            'sweepdata': {
                'period': 0.0005,
                'param': 'P1',
                'range': -5,
                'step': -0.01098901098901099,
                'start': 714.84130859375,
                'end': 709.84130859375
            },
            'scantype': 'scan1Dfast'
        })
        _, s = scanjob._convert_scanjob_vec(station=station, sweeplength=num)
        self.assertEqual(len(s), num)

        gates.close()
        ivvi.close()
Exemple #6
0
 def test_get_instrument_parameter(self):
     instrument = VirtualIVVI(instrumentName('test'), None)
     ix, p = get_instrument_parameter((instrument.name, 'dac2'))
     self.assertEqual(id(ix), id(instrument))
     self.assertEqual(id(p), id(instrument.dac2))
     ix, p = get_instrument_parameter((instrument, 'dac2'))
     self.assertEqual(id(p), id(instrument.dac2))
     ix, p = get_instrument_parameter(instrument.name + '.dac2')
     self.assertEqual(id(p), id(instrument.dac2))
     instrument.close()
Exemple #7
0
    def setUp(self):
        gate_map = {
            'T': (0, 15),
            'P1': (0, 3),
            'P2': (0, 4),
            'L': (0, 5),
            'D1': (0, 6),
            'R': (0, 7)
        }

        self.ivvi = VirtualIVVI(qtt.measurements.scans.instrumentName('ivvi'),
                                model=None)
        self.gates = virtual_gates(
            qtt.measurements.scans.instrumentName('gates'),
            instruments=[self.ivvi],
            gate_map=gate_map)
Exemple #8
0
    def test_scan2D(verbose=0):
        p = Parameter('p', set_cmd=None)
        q = Parameter('q', set_cmd=None)
        r = VoltageDivider(p, 4)
        _ = MultiParameter(instrumentName('multi_param'), [p, q])

        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        if verbose:
            print('test_scan2D: running scan2D')
        scanjob = scanjob_t({'sweepdata': dict(
            {'param': p, 'start': 0, 'end': 10, 'step': 2}), 'minstrument': [r]})
        scanjob['stepdata'] = dict(
            {'param': q, 'start': 24, 'end': 30, 'step': 1.})
        _ = scan2D(station, scanjob, liveplotwindow=False, verbose=0)

        scanjob = scanjob_t({'sweepdata': dict({'param': {
            'dac1': 1, 'dac2': .1}, 'start': 0, 'range': 10, 'step': 2}), 'minstrument': [r]})
        scanjob['stepdata'] = dict(
            {'param': {'dac2': 1}, 'start': 24, 'range': 6, 'end': np.NaN, 'step': 1.})
        _ = scan2D(station, scanjob, liveplotwindow=False, verbose=0)

        scanjob = scanjob_t({'sweepdata': dict(
            {'param': {'dac1': 1}, 'start': 0, 'range': 10, 'step': 2}), 'minstrument': [r]})
        scanjob['stepdata'] = {'param': MultiParameter('multi_param', [gates.dac2, gates.dac3])}
        scanjob['stepvalues'] = np.array([[2 * i, 3 * i] for i in range(10)])
        try:
            with warnings.catch_warnings():
                warnings.simplefilter('ignore')
                data = scan2D(station, scanjob, liveplotwindow=False, verbose=0)
        except Exception as ex:
            print(ex)
            warnings.warn('MultiParameter test failed!')
        # not supported:
        try:
            scanjob = scanjob_t({'sweepdata': dict({'param': {
                'dac1': 1}, 'start': 0, 'range': 10, 'step': 2, 'wait_time': 0.}), 'minstrument': [r]})
            scanjob['stepdata'] = dict(
                {'param': q, 'start': 24, 'range': 6, 'end': np.NaN, 'step': 1.})
            _ = scan2D(station, scanjob, liveplotwindow=False, verbose=0)
        except Exception as ex:
            if verbose:
                print('combination of Parameter and vector argument not supported')
        gates.close()
Exemple #9
0
    def test_parameterviewer(self):
        qtapp = pyqtgraph.mkQApp()

        ivvi = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('dummyivvi'),
            model=None)
        p = ParameterViewer(instruments=[ivvi])
        p.show()
        p.updatecallback()
        self.assertTrue(p.is_running())
        p.setGeometry(10, 10, 360, 600)

        p.set_parameter_properties(minimum_value=0)

        ivvi.close()
        p.stop()
        p.close()
        qtapp.processEvents()
Exemple #10
0
def test_parameterviewer():
    import pyqtgraph
    qtapp = pyqtgraph.mkQApp()
    import qtt.measurements.scans
    from qtt.instrument_drivers.virtual_instruments import VirtualIVVI

    ivvi = VirtualIVVI(name=qtt.measurements.scans.instrumentName('dummyivvi'),
                       model=None)
    p = ParameterViewer(instruments=[ivvi], instrumentnames=['ivvi'])
    p.show()
    p.updatecallback()
    assert (p.is_running())
    p.setGeometry(10, 10, 360, 600)

    p.stop()
    p.close()
    qtapp.processEvents()
    ivvi.close()
    def test_convert_scanjob_vec_scan2Dfast(self):
        p = Parameter('p', set_cmd=None)
        q = Parameter('q', set_cmd=None)
        r = VoltageDivider(p, 4)
        _ = MultiParameter(instrumentName('multi_param'), [p, q])

        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        scanjob = scanjob_t({
            'scantype':
            'scan2Dfast',
            'sweepdata':
            dict({
                'param': p,
                'start': 0,
                'end': 10,
                'step': 4
            }),
            'minstrument': [r]
        })

        scanjob['stepdata'] = dict({
            'param': q,
            'start': 24,
            'end': 32,
            'step': 1.
        })
        stepvalues, sweepvalues = scanjob._convert_scanjob_vec(station, 3, 5)
        actual_stepvalues = list(stepvalues)
        expected_stepvalues = [24.0, 28.0, 32.0]
        self.assertEqual(expected_stepvalues, actual_stepvalues)
        self.assertEqual(len(actual_stepvalues), 3)

        actual_sweepvalues = list(sweepvalues)
        expected_sweepvalues = [0, 2.5, 5.0, 7.5, 10.0]
        self.assertEqual(expected_sweepvalues, actual_sweepvalues)
        self.assertEqual(len(actual_sweepvalues), 5)
        gates.close()
Exemple #12
0
    def test_VirtualGates_serialization(self):
        """ Test for virtual gates object """
        gates = VirtualIVVI(
            name=instrumentName('ivvi_dummy_serialization_test'),
            model=None,
            gates=['P1', 'P2', 'P3', 'P4'])

        virts = VirtualGates(instrumentName('testvgates'), gates,
                             self.crosscap_map)
        vgdict = virts.to_dictionary()

        vx = VirtualGates.from_dictionary(vgdict,
                                          gates,
                                          name=instrumentName('vgdummy'))

        np.testing.assert_almost_equal(vx.get_crosscap_matrix_inv(),
                                       virts.get_crosscap_matrix_inv())
        self.assertTrue(vx.pgates() == ['P%d' % i for i in range(1, 4)])

        vx.close()
        gates.close()
        virts.close()
class TestVirtualIVVI(TestCase):
    def setUp(self):
        self.virtual_ivvi = VirtualIVVI(
            qtt.measurements.scans.instrumentName('test_ivvi'),
            model=None,
            dac_unit='mV')

    def tearDown(self):
        self.virtual_ivvi.close()

    def test_dac_parameters(self):
        self.assertEqual(self.virtual_ivvi.dac1.unit, 'mV')

        self.assertIsInstance(self.virtual_ivvi.dac5(), (float, int))
        self.virtual_ivvi.dac2.set(1.0)
        self.assertIsInstance(self.virtual_ivvi.dac2(), (float, int))
        self.virtual_ivvi.dac4.set(2.0)
        self.assertEqual(self.virtual_ivvi.dac4(), 2.0)

    def test_dac_validator(self):
        with self.assertRaises(ValueError):
            self.virtual_ivvi.dac1.set(4000)
    def test_convert_scanjob_vec_scan1Dfast_range(self):
        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        # exclusive end-value
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': 'dac1',
                'range': 8,
                'step': 2
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station)
        actual_values = list(sweepvalues)
        expected_values = [-4.0, -2.0, 0.0, 2.0]
        for actual_val, expected_val in zip(actual_values, expected_values):
            self.assertAlmostEqual(actual_val, expected_val, 12)
        self.assertEqual(len(actual_values), 4)

        # inclusive end-value
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': 'dac1',
                'range': 8,
                'step': 2
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station, sweeplength=5)
        actual_values = list(sweepvalues)
        expected_values = [-4.0, -2.0, 0.0, 2.0, 4.0]
        for actual_val, expected_val in zip(actual_values, expected_values):
            self.assertAlmostEqual(actual_val, expected_val, 12)
        self.assertEqual(len(actual_values), 5)

        gates.close()
    def test_convert_scanjob_vec_values_raises_exception(self):
        p = Parameter('p', set_cmd=None)
        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': p,
                'start': 20,
                'end': 20,
                'step': .0075
            }
        })
        self.assertRaises(ValueError, scanjob._convert_scanjob_vec, station)
        self.assertRaises(ValueError,
                          scanjob._convert_scanjob_vec,
                          station,
                          sweeplength=1)

        gates.close()
Exemple #16
0
def test_parameterviewer():
    import pyqtgraph
    _ = pyqtgraph.mkQApp()
    import qtt.measurements.scans
    from qtt.instrument_drivers.virtual_instruments import VirtualIVVI

    ivvi = VirtualIVVI(name=qtt.measurements.scans.instrumentName('dummyivvi'),
                       model=None)
    p = ParameterViewer(instruments=[ivvi], instrumentnames=['ivvi'])
    p.show()
    p.stop()
    print('stop')
    p.close()
    print('close done: is_running %s' % (p.is_running(), ))
    def test_convert_scanjob_vec_scan1Dfast_adjust_sweeplength(self):
        p = Parameter('p', set_cmd=None)
        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        # inclusive end-value
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': p,
                'start': -2,
                'end': 2,
                'step': .4
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station, sweeplength=5)
        actual_values = list(sweepvalues)
        expected_values = [-2.0, -1.0, 0.0, 1.0, 2.0]
        self.assertEqual(expected_values, actual_values)
        self.assertEqual(len(actual_values), 5)

        gates.close()
Exemple #18
0
    def test_add_instruments(self):
        ivvi1 = VirtualIVVI(instrumentName('ivvi'), model=None)
        ivvi2 = VirtualIVVI(instrumentName('ivv2'), model=None)
        instruments = [ivvi1, ivvi2]
        virtual_dac = VirtualDAC(instrumentName('gates'), instruments=[], gate_map={})

        virtual_dac.add_instruments(instruments)
        self.assertEqual(2, len(virtual_dac.instruments))
        self.assertEqual(instruments, virtual_dac.instruments)

        virtual_dac.add_instruments(instruments)
        self.assertEqual(2, len(virtual_dac.instruments))
        self.assertEqual(instruments, virtual_dac.instruments)

        virtual_dac.close()
        ivvi1.close()
        ivvi2.close()
Exemple #19
0
def initialize(reinit=False,
               nr_dots=2,
               maxelectrons=2,
               verbose=2,
               start_manager=False):

    global station, _initialized, model

    logger.info('virtualDot: start')
    if verbose >= 2:
        print('initialize: create virtual dot system')

    if _initialized:
        if reinit:
            close(verbose=verbose)
        else:
            return station
    logger.info('virtualDot: make DotModel')
    model = DotModel(name=qtt.measurements.scans.instrumentName('dotmodel'),
                     verbose=verbose >= 3,
                     nr_dots=nr_dots,
                     maxelectrons=maxelectrons,
                     sdplunger='SD1b')
    gate_map = model.gate_map
    if verbose >= 2:
        logger.info('initialize: DotModel created')
    ivvis = []
    for ii in range(model.nr_ivvi):
        ivvis.append(VirtualIVVI(name='ivvi%d' % (ii + 1), model=model))
    gates = virtual_gates(name='gates', gate_map=gate_map, instruments=ivvis)
    gates.set_boundaries(gate_boundaries(gate_map))

    logger.info('initialize: set values on gates')
    gates.set('D0', 101)
    for g in model.gates:
        gates.set(g, np.random.rand() - .5)

    # take into account the voltage divider on the ohmics
    for g in gates.parameters.keys():
        if g.startswith('O'):
            gg = getattr(gates, g)
            gg.unit = 'uV'

    vawg = SimulationAWG(qtt.measurements.scans.instrumentName('vawg'))

    logger.info('initialize: create virtual keithley instruments')
    keithley1 = VirtualMeter('keithley1', model=model)
    keithley3 = VirtualMeter('keithley3', model=model)
    keithley4 = VirtualMeter('keithley4', model=model)

    digitizer = SimulationDigitizer(
        qtt.measurements.scans.instrumentName('sdigitizer'), model=model)

    logger.info('initialize: create station')
    station = qcodes.Station(gates,
                             keithley1,
                             keithley3,
                             keithley4,
                             *ivvis,
                             vawg,
                             digitizer,
                             update_snapshot=False)
    station.awg = station.vawg
    station.metadata['sample'] = 'virtual_dot'
    station.model = model

    station.gate_settle = gate_settle
    station.depletiongate_name = 'D0'
    station.bottomchannel_current = station.keithley3.amplitude

    station.jobmanager = None
    station.calib_master = None

    _initialized = True
    if verbose:
        print('initialized virtual dot system (%d dots)' % nr_dots)
    return station
Exemple #20
0
class TestVirtualDAC(TestCase):
    def setUp(self):
        gate_map = {
            'T': (0, 15),
            'P1': (0, 3),
            'P2': (0, 4),
            'L': (0, 5),
            'D1': (0, 6),
            'R': (0, 7)
        }

        self.ivvi = VirtualIVVI(instrumentName('ivvi'), model=None)
        self.gates = VirtualDAC(instrumentName('gates'),
                                instruments=[self.ivvi],
                                gate_map=gate_map)

    def tearDown(self):
        self.gates.close()
        self.ivvi.close()

    def test_gates_get_set(self):
        expected_value = 100.
        self.gates.R.set(expected_value)
        self.assertEqual(self.gates.R.get(), expected_value)

    def test_named_instruments(self):
        gate_map = {'P1': (0, 1), 'P2': (0, 2), 'P1named': (self.ivvi.name, 1)}

        gates = VirtualDAC(instrumentName('gates'),
                           instruments=[self.ivvi],
                           gate_map=gate_map)

        expected_value = 20.
        gates.P1.set(expected_value)
        self.assertEqual(gates.P1named.get(), expected_value)
        gates.close()

    def test_set_gate_map(self):
        gate_map = {'P1': (0, 1), 'P2': (0, 2), 'P3': (0, 3)}
        virtual_dac = VirtualDAC(instrumentName('gates'),
                                 instruments=[self.ivvi],
                                 gate_map=gate_map)
        self.assertDictEqual(gate_map, virtual_dac.gate_map)
        self.assertTrue(hasattr(virtual_dac, 'P1'))
        self.assertTrue(hasattr(virtual_dac, 'P2'))
        self.assertTrue(hasattr(virtual_dac, 'P3'))

        new_gate_map = {'C1': (0, 11), 'C2': (0, 12), 'C3': (0, 13)}
        virtual_dac.gate_map = new_gate_map
        self.assertFalse(hasattr(virtual_dac, 'P1'))
        self.assertFalse(hasattr(virtual_dac, 'P2'))
        self.assertFalse(hasattr(virtual_dac, 'P3'))
        self.assertTrue(hasattr(virtual_dac, 'C1'))
        self.assertTrue(hasattr(virtual_dac, 'C2'))
        self.assertTrue(hasattr(virtual_dac, 'C3'))
        self.assertDictEqual(new_gate_map, virtual_dac.gate_map)

        virtual_dac.close()

    def test_get_boundaries(self):
        gate_map = {'P1': (0, 1), 'P2': (0, 2), 'P3': (0, 3)}
        virtual_dac = VirtualDAC(instrumentName('gates'),
                                 instruments=[self.ivvi],
                                 gate_map=gate_map)
        gate_boundaries = {'P1': (0, 1), 'P2': (-42, 42), 'P3': (-100, 100)}
        virtual_dac.set_boundaries(gate_boundaries)

        boundaries = virtual_dac.get_boundaries()
        self.assertDictEqual(gate_boundaries, boundaries)

        virtual_dac.close()

    def test_restrict_boundaries(self):
        gate_map = {'P1': (0, 1), 'P2': (0, 2), 'P3': (0, 3)}
        virtual_dac = VirtualDAC(instrumentName('test'),
                                 instruments=[self.ivvi],
                                 gate_map=gate_map)
        gate_boundaries = {'P1': (0, 100), 'P2': (0, 100)}
        virtual_dac.set_boundaries(gate_boundaries)
        virtual_dac.restrict_boundaries({'P1': (-50, 50), 'P3': (0, 1)})
        self.assertEqual(virtual_dac.get_boundaries(), {
            'P1': (0, 50),
            'P2': (0, 100),
            'P3': (0, 1)
        })
        self.assertEqual(self.ivvi.dac1.vals.valid_values, (0, 50))

        virtual_dac.close()

    def test_invalid_boundary(self):
        with self.assertRaises(ValueError):
            self.gates.set_boundaries({'P1': [2, 1]})

    def test_invalid_gate(self):
        with self.assertWarnsRegex(UserWarning, 'has no gate'):
            self.gates.set_boundaries({'no_gate': [0, 1]})

    def test_set_dacs(self):
        virtual_dac = VirtualDAC(instrumentName('gates'),
                                 instruments=[],
                                 gate_map={})
        virtual_dac.add_instruments([self.ivvi])
        self.assertIs(self.ivvi, virtual_dac.instruments[0])

        virtual_dac.close()

    def test_add_instruments(self):
        ivvi1 = VirtualIVVI(instrumentName('ivvi'), model=None)
        ivvi2 = VirtualIVVI(instrumentName('ivv2'), model=None)
        instruments = [ivvi1, ivvi2]
        virtual_dac = VirtualDAC(instrumentName('gates'),
                                 instruments=[],
                                 gate_map={})

        virtual_dac.add_instruments(instruments)
        self.assertEqual(2, len(virtual_dac.instruments))
        self.assertEqual(instruments, virtual_dac.instruments)

        virtual_dac.add_instruments(instruments)
        self.assertEqual(2, len(virtual_dac.instruments))
        self.assertEqual(instruments, virtual_dac.instruments)

        virtual_dac.close()
        ivvi1.close()
        ivvi2.close()

    def test_restore_at_exit(self):
        gates = self.gates
        starting_value = self.gates.P1()

        with self.gates.restore_at_exit():
            gates.P1.increment(10)
        self.assertEqual(gates.P1(), starting_value)

    def test_restore_at_exit_with_exception(self):
        gates = self.gates
        starting_value = self.gates.P1()
        with self.assertRaises(AttributeError):
            with gates.restore_at_exit():
                gates.P1.increment(10)
                gates.non_existing_gate.increment(10)
        self.assertEqual(gates.P1(), starting_value)
Exemple #21
0
#  Virtual AWG

settings = HardwareSettings()
virtual_awg = VirtualAwg([awg_adapter.instrument], settings)

marker_delay = 16e-6
virtual_awg.digitizer_marker_delay(marker_delay)

marker_uptime = 1e-2
virtual_awg.digitizer_marker_uptime(marker_uptime)


#  Station

gates = VirtualIVVI('gates', gates=['P1', 'P2'], model=None)
station = Station(virtual_awg, scope_reader.adapter.instrument, awg_adapter.instrument, gates)

#%% Enable the stimulus

demodulator = 1
signal_output = 1
oscillator = demodulator

update_stimulus(is_enabled=True, signal_output=signal_output, amplitude=0.1, oscillator=oscillator)

#%% Sensing a resonance

signal_input = signal_output

scanjob = scanjob_t(wait_time_startscan=1)
Exemple #22
0

#%% Debugging code

if __name__ == '__main__':
    test_parameterviewer()

    if 0:
        import qcodes
        import time
        import pdb
        import qtt.measurements.scans
        from qtt.instrument_drivers.virtual_instruments import VirtualIVVI

        ivvi = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('dummyivvi'),
            model=None)
        p = ParameterViewer(instruments=[ivvi], instrumentnames=['ivvi'])
        self = p
        p.show()
        self = p
        p.updatecallback()

        p.setGeometry(1540, 60, 360, 600)

        time.sleep(.1)
        ivvi.dac1.set(101)
        ivvi.dac2.set(102)

#%%
if __name__ == '__main__' and 0:
    plt.ylabel(label_y_axis)
    for ii in range(digitizer_data.shape[0]):
        plt.plot(digitizer_data[ii,:],'.', label='%d' % ii)
    plt.show()
    plt.legend()

plot_data_1d_x(data, 'Digitizer Data Points [a.u.]', 'Amplitude [V]')


#%%

from qtt.instrument_drivers.gates import VirtualDAC
from qtt.instrument_drivers.virtual_instruments import VirtualIVVI
from qcodes.station import Station

ivvi = VirtualIVVI(name='ivvi', model=None)
gates = VirtualDAC('gates', [ivvi], {'C1': (0, 1), 'C2': (0, 2)})

station = Station(ivvi, gates, virtual_awg, awg_1, digitizer)


#%%

from qtt.measurements.scans import scan1Dfast, scanjob_t

scanjob = scanjob_t({'minstrument': [1],'Naverage':100,'wait_time_start_scan':2,
                     'sweepdata': {'param': 'C2','start': 100,'end': 250, 'step': 1,'wait_time': 0.28}})
dataset_measurement_fast = scan1Dfast(station, scanjob)


logviewer = DataViewer()
Exemple #24
0
def test_virtual_gates(verbose=0):
    """ Test for virtual gates object """
    from qtt.instrument_drivers.virtual_instruments import VirtualIVVI
    from qtt.measurements.scans import instrumentName
    import pickle

    gates = VirtualIVVI(name=instrumentName('testivvi'),
                        model=None,
                        gates=['P1', 'P2', 'P3', 'P4'])

    crosscap_map = OrderedDict(
        (('VP1', OrderedDict((('P1', 1), ('P2', 0.6), ('P3', 0)))),
         ('VP2', OrderedDict((('P1', 0.3), ('P2', 1), ('P3', 0.3)))),
         ('VP3', OrderedDict((('P1', 0), ('P2', 0), ('P3', 1))))))
    vgates = virtual_gates(instrumentName('testvgates'), gates, crosscap_map)

    vp1 = vgates.VP1()
    if verbose:
        print('before set: VP1 {}'.format(vp1))
    vgates.VP1.set(10)
    vp1 = vgates.VP1()
    if verbose:
        print('after set: VP1 {}'.format(vp1))
    vgates.VP1.set(10)
    vp1 = vgates.VP1()
    if verbose:
        print('after second set: VP1 {}'.format(vp1))

    vgates_matrix = vgates.convert_map_to_matrix(crosscap_map)
    _ = vgates.convert_matrix_to_map(vgates_matrix)

    vgates.multi_set({'VP1': 10, 'VP2': 20, 'VP3': 30})
    all_values = vgates.allvalues()

    crosscap_matrix = vgates.get_crosscap_matrix()
    assert (crosscap_matrix[0][0] == 1.0)
    assert (crosscap_matrix[0][1] == 0.6)

    vgates.set_distances(1.0 / np.arange(1, 5))
    _ = vgates.to_dictionary()
    pickled_virtual_gates = pickle.dumps(vgates)
    extended_vgates = pickle.loads(pickled_virtual_gates)

    v_gates = vgates.vgates() + ['vP4']
    p_gates = vgates.pgates() + ['P4']
    extended_vgates = extend_virtual_gates(v_gates,
                                           p_gates,
                                           vgates,
                                           name='vgates')
    if verbose:
        extended_vgates.print_matrix()

    _ = update_cc_matrix(vgates, update_cc=np.eye(3), verbose=0)

    update_matrix = 0.1 * np.random.rand(3, 3)
    np.fill_diagonal(update_matrix, 1)

    # test normalization of virtual gate matrix
    extended_vgates, _, _ = update_cc_matrix(vgates,
                                             update_cc=update_matrix,
                                             verbose=0)
    np.testing.assert_almost_equal(
        extended_vgates.get_crosscap_matrix(),
        update_matrix.dot(vgates.get_crosscap_matrix()))

    # test normalization of virtual gate matrix
    serialized_matrix = extended_vgates.get_crosscap_matrix()
    extended_vgates.normalize_matrix()
    crosscap_matrix = extended_vgates.get_crosscap_matrix()
    for row in range(serialized_matrix.shape[0]):
        np.testing.assert_almost_equal(
            serialized_matrix[row] / serialized_matrix[row][row],
            crosscap_matrix[row])
    assert (np.all(crosscap_matrix.diagonal() == 1.0))

    vgates.close()
    extended_vgates.close()
    gates.close()
Exemple #25
0
    def test_convert_scanjob_vec_scan1Dfast_adjust_sweeplength_adjusted_end(
            self):
        p = Parameter('p', set_cmd=None)
        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        # exclusive end-value
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': p,
                'start': -20,
                'end': 20,
                'step': .0075
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station)
        actual_values = list(sweepvalues)
        self.assertEqual(actual_values[0], -20.0)
        self.assertAlmostEqual(actual_values[-1], 20.0 - 0.0025, 10)
        self.assertEqual(len(actual_values), 5334)

        # inclusive end-value
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': p,
                'start': -20,
                'end': 20,
                'step': .0075
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station,
                                                      sweeplength=40 / .0075 +
                                                      1)
        actual_values = list(sweepvalues)
        self.assertEqual(actual_values[0], -20.0)
        self.assertAlmostEqual(actual_values[-1], 20.0 - .0025, 10)
        self.assertAlmostEqual(scanjob['sweepdata']['end'], 20, 10)
        self.assertEqual(len(actual_values), 5334)

        # exclusive end-value
        scanjob = scanjob_t({
            'scantype':
            'scan1Dfast',
            'sweepdata':
            dict({
                'param': p,
                'start': -500,
                'end': 1,
                'step': .8,
                'wait_time': 3e-3
            })
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station)
        actual_values = list(sweepvalues)
        self.assertEqual(actual_values[0], -500.0)
        self.assertAlmostEqual(actual_values[-1], 1 - 0.2, 10)
        self.assertAlmostEqual(scanjob['sweepdata']['end'], 1, 10)
        self.assertEqual(len(actual_values), 627)

        # inclusive end-value
        scanjob = scanjob_t({
            'scantype':
            'scan1Dfast',
            'sweepdata':
            dict({
                'param': p,
                'start': -500,
                'end': 1,
                'step': .8,
                'wait_time': 3e-3
            })
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station,
                                                      sweeplength=(501 / .8) +
                                                      1)
        actual_values = list(sweepvalues)
        self.assertEqual(actual_values[0], -500.0)
        self.assertAlmostEqual(actual_values[-1], 0.8, 10)
        self.assertAlmostEqual(scanjob['sweepdata']['end'], 1, 10)
        self.assertEqual(len(actual_values), 627)

        gates.close()
Exemple #26
0
    def test_convert_scanjob_vec_range_values_will_not_raise_exception(self):
        p = Parameter('p', set_cmd=None)
        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        idx = 1
        for idx in range(1, 5):
            for start in range(-5, 1):
                for end in range(1, 5):
                    for step_in_range in range(1, 5):
                        step = step_in_range / (idx * 10)

                        # exclusive end-value
                        scanjob = scanjob_t({
                            'scantype': 'scan1Dfast',
                            'sweepdata': {
                                'param': p,
                                'start': start,
                                'end': end,
                                'step': step
                            }
                        })
                        _ = scanjob._convert_scanjob_vec(station)

                        scanjob = scanjob_t({
                            'scantype': 'scan1Dfast',
                            'sweepdata': {
                                'param': p,
                                'start': start,
                                'end': end,
                                'step': step
                            }
                        })

                        # inclusive end-value
                        scanjob = scanjob_t({
                            'scantype': 'scan1Dfast',
                            'sweepdata': {
                                'param': p,
                                'start': start,
                                'end': end,
                                'step': step
                            }
                        })
                        # generate a sweeplength so that the step-value doesn't change
                        _ = scanjob._convert_scanjob_vec(
                            station, sweeplength=((end - start) / step) + 1)
                        scanjob = scanjob_t({
                            'scantype': 'scan1Dfast',
                            'sweepdata': {
                                'param': p,
                                'start': start,
                                'end': end,
                                'step': step
                            }
                        })

        # all the conversions were successful
        self.assertEqual(idx, 4)
        gates.close()
Exemple #27
0
    def test_VirtualGates(self, verbose=0):
        """ Test for virtual gates object """

        gates = VirtualIVVI(name=instrumentName('testivvi'),
                            model=None,
                            gates=['P1', 'P2', 'P3', 'P4'])

        vgates = VirtualGates(instrumentName('testvgates'), gates,
                              self.crosscap_map)

        vp1 = vgates.VP1()
        if verbose:
            print('before set: VP1 {}'.format(vp1))
        vgates.VP1.set(10)
        vp1 = vgates.VP1()
        if verbose:
            print('after set: VP1 {}'.format(vp1))
        vgates.VP1.set(10)
        vp1 = vgates.VP1()
        if verbose:
            print('after second set: VP1 {}'.format(vp1))

        vgates_matrix = vgates.convert_map_to_matrix(self.crosscap_map)
        _ = vgates.convert_matrix_to_map(vgates_matrix)

        vgates.multi_set({'VP1': 10, 'VP2': 20, 'VP3': 30})
        all_values = vgates.allvalues()
        self.assertTrue(isinstance(all_values, dict))

        crosscap_matrix = vgates.get_crosscap_matrix()
        self.assertEqual(1.0, crosscap_matrix[0][0])
        self.assertEqual(0.6, crosscap_matrix[0][1])

        vgates.set_distances(1.0 / np.arange(1, 5))
        vgates_dictionary = vgates.to_dictionary()
        vgates_new = VirtualGates.from_dictionary(vgates_dictionary, gates,
                                                  'new_vgates')
        self.assertEqual(vgates_new.name, 'new_vgates')
        self.assertEqual(vgates_new.pgates(), vgates.pgates())
        vgates_new.close()

        v_gates = vgates.vgates() + ['vP4']
        p_gates = vgates.pgates() + ['P4']
        extended_vgates = extend_virtual_gates(v_gates,
                                               p_gates,
                                               vgates,
                                               name='vgates')
        if verbose:
            extended_vgates.print_matrix()

        extended_vgates.close()

        newvg, _, _ = update_cc_matrix(vgates,
                                       update_cc=np.eye(3),
                                       verbose=verbose)
        newvg.close()

        update_matrix = 0.1 * np.random.rand(3, 3)
        np.fill_diagonal(update_matrix, 1)

        # test normalization of virtual gate matrix
        extended_vgates, _, _ = update_cc_matrix(vgates,
                                                 update_cc=update_matrix,
                                                 verbose=verbose)
        np.testing.assert_almost_equal(
            extended_vgates.get_crosscap_matrix(),
            update_matrix.dot(vgates.get_crosscap_matrix()))

        # test normalization of virtual gate matrix
        serialized_matrix = extended_vgates.get_crosscap_matrix()
        extended_vgates.normalize_matrix()
        crosscap_matrix = extended_vgates.get_crosscap_matrix()
        for row in range(serialized_matrix.shape[0]):
            np.testing.assert_almost_equal(
                serialized_matrix[row] / serialized_matrix[row][row],
                crosscap_matrix[row])
        cc_matrix_diagonal = crosscap_matrix.diagonal()
        np.testing.assert_almost_equal(cc_matrix_diagonal, 1.)

        vgates.close()
        extended_vgates.close()
        gates.close()
 def setUp(self):
     self.virtual_ivvi = VirtualIVVI(
         qtt.measurements.scans.instrumentName('test_ivvi'),
         model=None,
         dac_unit='mV')
Exemple #29
0
    def test_convert_scanjob_vec_scan1Dfast(self):
        p = Parameter('p', set_cmd=None)
        gates = VirtualIVVI(
            name=qtt.measurements.scans.instrumentName('gates'), model=None)
        station = qcodes.Station(gates)
        station.gates = gates

        # exclusive end-value
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': p,
                'start': -2.,
                'end': 2.,
                'step': .4
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station)
        actual_values = list(sweepvalues)
        expected_values = [
            -2.0, -1.6, -1.2, -0.8, -0.4, 0.0, 0.4, 0.8, 1.2, 1.6
        ]
        for actual_val, expected_val in zip(actual_values, expected_values):
            self.assertAlmostEqual(actual_val, expected_val, 12)
        self.assertEqual(len(actual_values), 10)

        # exclusive: end - start < step
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': p,
                'start': 20,
                'end': 20.0050,
                'step': .0075
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station)
        actual_values = list(sweepvalues)
        expected_values = [20.0]
        for actual_val, expected_val in zip(actual_values, expected_values):
            self.assertAlmostEqual(actual_val, expected_val, 12)
        self.assertEqual(len(actual_values), 1)

        # inclusive end-value
        scanjob = scanjob_t({
            'scantype': 'scan1Dfast',
            'sweepdata': {
                'param': p,
                'start': -2.,
                'end': 2.,
                'step': .4
            }
        })
        _, sweepvalues = scanjob._convert_scanjob_vec(station, sweeplength=11)
        actual_values = list(sweepvalues)
        expected_values = [
            -2.0, -1.6, -1.2, -0.8, -0.4, 0.0, 0.4, 0.8, 1.2, 1.6, 2.0
        ]
        for actual_val, expected_val in zip(actual_values, expected_values):
            self.assertAlmostEqual(actual_val, expected_val, 12)
        self.assertEqual(len(actual_values), 11)

        gates.close()