Exemple #1
0
    def save_data(self):
        """
        save the data
        """
        if self.tab_id == 0: # 1D
            label = self._1D__gate_name
        elif self.tab_id == 1: # 2D
            label = self._2D__gate1_name + '_vs_' + self._2D__gate2_name

        is_ds_configured = False
        try:
            is_ds_configured = isinstance(sample_info.project, str)
        except: pass

        try:
            if is_ds_configured:
                logging.info('Save')
                job = do0D(self.vm_data_param, name=label)
                ds = job.run()
                return ds
            else:
                # use qcodes measurement
                measure = Measure(self.vm_data_param)
                data = measure.get_data_set(location=None,
                                            loc_record={
                                            'name': 'vm_data',
                                            'label': label})
                data = measure.run(quiet=True)
                data.finalize()
        except:
            logging.error(f'Error during save data', exc_info=True)
def _do_measurement_single(measurement: Measure, meas_params: tuple,
                           do_plots: Optional[bool]=True,
                           use_threads: bool=True) -> Tuple[QtPlot, DataSet]:

    try:
        parameters = list(meas_params)
        _flush_buffers(*parameters)
        interrupted = False

        try:
            data = measurement.run(use_threads=use_threads)
        except KeyboardInterrupt:
            interrupted = True
            print("Measurement Interrupted")

        if do_plots:
            plot, _ = _plot_setup(data, meas_params)
            # Ensure the correct scaling before saving
            plot.autorange()
            plot.save()

            if 'pdf_subfolder' in CURRENT_EXPERIMENT or 'png_subfolder' in CURRENT_EXPERIMENT:
                _do_MatPlot(data,meas_params)

        else:
            plot = None

        log.info("#[QCoDeS]# Saved dataset to: {}".format(data.location))

        if interrupted:
            raise KeyboardInterrupt
    except:
        log.exception("Exception in doO")
        raise
    return plot, data
Exemple #3
0
    def test_metadata(self):
        loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}'
        rcd = {'name': 'test_metadata'}
        loc_provider = FormatLocation(fmt=loc_fmt, record=rcd)
        c = Measure(self.p1).run(location=loc_provider)
        self.assertEqual(c.metadata['arrays']['this']['unit'], 'this unit')
        self.assertEqual(c.metadata['arrays']['this']['name'], 'this')
        self.assertEqual(c.metadata['arrays']['this']['label'], 'this label')
        self.assertEqual(c.metadata['arrays']['this']['is_setpoint'], False)
        self.assertEqual(c.metadata['arrays']['this']['shape'], (5, ))
        assert_array_equal(c.this.ndarray, np.zeros(5))

        self.assertEqual(c.metadata['arrays']['that']['unit'], 'that unit')
        self.assertEqual(c.metadata['arrays']['that']['name'], 'that')
        self.assertEqual(c.metadata['arrays']['that']['label'], 'that label')
        self.assertEqual(c.metadata['arrays']['that']['is_setpoint'], False)
        self.assertEqual(c.metadata['arrays']['that']['shape'], (5, ))
        assert_array_equal(c.that.ndarray, np.ones(5))

        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['unit'],
                         'this setpointunit')
        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['name'],
                         'this_setpoint')
        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['label'],
                         'this setpoint')
        self.assertEqual(
            c.metadata['arrays']['this_setpoint_set']['is_setpoint'], True)
        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['shape'],
                         (5, ))
        assert_array_equal(c.this_setpoint_set.ndarray, np.linspace(5, 9, 5))
Exemple #4
0
    def test_metadata(self):
        c = Measure(self.p1).run()
        self.assertEqual(c.metadata['arrays']['this']['unit'], 'this unit')
        self.assertEqual(c.metadata['arrays']['this']['name'], 'this')
        self.assertEqual(c.metadata['arrays']['this']['label'], 'this label')
        self.assertEqual(c.metadata['arrays']['this']['is_setpoint'], False)
        self.assertEqual(c.metadata['arrays']['this']['shape'], (5, ))
        assert_array_equal(c.this.ndarray, np.zeros(5))

        self.assertEqual(c.metadata['arrays']['that']['unit'], 'that unit')
        self.assertEqual(c.metadata['arrays']['that']['name'], 'that')
        self.assertEqual(c.metadata['arrays']['that']['label'], 'that label')
        self.assertEqual(c.metadata['arrays']['that']['is_setpoint'], False)
        self.assertEqual(c.metadata['arrays']['that']['shape'], (5, ))
        assert_array_equal(c.that.ndarray, np.ones(5))

        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['unit'],
                         'this setpointunit')
        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['name'],
                         'this_setpoint')
        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['label'],
                         'this setpoint')
        self.assertEqual(
            c.metadata['arrays']['this_setpoint_set']['is_setpoint'], True)
        self.assertEqual(c.metadata['arrays']['this_setpoint_set']['shape'],
                         (5, ))
        assert_array_equal(c.this_setpoint_set.ndarray, np.linspace(5, 9, 5))
def qc_run(name, seq, *params):
    loop = None
    for sp in seq.params:
        if loop is None:
            loop = Loop(sp[sp.values])
        else:
            loop = loop.loop((sp[sp.values]))

    play_task = Task(upload_play, seq)

    if loop is not None:
        m = loop.each(play_task, *params)
    else:
        m = Measure(play_task, *params)

    ds = m.run(loc_record={'name':name})
    return ds
