Exemplo n.º 1
0
def open_data(date, num):
    """
    Open a data file taken on a given date and with a given ID,
    and read in the data/metadata.
    """
    loc = find_data(date, num)
    if loc is None:
        return None
    data = qc.DataSet(location=loc)
    data.read()
    data.read_metadata()
    return data
def plot_cooldown(datas):
    """
    Plot resistance of ohmics during cooldown
    Datas is the datasets that make up the cooldown
    """
    
    # Calculate how many data points are in each array
    lengths = []
    for data in datas:
        time = data.time
        lengths.append(np.where(np.isnan(time))[0][0] - 1)
    
    # Make a new DataSet
    new_data = qc.DataSet(location="data/Cooldown")
    new_length = np.sum(lengths)
    # And add new dataarrays for each dataarray in the original data
    for d_arr in datas[0].arrays.values():
        data_array = qc.DataArray(
                name=d_arr.name,
                full_name=d_arr.full_name, 
                label=d_arr.full_name,
                array_id=d_arr.array_id,
                unit=d_arr.unit,
                is_setpoint=d_arr.is_setpoint,
                shape=(new_length, *d_arr.shape[1:]))
        data_array.init_data()
        new_data.add_array(data_array)
    
    # Then, update each of the set arrays
    for key, d_arr in new_data.arrays.items():
        d_arr.set_arrays = tuple(new_data.arrays[s_arr.name + "_set"] for s_arr in datas[0].arrays[key].set_arrays)
        
    # Then, fill in each item
    cumsum = 0
    for data, length in zip(datas, lengths):
        for key, d_arr in data.arrays.items():
            new_data.arrays[key][cumsum:cumsum+length] = d_arr.ndarray[0:length]
        cumsum += length
    
    # We also need to make time keep counting upwards
    cumsum = 0
    offs = 0
    for i, l in enumerate(lengths[:-1]):
        cumsum += l
        offs += new_data.time[l-1]
        new_data.time[cumsum:cumsum+lengths[i+1]] += offs
    
    return new_data
Exemplo n.º 3
0
 def loadInfo(self):
     logging.debug('loading info')
     try:
         for row in range(self._treemodel.rowCount()):
             index = self._treemodel.index(row, 0)
             i = 0
             while (index.child(i, 0).data() is not None):
                 filename = index.child(i, 3).data()
                 loc = os.path.dirname(filename)
                 tempdata = qcodes.DataSet(loc)
                 tempdata.read_metadata()
                 infotxt = self.getArrayStr(tempdata.metadata)
                 self._treemodel.setData(index.child(i, 1), infotxt)
                 i = i + 1
     except Exception as e:
         logging.warning(e)
Exemplo n.º 4
0
 def load_info(self):
     try:
         for row in range(self._treemodel.rowCount()):
             index = self._treemodel.index(row, 0)
             i = 0
             while (index.child(i, 0).data() is not None):
                 filename = index.child(i, 3).data()
                 loc = '\\'.join(filename.split('\\')[:-1])
                 tempdata = qcodes.DataSet(loc)
                 tempdata.read_metadata()
                 infotxt = DataViewer.get_data_info(tempdata.metadata)
                 self._treemodel.setData(index.child(i, 1), infotxt)
                 if 'comment' in tempdata.metadata.keys():
                     self._treemodel.setData(index.child(i, 4),
                                             tempdata.metadata['comment'])
                 i = i + 1
     except Exception as e:
         print(e)
Exemplo n.º 5
0
def calc_rho(field,
             data_xx,
             data_xy,
             curr=1e-9,
             width=50e-6,
             length=100e-6,
             field_center=1,
             name="Analyzed_Field_Sweep"):
    """
    Calculate rho_xx, rho_xy from given data sweeps:
    Parameters:
     - field: field setpoints
     - data_xx: V_xx DataArray
     - data_xy: V_xy DataArray
     - curr: Either the current as a number or as a DataArray. If a DataArray is given,
             the trace will be averaged to extract a mean current.
     - width/length: Width of the hall bar/distance between V_xx probes to extract
                     a sheet resistance
     - field_center:
     - name: Name to save output data
    """
    path = "data" / Path(name)

    np_field = field.ndarray.copy()
    np_xx = data_xx.ndarray.copy()
    np_xy = data_xy.ndarray.copy()

    if isinstance(curr, qc.DataArray):
        curr = np.average(-1 * (curr.ndarray.copy()) / 1e6)
        print(curr)

    # Calculate resistances
    rho_xy = np_xy / curr
    # rho_xx is scaled by the width+length of the hall bar to get a sheet resistivity
    rho_xx = (np_xx / curr) * (width / length)

    # Calculate density
    # We want to do a fit between (field_center, -field_center) tesla as there is some extra structure
    # above these values
    min_ind = np.where(np.abs(np_field + field_center) < 0.01)[0][0]
    max_ind = np.where(np.abs(np_field - field_center) < 0.01)[0][0]
    min_ind, max_ind = np.min((min_ind, max_ind)), np.max((min_ind, max_ind))
    res = np.polyfit(np_field[min_ind:max_ind], rho_xy[min_ind:max_ind], 1)
    poly = np.poly1d(res)

    # Then the density is given by 1/(|e| dp/dB), in cm^2
    density = 1 / (const.e * res[0])
    density *= 1e-4

    print("Density is: {:.2e} cm^-2".format(density))

    # And the calculated mobility is given by mu=1/(rho_xx |e| ns)
    mu = 1 / (rho_xx * const.e * density)

    # And let's quote the density slightly offset from 0, at 0.1T
    mob_ind = np.where(np.abs(np_field - 0.1) < 0.005)[0][0]
    mobility = mu[mob_ind]

    print("Mobility is: {:.2e} cm^2/V s".format(mobility))

    # And finally, let's create a new dataset. Leave location unset for now...
    dataset = qc.DataSet(location=str(path))

    da_field = qc.DataArray(array_id="Field",
                            label="Field",
                            unit="T",
                            is_setpoint=True,
                            preset_data=np_field)
    da_reduced_field = qc.DataArray(array_id="Reduced_Field",
                                    label="Field",
                                    unit="T",
                                    is_setpoint=True,
                                    preset_data=np_field[min_ind:max_ind])
    da_poly = qc.DataArray(array_id="Poly_Deg",
                           label="Polynomial Degree",
                           is_setpoint=True,
                           preset_data=list(range(2))[::-1])

    da_rho_xy = qc.DataArray(array_id="Rho_XY",
                             label="Rho XY",
                             unit="Ohms",
                             set_arrays=(da_field, ),
                             preset_data=rho_xy)
    da_rho_xy_fit = qc.DataArray(array_id="fit_Rho_XY",
                                 label="Rho XY",
                                 unit="Ohms",
                                 set_arrays=(da_reduced_field, ),
                                 preset_data=poly(np_field[min_ind:max_ind]))
    da_rho_xy_coef = qc.DataArray(array_id="coef_Rho_XY",
                                  label="Poly Coefficients",
                                  set_arrays=(da_poly, ),
                                  preset_data=res)
    da_rho_xx = qc.DataArray(array_id="Rho_XX",
                             label="Rho XX",
                             unit="Ohms",
                             set_arrays=(da_field, ),
                             preset_data=rho_xx)
    da_mu = qc.DataArray(array_id="mu",
                         label="Mobility",
                         unit="cm<sup>2</sup> (V s)<sup>-1</sup>",
                         set_arrays=(da_field, ),
                         preset_data=mu)

    dataset.add_array(da_field)
    dataset.add_array(da_reduced_field)
    dataset.add_array(da_poly)
    dataset.add_array(da_rho_xy)
    dataset.add_array(da_rho_xy_fit)
    dataset.add_array(da_rho_xy_coef)
    dataset.add_array(da_rho_xx)
    dataset.add_array(da_mu)

    # Save the data
    dataset.finalize()

    # Make some nice plots
    # Showing Density (Rho_XY) analysis
    fig, ax = plt.subplots()
    ax.plot(dataset.Field, dataset.Rho_XY, 'r')
    ax.plot(dataset.Field, dataset.fit_Rho_XY, 'k')
    ax.set_xlabel(format_ax(dataset.Field))
    ax.set_ylabel(format_ax(dataset.Rho_XY))
    ax.text(
        0.05,
        0.95,
        "Using {} current<br>".format(qtplot.siFormat(curr, suffix="A")) +
        "From a linear fit:<br>" +
        "dρ/dB = {}<br>".format(qtplot.siFormat(res[0], suffix="Ω")) +
        "n<sub>s</sub> = 1/(|e| dρ/dB) = {:e} cm<sup>-2</sup>".format(density),
        transform=ax.transAxes)
    fig.savefig(path / "rho_xy.png")

    # Showing Mobility analysis
    fig, ax = plt.subplots()
    ax.plot(dataset.Field, dataset.mu, c=color_cycle[5])
    ax.set_xlabel(format_ax(dataset.Field))
    ax.set_ylabel(format_ax(dataset.mu))
    ax.text(
        0.05,
        0.95,
        "Mobility extracted from:<br>" +
        "μ = 1/ρ<sub>xx</sub> |e| n<sub>s</sub>, with n<sub>s</sub>= {:.2e} cm<sup>-2</sup><br>"
        .format(density) +
        "And using W = {}, L = {}".format(qtplot.siFormat(width, suffix="m"),
                                          qtplot.siFormat(length, suffix="m")),
        transform=ax.transAxes)
    fig.savefig(path / "mobility.png")

    return dataset