inprints script improved
This commit is contained in:
@ -7,7 +7,6 @@ import numpy as np
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import epics
|
import epics
|
||||||
|
|
||||||
|
|
||||||
from slic.devices.xoptics.aramis_attenuator import Attenuator
|
from slic.devices.xoptics.aramis_attenuator import Attenuator
|
||||||
attenuator = Attenuator("SAROP31-OATA150", description="Cristallina attenuator OATA150")
|
attenuator = Attenuator("SAROP31-OATA150", description="Cristallina attenuator OATA150")
|
||||||
|
|
||||||
@ -27,18 +26,22 @@ testing_flag = True
|
|||||||
pos = np.array([0,0])
|
pos = np.array([0,0])
|
||||||
|
|
||||||
# parameters
|
# parameters
|
||||||
n_same_holes = 3
|
n_same_holes = 7
|
||||||
attenuations = np.logspace(0,-3,num=4)
|
attenuations = np.logspace(0,-6,num=7)
|
||||||
KBv_home = [1.5,1.7]
|
KBv_home = [1.5,1.7]
|
||||||
KBh_home = [1.6,1.8]
|
KBh_home = [1.6,1.8]
|
||||||
|
|
||||||
# Spacings
|
# Spacings
|
||||||
between_same_shots = 50
|
between_same_shots = 100
|
||||||
between_attenuations = 60
|
between_attenuations = 150
|
||||||
between_KB_settings = 200
|
between_KB_settings = 500
|
||||||
KBvs =[[1,2],[1,3]]
|
KBvs = [[1,2],[1,3],[1,2],[1,3],[1,2]]
|
||||||
KBhs = [[1,2],[1,2]]
|
KBhs = [[1,2],[1,2],[1,2],[1,3],[1,2]]
|
||||||
|
|
||||||
|
# Time estimates for total time calculation
|
||||||
|
t_kb_change = 30
|
||||||
|
t_shot = 5
|
||||||
|
t_atten_change = 20
|
||||||
|
|
||||||
def shoot(pos=pos,testing=testing_flag):
|
def shoot(pos=pos,testing=testing_flag):
|
||||||
if testing:
|
if testing:
|
||||||
@ -52,7 +55,6 @@ def change_benders(bender_1,bender_2,KB = None,do_not_move_benders = do_not_move
|
|||||||
check_KB_value(KB)
|
check_KB_value(KB)
|
||||||
|
|
||||||
current_values = get_bender_values(KB)
|
current_values = get_bender_values(KB)
|
||||||
|
|
||||||
if current_values[0] > bender_1 or current_values[1] > bender_2:
|
if current_values[0] > bender_1 or current_values[1] > bender_2:
|
||||||
print('Unbending first because of backlash')
|
print('Unbending first because of backlash')
|
||||||
if do_not_move_benders != True:
|
if do_not_move_benders != True:
|
||||||
@ -98,17 +100,40 @@ def get_bender_values(KB=None):
|
|||||||
|
|
||||||
def move_x_rel(distance,testing=testing_flag,pos=pos):
|
def move_x_rel(distance,testing=testing_flag,pos=pos):
|
||||||
if testing == True:
|
if testing == True:
|
||||||
pos = pos + [distance,0]
|
pos = pos + np.array([distance,0])
|
||||||
return pos
|
return pos
|
||||||
else:
|
else:
|
||||||
attocube.X.set_target_value(distance, relative=True)
|
attocube.X.set_target_value(distance, relative=True).wait()
|
||||||
|
|
||||||
def move_y_rel(distance,testing=testing_flag,pos=pos):
|
def move_y_rel(distance,testing=testing_flag,pos=pos):
|
||||||
if testing == True:
|
if testing == True:
|
||||||
pos = pos + [0,distance]
|
pos = pos + np.array([0,distance])
|
||||||
return pos
|
return pos
|
||||||
else:
|
else:
|
||||||
attocube.Y.set_target_value(distance, relative=True)
|
attocube.Y.set_target_value(distance, relative=True).wait()
|
||||||
|
|
||||||
|
def move_x(value,testing=testing_flag,pos=pos):
|
||||||
|
if testing == True:
|
||||||
|
pos[0]=value
|
||||||
|
return pos
|
||||||
|
else:
|
||||||
|
attocube.X.set_target_value(value, relative=False).wait()
|
||||||
|
|
||||||
|
def move_y(value,testing=testing_flag,pos=pos):
|
||||||
|
if testing == True:
|
||||||
|
pos[1]=value
|
||||||
|
return pos
|
||||||
|
else:
|
||||||
|
attocube.Y.set_target_value(value, relative=False).wait()
|
||||||
|
|
||||||
|
|
||||||
|
def move(target_pos,testing=True,pos=pos):
|
||||||
|
if testing == True:
|
||||||
|
pos = target_pos
|
||||||
|
return pos
|
||||||
|
else:
|
||||||
|
attocube.X.set_target_value(target_pos[0]).wait()
|
||||||
|
attocube.Y.set_target_value(target_pos[1]).wait()
|
||||||
|
|
||||||
|
|
||||||
def make_attenuations(attenuations,testing=testing_flag,pos=pos):
|
def make_attenuations(attenuations,testing=testing_flag,pos=pos):
|
||||||
@ -145,47 +170,48 @@ def make_same_shots(n_same_holes,testing=testing_flag,pos=pos):
|
|||||||
pos = move_x_rel(between_same_shots,pos=pos)
|
pos = move_x_rel(between_same_shots,pos=pos)
|
||||||
|
|
||||||
# Return back to where you started
|
# Return back to where you started
|
||||||
if testing == True:
|
move(original_position)
|
||||||
pos = original_position
|
|
||||||
else:
|
|
||||||
attocube.X.set_target_value(original_position, relative=False)
|
|
||||||
return pos
|
|
||||||
|
|
||||||
|
|
||||||
|
# Estimate total time
|
||||||
|
total_time = len(KBhs)*len(KBvs)*(t_kb_change+len(attenuations)*(t_atten_change+n_same_holes*t_shot) )
|
||||||
|
|
||||||
# Get the starting x-position
|
# Get the starting x-position
|
||||||
if testing == True:
|
if testing_flag == True:
|
||||||
starting_x_pos = pos
|
starting_x_pos = pos[0]
|
||||||
else:
|
else:
|
||||||
starting_x_pos = attocube.X.get_current_value()
|
starting_x_pos = attocube.X.get_current_value()
|
||||||
|
|
||||||
|
# The actual loop to make inprints
|
||||||
for KBv in KBvs:
|
for i,KBv in enumerate(KBvs):
|
||||||
change_benders(KBv[0],KBv[1],KB = 'v')
|
change_benders(KBv[0],KBv[1],KB = 'v')
|
||||||
|
|
||||||
for KBh in KBhs:
|
for ind,KBh in enumerate(KBhs):
|
||||||
change_benders(KBh[0],KBh[1],KB = 'h')
|
change_benders(KBh[0],KBh[1],KB = 'h')
|
||||||
|
|
||||||
|
print(f'Progress so far: KBv loop: {i+1}/{len(KBvs)}. KBh loop:{ind+1}/{len(KBhs)}')
|
||||||
make_attenuations(attenuations,pos=pos)
|
make_attenuations(attenuations,pos=pos)
|
||||||
|
|
||||||
print('Moving to a new KBh setting')
|
print(f'Moving to a new KBh setting')
|
||||||
# Move to the last shot of the same shot + the spacing between KB settings
|
# Move to the last shot of the same shot + the spacing between KB settings
|
||||||
pos = move_x_rel(between_KB_settings+between_same_shots*n_same_holes,pos=pos)
|
pos = move_x_rel(between_KB_settings+between_same_shots*(n_same_holes-1),pos=pos)
|
||||||
|
|
||||||
|
print('KBh set done, returning to starting_x_pos')
|
||||||
|
|
||||||
print('Moving to a new KBh setting')
|
|
||||||
# Move to the last shot of the same shot + the spacing between KB settings
|
# Move to the last shot of the same shot + the spacing between KB settings
|
||||||
pos = move_x_rel(between_KB_settings+between_same_shots*n_same_holes,pos=pos)
|
|
||||||
|
|
||||||
|
pos = move_x(starting_x_pos,pos=pos)
|
||||||
|
|
||||||
|
print('#################################################################################')
|
||||||
print('Moving to a new KBv setting')
|
print('Moving to a new KBv setting')
|
||||||
# Move to the last shot of the same shot + the spacing between KB settings
|
# Move to the last shot of the same shot + the spacing between KB settings
|
||||||
pos = move_y_rel(between_KB_settings+between_attenuations*len(attenuations),pos=pos)
|
|
||||||
|
|
||||||
|
pos = move_y_rel(between_KB_settings+between_attenuations*(len(attenuations)-1),pos=pos)
|
||||||
|
|
||||||
|
|
||||||
|
print('Inprints are done')
|
||||||
|
print(f'Total time estimate: {(total_time/60):.1f} minutes or {(total_time/60/60):.1f} hours')
|
||||||
|
|
||||||
# To do:
|
# To do:
|
||||||
# Fix movement of the attocubes in real time
|
# Fix movement of the attocubes in real time
|
||||||
# Load lut files into the controller and check that x is x and y is y
|
# Load lut files into the controller and check that x is x and y is y
|
||||||
# Finish movement in the final loop
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user