Exemple #1
0
def continousResistTemp(chip, devices, folder, save):
    global slope_plots, app
    global windows, plots, curves, figures, current_point

    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    num_plots = len(devices)
    #curves = initialization(num_plots)
    windows = lpf.create_windows(num_plots)
    plots = lpf.create_plots(windows, formatt='RvsT')
    curves = lpf.create_curves(plots)
    current_point = lpf.create_current_point(plots)

    windows[0].move(
        -900, 0)  # move to other desktop, spyder had been blocking before
    windows[0].setWindowState(QtCore.Qt.WindowActive)
    windows[0].raise_()

    # this will activate the window (yellow flashing on icon)
    windows[0].activateWindow()
    i = 0

    for device in devices:
        cards = inpfunc.get_cards(device)
        card1 = cards[0]
        card2 = cards[1]
        channels = inpfunc.get_channels(device)
        channel1 = channels[0]
        channel2 = channels[1]
        print("Device name is %s" % device.name)
        R, T, Tc = iv.tempandresrun(app, curves[i], current_point[i], card1,
                                    card2, channel1, channel2)
        print("Sweep Up Tc is %f" % Tc[0])
        print("Sweep Down Tc is %f" % Tc[1])
        Tc = np.mean(Tc)
        print("Averaged Tc is %f" % Tc)
        if save:
            name = ic.create_name(chip, device)
            name = name.replace(
                " ",
                "_")  #For fixing problem in Fix Tc with spaces in device name
            ic.create_dir((folder + name))
            filename = folder + name + "_ResistvsTemp_raw.dat"
            iv.save_rt_data_live(R, T, filename)  #Save data to sharepoint
            d.save_Crossbar_Tc(chip, Tc, folder, device)  #Save Tc to database
        i = i + 1
def get_Rn_Imax(folder, chip, devices):
    global slope_plots, app
    global windows, plots, curves, my_exporters, figures
    '''
     Inputs:
        Folder-Target folder for data to be saved
        Chip-Target Chip
        Devices-Devices on Target Chip
    Outputs:
        return_measurements_Rn-Array of rn measurements
        return_measurements_Imax-array of Imax measurements
        2 graphs for each device, one has Rn, Imax
        s
    Called By: 
        Measurement Functions- MEasure_JJs_Rn
    Calls On:
        sweep_current_live_Rn
        save_Rn_data
    '''
    # get variables
    inputs = inpfunc.format_input_Rn_Imax_devices(devices)
    channels = inputs[0]
    num_JJ = inputs[1]
    cards = inputs[2]

    # arrays that will be returned
    return_measurements_Rn = []
    return_measurements_Imax = []

    # check instance, so that it doesn't crash on exit (hopefully)
    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    num_plots = len(num_JJ)
    # create windows, plots, curves
    curves = initialization(num_plots)
    x, y = lpf.create_data(curves)

    slope_plots = lpf.create_slope_plots(plots)

    # data collection
    counter = 0
    steps = 0.00008
    # create exporters (trying to fix problem of C object being deleted
    my_exporters = []
    for i in range(0, num_plots):
        scene = plots[i].scene()
        exporter = exporters.ImageExporter(scene)
        my_exporters.append(exporter)

    # loop through and plot slope
    # i incremets by 2, counter by 1
    # get current number of JJ and channels
    for i in range(0, len(channels), 2):
        num_j = num_JJ[counter]
        chan1 = channels[i]
        chan2 = channels[i + 1]
        card1 = cards[i]
        card2 = cards[i + 1]

        dev = devices[counter]
        ic_pred = d.predict_Ic(d.chip_Jc(chip), dev.JJ_radius_nom * 1e-06)
        steps = (ic_pred * 16) / 100
        print("-----------------")
        print(steps)

        # bring current window to focus
        windows[counter].move(
            -900, 0)  # move to other desktop, spyder had been blocking before
        windows[counter].setWindowState(QtCore.Qt.WindowActive)
        windows[counter].raise_()

        # this will activate the window (yellow flashing on icon)
        windows[counter].activateWindow()

        # plot, from zero, to at least V_max (num_j*2.5e-03) and stop when slope exceeds certain amount
        # see iv.sweep_current_live_Rn
        I, V, R, slope, slope_index = iv.sweep_current_live_Rn(
            app, curves[counter], 1, 0, num_j * 2.5e-03, steps, card1, card2,
            chan1, chan2, dev)
        if I == 0 and V == 0 and R == 0:
            return 0, 0

        # plot the slope and get the location it was plotted
        try:
            slope_index, slope = plot_slope(I, V, counter, slope, slope_index)
        except:
            print("\nERROR!\n")
            slope_index = 0
            slope = 1e-09

        # set label
        label = pg.TextItem(text=("Slope: " + str(slope)),
                            color=(0, 0, 0),
                            fill=(255, 0, 0),
                            anchor=(-.5, -.5))
        label.setPos(I[slope_index], V[slope_index])
        plots[counter].addItem(label)

        # append to total data
        x[counter] = I
        y[counter] = V

        # create name
        name = ic.create_name(chip, devices[counter])
        plots[counter].setTitle(name)
        # new fig
        #fig = plt.figure()
        #figures.append(fig)

        # plot differential
        #Rdiff = np.diff(V)/np.diff(I)
        #plt.plot(V[0:-1], Rdiff)

        # saving
        filename = (folder + name + "_Rn.png")
        ic.create_dir(filename)
        print(filename)
        iv.save_data_live(I, V, R, (folder + name + "_Rn_raw.dat"))
        plt.savefig(folder + name + '_Rn_Diff.png')

        return_measurements_Rn.append(slope / num_JJ[counter])
        return_measurements_Imax.append(I[slope_index + 5])
        save_Rn_data((slope / num_JJ[counter]), I[slope_index + 5],
                     folder + name)

        try:
            my_exporters[counter].export(filename)
        except:
            print("oh noooo, wrapped object was deleted\n")

        counter += 1
    return return_measurements_Rn, return_measurements_Imax
