How to use the qcodes.data.data_array.DataArray function in qcodes

To help you get started, we’ve selected a few qcodes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QuTech-Delft / qtt / src / qtt / utilities / tools.py View on Github external
abs(setpoints[1][0, -1] - setpoints[1][0, 0])]
    samprates = [im.shape[0] // mVrange[0], im.shape[1] // mVrange[1]]
    factor = int(max(samprates) // min(samprates))
    if factor >= 2:
        axis = int(samprates[0] - samprates[1] < 0)
        if axis == 0:
            facrem = im.shape[0] % factor
            if facrem > 0:
                im = im[:-facrem, :]
            facrem = facrem + 1
            im = im.reshape(im.shape[0] // factor, factor, im.shape[1]).mean(1)
            spy = np.linspace(setpoints[0][0], setpoints[
                0][-facrem], im.shape[0])
            spx = np.tile(np.expand_dims(np.linspace(
                setpoints[1][0, 0], setpoints[1][0, -1], im.shape[1]), 0), im.shape[0])
            setpointy = DataArray(name='Resampled_' + setpoints[0].array_id,
                                  array_id='Resampled_' + setpoints[0].array_id, label=setpoints[0].label,
                                  unit=setpoints[0].unit, preset_data=spy, is_setpoint=True)
            setpointx = DataArray(name='Resampled_' + setpoints[1].array_id,
                                  array_id='Resampled_' + setpoints[1].array_id, label=setpoints[1].label,
                                  unit=setpoints[1].unit, preset_data=spx, is_setpoint=True)
            setpoints = [setpointy, setpointx]
        else:
            facrem = im.shape[1] % factor
            if facrem > 0:
                im = im[:, :-facrem]
            facrem = facrem + 1
            im = im.reshape(im.shape[0], im.shape[1] //
                            factor, factor).mean(-1)
            spx = np.tile(np.expand_dims(np.linspace(setpoints[1][0, 0], setpoints[
                1][0, -facrem], im.shape[1]), 0), [im.shape[0], 1])
            idx = setpoints[1].array_id
github QuTech-Delft / qtt / src / qtt / measurements / scans.py View on Github external
if update_plot:
            if liveplotwindow:
                myupdate()
            pyqtgraph.mkQApp().processEvents()  # needed for the parameterviewer

        if qtt.abort_measurements():
            print('  aborting measurement loop')
            break

    myupdate()
    dt = time.time() - t0

    if scanjob['scantype'] == 'scan1Dvec':
        for param in scanjob['phys_gates_vals']:
            parameter = station.gates.parameters[param]
            arr = DataArray(name=parameter.name, array_id=parameter.name, label=parameter.label, unit=parameter.unit,
                            preset_data=scanjob['phys_gates_vals'][param],
                            set_arrays=(alldata.arrays[sweepvalues.parameter.name],))
            alldata.add_array(arr)

    if not hasattr(alldata, 'metadata'):
        alldata.metadata = dict()

    if extra_metadata is not None:
        update_dictionary(alldata.metadata, **extra_metadata)

    update_dictionary(alldata.metadata, scanjob=dict(scanjob),
                      dt=dt, station=station.snapshot())

    if 'gates' in station.components:
        gates = station.gates
        gatevals = gates.allvalues()
github QuTech-Delft / qtt / src / qtt / data.py View on Github external
passed to it as `record`.

    Raises:
        See _make_data_set for the ValueError and TypeError exceptions that can be raised

    Returns:
        The resulting dataset.

    """
    setpoint_datay = np.array(y)
    setpoint_datax = np.array(x)
    setpoint_dataxy = np.tile(setpoint_datax, [setpoint_datay.size, 1])
    preset_data = np.NaN * np.ones((setpoint_datay.size, setpoint_datax.size))
    setpointy = DataArray(name=yname, array_id=yname, preset_data=setpoint_datay,
                          unit=yunit, is_setpoint=True)
    setpointx = DataArray(name=xname, array_id=xname, preset_data=setpoint_dataxy,
                          unit=xunit, set_arrays=(setpointy,), is_setpoint=True)

    if isinstance(zname, (str, qcodes.Parameter)):
        if isinstance(z, np.ndarray):
            measured_data_list = [z]
        else:
            measured_data_list = z
        measurement_list = [zname]
    else:
        measured_data_list = z
        measurement_list = zname

    measurement_unit = zunit

    data_set, _ = _make_data_set(measured_data_list, measurement_list, measurement_unit, location, loc_record,
                                 preset_data, [setpointy, setpointx])
github QuTech-Delft / qtt / src / qtt / data.py View on Github external
False: The resulting dataset.
    """
    _check_parameter(p1)
    _check_parameter(p2)

    y = p1
    x = p2
    z = preset_data

    setpoint_datay = np.array(y)
    setpoint_datax = np.array(x)
    setpoint_dataxy = np.tile(setpoint_datax, [setpoint_datay.size, 1])
    preset_data = np.NaN * np.ones((setpoint_datay.size, setpoint_datax.size))
    setpointy = DataArray(name=y.name, array_id=y.name, preset_data=setpoint_datay,
                          unit=y.parameter.unit, is_setpoint=True)
    setpointx = DataArray(name=x.name, array_id=x.name, preset_data=setpoint_dataxy,
                          unit=x.parameter.unit, set_arrays=(setpointy,), is_setpoint=True)

    if isinstance(measure_names, (str, qcodes.Parameter)):
        measured_data_list = [z]
        measurement_list = [measure_names]
    else:
        measured_data_list = z
        measurement_list = measure_names

    measurement_unit = None

    data_set, measure_names = _make_data_set(measured_data_list, measurement_list, measurement_unit, location,
                                             loc_record, preset_data, [setpointy, setpointx])

    data_set.last_write = -1
github QuTech-Delft / qtt / src / qtt / data.py View on Github external
Depending on parameter return_names:
            True: The resulting dataset and a tuple with the names of the added arrays (setpoint and measurements).
            False: The resulting dataset.
    """
    _check_parameter(p1)
    _check_parameter(p2)

    y = p1
    x = p2
    z = preset_data

    setpoint_datay = np.array(y)
    setpoint_datax = np.array(x)
    setpoint_dataxy = np.tile(setpoint_datax, [setpoint_datay.size, 1])
    preset_data = np.NaN * np.ones((setpoint_datay.size, setpoint_datax.size))
    setpointy = DataArray(name=y.name, array_id=y.name, preset_data=setpoint_datay,
                          unit=y.parameter.unit, is_setpoint=True)
    setpointx = DataArray(name=x.name, array_id=x.name, preset_data=setpoint_dataxy,
                          unit=x.parameter.unit, set_arrays=(setpointy,), is_setpoint=True)

    if isinstance(measure_names, (str, qcodes.Parameter)):
        measured_data_list = [z]
        measurement_list = [measure_names]
    else:
        measured_data_list = z
        measurement_list = measure_names

    measurement_unit = None

    data_set, measure_names = _make_data_set(measured_data_list, measurement_list, measurement_unit, location,
                                             loc_record, preset_data, [setpointy, setpointx])
github QuTech-Delft / qtt / src / qtt / dataset_processing.py View on Github external
input_array_name: Name of the data array to be processed
        output_array_nane: Name of the output array or None to operate in place
        processing_function: Method to apply to the data array
        label: Label for the output array
        unit: Unit for the output array
    """
    array = dataset.default_parameter_array(input_array_name)
    data = processing_function(np.array(array))
    if label is None:
        label = array.label
    if unit is None:
        unit = array.unit
    if output_array_name is None:
        array.ndarray[:] = data
    else:
        data_array = DataArray(array_id=output_array_name, name=output_array_name, label=label,
                                      set_arrays=array.set_arrays, preset_data=data, unit=unit)
        dataset.add_array(data_array)
    return dataset
github QuTech-Delft / qtt / src / qtt / data.py View on Github external
measure_names = []
    measure_units = []
    for parameter in measurement_list:
        if isinstance(parameter, str):
            # parameter is a str
            measure_names += [parameter]
            measure_units += [measurement_unit]
        elif isinstance(parameter, qcodes.Parameter):
            # parameter is a Parameter
            measure_names += [parameter.name]
            measure_units += [parameter.unit]
        else:
            raise TypeError('Type of measurement names must be str or qcodes.Parameter')

    for idm, mname in enumerate(measure_names):
        preset_data_array = DataArray(name=mname, array_id=mname, label=mname, unit=measure_units[idm],
                                      preset_data=np.copy(preset_data), set_arrays=set_arrays)
        data_set.add_array(preset_data_array)
        if measured_data_list is not None and measured_data_list[idm] is not None:
            measured_array = np.array(measured_data_list[idm])
            if measured_array.shape != preset_data.shape:
                logger.warning(f'Shape of measured data {preset_data.shape} does not match '
                               f'setpoint shape {measured_array.shape}')

            getattr(data_set, mname).ndarray = measured_array

    if len(setpoints) > 1:
        data_set.add_array(setpoints[1])
        data_set.add_array(setpoints[0])
    else:
        data_set.add_array(setpoints[0])
github QuTech-Delft / qtt / src / qtt / data.py View on Github external
- `False` - denotes an only-in-memory temporary DataSet.
        loc_record (dict or None): If location is a callable, this will be
            passed to it as `record`.

    Raises:
        See _make_data_set for the ValueError and TypeError exceptions that can be raised

    Returns:
        The resulting dataset.
    """
    setpoint_data = np.array(x)
    preset_data = np.NaN * np.ones(setpoint_data.size)
    if y is not None:
        y = np.array(y)

    setpoint = DataArray(name=xname, array_id=xname, preset_data=setpoint_data, unit=xunit, is_setpoint=True)

    if isinstance(yname, (str, qcodes.Parameter)):
        measured_data_list = [y]
        measurement_list = [yname]
    else:
        measured_data_list = y
        measurement_list = yname

    measurement_unit = yunit

    data_set, _ = _make_data_set(measured_data_list, measurement_list, measurement_unit, location, loc_record,
                                 preset_data, [setpoint])

    return data_set
github QuTech-Delft / qtt / src / qtt / data.py View on Github external
Raises:
        See _make_data_set for the ValueError and TypeError exceptions that can be raised
        See _check_parameter for the TypeError exceptions that can be raised

    Returns:
        Depending on parameter return_names
            True: The resulting dataset and a tuple with the names of the added arrays (setpoint and measurements).
            False: The resulting dataset.
    """
    _check_parameter(p)

    setpoint_data = np.array(p)
    preset_data = np.NaN * np.ones(setpoint_data.size)

    setpoint = DataArray(name=p.name, array_id=p.name, label=p.parameter.label,
                         unit=p.parameter.unit, preset_data=setpoint_data, is_setpoint=True)

    if isinstance(yname, (str, qcodes.Parameter)):
        measured_data_list = [y]
        measurement_list = [yname]
    else:
        measured_data_list = y
        measurement_list = yname

    measurement_unit = None

    data_set, measure_names = _make_data_set(measured_data_list, measurement_list, measurement_unit, location,
                                             loc_record, preset_data, [setpoint])

    data_set.metadata['default_parameter_name'] = measure_names[0]
    if return_names:
github QuTech-Delft / qtt / src / qtt / data.py View on Github external
- `False` - denotes an only-in-memory temporary DataSet.
        loc_record (dict or None): If location is a callable, this will be
            passed to it as `record`.

    Raises:
        See _make_data_set for the ValueError and TypeError exceptions that can be raised

    Returns:
        The resulting dataset.

    """
    setpoint_datay = np.array(y)
    setpoint_datax = np.array(x)
    setpoint_dataxy = np.tile(setpoint_datax, [setpoint_datay.size, 1])
    preset_data = np.NaN * np.ones((setpoint_datay.size, setpoint_datax.size))
    setpointy = DataArray(name=yname, array_id=yname, preset_data=setpoint_datay,
                          unit=yunit, is_setpoint=True)
    setpointx = DataArray(name=xname, array_id=xname, preset_data=setpoint_dataxy,
                          unit=xunit, set_arrays=(setpointy,), is_setpoint=True)

    if isinstance(zname, (str, qcodes.Parameter)):
        if isinstance(z, np.ndarray):
            measured_data_list = [z]
        else:
            measured_data_list = z
        measurement_list = [zname]
    else:
        measured_data_list = z
        measurement_list = zname

    measurement_unit = zunit