Exemple #6
0
    def test_array_and_scalar(self):
        self.p1.set(42)
        data = Measure(MultiGetter(arr=(5, 6)), self.p1).run_temp()

        self.assertEqual(data.single_set.tolist(), [0])
        self.assertEqual(data.P1.tolist(), [42])
        self.assertEqual(data.index0.tolist(), [0, 1])
        self.assertEqual(data.arr.tolist(), [5, 6])
        self.assertEqual(len(data.arrays), 4, data.arrays)
Exemple #7
0
    def test_simple_scalar(self):
        data = Measure(self.p1).run_temp()

        self.assertEqual(data.single_set.tolist(), [0])
        self.assertEqual(data.P1.tolist(), [1])
        self.assertEqual(len(data.arrays), 2, data.arrays)

        self.assertNotIn('loop', data.metadata)

        meta = data.metadata['measurement']
        self.assertEqual(meta['__class__'], 'qcodes.measure.Measure')
        self.assertEqual(len(meta['actions']), 1)
        self.assertFalse(meta['use_threads'])

        ts_start = datetime.strptime(meta['ts_start'], '%Y-%m-%d %H:%M:%S')
        ts_end = datetime.strptime(meta['ts_end'], '%Y-%m-%d %H:%M:%S')
        self.assertGreaterEqual(ts_end, ts_start)
Exemple #8
0
    def doFastSweep(self, start: float, stop: float, steps: int,
                    mode: str) -> DataSet:
        """
        Perform a fast sweep using a deployed lua script and
        return a QCoDeS DataSet with the sweep.

        Args:
            start: starting sweep value (V or A)
            stop: end sweep value (V or A)
            steps: number of steps
            mode: What kind of sweep to make.
                'IV' (I versus V) or 'VI' (V versus I)
        """
        # prepare setpoints, units, name
        self.fastsweep.prepareSweep(start, stop, steps, mode)

        data = Measure(self.fastsweep).run()

        return data
Exemple #9
0
    def doFastSweep(self, start: float, stop: float, steps: int,
                    mode: str) -> DataSet:
        """
        Perform a fast sweep using a deployed lua script and
        return a QCoDeS DataSet with the sweep.

        Args:
            start: starting sweep value (V or A)
            stop: end sweep value (V or A)
            steps: number of steps
            mode: Type of sweep, either 'IV' (voltage sweep),
                'VI' (current sweep two probe setup) or
                'VIfourprobe' (current sweep four probe setup)
        """
        # prepare setpoints, units, name
        self.fastsweep.prepareSweep(start, stop, steps, mode)

        data = Measure(self.fastsweep).run()

        return data
Exemple #10
0
    def test_metadata(self):
        loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}'
        rcd = {'name': 'test_metadata'}
        param_name_1 = "multi_setpoint_param_this"
        param_name_2 = "multi_setpoint_param_that"
        setpoint_name = "multi_setpoint_param_this_setpoint_set"
        loc_provider = FormatLocation(fmt=loc_fmt, record=rcd)
        c = Measure(self.p1).run(location=loc_provider)
        self.assertEqual(c.metadata['arrays'][param_name_1]['unit'],
                         'this unit')
        self.assertEqual(c.metadata['arrays'][param_name_1]['name'],
                         param_name_1)
        self.assertEqual(c.metadata['arrays'][param_name_1]['label'],
                         'this label')
        self.assertEqual(c.metadata['arrays'][param_name_1]['is_setpoint'],
                         False)
        self.assertEqual(c.metadata['arrays'][param_name_1]['shape'], (5, ))
        assert_array_equal(getattr(c, param_name_1).ndarray, np.zeros(5))

        self.assertEqual(c.metadata['arrays'][param_name_2]['unit'],
                         'that unit')
        self.assertEqual(c.metadata['arrays'][param_name_2]['name'],
                         param_name_2)
        self.assertEqual(c.metadata['arrays'][param_name_2]['label'],
                         'that label')
        self.assertEqual(c.metadata['arrays'][param_name_2]['is_setpoint'],
                         False)
        self.assertEqual(c.metadata['arrays'][param_name_2]['shape'], (5, ))
        assert_array_equal(getattr(c, param_name_2).ndarray, np.ones(5))

        self.assertEqual(c.metadata['arrays'][setpoint_name]['unit'],
                         'this setpointunit')
        self.assertEqual(c.metadata['arrays'][setpoint_name]['name'],
                         "multi_setpoint_param_this_setpoint")
        self.assertEqual(c.metadata['arrays'][setpoint_name]['label'],
                         'this setpoint')
        self.assertEqual(c.metadata['arrays'][setpoint_name]['is_setpoint'],
                         True)
        self.assertEqual(c.metadata['arrays'][setpoint_name]['shape'], (5, ))
        assert_array_equal(
            getattr(c, setpoint_name).ndarray, np.linspace(5, 9, 5))
Exemple #11
0
    def test_simple_array(self):
        data = Measure(MultiGetter(arr=(1.2, 3.4))).run_temp()

        self.assertEqual(data.index0.tolist(), [0, 1])
        self.assertEqual(data.arr.tolist(), [1.2, 3.4])
        self.assertEqual(len(data.arrays), 2, data.arrays)