-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathandor_routines.py
102 lines (73 loc) · 2.32 KB
/
andor_routines.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
from evora.debug import DEBUGGING
if DEBUGGING:
from evora.dummy import Dummy as andor
else:
import evora.andor as andor
import time
# biases: Readout noise from camera (effectively 0 s exposure)
# flats: take an image with even lighting (i.e. the white paint of the dome)
# darks: image while shutter closed
def startup():
'''
Initializes the camera and sets the acquisition mode to single scan.
Returns:
- dimensions: tuple of the image dimensions
'''
# implement with config values
andor.initialize()
andor.setAcquisitionMode(1)
andor.setExposureTime(0.1)
image_dimensions = andor.getDetector()["dimensions"]
andor.setShutter(1, 0, 50, 50)
andor.setImage(1, 1, 1, image_dimensions[0], 1, image_dimensions[1])
return {"dimensions": image_dimensions, "status": 20002}
def activateCooling(target_temperature=-10):
'''
Activates the camera cooling system and sets the target temperature.
Parameters:
- target_temperature: the desired temperature of the camera sensor
Returns:
- 20002: success
'''
# andor.setFanMode(2)
andor.coolerOn()
andor.setTargetTEC(target_temperature)
return 20002
def deactivateCooling(fan_mode_high=False):
'''
Deactivates the camera cooling system.
Parameters:
- fan_mode_high: whether the fan mode should be set to high
Returns:
- 20002: success
'''
andor.coolerOff()
# andor.setFanMode(0 if fan_mode_high else 1)
return 20002
def acquisition(dim, exposure_time=0.1):
'''
Acquires an image with the given dimensions and exposure time.
Parameters:
- dim: tuple of the image dimensions
Returns:
- data: the acquired image data
'''
andor.setExposureTime(exposure_time)
andor.startAcquisition()
time.sleep(exposure_time + 0.5)
# while (camera_status == 20072):
# camera_status = andor.getStatus()
return {"data": andor.getAcquiredData(dim)["data"], "status": 20002}
def acquireBias(dim):
'''
Acquires a bias image.
Parameters:
- dim: tuple of the image dimensions
Returns:
- image: the acquired bias image
'''
andor.setShutter(1, 2, 50, 50)
andor.setImage(1, 1, 1, dim[0], 1, dim[1])
image = acquisition(dim, exposure_time=0.0)
andor.setShutter(1, 0, 50, 50)
return image