def get_Rn_Imax_and_save(folder, folder_link, chip, devices, meas_ids):
    global slope_plots, app
    global windows, plots, curves
    global my_exporters
    '''
    
    :param folder: Target folder for data to be saved
    
    :param folder_link: Web Link to Folder
    
    :param chip: Target Chip
   
    :param devices: Array of Target devices
   
    :param  Meas_IDs: Array of Measurement Ids
   
    :return: return_measurements_Rn- Array of rn measurements
        
    :return: return_measurements_Imax-array of Imax measurements
      
    :Graphs: 1 Rn, 1 Imax for each device
    
    Saves in database after every run
   
    Called By: 
      
        -Measurement Functions- Measure_PCM_chip_cold
    
    Calls On:
       
        -sweep_current_live_Rn
        
        -save_Rn_data
    '''

    # get variables
    inputs = inpfunc.format_input_Rn_Imax_devices(devices)
    channels = inputs[0]
    num_JJ = inputs[1]
    cards = inputs[2]

    # arrays that will be returned
    return_measurements_Rn = []
    return_measurements_Imax = []

    # check instance, so that it doesn't crash on exit
    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    num_plots = len(num_JJ)

    # create windows, plots, curves
    curves = initialization(num_plots)
    x, y = lpf.create_data(curves)

    slope_plots = lpf.create_slope_plots(plots)

    # data collection
    counter = 0

    # create exporters (trying to fix problem of C object being deleted
    my_exporters = []
    for i in range(0, num_plots):
        scene = plots[i].scene()
        exporter = exporters.ImageExporter(scene)
        my_exporters.append(exporter)

    # loop through and plot slope
    # i incremets by 2, counter by 1
    for i in range(0, len(channels), 2):
        # get current number of JJ and channels
        num_j = num_JJ[counter]
        chan1 = channels[i]
        chan2 = channels[i + 1]
        card1 = cards[i]
        card2 = cards[i + 1]
        # create steps based on device, method: Ic*16/100
        dev = devices[counter]
        ic_pred = d.predict_Ic(d.chip_Jc(chip), dev.JJ_radius_nom * 1e-06)
        steps = (ic_pred * 16) / 100
        print("-----------------")
        print(steps)

        # bring current window to focus
        windows[counter].move(
            -900, 0)  # move to other desktop, spyder had been blocking before
        windows[counter].setWindowState(QtCore.Qt.WindowActive)
        windows[counter].raise_()

        # this will activate the window (yellow flashing on icon)
        windows[counter].activateWindow()

        # plot, from zero, to at least V_max (num_j*2.5e-03) and stop when slope exceeds certain amount
        # see iv.sweep_current_live_Rn

        I, V, R, slope, slope_index = iv.sweep_current_live_Rn(
            app, curves[counter], 1, 0, num_j * 4e-03, steps, card1, card2,
            chan1, chan2, dev)
        if slope is None:
            slope = 1e-09

        if I == 0 and V == 0 and R == 0:
            return 0, 0

        # plot the slope and get the location it was plotted
        try:
            slope_index_old, slope_old = plot_slope(I, V, counter, slope,
                                                    slope_index)
        except:
            print("\nERROR!\n")
            slope_index = 0
            slope = 1e-09
        # set label
        label = pg.TextItem(text=("Slope: " + str(slope)),
                            color=(0, 0, 0),
                            fill=(255, 0, 0),
                            anchor=(-.5, -.5))
        label.setPos(I[slope_index], V[slope_index])
        plots[counter].addItem(label)

        # append to total data
        x[counter] = I
        y[counter] = V

        # create name
        name = ic.create_name(chip, devices[counter])
        plots[counter].setTitle(name)

        # new fig
        #        fig = plt.figure()

        # plot differential
        #       Rdiff = np.diff(V)/np.diff(I)
        #     plt.plot(V[0:-1], Rdiff)

        #Saving Locally
        filename = (folder + name)
        print(filename)
        ic.create_dir(filename)

        sub_folder = "/RawData_Rn"
        filename = (folder + sub_folder + name + "_Rn_raw.dat")
        ic.create_dir(filename)  # function to create dir if doesn't exist
        print(filename)
        iv.save_data_live(
            I, V, R,
            (folder + sub_folder + name + "_Rn_raw.dat"))  # save the raw data
        # changed to here 2/15
        plt.savefig(folder + sub_folder + name + '_Rn_Diff.png')

        sub_folder = "/Rn_values"
        filename = (folder + sub_folder + name)
        print(filename)
        ic.create_dir(filename)  # function to create dir if doesn't exist

        return_measurements_Rn.append(slope / num_JJ[counter])
        try:
            return_measurements_Imax.append(I[slope_index + 5])
            save_Rn_data((slope / num_JJ[counter]), I[slope_index + 5],
                         filename)
        except:
            return_measurements_Imax.append(1e-09)
            save_Rn_data((slope / num_JJ[counter]), 1e-09, folder + name)

        sub_folder = "/Graphs"
        filename = (folder + sub_folder + name + "_Rn.png")
        print(filename)
        ic.create_dir(filename)  # function to create dir if doesn't

        try:
            my_exporters[counter].export(filename)
        except:
            print("oh noooo, wrapped object was deleted\n")

        # saving to database
        Rn = return_measurements_Rn[counter]
        Imax = return_measurements_Imax[counter]
        device = devices[counter]
        d.save_JJ_Measurements_Rn(chip, Rn, Imax, meas_ids[counter], device)

        counter = counter + 1
    return return_measurements_Rn, return_measurements_Imax
