-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibrate_zero_angle.py
58 lines (40 loc) · 1.58 KB
/
calibrate_zero_angle.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
'''
Go to the center of the grid
'''
from autoscript_sdb_microscope_client import SdbMicroscopeClient
from autoscript_sdb_microscope_client.enumerations import *
from autoscript_sdb_microscope_client.structures import *
import numpy as np
# Connect to microscope
quattro = SdbMicroscopeClient()
quattro.connect('localhost') # local connection (Support PC) or offline scripting
from smaract_folder import connexion_smaract_64bits as sm
smaract = sm.smaract_class(calibrate=False)
# Save the current position as the center of the grid
position_zero = quattro.specimen.stage.current_position
zoom_zero = quattro.beams.electron_beam.horizontal_field_width.value
# Go to the upper side of the grid
quattro.specimen.stage.relative_move(StagePosition(y=150e-6))
# Zoom in
quattro.beams.electron_beam.horizontal_field_width.value = 200e-6
# Autofocus
quattro.auto_functions.run_auto_focus()
# Save the value of focus
focus_1 = quattro.beams.electron_beam.working_distance.value
# Go to the lower side of the grid
quattro.specimen.stage.relative_move(StagePosition(y=-2*150e-6))
# Autofocus
quattro.auto_functions.run_auto_focus()
# Save the value of focus
focus_2 = quattro.beams.electron_beam.working_distance.value
# Go to the center
quattro.specimen.stage.absolute_move(position_zero)
# Go to the initial zoom level
quattro.beams.electron_beam.horizontal_field_width.value = zoom_zero
# Calculate the value of angle
angle = np.arctan(focus_1/focus_2)
# Correct the angle
zede, igrec, _ = smaract.getpos()
smaract.setpos_abs([zede, igrec, angle])
# Zero angle on Smaract device
smaract.set_zero_position(2)