def get_data_direct(Chip, Device): import numpy as np from urllib.request import urlopen import database_v4 as d path = "C:/Users/sdk/Downloads/" path = "E:/Users/volt.686QVACTEST/National Institute of Standards and Technology (NIST)/SEG - SFQ_Circuits/" directories = d.get_data_directory(Chip) rn_locations = [] raw_locations = [] if directories == -1: return -1 print(directories) for directory in directories: path = "http://132.163.82.9:3000/" d_location = find_D(directory, Chip) if (d_location == -1): return -1 path = path + directory[d_location:] device = d.find_device(Device, output=0) if (device == -1): return -1 size = device.JJ_radius_nom chip_info_name = Chip + "_" + Device + "_" + (str)(size) raw_data_filename = path + "/RawData_Rn/" + chip_info_name + "_Rn_raw.dat" rn_filename = path + "/Rn_values/" + chip_info_name + "_Rn.dat" rn_locations.append(rn_filename) raw_locations.append(raw_data_filename) for i, raw in enumerate(raw_locations): print(raw) try: raw_file = urlopen(raw, timeout=5) Rn_file = urlopen(rn_locations[i], timeout=5) worked_raw = raw except: pass try: I, V, R = np.loadtxt(raw_file, unpack=True) Ic, Vc = np.loadtxt(Rn_file) except: print("Problem reading file!") return -1 return I, V, worked_raw
def get_cards(device): ''' :return: Card that the device is using ''' if type(device) == str: device = d.find_device(device) card1 = device.card1 card2 = device.card2 return [card1, card2]
def get_channels(device): ''' :return: [chan1, chan2] array ''' if type(device) == str: device = d.find_device(device) channels = [] chan1 = device.channel1 channels.append(chan1) chan2 = device.channel2 channels.append(chan2) return channels
def deviceselectionchange(self): current = self.Device.currentText() if current != 'Device': device = d.find_device(current) Input = inpfunc.format_input_Ic_Ir_devices([device], self.Jc) # print(input) cards = Input[0] channels = Input[1] chan1 = channels[0] chan2 = channels[1] sweeps = Input[2] Imin = sweeps[0] # Imin = "%0.2E" % Imin Imax = sweeps[1] # Imax = "%0.2E" % Imax step = Input[3] step = (float)("%0.2E" % step[0]) # step = step[0] num_sweep = Input[4] self.channel1_EditField.setCurrentIndex(chan1 - 1) self.channel2_EditField.setCurrentIndex(chan2 - 1) if self.mA_button.isChecked(): multplier = 1000 else: multplier = 1 print(cards) if not self.lockbutton.isChecked(): self.I_min_EditField.setText(str(Imin * multplier)) self.I_max_EditField.setText(str(Imax * multplier)) self.step_EditField.setText(str(step * multplier)) self.card_EditField.setText(str(cards[0])) self.card2_EditField.setText(str(cards[1])) self.step_helper.setCurrentIndex(0) # print("ok") self.sweep_EditField.setText(str(num_sweep[0]))
def plotter(self): # Clear graph try: self.my_graph1.plot.clear() except: pass # Get inputs inputs = self.getInput() # Format: [I_min, I_max, step, card, card2, channel1, channel2, sweep] # -1 if all are numbers, gives location of error otherwise wrong_box = self.checkValues(inputs) # units if self.mA_button.isChecked(): multiplier = 1e-03 else: multiplier = 1 # Plotting: if wrong_box == -1: # converting from strings to int or float #for i in range(len(inputs)): # try: # inputs[i] = int(inputs[i]) # except: # inputs[i] = float(inputs[i]) # print(variables) # for test purposes if "Increment" in self.step_helper.currentText(): number = False else: number = True inputs[2] = iv.calc_steps(inputs[0], inputs[1], inputs[2], number) # print(inputs[2]) title_text = "I-V Curve for %s_%s" % (self.Chip.currentText(), self.Device.currentText()) g = self.my_graph1 plot = g.plot g.plot.setTitle(title_text) self.data = [0] curves = [] for i in range(0, inputs[6]): self.curve = g.plot.getPlotItem().plot() curves.append(self.curve) # print("here") # print(inputs) # iv.plot_IV_test(app,curves,inputs[6],inputs[0],inputs[1],inputs[2],inputs[3],inputs[4],inputs[5]) # print("here1") # order of inputs: app, curve, num_sweeps, min, max, step, card, chan1, chan2 # print(float(self.step_EditField.text())) # Format: [I_min, I_max, step, card, card2, channel1, channel2, sweep] I_min = inputs[0] * multiplier I_max = inputs[1] * multiplier step = inputs[2] * multiplier card1 = inputs[3] card2 = inputs[4] channel1 = inputs[5] channel2 = inputs[6] sweep = inputs[7] chip = d.find_chip(self.Chip.currentText()) device = d.find_device(self.Device.currentText()) iv.sweep_current_live_GUI(app, plot, curves, sweep, I_min, I_max, step, card1, card2, channel1, channel2, self.Save, chip, device) # Format: (app, curves, number_of_sweeps, I_min, I_max, step, card1, card2, channel1, channel2) # self.timer = QtCore.QTimer() # self.timer.timeout.connect(self.update) # self.timer.start(0) else: warning_box = QtWidgets.QMessageBox() if (wrong_box == 0): warning_box.setText("Increment is too big.") else: warning_box.setText( self.whichBox(wrong_box) + " needs to be a number.") warning_box.exec_()
def plot_IV_from_GUI(app, plot, Chip, Device): """ Plots an Raw IV curve for a single device :param app: pyqtgraph construct :param plot: pyqtgraph constuct :param Chip: Target Chip :param Device: Target Device :Graphs: Voltage on y axis and Current on x axis Called By: -Measurement_GUI_V3-Plot Calls on: -Database V4 -Show_devices_from_chip -show_measurements_from_device """ import numpy as np from urllib.request import urlopen import database_v4 as d import pyqtgraph as pg path = "C:/Users/sdk/Downloads/" path = "E:/Users/volt.686QVACTEST/National Institute of Standards and Technology (NIST)/SEG - SFQ_Circuits/" directories = d.get_data_directory(Chip) ic_locatoins = [] raw_locations = [] if directories == -1: return -1 for directory in directories: path = "http://132.163.82.9:3000/" d_location = find_D(directory, Chip) if (d_location == -1): return -1 path = path + directory[d_location:] chip = d.find_chip(Chip) device = d.find_device(Device, output=0, optional_designid=chip.design_id) if (device == -1): return -1 size = device.JJ_radius_nom chip_info_name = Chip + "_" + Device + "_" + (str)(size) raw_data_filename = path + "/RawData/" + chip_info_name + "_Ic_raw.dat" ic_filename = path + "/Ic_values/" + chip_info_name + "_Ic.dat" ic_locatoins.append(ic_filename) raw_locations.append(raw_data_filename) for i, raw in enumerate(raw_locations): try: raw_file = urlopen(raw, timeout=5) Ic_file = urlopen(ic_locatoins[i], timeout=5) except: pass try: I, V, R = np.loadtxt(raw_file, unpack=True) Ic, Vc = np.loadtxt(Ic_file) except: print("Problem reading file") return -1 plot.showGrid(x=True, y=True, alpha=0.3) plot.setLabel('left', 'V', 'V') plot.setLabel('bottom', 'I', 'A') plot.getAxis('bottom').setTicks(None) curve = plot.plot() curve.setData(I, V, symbol='o', symbolBrush='w', symbolSize=5) for n1 in range(0, len(Ic)): if n1 < 2: type_of_current = "I" + str(n1) label = pg.TextItem(text="", color=(0, 0, 0), fill=(0, 255, 255), anchor=(0, -1)) else: type_of_current = "I" + str(n1) label = pg.TextItem(text="", color=(0, 0, 0), fill=(0, 255, 255), anchor=(0, 2)) I_c = type_of_current + ':(' + '{:.2E}'.format( Ic[n1]) + ',' + '{:.2E}'.format(Vc[n1]) + ')' label.setText(I_c) label.setPos(Ic[n1], Vc[n1]) plot.addItem(label) new_curve = plot.plot() new_curve.setData(Ic[n1:n1 + 1], Vc[n1:n1 + 1], symbol='o', symbolBrush='c', symbolSize=10) app.processEvents()
def plot_from_GUI(app, plot, chipname, devicename, plottype="RN"): from urllib.request import urlopen import database_v4 as d4 pick = False while not pick: if plottype == "RN": directories = d.get_data_directory(chipname) filemidraw = "/RawData_Rn/" fileendraw = "_Rn_raw.dat" filemidcrit = "/Rn_values/" fileendcrit = "_Rn.dat" pick = True elif plottype == "TC": directories = d.get_data_directory(chipname, typeofdata="Crossbar") filemidraw = "/" fileendraw = "_ResistvsTemp_raw.dat" filemidcrit = "" fileendcrit = "" pick = True elif plottype == "LC": directories = d.get_data_directory(chipname, typeofdata="Squid") filemidraw = "/" fileendraw = "_Ic_raw.dat" filemidcrit = "/" fileendcrit = "_LC_step_raw.dat" #filemidcrit="" #fileendcrit="" pick = True elif plottype == "Imax": directories = d.get_data_directory(chipname, typeofdata="Via") filemidraw = "/" fileendraw = "_Via_Raw.dat" filemidcrit = "" fileendcrit = "" pick = True elif plottype == "SQRN": #SQUID Rn directories = d.get_data_directory(chipname, typeofdata="Squid") filemidraw = "/" fileendraw = "_Ic_raw.dat" filemidcrit = "" fileendcrit = "" pick = True elif plottype == "IC": directories = d.get_data_directory(chipname) filemidraw = "/RawData/" fileendraw = "_Ic_raw.dat" filemidcrit = "/Ic_values/" fileendcrit = "_Ic.dat" pick = True else: print("Hmm, not sure what to do with this") plottype = input("Enter a valid input: RN,SQRN,TC,LC,IC or Imax") return -1 if filemidcrit: raw_locations = [] crit_locations = [] else: raw_locations = [] crit_locations = int(5) if directories == -1: print("No directories found for chip %s and device %s" % (chipname, devicename)) return -1 device = d4.find_device(devicename, output=0) if (device == -1): print("No device found with name %s" % devicename) return -1 print("Directories for chip %s and device %s" % (chipname, devicename)) for i, dire in enumerate(directories): print("%d : %s" % (i, dire)) for directory in directories: path = "http://132.163.82.9:3000/" d_location = find_D(directory, chipname) if (d_location == -1): print("No matching chipname found using find_D") return -1 path = path + directory[d_location:] size = device.JJ_radius_nom chip_info_name = chipname + "_" + devicename + "_" + (str)(size) raw_filename = path + filemidraw + chip_info_name + fileendraw if " " in raw_filename: raw_filename = raw_filename.replace(" ", "_") raw_locations.append(raw_filename) if type(crit_locations) == int: pass else: crit_filename = path + filemidcrit + chip_info_name + fileendcrit crit_locations.append(crit_filename) for i, raw in enumerate(raw_locations): try: raw_file = urlopen(raw, timeout=5) print("Opened file with location %s" % raw) goodraw = raw goodcrit = crit_locations[i] except: print("Unable to open raw data url at %s" % raw) pass if type(crit_locations) == int or crit_locations == []: pass else: try: crit_file = urlopen(crit_locations[i], timeout=5) except: print("Unable to open crit data url at %s" % crit_locations[i]) pass if plottype == "RN": try: I, V, _ = np.loadtxt(raw_file, unpack=True) except: print("Problem opening raw file with successful urlopen!") return -1 try: Ic, Vc = np.loadtxt(crit_file) except: print("Problem opening crit file with successful urlopen!") pass plot.showGrid(x=True, y=True, alpha=0.3) plot.setLabel('left', 'V', 'V') plot.setLabel('bottom', 'I', 'A') curve = plot.plot() curve.setData(I, V, symbol='o', symbolBrush='w', symbolSize=5) return I, V, goodraw elif plottype == "IC": try: I, V, _ = np.loadtxt(raw_file, unpack=True) except: print("Problem opening raw file with successful urlopen!") return -1 plot.showGrid(x=True, y=True, alpha=0.3) plot.setLabel('left', 'V', 'V') plot.setLabel('bottom', 'I', 'A') curve1 = plot.plot() curve2 = plot.plot() curve1.setData(I[:int((len(I) + 1) / 2)], V[:int((len(I) + 1) / 2)], symbol='o', symbolBrush='w', symbolSize=5) curve2.setData(I[int((len(I) + 1) / 2):], V[int((len(I) + 1) / 2):], symbol='o', symbolBrush='r', symbolSize=5) return I, V, raw_file, goodcrit elif plottype == "TC": # pdb.set_trace() try: R, T = np.loadtxt(raw_file, unpack=True) except: print("Problem opening raw file with successful urlopen!") return -1 tc = d4.show_crossbar_measurements_from_device(chipname, devicename).Tc plot.showGrid(x=True, y=True, alpha=0.3) plot.setLabel('left', 'R', 'Ohms') plot.setLabel('bottom', 'T', 'K') curve = plot.plot() curve.setData(T, R, symbol='o', symbolBrush='w', symbolSize=5) return R, T, tc elif plottype == "LC": lcI = [] lcV = [] try: fullI, fullV = np.loadtxt(raw_file, unpack=True) except Exception as e: print("The issue is %s" % e) print("Problem reading file!") return -1 try: lcI, lcV = np.loadtxt(crit_file, unpack=True) critfile = True except: print("Problem opening LC step file with successful urlopen!") critfile = False pass plot.showGrid(x=True, y=True, alpha=0.3) plot.setLabel('bottom', 'I', 'Amps') plot.setLabel('left', 'V', 'Volts') curve1 = plot.plot() #Only display data in the first quadrant fullI = np.array(fullI) fullV = np.array(fullV) mask = fullI > 0 fullI = fullI[mask] fullV = fullV[mask] curve1.setData(fullI, fullV, symbol='o', symbolBrush='r', symbolSize=5) if critfile: curve2 = plot.plot() curve2.setData(lcI, lcV, symbol='o', symbolBrush='w', symbolSize=5) return fullI, fullV, lcI, lcV else: return fullI, fullV, [0], [0] ''' from pyqtgraph import exporters scene=plot.scene() exporter = exporters.ImageExporter(scene) try: exporter.export(currpng) except: print("oh noooo, wrapped object was deleted\n") ''' elif plottype == "Imax": try: I, V, R = np.loadtxt(raw_file, unpack=True) except Exception as e: print("The issue is %s" % e) print("Problem reading file!") return -1 meas = d4.show_via_measurements_from_device(chipname, devicename) Imax = meas.Imax plot.showGrid(x=True, y=True, alpha=0.3) plot.setLabel('left', 'V', 'Volts') plot.setLabel('bottom', 'I', 'Amps') curve = plot.plot() curve.setData(I, V, symbol='o', symbolBrush='w', symbolSize=5) return I, V, Imax elif plottype == "SQRN": try: I, V = np.loadtxt(raw_file, unpack=True) except: print("Problem opening raw file with successful urlopen!") return -1 plot.showGrid(x=True, y=True, alpha=0.3) plot.setLabel('left', 'V', 'V') plot.setLabel('bottom', 'I', 'A') I = np.array(I) V = np.array(V) mask = I > 0 I = I[mask] V = V[mask] curve = plot.plot() curve.setData(I, V, symbol='o', symbolBrush='w', symbolSize=5) return I, V, raw_file else: print("HMMMM, this shouldnt be possible") return -1