Exemple #4
0
def measure_SQUID_periodicity(folder, folder_link, chip, devices, save, manual,
                              minIflux, maxIflux, step, Ibias):
    global slope_plots, app
    global windows, plots, curves, figures

    number_of_sweeps = 5  #Changes the number of different Ibiases the Iflux sweep is done at

    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    num_plots = len(devices)
    windows = lpf.create_windows(num_plots)
    plots = lpf.create_plots(windows, formatt='VvsIflux')
    curves = lpf.create_curves(plots)
    current_point = lpf.create_current_point(plots)

    windows[0].move(
        -900, 0)  # move to other desktop, spyder had been blocking before
    windows[0].setWindowState(QtCore.Qt.WindowActive)
    windows[0].raise_()
    windows[0].activateWindow()

    i = 0
    for device in devices:
        cards = inpfunc.get_cards(device)
        card1 = cards[0]
        card2 = cards[1]
        channels = inpfunc.get_channels(device)
        channel1 = channels[0]
        channel2 = channels[1]

        if manual:
            period, Iflux_min_Ic, I, V = iv.sweep_current_vphi(
                app, curves[i], current_point[i], card1, card2, channel1,
                channel2, minIflux, maxIflux, step, Ibias, Ibias + 1, 1)
        else:
            measurements = d.show_squid_measurements_from_device(chip, device)
            average_Ic = get_average_Ic(measurements)
            Ibias_step = average_Ic / (number_of_sweeps + 1)
            Ibias_min = Ibias_step
            Ibias_max = average_Ic - Ibias_step
            period, Iflux_min_Ic, I, V = iv.sweep_current_vphi(
                app, curves[i], current_point[i], card1, card2, channel1,
                channel2, 0, 3e-03, 0.5e-05, Ibias_min, Ibias_max, Ibias_step)

        if save:
            new, meas = d.save_SQUID_periodicity(chip, period, Iflux_min_Ic,
                                                 folder, device)
            name = ic.create_name(chip, device)
            if new:
                ic.create_dir(folder + name)
            else:
                folder = 'E:/Users/volt.686QVACTEST/National Institute of Standards and Technology (NIST)/SEG - SFQ_Circuits' + '/' + meas.data_directory[
                    pg.find_D(meas.data_directory, chip):]
            iv.save_data(
                I, V,
                (folder + name + "_period_raw.dat"))  #Save data to sharepoint

        i = i + 1
