Menu

[r239]: / duallia.py  Maximize  Restore  History

Download this file

94 lines (73 with data), 3.0 kB

 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Measurement over one stage with two Lock-In amplifiers.
by Markus Haehnel
"""
# Copyright 2014 <>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
from thzshaker import device
import numpy as np
import time, os
##### Configuration ######
filedirectory = "C:/THz-Shaker/"
filename = "duallia.thz"
# Lock-In 1 - fast one
lia1module = device.lockinamp.stanfordresearch830
lia1pref = { # Default values can be deleted
"wait" : True,
"resource" : "GPIB0::8::INSTR",
}
# Lock-In 2 - slow one
lia2module = device.lockinamp.stanfordresearch830
lia2pref = { # Default values can be deleted
"wait" : False,
"resource" : "GPIB0::12::INSTR",
}
# Stage
stagepref = { # Default values can be deleted
"start" : 7.45*10**(-3), # [m]
"stop" : 7.52*10**(-3), # [m]
"step" : 0.005*10**(-3), # [m]
"resource" : "COM1",
"stage" : 1,
"speed" : 0.005*10**(-3), # [m/s]
"unit" : 1000.00, # meter*unit = [stage unit]
"model" : "Newport, Motion Controller, Model ESP301-3N",
}
def main():
lia1 = lia1module.api(lia1module.preferences(**lia1pref))
lia2 = lia2module.api(lia2module.preferences(**lia2pref))
stage = device.stage.stage(device.stage.preferences(**stagepref))
position, values1, values2 = [], [], []
for pos in stage:
position.append(pos)
tmp = [] # avarage multiple points from lia1
tc2 = lia2.get_timeconstant()
t0 = time.time()
while time.time() - t0 <= tc2:
tmp.append(lia1.measure(wait=True))
values1.append(np.mean(tmp))
values2.append(lia2.measure(wait=False))
arr = np.zeros((len(position), 5))
arr[:, 0] = position
arr[:, 1], arr[:, 2] = np.real(values1), np.imag(values1)
arr[:, 3], arr[:, 4] = np.real(values2), np.imag(values2)
np.savetxt(os.path.join(filedirectory, filename), arr)
# preferences can be also exported as string over 'str(stagepref)'
if __name__ == "__main__":
main()