-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathandor_routines.py
More file actions
104 lines (75 loc) · 2.46 KB
/
Copy pathandor_routines.py
File metadata and controls
104 lines (75 loc) · 2.46 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
93
94
95
96
97
98
99
100
101
102
103
104
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(andor):
'''
Initializes the camera and sets the acquisition mode to single scan.
Parameters:
- andor: andor camera instance
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(andor, target_temperature=-10):
'''
Activates the camera cooling system and sets the target temperature.
Parameters:
- andor: andor camera instance
- 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(andor, fan_mode_high=False):
'''
Deactivates the camera cooling system.
Parameters:
- andor: andor camera instance
- 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(andor, dim, exposure_time=0.1):
'''
Acquires an image with the given dimensions and exposure time.
Parameters:
- andor: andor camera instance
- dim: tuple of the image dimensions
- exposure_time: how long to expose for (sec)
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(andor, dim):
'''
Acquires a bias image.
Parameters:
- andor: andor camera instance
- 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