Exemple #5
0
def measure_SQUID_IV_no_flux(folder, folder_link, chip, devices, save, manual,
                             min_Ibias, max_Ibias, step_Ibias):
    global slope_plots, app
    global windows, plots, curves, figures

    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    num_plots = len(devices)
    windows = lpf.create_windows(num_plots)
    plots = lpf.create_plots(windows, formatt='IV')
    curves = lpf.create_curves(plots)
    current_point = lpf.create_current_point(plots)
    ic_curves_all = []
    for i in range(len(plots)):
        ic_curves = []
        for j in range(4):
            ic_curves.append(plots[i].plot())
        ic_curves_all.append(ic_curves)

    windows[0].move(
        -900, 0)  # move to other desktop, spyder had been blocking before
    windows[0].setWindowState(QtCore.Qt.WindowActive)
    windows[0].raise_()
    windows[0].activateWindow()

    i = 0
    for device in devices:
        cards = inpfunc.get_cards(device)
        card1 = cards[0]
        card2 = cards[1]
        channels = inpfunc.get_channels(device)
        channel1 = channels[0]
        channel2 = channels[1]

        if manual:
            I, V, Ics = iv.sweep_current(app, curves[i], current_point[i],
                                         ic_curves_all[i], plots[i], card1,
                                         card2, channel1, channel2, min_Ibias,
                                         max_Ibias, step_Ibias)
        else:
            I, V, Ics = iv.sweep_current(app, curves[i], current_point[i],
                                         ic_curves_all[i], plots[i], card1,
                                         card2, channel1, channel2, -0.4e-03,
                                         0.4e-03, 0.005e-03)

        if save:
            new, meas = d.save_SQUID_no_flux(chip, Ics, folder, device)
            name = ic.create_name(chip, device)
            if new:  #If a new measurement was created, create a new folder
                ic.create_dir(folder + name)
            else:  #If the data was added to an existing measurement, add to existing folder
                folder = 'E:/Users/volt.686QVACTEST/National Institute of Standards and Technology (NIST)/SEG - SFQ_Circuits' + '/' + meas.data_directory[
                    pg.find_D(meas.data_directory, chip):]
            iv.save_data(
                I, V,
                (folder + name + "_Ic_raw.dat"))  #Save data to sharepoint

        i = i + 1
