コード例 #1
0
ファイル: videomode_processor.py プロジェクト: q4quanta/qtt
    def __init__(self, station, verbose=1):
        self.station = station
        self.verbose = verbose

        self.scan_parameters = {}
        self.period_1d = qcodes.ManualParameter('period_1d',
                                                initial_value=1e-3)
コード例 #2
0
def test_datasaver_multidim_array(experiment, bg_writing):
    """
    Test that inserting multidim parameters as arrays works as expected
    """
    meas = Measurement(experiment)
    size1 = 10
    size2 = 15

    data_mapping = {
        name: i
        for i, name in zip(range(4), ['x1', 'x2', 'y1', 'y2'])
    }

    x1 = qc.ManualParameter('x1')
    x2 = qc.ManualParameter('x2')
    y1 = qc.ManualParameter('y1')
    y2 = qc.ManualParameter('y2')

    meas.register_parameter(x1, paramtype='array')
    meas.register_parameter(x2, paramtype='array')
    meas.register_parameter(y1, setpoints=[x1, x2], paramtype='array')
    meas.register_parameter(y2, setpoints=[x1, x2], paramtype='array')
    data = np.random.rand(4, size1, size2)
    expected = {
        'x1': data[0, :, :],
        'x2': data[1, :, :],
        'y1': data[2, :, :],
        'y2': data[3, :, :]
    }
    with meas.run(write_in_background=bg_writing) as datasaver:
        datasaver.add_result(
            (str(x1), expected['x1']), (str(x2), expected['x2']),
            (str(y1), expected['y1']), (str(y2), expected['y2']))

    datadicts = _get_data_from_ds(datasaver.dataset)
    assert len(datadicts) == 2
    for datadict_list in datadicts:
        assert len(datadict_list) == 3
        for datadict in datadict_list:
            dataindex = data_mapping[datadict['name']]
            expected_data = data[dataindex, :, :].ravel()
            assert_allclose(datadict['data'], expected_data)

            assert datadict['data'].shape == (size1 * size2, )
コード例 #3
0
ファイル: test_tools.py プロジェクト: RasmusBC59/qtt
    def test_reshape_metadata(self, quiet=True):
        param = qcodes.ManualParameter('dummy')
        data_set = qcodes.loops.Loop(param[0:1:10]).each(param).run(quiet=quiet)

        metadata = reshape_metadata(data_set, printformat='dict')
        self.assertTrue(metadata.startswith('dataset'))

        data_set.metadata['scanjob'] = {'scanjobdict': True}
        metadata = reshape_metadata(data_set, printformat='dict')
        self.assertIn('scanjobdict', metadata)
コード例 #4
0
def test_reshape_metadata():
    import qtt.measurements.scans
    param = qcodes.ManualParameter('dummy')
    try:
        dataset = qcodes.Loop(param[0:1:10]).each(param).run()
    except:
        dataset = None
        pass
    if dataset is not None:
        _ = reshape_metadata(dataset, printformat='dict')
    instr = qcodes.Instrument(
        qtt.measurements.scans.instrumentName(
            '_dummy_test_reshape_metadata_123'))
    st = qcodes.Station(instr)
    _ = reshape_metadata(st, printformat='dict')
    instr.close()
