-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRotScanTest.py
136 lines (103 loc) · 3.55 KB
/
RotScanTest.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 28 14:30:00 2019
@author: amonl
"""
from instruments import delaystage, lockinamplifier, cryostat
import random
"""ROT SCAN"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
import time
import h5py
class Rotscan_measurements(object):
def __init__(self):
#self.lockin_amplifier = lockinamplifier.SR830()
self.rot_stage = delaystage.ThorLabs_rotational_stage()
self.cryostat = cryostat.ITC503s(COMport='COM5')
def init_instruments(self):
#self.lockin_amplifier.ser.port='COM4'
#self.lockin_amplifier.connect()
self.cryostat.connect()
## Magnet=CurrentSupplyLib.CurrentSUP()
## Magnet.initcurrentsupply()
## Magnet.SetVoltage(40)
## Magnet.SetCurrent(0)
## Magnet.SwitchForward()
self.rot_stage.connect()
time.sleep(2) # TODO: move to inside stage class
def create_points(self, N):
Points = []
step = 360 / N
for i in range(0, N):
Points.append(i * step)
return Points
@staticmethod
def save(name, X, Y):
File = h5py.File(name + time.ctime().replace(':','-') + ".h5", "w")
data = np.array([X, Y])
dset = File.create_dataset("rotscan", (len(X), 2))
dset[...] = data.T
File.close()
np.savetxt(name + time.ctime().replace(':', '-') + 'txt.txt', (X,Y))
def rotscan_measure(self, name, N_steps, save=False, time_constant=1, var='Y'):
self.init_instruments()
style.use("fivethirtyeight")
fig = plt.gcf()
fig.show()
fig.canvas.draw()
#time.sleep(3)
X = self.create_points(N_steps)
Y = []
for item in X:
X_helper = []
self.rot_stage.move_absolute(item)
##time.sleep(3*time_constant)
Y.append(random.randint(0, N_steps)) #lockin readout herte when lockin is available!!!
for i in range(len(Y)):
X_helper.append([X[i]])
#self.lockin_amplifier.disconnect()
plt.plot(X_helper, Y)
plt.pause(0.01)
fig.canvas.draw()
if save:
self.save(name, X, Y) #+'-'+str(N_steps), X, Y)
return X, Y
def finish(self):
#self.lockin_amplifier.disconnect()
self.rot_stage.disconnect()
self.cryostat.disconnect()
# %%
def main():
temperature = 295.5
save = False
N_angles = 6
meas = Rotscan_measurements()
meas.init_instruments()
#or temperature in range(297,305):
# meas.cryostat.connect()
# meas.cryostat.change_temperature(temperature)
# meas.cryostat.disconnect()
file_name = 'test'#+str(temperature)
meas.cryostat.change_temperature(temperature)
meas.cryostat.disconnect()
meas.rotscan_measure(file_name, N_angles, save)
meas.finish()
'''
T_List = [290, 305]
angle = 0
meas = Rotscan_measurements()
meas.init_instruments()
#or temperature in range(297,305):
# meas.cryostat.connect()
# meas.cryostat.change_temperature(temperature)
# meas.cryostat.disconnect()
file_name = 'test'#+str(temperature)
meas.rot_stage.move_absolute(item)
meas.temperaturescan_measure(file_name, angle, T_List)
meas.finish()
''' # move these ''' right below 'def main()'
if __name__ == '__main__':
main()