Exemple #6
0
def sweep_current_live_GUI(app,plot, curves, number_of_sweeps, I_min, I_max, step, card1, card2, channel1, channel2,save,chip,device):
    """
     Automates the sweep_current_live function for the older GUI
    
    :param app, curve: (both pyqtgraph constructs)
  
    :param number_of_sweeps: number of sweeps to complete
    
    :param I_min, I_max: Respective max and min current values
    
    :param step: step size
    
    :param card1, card2: Target Cards 1 and 2
    
    :param channel1, channel2: Target Channels 1 and 2
    
    :return: I,V,R arrays
    
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    
    Called By:
        
        -Get Rn Imax 
      
        -Get Rn Imax and save
    
    Calls On:
        
        -sweep_current_live_variable_points
        
        -sweep_current_live
    
    """
    # current initialization variables
    # lower range has less noise

    Irange = 1.3e-01
    compliance_voltage = 10.

    # get GPIB instruments
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()

    # different init. for squids vs. pcm

    vf.intialize_switch_all(Switch)



    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)

    vf.intialize_voltage(Voltmeter, nplc, Vrange)


    vf.close_channel(Switch, card1,channel1) # instead of card, used to be 1
    time.sleep(0.2)

    vf.close_channel(Switch,card2,channel2) # instead of card, used to be 1
    time.sleep(0.2)

    vf.turnon_current_yoko(CurrentSource)
    time.sleep(0.2)

    vf.open_short(Switch, card1, shorts)

    time.sleep(.2)

    #Going to use lists to start with for flexibility, even though slower than arrays
    # starting 7/24: voltmeter reads non zero when the current is zero
    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    print('Offset: %s' %offset)

    global go
    go = 1
    #Sweep Current up
    for n in range(0, number_of_sweeps):
        I_values = []
        V_values = []
        R_values = []

        if n%2==0:
            color = 'w'
        else:
            color = 'b'
        if n>1:
            curves[n-2].setData([],[])

        print('\nChannel %d:%d SweepUp Current:'%(channel1,channel2))
        
        
        for I in np.arange(I_min, I_max, step):
            vf.set_current_fast_yoko(CurrentSource, I)

            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            # new, for fixing the offset 7/24:
            V_values.append(V-offset)
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curves[n].setData(I_values,V_values, symbol='o', pen = color,symbolBrush=color, symbolSize=7)
            app.processEvents()
            if go == 0:
                break
            print('%e '%I,end=" ")

        #Sweep Current down
        print('\nChannel %d:%d SweepDown Current:'%(channel1,channel2))
        for I in np.arange(I_max-step, I_min, -step):
            vf.set_current_fast_yoko(CurrentSource, I)
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            V_values.append(V-offset)
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curves[n].setData(I_values,V_values, symbol='o', pen=color,symbolBrush=color, symbolSize=7)
            app.processEvents()
            if go ==0:
                break
            print('%e'%I,end=" ")


    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)

    vf.close_short(Switch, card1, shorts)
    time.sleep(.2)


    vf.open_channel(Switch,card1,channel1)
    vf.open_channel(Switch,card1,channel2)
    
    if save:
        
        current_time = time.strftime("_%Y-%m-%d_%H-%M-%S_IVGUI")
        dirname = ("E:/Users/volt.686QVACTEST/National Institute of Standards and Technology (NIST)/SEG - SFQ_Circuits/")
        import measure_Ic as ic
        folder = dirname+ str(chip.name)+current_time
        name=ic.create_name(chip.name,device)
        filename=folder+name
        ic.create_dir(filename)
        print(filename)
        save_data_live(I_values, V_values, R_values,(folder+name+"_sweep.dat"))
        
        from pyqtgraph import exporters
        exporter = exporters.ImageExporter(plot.scene())
        try:
            exporter.export(filename+"_sweep.png") # export the graph
        except:
            print("Oh no wrapped object was deleted!!!!!")
    
    try:
        return I_values, V_values, R_values
    except:
        return 0,0,0
