large cleanup, part 1
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
from time import sleep, time
|
||||
from cristallina import cta, daq
|
||||
|
||||
|
||||
def make_pulse_train():
|
||||
recording = daq.acquire('pulsing_sequence',n_pulses=100*101,wait=False)
|
||||
recording = daq.acquire("pulsing_sequence", n_pulses=100 * 101, wait=False)
|
||||
cta.start()
|
||||
recording.wait()
|
||||
print('done')
|
||||
print("done")
|
||||
|
||||
#daq.acquire(filename, data_base_dir=None, detectors=None, channels=None, pvs=None, scan_info=None, n_pulses=100, continuous=False, is_scan_step=False, wait=True):
|
||||
|
||||
# daq.acquire(filename, data_base_dir=None, detectors=None, channels=None, pvs=None, scan_info=None, n_pulses=100, continuous=False, is_scan_step=False, wait=True):
|
||||
|
@ -3,9 +3,10 @@ from time import sleep, time
|
||||
from tracemalloc import start
|
||||
import numpy as np
|
||||
from collections import defaultdict
|
||||
#from epics import PV
|
||||
#from slic.utils import nice_arange
|
||||
#from slic.devices.general.motor import Motor
|
||||
|
||||
# from epics import PV
|
||||
# from slic.utils import nice_arange
|
||||
# from slic.devices.general.motor import Motor
|
||||
import matplotlib.pyplot as plt
|
||||
import epics
|
||||
from cristallina import Newport_large, attocube, attenuator
|
||||
@ -15,80 +16,81 @@ from tqdm import tqdm
|
||||
from standa import standa
|
||||
|
||||
from slic.devices.timing.events import CTASequencer
|
||||
|
||||
cta = CTASequencer("SAR-CCTA-ESC")
|
||||
|
||||
# setup logging
|
||||
# setup logging
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("slic.hole_drilling")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
#formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(message)s',
|
||||
# formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(message)s',
|
||||
# datefmt='%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# create file handler which logs
|
||||
try:
|
||||
fh = logging.FileHandler('/sf/cristallina/applications/slic/cristallina/log/hole_drilling.log')
|
||||
try:
|
||||
fh = logging.FileHandler("/sf/cristallina/applications/slic/cristallina/log/hole_drilling.log")
|
||||
fh.setLevel(logging.DEBUG)
|
||||
#fh.setFormatter(formatter)
|
||||
# fh.setFormatter(formatter)
|
||||
logger.addHandler(fh)
|
||||
except PermissionError as e:
|
||||
logger.warning("Cannot write log file.")
|
||||
logger.warning(e)
|
||||
|
||||
|
||||
|
||||
attenuator = Attenuator("SAROP31-OATA150", description="Cristallina attenuator OATA150")
|
||||
|
||||
from slic.devices.xoptics.kb import KBHor,KBVer
|
||||
kbHor = KBHor(
|
||||
"SAROP31-OKBH154",
|
||||
description="Cristallina horizontal KB mirror"
|
||||
)
|
||||
from slic.devices.xoptics.kb import KBHor, KBVer
|
||||
|
||||
kbVer = KBVer(
|
||||
"SAROP31-OKBV153",
|
||||
description="Cristallina vertical KB mirror"
|
||||
)
|
||||
kbHor = KBHor("SAROP31-OKBH154", description="Cristallina horizontal KB mirror")
|
||||
|
||||
kbVer = KBVer("SAROP31-OKBV153", description="Cristallina vertical KB mirror")
|
||||
|
||||
do_not_move_benders = True
|
||||
testing_flag = False
|
||||
pos = np.array([0,0])
|
||||
pos = np.array([0, 0])
|
||||
|
||||
# parameters
|
||||
n_same_holes = 3
|
||||
attenuations = np.linspace(0.15,0.35,9)#np.linspace(0.1,0.35,11)#np.linspace(0.1,0.35,6)#np.logspace(-3,0,num=7)
|
||||
KBv_home = [1.3 , 1.6]
|
||||
KBh_home = [1.4 , 1.7]
|
||||
attenuations = np.linspace(0.15, 0.35, 9) # np.linspace(0.1,0.35,11)#np.linspace(0.1,0.35,6)#np.logspace(-3,0,num=7)
|
||||
KBv_home = [1.3, 1.6]
|
||||
KBh_home = [1.4, 1.7]
|
||||
|
||||
# Spacings
|
||||
between_same_shots = 150
|
||||
between_attenuations = 150
|
||||
between_KB_settings = 500#500
|
||||
between_KB_settings = 500 # 500
|
||||
|
||||
|
||||
### 23.02
|
||||
def kb_settings_list(best,step,no_steps):
|
||||
def kb_settings_list(best, step, no_steps):
|
||||
for i in range(no_steps):
|
||||
if i == 0:
|
||||
l=[]
|
||||
l.append([best[0]+i*step,best[1]])
|
||||
l = []
|
||||
l.append([best[0] + i * step, best[1]])
|
||||
for i in range(no_steps):
|
||||
if i == 0:
|
||||
pass
|
||||
l.append([best[0],best[1]+i*step])
|
||||
return l
|
||||
l.append([best[0], best[1] + i * step])
|
||||
return l
|
||||
|
||||
|
||||
KBvs = kb_settings_list([1.595, 1.874], 0.05, 3)
|
||||
KBhs = kb_settings_list([1.799000, 2.100000], 0.05, 3)
|
||||
|
||||
KBvs = kb_settings_list([1.595,1.874],0.05,3)
|
||||
KBhs = kb_settings_list([1.799000,2.100000],0.05,3)
|
||||
|
||||
### 24.02
|
||||
def kb_settings_list_new(best,step,no_steps_one_way):
|
||||
l=[]
|
||||
first = np.array(best) - np.array([step*no_steps_one_way,step*no_steps_one_way])
|
||||
for i in range(no_steps_one_way*2+1):
|
||||
l.append([first[0]+i*step,first[1]+i*step])
|
||||
return l
|
||||
KBvs = kb_settings_list_new([1.595,1.874],0.0075,3)
|
||||
KBhs = kb_settings_list_new([1.799000,2.100000],0.0075,3)
|
||||
def kb_settings_list_new(best, step, no_steps_one_way):
|
||||
l = []
|
||||
first = np.array(best) - np.array([step * no_steps_one_way, step * no_steps_one_way])
|
||||
for i in range(no_steps_one_way * 2 + 1):
|
||||
l.append([first[0] + i * step, first[1] + i * step])
|
||||
return l
|
||||
|
||||
|
||||
KBvs = kb_settings_list_new([1.595, 1.874], 0.0075, 3)
|
||||
KBhs = kb_settings_list_new([1.799000, 2.100000], 0.0075, 3)
|
||||
|
||||
|
||||
# Time estimates for total time calculation (time in seconds)
|
||||
@ -100,9 +102,10 @@ t_atten_change = 10
|
||||
smaract_stage = True
|
||||
# Change to mm from um if smaract stage selected
|
||||
if smaract_stage:
|
||||
between_same_shots = between_same_shots/1000
|
||||
between_attenuations = between_attenuations/1000
|
||||
between_KB_settings = between_KB_settings/1000
|
||||
between_same_shots = between_same_shots / 1000
|
||||
between_attenuations = between_attenuations / 1000
|
||||
between_KB_settings = between_KB_settings / 1000
|
||||
|
||||
|
||||
def shoot(n_shots=1):
|
||||
epics.caput("SAR-CCTA-ESC:seq0Ctrl-Cycles-I", n_shots)
|
||||
@ -113,6 +116,7 @@ def shoot(n_shots=1):
|
||||
def move_x_rel(distance):
|
||||
standa.x.mvr(distance)
|
||||
|
||||
|
||||
def move_y_rel(distance):
|
||||
standa.z.mvr(distance)
|
||||
|
||||
@ -121,64 +125,70 @@ def move_absolute(x, y):
|
||||
standa.x.mv(x).wait()
|
||||
standa.z.mv(y).wait()
|
||||
|
||||
def make_holes(quantity,spacing=0.25,wait=1):
|
||||
|
||||
def make_holes(quantity, spacing=0.25, wait=1):
|
||||
start_x = standa.x.get()
|
||||
start_y = standa.z.get()
|
||||
|
||||
print(f'Starting postion:\n {standa}')
|
||||
|
||||
print(f"Starting postion:\n {standa}")
|
||||
|
||||
for i in range(quantity):
|
||||
print(f'Shot {i}')
|
||||
print(f"Shot {i}")
|
||||
shoot()
|
||||
sleep(wait)
|
||||
move_x_rel(spacing)
|
||||
print('Done')
|
||||
print('Returning to the start')
|
||||
print("Done")
|
||||
print("Returning to the start")
|
||||
standa.x.mv(start_x)
|
||||
standa.z.mv(start_y)
|
||||
|
||||
|
||||
def drill_holes_grid(x_start, x_stop, n_cols, y_start, y_stop, n_rows, wait_time=0.5):
|
||||
# make grid
|
||||
x_pos = np.linspace(x_start, x_stop, n_cols)
|
||||
x_spacing = (x_stop-x_start)/(n_cols-1)
|
||||
x_spacing = (x_stop - x_start) / (n_cols - 1)
|
||||
|
||||
y_pos = np.linspace(y_start, y_stop, n_rows)
|
||||
y_spacing = (y_stop-y_start)/(n_rows-1)
|
||||
y_spacing = (y_stop - y_start) / (n_rows - 1)
|
||||
|
||||
# TODO: add settings we want to change per row
|
||||
row_settings = defaultdict(lambda: {'n_pulses' : 100})
|
||||
row_settings[0] = {'n_pulses' : 500}
|
||||
row_settings[1] = {'n_pulses' : 100}
|
||||
row_settings[2] = {'n_pulses' : 10}
|
||||
row_settings[3] = {'n_pulses' : 1}
|
||||
row_settings = defaultdict(lambda: {"n_pulses": 100})
|
||||
row_settings[0] = {"n_pulses": 500}
|
||||
row_settings[1] = {"n_pulses": 100}
|
||||
row_settings[2] = {"n_pulses": 10}
|
||||
row_settings[3] = {"n_pulses": 1}
|
||||
|
||||
x_start = standa.x.get()
|
||||
y_start = standa.z.get()
|
||||
|
||||
logger.info(f"Begin hole pattern at x:{x_start:.5f}, y:{y_start:.5f}, with transmission: {attenuator.get_transmission():.5f}.")
|
||||
logger.info(
|
||||
f"Begin hole pattern at x:{x_start:.5f}, y:{y_start:.5f}, with transmission: {attenuator.get_transmission():.5f}."
|
||||
)
|
||||
|
||||
for row, y in enumerate(y_pos):
|
||||
settings = row_settings[row]
|
||||
n_pulses = settings['n_pulses']
|
||||
n_pulses = settings["n_pulses"]
|
||||
|
||||
for x in x_pos:
|
||||
move_absolute(x, y)
|
||||
sleep(wait_time)
|
||||
|
||||
shoot(n_pulses)
|
||||
|
||||
|
||||
sleep(0.2)
|
||||
while cta.cta_client.is_running():
|
||||
# wait until sequence is done
|
||||
print('waiting for CTA ...')
|
||||
print("waiting for CTA ...")
|
||||
sleep(0.1)
|
||||
|
||||
logger.info(f"At {time():.5f}s, drilled {n_pulses} hole(s) at x:{x:.5f}, y:{y:.5f}, with transmission: {attenuator.get_transmission():.5f}.")
|
||||
logger.info(
|
||||
f"At {time():.5f}s, drilled {n_pulses} hole(s) at x:{x:.5f}, y:{y:.5f}, with transmission: {attenuator.get_transmission():.5f}."
|
||||
)
|
||||
|
||||
move_absolute(x_start, y_start)
|
||||
|
||||
def drill_here():
|
||||
|
||||
def drill_here():
|
||||
x_start = standa.x.get()
|
||||
x_stop = x_start + 2
|
||||
n_cols = 11
|
||||
|
@ -2,9 +2,10 @@ from datetime import datetime
|
||||
from time import sleep, time
|
||||
from tracemalloc import start
|
||||
import numpy as np
|
||||
#from epics import PV
|
||||
#from slic.utils import nice_arange
|
||||
#from slic.devices.general.motor import Motor
|
||||
|
||||
# from epics import PV
|
||||
# from slic.utils import nice_arange
|
||||
# from slic.devices.general.motor import Motor
|
||||
import matplotlib.pyplot as plt
|
||||
import epics
|
||||
from cristallina import Newport_large, attocube, attenuator
|
||||
@ -14,56 +15,56 @@ from tqdm import tqdm
|
||||
|
||||
attenuator = Attenuator("SAROP31-OATA150", description="Cristallina attenuator OATA150")
|
||||
|
||||
from slic.devices.xoptics.kb import KBHor,KBVer
|
||||
kbHor = KBHor(
|
||||
"SAROP31-OKBH154",
|
||||
description="Cristallina horizontal KB mirror"
|
||||
)
|
||||
from slic.devices.xoptics.kb import KBHor, KBVer
|
||||
|
||||
kbVer = KBVer(
|
||||
"SAROP31-OKBV153",
|
||||
description="Cristallina vertical KB mirror"
|
||||
)
|
||||
kbHor = KBHor("SAROP31-OKBH154", description="Cristallina horizontal KB mirror")
|
||||
|
||||
kbVer = KBVer("SAROP31-OKBV153", description="Cristallina vertical KB mirror")
|
||||
|
||||
do_not_move_benders = True
|
||||
testing_flag = False
|
||||
pos = np.array([0,0])
|
||||
pos = np.array([0, 0])
|
||||
|
||||
# parameters
|
||||
n_same_holes = 3
|
||||
attenuations = np.linspace(0.15,0.35,9)#np.linspace(0.1,0.35,11)#np.linspace(0.1,0.35,6)#np.logspace(-3,0,num=7)
|
||||
KBv_home = [1.3 , 1.6]
|
||||
KBh_home = [1.4 , 1.7]
|
||||
attenuations = np.linspace(0.15, 0.35, 9) # np.linspace(0.1,0.35,11)#np.linspace(0.1,0.35,6)#np.logspace(-3,0,num=7)
|
||||
KBv_home = [1.3, 1.6]
|
||||
KBh_home = [1.4, 1.7]
|
||||
|
||||
# Spacings
|
||||
between_same_shots = 150
|
||||
between_attenuations = 150
|
||||
between_KB_settings = 500#500
|
||||
between_KB_settings = 500 # 500
|
||||
|
||||
|
||||
### 23.02
|
||||
def kb_settings_list(best,step,no_steps):
|
||||
def kb_settings_list(best, step, no_steps):
|
||||
for i in range(no_steps):
|
||||
if i == 0:
|
||||
l=[]
|
||||
l.append([best[0]+i*step,best[1]])
|
||||
l = []
|
||||
l.append([best[0] + i * step, best[1]])
|
||||
for i in range(no_steps):
|
||||
if i == 0:
|
||||
pass
|
||||
l.append([best[0],best[1]+i*step])
|
||||
return l
|
||||
l.append([best[0], best[1] + i * step])
|
||||
return l
|
||||
|
||||
|
||||
KBvs = kb_settings_list([1.595, 1.874], 0.05, 3)
|
||||
KBhs = kb_settings_list([1.799000, 2.100000], 0.05, 3)
|
||||
|
||||
KBvs = kb_settings_list([1.595,1.874],0.05,3)
|
||||
KBhs = kb_settings_list([1.799000,2.100000],0.05,3)
|
||||
|
||||
### 24.02
|
||||
def kb_settings_list_new(best,step,no_steps_one_way):
|
||||
l=[]
|
||||
first = np.array(best) - np.array([step*no_steps_one_way,step*no_steps_one_way])
|
||||
for i in range(no_steps_one_way*2+1):
|
||||
l.append([first[0]+i*step,first[1]+i*step])
|
||||
return l
|
||||
KBvs = kb_settings_list_new([1.595,1.874],0.0075,3)
|
||||
KBhs = kb_settings_list_new([1.799000,2.100000],0.0075,3)
|
||||
def kb_settings_list_new(best, step, no_steps_one_way):
|
||||
l = []
|
||||
first = np.array(best) - np.array([step * no_steps_one_way, step * no_steps_one_way])
|
||||
for i in range(no_steps_one_way * 2 + 1):
|
||||
l.append([first[0] + i * step, first[1] + i * step])
|
||||
return l
|
||||
|
||||
|
||||
KBvs = kb_settings_list_new([1.595, 1.874], 0.0075, 3)
|
||||
KBhs = kb_settings_list_new([1.799000, 2.100000], 0.0075, 3)
|
||||
|
||||
|
||||
# Time estimates for total time calculation (time in seconds)
|
||||
@ -75,29 +76,31 @@ t_atten_change = 10
|
||||
smaract_stage = True
|
||||
# Change to mm from um if smaract stage selected
|
||||
if smaract_stage:
|
||||
between_same_shots = between_same_shots/1000
|
||||
between_attenuations = between_attenuations/1000
|
||||
between_KB_settings = between_KB_settings/1000
|
||||
between_same_shots = between_same_shots / 1000
|
||||
between_attenuations = between_attenuations / 1000
|
||||
between_KB_settings = between_KB_settings / 1000
|
||||
|
||||
def shoot(pos=pos,testing=testing_flag):
|
||||
|
||||
def shoot(pos=pos, testing=testing_flag):
|
||||
if testing:
|
||||
print(f'Shot at: {pos}')
|
||||
print(f"Shot at: {pos}")
|
||||
return pos
|
||||
else:
|
||||
print(f'Shot at: {pos}')
|
||||
print(f"Shot at: {pos}")
|
||||
sleep(2)
|
||||
epics.caput("SAR-CCTA-ESC:seq0Ctrl-Start-I",1)
|
||||
epics.caput("SAR-CCTA-ESC:seq0Ctrl-Start-I", 1)
|
||||
pass
|
||||
|
||||
def change_benders(bender_1,bender_2,KB = None,do_not_move_benders = do_not_move_benders):
|
||||
|
||||
def change_benders(bender_1, bender_2, KB=None, do_not_move_benders=do_not_move_benders):
|
||||
check_KB_value(KB)
|
||||
|
||||
|
||||
current_values = get_bender_values(KB)
|
||||
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:
|
||||
# Move home first
|
||||
if KB == 'h' or KB == 'H':
|
||||
if KB == "h" or KB == "H":
|
||||
kbHor.bend1.set_target_value(KBh_home[0]).wait()
|
||||
sleep(1)
|
||||
kbHor.bend2.set_target_value(KBh_home[1]).wait()
|
||||
@ -109,13 +112,13 @@ def change_benders(bender_1,bender_2,KB = None,do_not_move_benders = do_not_move
|
||||
sleep(1)
|
||||
|
||||
if do_not_move_benders:
|
||||
print(f'Bender 1 to: {bender_1}')
|
||||
print(f'Bender 2 to: {bender_2}')
|
||||
return
|
||||
print(f"Bender 1 to: {bender_1}")
|
||||
print(f"Bender 2 to: {bender_2}")
|
||||
return
|
||||
|
||||
# Move to the new position
|
||||
print(f'Changing {KB} bender to: [{bender_1} , {bender_2}]')
|
||||
if KB == 'h' or KB == 'H':
|
||||
print(f"Changing {KB} bender to: [{bender_1} , {bender_2}]")
|
||||
if KB == "h" or KB == "H":
|
||||
kbHor.bend1.set_target_value(bender_1).wait()
|
||||
sleep(1)
|
||||
kbHor.bend2.set_target_value(bender_2).wait()
|
||||
@ -125,67 +128,72 @@ def change_benders(bender_1,bender_2,KB = None,do_not_move_benders = do_not_move
|
||||
sleep(1)
|
||||
kbVer.bend2.set_target_value(bender_2).wait()
|
||||
sleep(1)
|
||||
|
||||
|
||||
|
||||
def check_KB_value(KB):
|
||||
if KB not in ['H','h','V','v']:
|
||||
raise KeyError(f"KB can only be horizontal (H) or vertical (V), not {KB}")
|
||||
if KB not in ["H", "h", "V", "v"]:
|
||||
raise KeyError(f"KB can only be horizontal (H) or vertical (V), not {KB}")
|
||||
|
||||
|
||||
def get_bender_values(KB=None):
|
||||
check_KB_value(KB)
|
||||
if KB == 'h' or KB == 'H':
|
||||
return [kbHor.bend1.get(),kbHor.bend2.get()]
|
||||
if KB == "h" or KB == "H":
|
||||
return [kbHor.bend1.get(), kbHor.bend2.get()]
|
||||
else:
|
||||
return [kbVer.bend1.get(),kbVer.bend2.get()]
|
||||
return [kbVer.bend1.get(), kbVer.bend2.get()]
|
||||
|
||||
|
||||
def move_x_rel(distance,testing=testing_flag,pos=pos):
|
||||
def move_x_rel(distance, testing=testing_flag, pos=pos):
|
||||
if testing == True:
|
||||
pos = pos + np.array([distance,0])
|
||||
pos = pos + np.array([distance, 0])
|
||||
return pos
|
||||
else:
|
||||
if smaract_stage:
|
||||
smaract_mini_XYZ.x.mvr(distance).wait()
|
||||
else:
|
||||
attocube.X.set_target_value(distance, relative=True).wait()
|
||||
pos = pos + np.array([distance,0])
|
||||
pos = pos + np.array([distance, 0])
|
||||
return pos
|
||||
|
||||
def move_y_rel(distance,testing=testing_flag,pos=pos):
|
||||
|
||||
def move_y_rel(distance, testing=testing_flag, pos=pos):
|
||||
if testing == True:
|
||||
pos = pos + np.array([0,distance])
|
||||
pos = pos + np.array([0, distance])
|
||||
return pos
|
||||
else:
|
||||
if smaract_stage:
|
||||
smaract_mini_XYZ.y.mvr(distance).wait()
|
||||
else:
|
||||
attocube.Y.set_target_value(distance, relative=True).wait()
|
||||
pos = pos + np.array([0,distance])
|
||||
pos = pos + np.array([0, distance])
|
||||
return pos
|
||||
|
||||
def move_x(value,testing=testing_flag,pos=pos):
|
||||
|
||||
def move_x(value, testing=testing_flag, pos=pos):
|
||||
if testing == True:
|
||||
pos[0]=value
|
||||
pos[0] = value
|
||||
return pos
|
||||
else:
|
||||
if smaract_stage:
|
||||
smaract_mini_XYZ.x.mv(value).wait()
|
||||
else:
|
||||
attocube.X.set_target_value(value, relative=False).wait()
|
||||
return [value,pos[1]]
|
||||
return [value, pos[1]]
|
||||
|
||||
def move_y(value,testing=testing_flag,pos=pos):
|
||||
|
||||
def move_y(value, testing=testing_flag, pos=pos):
|
||||
if testing == True:
|
||||
pos[1]=value
|
||||
pos[1] = value
|
||||
return pos
|
||||
else:
|
||||
if smaract_stage:
|
||||
smaract_mini_XYZ.y.mv(value).wait()
|
||||
else:
|
||||
else:
|
||||
attocube.Y.set_target_value(value, relative=False).wait()
|
||||
return [pos[0],value]
|
||||
return [pos[0], value]
|
||||
|
||||
def move(target_pos,testing=True,pos=pos):
|
||||
|
||||
def move(target_pos, testing=True, pos=pos):
|
||||
if testing == True:
|
||||
pass
|
||||
else:
|
||||
@ -198,16 +206,18 @@ def move(target_pos,testing=True,pos=pos):
|
||||
pos = target_pos
|
||||
return pos
|
||||
|
||||
|
||||
def get_original_position(testing=testing_flag):
|
||||
if testing == True:
|
||||
original_position = pos
|
||||
else:
|
||||
if smaract_stage:
|
||||
original_position = [smaract_mini_XYZ.x.get_current_value(),smaract_mini_XYZ.y.get_current_value()]
|
||||
original_position = [smaract_mini_XYZ.x.get_current_value(), smaract_mini_XYZ.y.get_current_value()]
|
||||
else:
|
||||
original_position = [attocube.X.get_current_value(),attocube.Y.get_current_value()]
|
||||
original_position = [attocube.X.get_current_value(), attocube.Y.get_current_value()]
|
||||
return original_position
|
||||
|
||||
|
||||
def set_attenuation(value):
|
||||
attenuator.set_transmission(value)
|
||||
sleep(1)
|
||||
@ -215,20 +225,21 @@ def set_attenuation(value):
|
||||
sleep(1)
|
||||
return value
|
||||
|
||||
def make_attenuations(attenuations,testing=testing_flag,pos=pos):
|
||||
|
||||
def make_attenuations(attenuations, testing=testing_flag, pos=pos):
|
||||
original_position = get_original_position(testing=testing)
|
||||
|
||||
|
||||
# Make all attenuations
|
||||
for attenuation in attenuations:
|
||||
print(f'Setting attenuation to: {attenuation}')
|
||||
print(f"Setting attenuation to: {attenuation}")
|
||||
if testing:
|
||||
print('Testing: no attenuator change')
|
||||
print("Testing: no attenuator change")
|
||||
else:
|
||||
set_attenuation(attenuation)
|
||||
print('Making same shots')
|
||||
make_same_shots(n_same_holes,pos=pos,testing=testing)
|
||||
pos = move_y_rel(between_attenuations,pos=pos,testing=testing)
|
||||
|
||||
print("Making same shots")
|
||||
make_same_shots(n_same_holes, pos=pos, testing=testing)
|
||||
pos = move_y_rel(between_attenuations, pos=pos, testing=testing)
|
||||
|
||||
# Return back to where you started
|
||||
if testing == True:
|
||||
pos = original_position
|
||||
@ -236,24 +247,34 @@ def make_attenuations(attenuations,testing=testing_flag,pos=pos):
|
||||
pos = move(original_position, testing=testing)
|
||||
return pos
|
||||
|
||||
def make_same_shots(n_same_holes,testing=testing_flag,pos=pos):
|
||||
|
||||
def make_same_shots(n_same_holes, testing=testing_flag, pos=pos):
|
||||
original_position = get_original_position(testing=testing)
|
||||
|
||||
|
||||
# Make holes
|
||||
for shot in range(n_same_holes):
|
||||
sleep(1)
|
||||
shoot(pos=pos,testing=testing)
|
||||
pos = move_x_rel(between_same_shots,pos=pos,testing=testing)
|
||||
|
||||
# Return back to where you started
|
||||
move(original_position,testing=testing)
|
||||
|
||||
shoot(pos=pos, testing=testing)
|
||||
pos = move_x_rel(between_same_shots, pos=pos, testing=testing)
|
||||
|
||||
def estimate_total_time(KBhs=KBhs,KBvs=KBvs,attenuations=attenuations,n_same_holes=n_same_holes,t_kb_change=t_kb_change,t_atten_change=t_atten_change,t_shot=t_shot):
|
||||
total_time = len(KBhs)*len(KBvs)*( t_kb_change+len(attenuations)*(t_atten_change+n_same_holes*t_shot) )
|
||||
print(f'Total time estimate: {(total_time/60):.1f} minutes or {(total_time/60/60):.1f} hours')
|
||||
# Return back to where you started
|
||||
move(original_position, testing=testing)
|
||||
|
||||
|
||||
def estimate_total_time(
|
||||
KBhs=KBhs,
|
||||
KBvs=KBvs,
|
||||
attenuations=attenuations,
|
||||
n_same_holes=n_same_holes,
|
||||
t_kb_change=t_kb_change,
|
||||
t_atten_change=t_atten_change,
|
||||
t_shot=t_shot,
|
||||
):
|
||||
total_time = len(KBhs) * len(KBvs) * (t_kb_change + len(attenuations) * (t_atten_change + n_same_holes * t_shot))
|
||||
print(f"Total time estimate: {(total_time/60):.1f} minutes or {(total_time/60/60):.1f} hours")
|
||||
return total_time
|
||||
|
||||
|
||||
# Get the starting x-position
|
||||
if testing_flag == True:
|
||||
starting_x_pos = pos[0]
|
||||
@ -264,53 +285,54 @@ else:
|
||||
starting_x_pos = attocube.X.get_current_value()
|
||||
|
||||
|
||||
def make_everything(KBvs,KBhs,attenuations,n_same_holes,testing=testing_flag,pos=pos,do_not_move_benders=True):
|
||||
def make_everything(KBvs, KBhs, attenuations, n_same_holes, testing=testing_flag, pos=pos, do_not_move_benders=True):
|
||||
# The loop to make inprints
|
||||
for i,KBv in enumerate(tqdm(KBvs)):
|
||||
change_benders(KBv[0],KBv[1],KB = 'v',do_not_move_benders=do_not_move_benders)
|
||||
for i, KBv in enumerate(tqdm(KBvs)):
|
||||
change_benders(KBv[0], KBv[1], KB="v", do_not_move_benders=do_not_move_benders)
|
||||
|
||||
for ind,KBh in enumerate(KBhs):
|
||||
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,testing=testing)
|
||||
for ind, KBh in enumerate(KBhs):
|
||||
change_benders(KBh[0], KBh[1], KB="h")
|
||||
|
||||
print(f'Moving to a new KBh setting')
|
||||
# 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-1),pos=pos,testing=testing)
|
||||
print(f"Progress so far: KBv loop: {i+1}/{len(KBvs)}. KBh loop:{ind+1}/{len(KBhs)}")
|
||||
make_attenuations(attenuations, pos=pos, testing=testing)
|
||||
|
||||
print('KBh set done, returning to starting_x_pos')
|
||||
# Move to the last shot of the same shot + the spacing between KB settings
|
||||
print(f"Moving to a new KBh setting")
|
||||
# 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 - 1), pos=pos, testing=testing)
|
||||
|
||||
pos = move_x(starting_x_pos,pos=pos,testing=testing)
|
||||
print("KBh set done, returning to starting_x_pos")
|
||||
# Move to the last shot of the same shot + the spacing between KB settings
|
||||
|
||||
print('#################################################################################')
|
||||
print('Moving to a new KBv setting')
|
||||
# Move to the last shot of the same shot + the spacing between KB settings
|
||||
pos = move_x(starting_x_pos, pos=pos, testing=testing)
|
||||
|
||||
pos = move_y_rel(between_KB_settings+between_attenuations*(len(attenuations)-1),pos=pos,testing=testing)
|
||||
print("#################################################################################")
|
||||
print("Moving to a new KBv setting")
|
||||
# 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) - 1), pos=pos, testing=testing)
|
||||
|
||||
print('Inprints are done')
|
||||
print("Inprints are done")
|
||||
set_attenuation(1e-6)
|
||||
status_pv = PV('SF-OP:ESC-MSG:STATUS')
|
||||
status_pv = PV("SF-OP:ESC-MSG:STATUS")
|
||||
status_pv.put(0)
|
||||
|
||||
# print(f'Total time estimate: {(total_time/60):.1f} minutes or {(total_time/60/60):.1f} hours')
|
||||
|
||||
# print(f'Total time estimate: {(total_time/60):.1f} minutes or {(total_time/60/60):.1f} hours')
|
||||
|
||||
|
||||
# To do:
|
||||
# Fix movement of the attocubes in real time
|
||||
# Load lut files into the controller and check that x is x and y is y
|
||||
|
||||
def make_z_scan(z_list,n_same_holes,attenuations,vertical_spacing=0.150):
|
||||
|
||||
|
||||
def make_z_scan(z_list, n_same_holes, attenuations, vertical_spacing=0.150):
|
||||
original_position = get_original_position(testing=False)
|
||||
for attenuation in attenuations:
|
||||
set_attenuation(attenuation)
|
||||
for z in z_list:
|
||||
Newport_large.mv(z).wait()
|
||||
sleep(1)
|
||||
make_same_shots(n_same_holes,testing=False)
|
||||
move_y_rel(vertical_spacing,testing=False)
|
||||
move(original_position,testing=False)
|
||||
make_same_shots(n_same_holes, testing=False)
|
||||
move_y_rel(vertical_spacing, testing=False)
|
||||
move(original_position, testing=False)
|
||||
sleep(1)
|
||||
move_x_rel(1,testing=False)
|
||||
move_x_rel(1, testing=False)
|
||||
|
Reference in New Issue
Block a user