コード例 #5
0
        'localos', 'TCPIP0::192.168.15.105::inst0::INSTR')
    STATION.add_component(localos)
    cavity = RohdeSchwarz_SGS100A(
        'cavity', 'TCPIP0::192.168.15.104::inst0::INSTR')
    STATION.add_component(cavity)
    awg = AWG5014_ext(
        'awg', 'TCPIP0::192.168.15.102::inst0::INSTR', timeout=40)
    STATION.add_component(awg)
    mercury = MercuryiPS(name='mercury',
                         address='192.168.15.200',
                         port=7020,
                         axes=['X', 'Y', 'Z'])
    STATION.add_component(mercury)
    vna = VNA_ext('VNA', 'TCPIP0::192.168.15.103::inst0::INSTR')
    STATION.add_component(vna)
    dummy_time = qc.ManualParameter('dummy_time')
    mag_sphere = SphereCor('Magnet', mercury.x_fld, keith.By, mercury.z_fld)
    STATION.add_component(mag_sphere)
    mag_sphere.radius.label = 'B magnitude'
    mag_sphere.radius.unit = 'T'
    mag_sphere.theta.label = 'B theta'
    mag_sphere.phi.label = 'B phi'

    # Specify which parameters are to be added to the monitor and printed in
    # metadata
    param_monitor_list = [
        qdac.ch01_v, qdac.ch02_v, qdac.ch03_v, qdac.ch04_v,
        samp_ctrl.num_avg, samp_ctrl.int_time, samp_ctrl.int_delay,
        rec_ctrl.num_avg, rec_ctrl.int_time, rec_ctrl.int_delay,
        ave_ctrl.num_avg, ave_ctrl.int_time, ave_ctrl.int_delay,
        awg.state, awg.ch1_amp, awg.ch2_amp,
コード例 #6
0
def data_log(delay,
             *MeasParams,
             N=None,
             minutes=None,
             DataName='',
             XParam=None,
             YParam=None,
             breakif=None,
             plot_results=True,
             save_plots=True):
    """A loop that takes measurements every "delay" seconds (starts measuring
    at startup, and each delay comes after the measurement). Either choose to
    measure N times or for minutes. The arrays of the data are: count_set
    (the number of the data point), time0 (the time since the start),
    *MeasParams (comma-separated collection of parameters (instr.param)
    measured at each point)

    Note that the amount of minutes may be slightly larger than min because
    this assumes the time of measurement for the parameters is 0.

    Returns: data (a DataSet object), plot (a plot or a list of plots
    if MeasParams has more than one parameter)

    Arguments:
    delay: Seconds between each measurement
    *MeasParams: a comma-separated collection of parameters to measure
    Keyword Arguments:
    N: The number of data points to take (if left None, need to use minutes)
    minutes: The number of minutes to take data points (if left as None, need
                to use N). If minutes/delay is not an integer, rounds up
    DataName: the name to be placed on the file (defaults to '')
    XParam: an optional specification of the x-axis parameter to plot (defaults
            to time0 for all plots). If you want different x-axes for different
            plots, use a list. To include time0 in that list, use the string
            'time' or 'time0'. The list must be the same length as YParam or
            MeasParams
    YParam: optional specification of y-axis parameters to plot (if not
            specified, it will create one plot per MeasParam).
    breakif: specify a parameterless function that returns true when the break
            condition is met (example ppms temperature < 2.01)
    plot_results: if you want to do the data log without plots, set this to
            False
    save_plots: True by default. If false, doesn't save plots at the end of the
                sweep

    """
    if breakif is None:

        def breakif():
            pass

    count = qc.ManualParameter('count')
    time0 = time_from_start('time0')
    if N is None and minutes is None:
        return ValueError('Must have either N or minutes arguments')
    elif N is not None and minutes is not None:
        return ValueError('Only use N or minutes arguments')
    elif N is not None and minutes is None:
        loop = qc.Loop(count.sweep(1, int(N),
                                   step=1)).each(time0, *MeasParams,
                                                 qc.Wait(delay),
                                                 qc.BreakIf(breakif))
    elif minutes is not None and N is None:
        N = ceil(minutes * 60 / delay)
        loop = qc.Loop(count.sweep(1, int(N),
                                   step=1)).each(time0, *MeasParams,
                                                 qc.Wait(delay),
                                                 qc.BreakIf(breakif))
    data = loop.get_data_set(name=DataName)
    plot = []

    def _plot_update():
        if type(plot) is list:
            for p in plot:
                p.update()
        else:
            plot.update()

    def _plot_save():
        if type(plot) is list:
            for p in plot:
                p.save()
        else:
            plot.save()

    if plot_results:
        if XParam is None:
            XParam = time0

        if len(MeasParams) == 1:
            plot = qc.QtPlot(getattr(data, str(XParam)),
                             getattr(data, str(*MeasParams)),
                             window_title=str(XParam) + ' vs. ' +
                             str(*MeasParams))
            loop.with_bg_task(plot.update)
        else:
            if YParam is None:
                YParam = MeasParams
            if type(XParam) is not list and type(XParam) is not tuple:
                if type(YParam) is not list and type(YParam) is not tuple:
                    XParam = [XParam]
                    YParam = [YParam]
                else:
                    XParam = [XParam] * len(MeasParams)
            elif len(XParam) != len(YParam):
                raise ValueError('length of XParam list must be the same as' +
                                 'length of YParam list')
            for i in range(len(XParam)):
                if type(XParam[i]) is str:
                    if XParam[i] == 'time' or XParam[i] == 'time0':
                        XParam[i] = time0

            # plot = []
            for i in range(len(YParam)):
                title = str(YParam[i]) + ' vs. ' + str(XParam[i])
                plot.append(
                    qc.QtPlot(getattr(data, str(XParam[i])),
                              getattr(data, str(YParam[i])),
                              window_title=title))

            # def _plot_update():
            #     for p in plot:
            #         p.update()
            #
            # def _plot_save():
            #     for p in plot:
            #         p.save()

            loop.with_bg_task(_plot_update)
    try:
        time0.reset()
        loop.run()
        if save_plots and plot_results:
            _plot_save()
        return data, plot
    except KeyboardInterrupt:
        if plot_results:
            _plot_update()
            if save_plots:
                _plot_save()
        print('Keyboard Interrupt')
        return data, plot