Exemple #7
0
def get_Resistance(folder, chip, devices, OptionalCurrent=0):
    '''
    Sweep the current from 0 to 3mA and return the resistance.
    
    :param Folder: Target folder for data to be saved
  
    :param Chip: Target Chip
   
    :param Devices: Devices on Target Chip
        
    :return: return_measurements_Resistance-I,V,R arrays
    
    :return: funkygraphlist-List of abnormal graphs
    
    Called By: 
        
        -Measurement Functions
         
            -check_connections
        
            -Measure_PCM_Chip_Warm
    
    Calls On:
        
        -plot_Resistance_Array_live
        
        -save_Resistance_data_device
        
        -save_data_live
    
    '''

    # globals- necesarry to avoid automatic deletion of objects
    global app
    global windows, plots, curves, my_exporters
    # get variables
    inputs = inpfunc.format_input_resistance(devices)
    cards = inputs[0]
    channels = inputs[1]

    # create instance of the app
    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    # detect the number of plots need based on the cards, since there is a 1:1 ratio
    # between devices and cards (%use devices?)
    num_plots = len(devices)
    print("num plots: %d" % num_plots)

    # initialize by opening correct number of windows
    # each window contains a plot, each plot a curve and they are all stored in arrays
    curves = initialization(num_plots)

    # we need two indexes, one for pairs, one for normal
    index_pairs = 0
    index = 0

    my_exporters = []  # array to hold exporters

    # create exporters
    for i in range(0, num_plots):
        exporter = exporters.ImageExporter(plots[i].scene())
        my_exporters.append(exporter)

    return_measurements = []
    funkygraphlist = []
    # take all the sweeps
    for i in range(0, num_plots):
        print("Begin Device %s sweep" % (i))
        # get two channels and two current limits that are needed
        my_channels = []
        my_channels.append(channels[index_pairs])
        my_channels.append(channels[index_pairs + 1])

        my_cards = []
        my_cards.append(cards[index_pairs])
        my_cards.append(cards[index_pairs + 1])

        name = ic.create_name(chip, devices[i])  # create the name
        plots[i].setTitle(name)  # set title to name

        # bring current window to focus
        windows[i].move(
            -900, 0)  # move to other desktop, spyder had been blocking before
        windows[i].setWindowState(QtCore.Qt.WindowActive)
        windows[i].raise_()

        # this will activate the window (yellow flashing on icon)
        windows[i].activateWindow()
        extra_res = 0
        if "2x20" in devices[i].name and devices[i].design_id[
                0].name == "PCMRS":
            extra_res = 138.19
        if "10x40" in devices[i].name and devices[i].design_id[
                0].name == "PCMRS":
            extra_res = 138.37
        # sweep the current device
        max_current = 2e-03
        if OptionalCurrent != 0:
            max_current = OptionalCurrent
        I, V, R, funkygraphs = rc.plot_Resistance_Array_live(
            app,
            curves[i],
            my_cards[0],
            my_cards[1],
            my_channels[0],
            my_channels[1],
            max_current,
            continuity=True,
            extra_res=extra_res)

        try:
            m, b, r2, p, stdev = stats.linregress(I, V)
        except:
            m = 1e-09

        if funkygraphs:
            funkygraphlist.append(devices[i].name)

        if I == 0 and V == 0 and R == 0:
            return 0, 0

        slope = (V[-1] - V[0]) / (I[-1] - I[0])

        # Plotting Critical Currents #

        # arrays that will be returned
        return_measurements.append(m)

        # setting labels
        label = pg.TextItem(text="",
                            color=(0, 0, 0),
                            fill=(255, 0, 0),
                            anchor=(0, -1))

        # label text
        label_text = ("Resistance: %s" % slope)
        label.setText(label_text)
        label.setPos(I[int(len(I) / 2)], V[int(len(V) / 2)])
        graph = plots[i]
        graph.addItem(label)
        new_curve = plots[i].plot()
        new_curve.setData([I[0], I[-1]], [V[0], V[-1]],
                          symbol='o',
                          symbolBrush='r',
                          pen='r',
                          symbolSize=10)

        # Saving #

        filename = (folder + name + "_Resistance.png")
        print(filename)
        ic.create_dir(filename)  # function to create dir if doesn't exist

        iv.save_data_live(
            I, V, R,
            (folder + name + "_Resistance_raw.dat"))  # save the raw data
        save_Resistance_data_device(slope,
                                    (folder + name))  # save the important data

        try:
            my_exporters[i].export(filename)  # export the graph
        except:
            print("Oh no wrapped object was deleted!!!!!")

        # repeat
        index = index + 1
        index_pairs = index_pairs + 2

        app.processEvents()
        print("End Device %s sweep\n" % (i))
    return return_measurements, funkygraphlist
Exemple #8
0
def get_resistance_arrays(folder, chip, devices):
    '''
    Takes a sweep from 0 to 3mA and returns the slope
    
    :param Folder: Target folder for data to be saved
  
    :param Chip: Target Chip
   
    :param Devices: Devices on Target Chip
        
    :return: return_measurements_Resistance-I,V,R arrays
    
   
    
    Called By: 
        
        -Measurement Functions
         
            -Measure_PCM_Chip_Cold
        
            -Measure_PCM_Chip_Warm
    
    Calls On:
        
        -plot_Resistance_Array_live
        
        -plot_slope_Resistance_arrays
        
        -save_data_live
        
        -save_resistance_data
        
        -save_JJ_Measurements_Ic
    

    '''
    global slope_plots, app
    global windows, plots, curves, my_exporters

    # get variables
    inputs = inpfunc.format_input_resistance(devices)
    cards = inputs[0]
    channels = inputs[1]

    # arrays that will be returned
    return_measurements_Resistance = []

    # check instance, so that it doesn't crash on exit (hopefully)
    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    num_plots = int(len(cards) / 2)

    # create windows, plots, curves
    curves = initialization(num_plots)

    # data collection
    counter = 0

    # create exporters (trying to fix problem of C object being deleted)
    my_exporters = []
    for i in range(0, num_plots):
        scene = plots[i].scene()
        exporter = exporters.ImageExporter(scene)
        my_exporters.append(exporter)

    # loop through and plot slope
    # i incremets by 2, counter by 1
    for i in range(0, len(channels), 2):

        slope_plots = lpf.create_slope_plots_resistor_arrays(plots)

        # get current number of JJ and channels
        chan1 = channels[i]
        chan2 = channels[i + 1]
        card1 = cards[i]
        card2 = cards[i + 1]

        # bring current window to focus
        windows[counter].move(
            -900, 0)  # move to other desktop, spyder had been blocking before
        windows[counter].setWindowState(QtCore.Qt.WindowActive)
        windows[counter].raise_()

        # this will activate the window (yellow flashing on icon)
        windows[counter].activateWindow()

        # Sweep from 0 to 3 mA
        max_current = 3e-03
        # import pdb;pdb.set_trace()
        I, V, R, _ = rc.plot_Resistance_Array_live(app, curves[counter], card1,
                                                   card2, chan1, chan2,
                                                   max_current)
        # plot the slope and get the location it was plotted
        resistances, indicies = plot_slope_Resistor_Arrays(I, V, counter)
        print(resistances)

        # set label
        for i in range(0, len(resistances)):
            index = indicies[i]
            label = pg.TextItem(text=("Slope: " + str(resistances[i])),
                                color=(0, 0, 0),
                                fill=(255, 0, 0),
                                anchor=(-.5, -.5))
            label.setPos(I[index], V[index])
            plots[counter].addItem(label)

        # append to total data
        return_measurements_Resistance.append(resistances)

        # create name
        name = ic.create_name(chip, devices[counter])
        plots[counter].setTitle(name)

        # saving

        filename = (folder + name + "_Resistor_Array.png")
        print(filename)
        ic.create_dir(filename)

        iv.save_data_live(I, V, R, (folder + name + "_Resistor_Array_raw.dat"))

        save_resistance_data(resistances, folder + name)

        try:
            my_exporters[counter].export(filename)
        except:
            print("oh noooo, wrapped object was deleted\n")

        counter += 1

    return return_measurements_Resistance
