Skip to content
Snippets Groups Projects
Commit bc73d218 authored by 29iduser's avatar 29iduser
Browse files

debugging sotw

parent 3dcf9d88
No related branches found
No related tags found
No related merge requests found
......@@ -60,17 +60,6 @@ def ARPES_init(*userName,**kwargs):
kwargs.setdefault('set_folders',False)
kwargs.setdefault('reset',False)
kwargs.setdefault('debug',False)
if kwargs['debug']:
print(userName)
if len(userName) == 0:
user_name = saveData_user(kwargs['scan_ioc'])
else:
user_name = userName[0]
if user_name == 'staff':
user_name = 'Staff'
kwargs['mode'] = 'staff'
#motors
physical_motors = ['x','y','z','th','chi','phi']
......@@ -78,22 +67,33 @@ def ARPES_init(*userName,**kwargs):
global ARPES_Motors
ARPES_Motors = Motors('ARPES',_ARPES_motor_dictionary(),physical_motors,pseudo_motors)
#BL_config
if kwargs['debug']:
print("Beamline_Config")
#endstation
BL_kwargs={'debug':kwargs['debug']}
iex.BL = Beamline_Config('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],ARPES_Motors,**BL_kwargs)
BLconfig_safe_state_set(ARPES_safe_state)
BLconfig_get_set(ARPES_get_all)
iex.BL.ca_list = _ARPES_ca_list()
#userName
if len(userName) == 0:
saveData_get_all(kwargs['scan_ioc'])
user_name = mda_user_name()
else:
user_name = userName[0]
if user_name == 'staff':
user_name = 'Staff'
kwargs['mode'] = 'staff'
if kwargs['debug']:
print(userName)
#setting folders
if kwargs['set_folders']:
if len(userName)==0:
user_name = input('user name: ')
folders_ARPES(user_name,**kwargs)
#logging
if kwargs['set_folders']:
log_init('ARPES',user_name,_ARPES_log_dictionary,set_file=True)
......@@ -130,6 +130,7 @@ def ARPES_init(*userName,**kwargs):
print ('\nARPES initalized')
print('\tpath = "'+mda_filepath()+'"')
print('\tprefix = "'+mda_prefix()+'"')
#return any detectors or other parameters that you want access to from jupyter
return tey,ca15
......@@ -194,7 +195,7 @@ def _ARPES_motor_dictionary():
motor_dictionary={}
for name in motor_nums.keys():
pv = '29idc:m'+str(motor_nums[name])
pv = p+str(motor_nums[name])
motor_dictionary.update({name:[pv+'.RBV',pv+'.VAL',pv+'.SPMG',pv]})
return motor_dictionary
......@@ -527,7 +528,7 @@ def _ARPES_snake_userCalc(**kwargs):
def ARPES_snake_set(snake,**kwargs):
"""
used for snake scanning
snake = True/False used for snake/typewritter scanning
"""
kwargs.setdefault('scan_dim',1)
scan_ioc = mda_ioc()
......@@ -765,12 +766,12 @@ def ARPES_safe_state(**kwargs):
EA.off(quiet=False)
else:
print('EA is not running, visually confirm HV is off')
branch = 'c'
if kwargs['shutter_close']:
branch_shutter_close()
branch_shutter_close(branch=branch)
if kwargs['valve_close']:
branch_valve_close()
branch_valve_close(branch=branch)
##############################################################################################################
############################## ARPES_scanPause ##############################
......
......@@ -236,7 +236,7 @@ def ID_on(verbose=True):
#caput(ID_pvs()['energy_sp'],3.8)
caput(ID_pvs()['main_power'],'On',wait=True,timeout=18000)
sleep(5)
sleep(10)
def ID_start(ID_mode='RCP',QP_ratio=None, verbose=True):
"""
......@@ -290,10 +290,10 @@ def ID_switch_mode(ID_mode):
ID_mode_set(ID_mode)
ID_ready()
if ID_mode_get() != ID_mode:
if ID_mode_get(verbose=False) != ID_mode:
print_warning_message("ID mode switch had an error, please try again")
else:
print("ID Mode:",ID_mode_get())
print("ID Mode:",ID_mode_get(verobse=False))
def ID_get(verbose=False):
......@@ -376,12 +376,12 @@ def ID_set(keV,verbose=True):
ID_ready(verbose=False)
#Add check if moved
#run twice to make sure ready (sometime busy is weird and instantaneously give ready)
ID_ready(verbose=False)
if ID_bw_ok() == False:
caput(ID_pvs()['start_ramp'],1)
caput(ID_pvs()['start_ramp'],0)
print_warning_message('ID_bw_ok is not ok')
def ID_bw_ok():
"""
......@@ -391,9 +391,9 @@ def ID_bw_ok():
ID_SP = ID_get_sp(verbose=False)
ID_RBV = ID_get()
if ID_SP/10 < abs(ID_SP-ID_RBV):
return True
else:
return False
else:
return True
def ID_energy_set(keV,verbose=True):
"""
Sets optimum ID set point for hv(eV) (max intensity)
......@@ -436,17 +436,29 @@ def ID_QP_ratio_get(verbose=True):
calculate the QP ratio
"""
Byq=caget(ID_pvs()['By_q'])
Vcoil=caget(ID_pvs()['Vcoil'])
ratio_calc=round(Byq/Vcoil,3)*100
ratio_RBV=caget(ID_pvs()['QP_ratio'])
if verbose:
print("QP RBV =", ratio_RBV,"%")
print("QP calculated ratio =", ratio_calc ,"%")
if ID_get_rbv_eV() < 3700:
IDmode = ID_mode_get(verbose=False)
Byq=caget(ID_pvs()['By_q'])
Vcoil=caget(ID_pvs()['Vcoil'])
Bxq=caget(ID_pvs()['Bx_q'])
Hcoil=caget(ID_pvs()['Hcoil'])
if IDmode == 'H':
ratio_calc=round(Bxq/Hcoil,2)*100
elif IDmode == 'V':
ratio_calc=round(Byq/Vcoil,2)*100
elif IDmode == 'RCP' or IDmode == 'LCP':
ratio_calc = round(((Byq/Vcoil)**2+(Bxq/Hcoil)**2)/2,3)*100
ratio_RBV=caget(ID_pvs()['QP_ratio'])
if verbose:
print("QP RBV =", ratio_RBV,"%")
print("QP calculated ratio =", ratio_calc ,"%")
if abs(ratio_RBV-ratio_calc)>1:
message_string="QP RBV and QP calc do not agree \nCheck Interlocks"
if abs(ratio_RBV-ratio_calc)>1:
message_string="QP RBV and QP calc do not agree \nCheck Interlocks"
print_warning_message(message_string)
else:
message_string('ID is not ON')
print_warning_message(message_string)
return ratio_RBV, ratio_calc
......@@ -565,7 +577,7 @@ def ID_scan_fillin_table(ID_array,**kwargs):
############################## ID direction table ##############################
##############################################################################################################
def ID_Table():
def ID_Table(verbose=False):
"""
Previously: ID_Table
......@@ -573,7 +585,7 @@ def ID_Table():
table = caget("ID29:TableDirection") # up = 1 , down = 0
By = caget("ID29:ByPolaritySet") # pos = 1, neg = 0
mode = ID_mode_get()
mode = ID_mode_get(verbose)
if By > 0:
print("\nBy > 0")
......
......@@ -62,47 +62,58 @@ def kappa_init(*userName,**kwargs):
kwargs.setdefault('mode','user')
kwargs.setdefault('set_folders',False)
kwargs.setdefault('reset',False)
kwargs.setdefault('debug',False)
#motors
physical_motors = ['x','y','z','tth','kth','kap','kphi']
pseudo_motors = ['th','chi','phi']
global kappa_Motors
kappa_Motors = Motors('kappa',_kappa_motor_dictionary(),physical_motors,pseudo_motors)
#endstation
iex.BL = Beamline_Config('kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],kappa_Motors)
#BL_config
if kwargs['debug']:
print("Beamline_Config")
BL_kwargs={'debug':kwargs['debug']}
iex.BL = Beamline_Config('kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],kappa_Motors,**BL_kwargs)
BLconfig_safe_state_set(kappa_safe_state)
BLconfig_get_set(kappa_get_all)
iex.BL.ca_list = _kappa_ca_list()
#userName
if len(userName) == 0:
saveData_get_all(kwargs['scan_ioc'])
user_name = mda_user_name()
else:
user_name = userName[0]
if user_name == 'staff':
user_name = 'Staff'
kwargs['mode'] = 'staff'
if kwargs['debug']:
print(userName)
#setting folders
if kwargs['set_folders']:
if BLconfig_mode() == 'staff':
user_name = 'Staff'
else:
if len(userName)==0:
user_name = input('user name: ')
else:
user_name = userName[0]
print(user_name)
if len(userName)==0:
user_name = input('user name: ')
folders_kappa(user_name,**kwargs)
else:
user_name = mda_user_name()
print('user_name:',user_name)
#logging
log_init('kappa',user_name,_kappa_log_dictionary,set_file=False)
if kwargs['set_folders']:
log_name_set()
log_init('kappa',user_name,_kappa_log_dictionary,set_file=True)
else:
log_init('kappa',user_name,_kappa_log_dictionary,set_file=False)
#MPA
global mpa
iex.mpa = MPA()
global mpa,tth_pv,tthdet
iex.mpa = MPA()
mpa = iex.mpa
#global detectors
global tth_pv,tthdet
tthdet = Kappa_Detector(kappa_Motors)
tth_pv = _kappa_motor_dictionary('tth')[3]
tth_pv = _kappa_motor_dictionary()['tth'][3]
#global detectors
global tey,d3,d4,mesh
......@@ -121,7 +132,10 @@ def kappa_init(*userName,**kwargs):
#enable cameras - m3r + endstation
_enable_endstation_cameras()
print ('\nkappa initalized')
print ('\nkappa initalized')
print('\tpath = "'+mda_filepath()+'"')
print('\tprefix = "'+mda_prefix()+'"')
#return any detectors or other parameters that you want access to from jupyter
return tey,d3,d4,mesh,tth_pv,tthdet
......@@ -219,12 +233,13 @@ def _kappa_detector_dictionary(**kwargs):
return det_dict
def _kappa_motor_dictionary(name):
def _kappa_motor_dictionary():
"""
motor_dictionary = {name:[rbv,val,spmg,pv]} for physical and psuedo/Euler motors
usage:
kappa_PVmotor('x') => ['29idKappa:m2.RBV', '29idKappa:m2.VAL', '29idKapp:m2.SPMG','29idKappa:m2']
"""
p = '29idKappa:m'
motor_nums={
'x':2,
'y':3,
......@@ -241,12 +256,12 @@ def _kappa_motor_dictionary(name):
}
motor_dictionary = {}
for name in motor_nums.keys():
pv = '29idKappa:m'+str(motor_nums[name])
motor_dictionary.update({name:[pv+'.VAL',pv+'.SPMG',pv]})
pv = p+str(motor_nums[name])
motor_dictionary.update({name:[pv+'.VAL',pv+'.RBV',pv+'.SPMG',pv]})
for name in Euler_motors.keys():
pv = Euler_motors[name]
motor_dictionary.update({name:[pv+'RBV',pv,'',pv]})
motor_dictionary.update({name:[pv,pv+'RBV','',pv]})
return motor_dictionary
......@@ -429,7 +444,7 @@ def _kappa_log_dictionary():
##############################################################################################################
############################## kappa scanRecord ##############################
##############################################################################################################
def _kappa_scan_before_sequence(scan_ioc,scan_dim,**kwargs):
def _kappa_scan_before_sequence(**kwargs):
"""
writes the user string sequence to happen at the beginning of a scan
returns before_scan_pv = pv for userStringSeq for before scan
......@@ -442,6 +457,8 @@ def _kappa_scan_before_sequence(scan_ioc,scan_dim,**kwargs):
kwargs.setdefault('seq_num',9)
seq_num=kwargs['seq_num']
scan_ioc = mda_ioc()
before_scan_pv,before_scan_proc = userStringSeq_pvs(scan_ioc, seq_num)
#clear and write the before scan user sequence
......@@ -471,7 +488,7 @@ def _kappa_scan_after_pvs(clear=False,**kwargs):
userStringSeq_clear(scan_ioc,seq_num)
return after_scan_pv,after_scan_proc
def _kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs):
def _kappa_scan_after_sequence(**kwargs):
"""
writes the user string sequence to happen at the end of a scan
returns after_scan_pv = pv for userStringSeq for after scan
......@@ -508,7 +525,7 @@ def _kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs):
return after_scan_proc
def _kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs): # do we need to add 29idb:ca5 ???
def _kappa_detector_triggers_sequence(**kwargs): # do we need to add 29idb:ca5 ???
"""
sets the trigger sequence for the endstation
"""
......@@ -535,22 +552,23 @@ def _kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs): # do we ne
#trigger scaler if any
last+=1
scaler_pv = kappa_scaler_pv()
caput(detector_triggers_pv+".LNK" +str(1),scaler_pv)+" PP"
caput(detector_triggers_pv+"STR"+str(1),'Count')
caput(detector_triggers_pv+".LNK" +str(1),scaler_pv)
caput(detector_triggers_pv+".STR"+str(1),'Count')
return detector_triggers_proc
def _kappa_trigger_dictionary(scan_ioc,scan_dim,**kwargs):
def _kappa_trigger_dictionary(**kwargs):
"""
need to do something
"""
trigger_dictionary = {
1:_kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs),
1:_kappa_detector_triggers_sequence(**kwargs),
}
return trigger_dictionary
def _kappa_snake_userCalc(**kwargs):
"""
used to flip the sign of the step after a scan
snake scans as opposed to typewriter scans
"""
......@@ -575,7 +593,7 @@ def _kappa_snake_userCalc(**kwargs):
def kappa_snake_set(snake,**kwargs):
"""
used for snake scanning
snake = True/False used for snake/typewritter scanning
"""
kwargs.setdefault('scan_dim',1)
scan_ioc = mda_ioc()
......
......@@ -88,7 +88,7 @@ class Logfile:
pv_dict={
'Test':'29idb:userStringSeq10.STR1',
'ARPES':'29idb:userStringSeq10.STR2',
'Kappa':'29idb:userStringSeq10.STR3',
'kappa':'29idb:userStringSeq10.STR3',
'Octupole':'29idb:userStringSeq10.STR4',
}
if self.endstation_name in pv_dict.keys():
......
......@@ -59,31 +59,32 @@ def Octupole_init(*userName,**kwargs):
kwargs.setdefault('reset',False)
kwargs.setdefault('debug',False)
if kwargs['debug']:
print(userName)
if len(userName) == 0:
saveData_get_all(kwargs['scan_ioc'])
user_name = mda_user_name()
else:
user_name = userName[0]
if user_name == 'staff':
user_name = 'Staff'
kwargs['mode'] = 'staff'
#motors
physical_motors = ['x','y','z','th','tth']
pseudo_motors = ['']
global Octupole_Motors
Octupole_Motors = Motors('Octupole',_Octupole_motor_dictionary(),physical_motors,pseudo_motors)
#BL_config
if kwargs['debug']:
print("Beamline_Config")
#endstation
BL_kwargs={'debug':kwargs['debug']}
iex.BL = Beamline_Config('Octupole',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],Octupole_Motors,**BL_kwargs)
BLconfig_safe_state_set(Octupole_safe_state)
BLconfig_get_set(Octupole_get_all)
iex.BL.ca_list = _Octupole_ca_list()
#userName
if len(userName) == 0:
saveData_get_all(kwargs['scan_ioc'])
user_name = mda_user_name()
else:
user_name = userName[0]
if user_name == 'staff':
user_name = 'Staff'
kwargs['mode'] = 'staff'
if kwargs['debug']:
print(userName)
#setting folders
if kwargs['set_folders']:
......@@ -125,6 +126,7 @@ def Octupole_init(*userName,**kwargs):
print ('\nOctupole initalized')
print('\tpath = "'+mda_filepath()+'"')
print('\tprefix = "'+mda_prefix()+'"')
#return any detectors or other parameters that you want access to from jupyter
return tey,tfy,pd,mesh,diag,kbh,kbv
......
......@@ -7,11 +7,14 @@ branch_GVs={
'd':('14'),
}
def branch_valve_close():
def branch_valve_close(branch=None):
"""
closes the endstation valve for the current branch
closes the endstation valve for the current branch or specified branch
"""
GV = branch_GVs[iex.BL.branch]
if branch == None:
GV = branch_GVs[iex.BL.branch]
else:
GV = branch_GVs[branch]
valve_close(GV, verbose=True)
def branch_valve_open():
......
......@@ -510,7 +510,7 @@ def switch_branch(branch, force=False, shutter=True,enable_cams=True):
if branch in d.keys():
if m3r_branch() == branch and not force:
print("\nWell, looks like the beam is already in this branch...")
print("...if you want to force the mirror motion, use the argument: forced=True")
print("...if you want to force the mirror motion, use the argument: force=True")
else:
# Close both shutters:
print("\n")
......
......@@ -74,8 +74,7 @@ def interactive_fct():
print('\nresuming script...\n')
if flag == '2':
print('\nrepeating scan...\n')
if flag == '':
return
return flag
def input2float(ask,default_x=0):
......@@ -313,15 +312,14 @@ def sotw_slit_positions(**kwargs):
except:
print(v,h)
flag = interactive_fct()
if flag == '':
break
if slit_name == 'slit2B':
sotw_M0M1_steering(h,v)
flag = interactive_fct()
if flag == '':
flag_plot = interactive_fct()
if flag_plot == '':
break
else:
flag = int(flag_plot)
if slit_name == 'slit2B':
sotw_M0M1_update_dictionary()
......@@ -524,18 +522,19 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs):
flag=2
while flag>1:
scanNum_h, scanNum_v = sotw_ID_steering_scan(**kwargs)
flag = sotw_ID_steering_plot(detCA4,scanNum_h,scanNum_v)
if flag == '':
return
flag_plot = sotw_ID_steering_plot(detCA4,scanNum_h,scanNum_v)
if flag_plot == '':
break
else:
flag = int(flag_plot)
diagnostic('mesh_W','out')
###### Wire scans:
if 'wire' in kwargs['scanType']:
print("\n\n================== Slit 1A scans:")
flag = sotw_wire(detH,detV,**kwargs)
if flag == '':
return
sotw_wire(detH,detV,**kwargs)
###### Mono/slit scans:
if 'monoVslit' in kwargs['scanType']:
......@@ -550,9 +549,8 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs):
foo=input('Is detector D'+str(kwargs['detDiode'])+' in direct beam (y or n)? >')
print("\n\n================== Mono/slit scans:")
flag =sotw_slit_positions(**kwargs)
if flag == '':
return
flag_plot =sotw_slit_positions(**kwargs)
###### Check flux:
......@@ -561,9 +559,11 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs):
flag=2
while flag==2:
sotw_check_flux(**kwargs)
flag=interactive_fct()
if flag == '':
break
flag_plot=interactive_fct()
if flag_plot == '':
return
else:
flag = int(flag_plot)
diagnostics_all_out()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment