-
Notifications
You must be signed in to change notification settings - Fork 0
/
Conductance Measurement.py
106 lines (91 loc) · 4.04 KB
/
Conductance Measurement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
"""
Created on Tue May 15 16:39:11 2012
@author: Bram
"""
# Use this command to compile interface pyuic4 -x plotter.ui -o plotter.py
import sys
import matplotlib
import measurement
import time
import threading
from pylab import *
from plotter import Ui_MainWindow
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtNetwork import *
from PyQt4 import QtCore
class MyForm(QMainWindow,Ui_MainWindow):
def __init__(self, parent=None):
#build parent user interface
QMainWindow.__init__(self, parent)
self.setupUi(self)
self.connect(self.goButton, SIGNAL('clicked()'),self.go)
self.connect(self.quit, SIGNAL('clicked()'),self.closeProgram)
def go(self):
print "Starting Measurement..."
threading.Thread(target=self.do_start, name="_gen_").start()
def do_start(self):
delay = self.delay.value()
max_gate = self.maxGate.value()
stepsize = self.stepSize.value()
gate_voltage = 0
windowlower = self.windowlower.value()
windowupper = self.windowupper.value()
windowstep = self.windowstep.value()
ax = self.mplwidget.figure.add_subplot(111)
print "Window %f to %f" % (windowlower, windowupper)
print "Step Size: %f" % stepsize
out_file = open ('test.txt', 'w')
print 'Gate\t Conductance\t X-Value\t Temperature\t Time'
out_file.write('Gate\t Conductance\t X-Value\t Temperature\t Time \n')
x = []
y = []
# Sweep Up Gate
while gate_voltage > max_gate:
measurement.setNextGate(gate_voltage)
time.sleep(delay)
data = measurement.read(gate_voltage)
x.append(gate_voltage)
y.append(data[1])
print "%f \t %f \t %r \t %f \t %f" % (data[0], data[1], data[2], data[3], data[4])
out_file.write("%f \t %f \t %r \t %f \t %f \n" % (data[0], data[1], data[2], data[3],data[4]))
self.mplwidget.axes.plot(x,y)
self.gate_display.display(gate_voltage)
self.conductance.display(data[1])
self.time.display(data[4])
self.temp.display(data[3])
self.mplwidget.draw()
self.show()
if (gate_voltage <= windowlower and gate_voltage >= windowupper):
gate_voltage = gate_voltage - windowstep
else:
gate_voltage = gate_voltage - stepsize
## Sweep Down Gate
while gate_voltage <= 0:
measurement.setNextGate(gate_voltage)
time.sleep(delay)
data = measurement.read(gate_voltage)
x.append(gate_voltage)
y.append(data[1])
print "%f \t %f \t %r \t %f \t %f" % (data[0], data[1], data[2], data[3], data[4])
out_file.write("%f \t %f \t %r \t %f \t %f \n" % (data[0], data[1], data[2], data[3],data[4]))
self.mplwidget.axes.plot(x,y)
self.gate_display.display(gate_voltage)
self.conductance.display(data[1])
self.time.display(data[4])
self.temp.display(data[3])
self.mplwidget.draw()
self.show()
if (gate_voltage <= windowlower and gate_voltage >= windowupper):
gate_voltage = gate_voltage + windowstep
else:
gate_voltage = gate_voltage + stepsize
def closeProgram(self):
qApp.exit(0)
if __name__ == "__main__":
#This function means this was run directly, not called from another python file.
app = QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())