Exemple #9
0
def get_Resistance_Via(folder, chip, devices):
    '''
    Sweeps from 0 to 3mA and returns the slope
    
    :param folder: folder name of where data will be saved
        
    :param chip: Target chip
    
    :param devices: Array of target devices
   
    :return:   return_measurements: I,V,R arrays
    
    Called By:
        
        Measurement_Functions
            
            -measure pcm cold and warm
   
    Calls On:
        
        -plot_Resistance_Array_live
        
        -save_data_live
        
        -save_Resistance_data_Via
    '''
    # globals- necesarry to avoid automatic deletion of objects
    global app
    global windows, plots, curves, my_exporters
    # get variables
    inputs = inpfunc.format_input_resistance(devices)
    cards = inputs[0]
    channels = inputs[1]

    # create instance of the app
    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication(sys.argv)
    else:
        pass

    # detect the number of plots need based on the cards, since there is a 1:1 ratio
    # between devices and cards (%use devices?)
    num_plots = len(cards)
    print("num plots: %d" % num_plots)

    # initialize by opening correct number of windows
    # each window contains a plot, each plot a curve and they are all stored in arrays
    curves = initialization(num_plots)

    # we need two indexes, one for pairs, one for normal
    index_pairs = 0
    index = 0

    my_exporters = []  # array to hold exporters

    # create exporters
    for i in range(0, num_plots):
        exporter = exporters.ImageExporter(plots[i].scene())
        my_exporters.append(exporter)

    return_measurements = []
    # take all the sweeps
    for i in range(0, num_plots):
        print("Begin Device %s sweep" % (i))
        # get two channels and two current limits that are needed
        my_channels = []
        my_channels.append(channels[index_pairs])
        my_channels.append(channels[index_pairs + 1])

        name = ic.create_name(chip, devices[i])  # create the name
        plots[i].setTitle(name)  # set title to name

        # bring current window to focus
        windows[i].move(
            -900, 0)  # move to other desktop, spyder had been blocking before
        windows[i].setWindowState(QtCore.Qt.WindowActive)
        windows[i].raise_()

        # this will activate the window (yellow flashing on icon)
        windows[i].activateWindow()

        # sweep the current device
        max_current = .6e-03

        I, V, R = rc.plot_Resistance_Array_live(app, curves[i], cards[i],
                                                my_channels[0], my_channels[1],
                                                max_current)

        # find the slope
        slope = (V[-1] - V[0]) / (I[-1] - I[0])

        # Plotting Critical Currents #

        # arrays that will be returned
        return_measurements.append(slope)

        # setting labels
        label = pg.TextItem(text="",
                            color=(0, 0, 0),
                            fill=(255, 0, 0),
                            anchor=(0, -1))

        # label text
        label_text = ("Resistance: %s" % slope)
        label.setText(label_text)
        label.setPos(I[int(len(I) / 2)], V[int(len(V) / 2)])
        graph = plots[i]
        graph.addItem(label)

        # add red line to represent slope
        new_curve = plots[i].plot()
        new_curve.setData([I[0], I[-1]], [V[0], V[-1]],
                          symbol='o',
                          symbolBrush='r',
                          pen='r',
                          symbolSize=10)

        #Saving
        filename = (folder + name + "_Via.png")
        print(filename)
        ic.create_dir(filename)  # function to create dir if doesn't exist

        iv.save_data_live(
            I, V, R, (folder + name + "_Via_Raw.dat"))  # save the raw data
        save_Resistance_data_Via(slope,
                                 (folder + name))  # save the important data

        try:
            my_exporters[i].export(filename)  # export the graph
        except:
            print("Oh no wrapped object was deleted!!!!!")

        # repeat
        index = index + 1
        index_pairs = index_pairs + 2

        app.processEvents()
        print("End Device %s sweep\n" % (i))

    return return_measurements