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

dubug

parent c8519496
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ from time import sleep
from epics import caget,caput
import iexcode.instruments.cfg as iex
from iexcode.instruments.conversions_constants import *
from iexcode.instruments.SRS_current_amplifiers import *
from iexcode.instruments.Keithley_current_amplifiers import *
from iexcode.instruments.diagnostics import *
......
......@@ -604,7 +604,7 @@ def M0M1_steering(h_position,v_position,verbose=False):
def monoVslit_quick_scan(slit_name, **kwargs):
def monoVslit_quick_scan(slit_name,**kwargs):
"""
sets the slit to be narrow and scans along and across the grating
at 500 eV to see if M0/M1 are steering the beam to the center of the grating
......
......@@ -123,6 +123,202 @@ def interactive_fit_mda(val_name,scannum,det,FWHM_or_PolyOrder,fct,**kwargs):
flagfit=2
return flagfit,val
def sotw_BLinit(branch):
"""
returns the init function for sotw
"""
if branch == 'c':
BL_init=ARPES_init
elif branch == 'd':
BL_init=kappa_init
else:
print_warning_message('Not a valid branch')
BL_init=None
return BL_init
def sotw_setup(grt,branch,wait,**kwargs):
"""
All the start_of_the_week initalization stuff
doesn't get run if kwargs['repeat']=False
"""
# checkin branch is defined and initializing BLconfig
branch=branch.lower()
BL_init = sotw_BLinit(branch)
if branch == 'd':
cam_exposure_time(m3r_camNum,0.001)
BL_init('staff',reset=True,set_folders=True,xrays=True)
switch_branch(branch)
log_name_set('StartOfTheWeek_log.txt')
log_print("\n\n================== Start Of The Week @ "+today('slash')+':\n')
#switching grating if needed
grating(grt)
###########################################################################
### stuff that requires beam
###########################################################################
### Wait for next 8AM:
if wait:
t = datetime.today()
if 0 <= t.hour <= 8:
wait_for_it(0,8,5)
else:
wait_for_it(1,8,5)
### checking branch shutter:
branch_shutter_open()
main_shutter_open()
if main_shutter_status() == False:
print_warning_message('Aborting... main shutter did not open')
return
if branch_shutter_status() == False:
print_warning_message('Aborting... '+branch+'-branch shutter did not open')
return
### checking QP ratio:
QP=ID_QP_ratio_get()[0]
if QP != 100:
foo=input('QP on!!! Continue (y or n)? >')
if foo.lower() == 'y' or foo.lower() == 'yes':
status = 'Continueing'
else:
status = 'Aborting...'
print(status)
return
### checking ID:
polarization(kwargs['mode'])
def sotw_ID_steering(detCA4,**kwargs):
"""
slit1A/ID_steering
"""
#scanning
ID_steering_scans(**kwargs)
#plotting
scanNum_h = last_mda()-1
scanNum_v = last_mda()
flagfit, h = interactive_fit_mda('H_center',scanNum_h,detCA4,1,'gauss',xrange=[-1,1])
if flagfit == '':
return
flagfit, v = interactive_fit_mda('V_center',scanNum_v,detCA4,1,'gauss',xrange=[-1,1],val_name='V_center')
if flagfit == '':
return
try:
ID_steering_message(h,v)
flag = interactive_fct()
except:
print('\nUnable to calculate ID steering')
print('steering out => move beam more positive (10 urad ~ 0.25 mm)')
print('steering up => move beam more positive (10 urad ~ 0.25 mm)')
flag = interactive_fct()
return flag
def sotw_wire(detH,detV,**kwargs):
"""
"""
#scanning
wire_scans(**kwargs)
#plotting
try:
scanNum_h = last_mda()-1
scanNum_v = last_mda()
plot_mda(scanNum_h,detH,scanNum_v,detV,title='wire-H (blue) & wire-V (orange)');plt.show()
except:
print('Unable to plot. Try:')
print("plot_mda("+str(scanNum_h)+","+str(detH)+","+str(scanNum_v)+","+str(detV)+",title='wire-H (blue) & wire-V (orange)');plt.show()")
flag = interactive_fct()
return flag
def sotw_slit_vs_mono(grt,slit_name,detDiode,**kwargs):
"""
"""
for slit_name in ['slit2B','slit1A']:
message={'slit2B': 'M1 alignment and slit center','slit1A':'slit center'}
print('\n---------- Scanning '+slit_name+':\n')
message[slit_name]
flag=2
list_position = [grt,0,0,0,0]
flag = 2
while flag>1:
#scanning
if kwargs['monoVslit_quick']:
monoVslit_quick_scan(slit_name,**kwargs)
else:
monoVslit_full_profile_scan(slit_name,**kwargs)
#plotting
c = mono_grating_density_get()/1200
scanNum_v = last_mda()-1
scanNum_h = last_mda()
if kwargs['monoVslit_quick']:
flagfit, h = interactive_fit_mda('H_center',scanNum_h,detDiode,1,'gauss',xrange=[-1,1])
if flagfit == '':
return
flagfit, v = interactive_fit_mda('V_center',scanNum_v,detDiode,c,'gauss',xrange=[-1,1])
if flagfit == '':
return
flag = interactive_fct()
print('\nBeam position - '+slit_name[-2:]+':')
print(f" - vertical: V = {round(v,3)}")
print(f" - horizontal: H = {round(h,3)}")
if slit_name == 'slit2B':
#beam steering calculations
new_roll = M0M1_steering(h,v)
list_position[2] = v
list_position[1] = h
foo = input('\nDo you want to steer M1 (y or n)?')
if foo[0].lower() == 'y':
new_roll = input2float('New M1 roll value => ',new_roll)
try:
FMB_mirror_move(1,'RZ',new_roll)
sleep(2)
FMB_mirror_get(1)
print('\nrepeating scans...')
flag == 2
except:
print('\invalid input; unable to move M1')
flag = interactive_fct()
#update M1 dictionary
foo=input('Do you want to update the M1 (y or n)? >')
if foo[0].lower() == 'y':
update_mirror_dict(1)
if flag == '':
return
elif slit_name == 'slit1A':
list_position[4] = v
list_position[3] = h
if flag == '':
return
flag = 2
#update slit dictionary
print('\nBeam center fit @ ['+grt+',2V,2H,1V,1H]:'+str(list_position))
foo=input('Do you want to update the slit dictionary (y or n)? >')
if foo[0].lower() == 'y':
slit_list=input('do you want to use '+str(list_position)+' (y or n)? >')
if foo[0].lower() == 'y':
update_slit_dict(list_position)
else:
update_slit_dict()
def StartOfTheWeek(grt,branch,wait=False,**kwargs):
"""
This should be run every at the start of every week; 50 min total.
......@@ -168,69 +364,14 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs):
print_warning_message(scan+" is not a valid scan scanType=['slit1','wire','flux','monoVslit']")
return
# checkin branch is defined and initializing BLconfig
branch=branch.lower()
if branch == 'c':
BL_init=ARPES_init
elif branch == 'd':
BL_init=kappa_init
cam_exposure_time(m3r_camNum,0.001)
else:
print_warning_message('Not a valid branch')
return
if kwargs['repeat']:
#check to see if init is defined
BL_init=sotw_BLinit(branch)
if BLconfig_branch() != branch:
BL_init('staff',reset=True,set_folders=False,xrays=True)
else:
BL_init('staff',reset=True,set_folders=True,xrays=True)
switch_branch(branch)
log_name_set('StartOfTheWeek_log.txt')
log_print("\n\n================== Start Of The Week @ "+today('slash')+':\n')
#switching grating if needed
grating(grt)
###########################################################################
### stuff that requires beam
###########################################################################
### Wait for next 8AM:
if wait:
t = datetime.today()
if 0 <= t.hour <= 8:
wait_for_it(0,8,5)
else:
wait_for_it(1,8,5)
### checking branch shutter:
branch_shutter_open()
main_shutter_open()
if main_shutter_status() == False:
print_warning_message('Aborting... main shutter did not open')
return
if branch_shutter_status() == False:
print_warning_message('Aborting... '+branch+'-branch shutter did not open')
return
sotw_setup(grt,branch,wait,**kwargs)
### checking QP ratio:
QP=ID_QP_ratio_get()[0]
if QP != 100:
foo=input('QP on!!! Continue (y or n)? >')
if foo.lower() == 'y' or foo.lower() == 'yes':
status = 'Continueing'
else:
status = 'Aborting...'
print(status)
return
### checking ID:
polarization(kwargs['mode'])
### Ready to start:
scanNum = mda_fileNum()
###########################################################################
### scanning
###########################################################################
......@@ -240,140 +381,31 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs):
print("\n\n================== Slit 1A scans:")
flag=2
while flag>1:
#scanning
ID_steering_scans(**kwargs)
#plotting
scanNum_h = last_mda()-1
scanNum_v = last_mda()
flagfit, h = interactive_fit_mda('H_center',scanNum_h,detCA4,1,'gauss',xrange=[-1,1])
if flagfit == '':
return
flagfit, v = interactive_fit_mda('V_center',scanNum_v,detCA4,1,'gauss',xrange=[-1,1],val_name='V_center')
if flagfit == '':
return
try:
ID_steering_message(h,v)
flag = interactive_fct()
except:
print('\nUnable to calculate ID steering')
print('steering out => move beam more positive (10 urad ~ 0.25 mm)')
print('steering up => move beam more positive (10 urad ~ 0.25 mm)')
flag = interactive_fct()
flag = sotw_ID_steering(detCA4,**kwargs)
if flag == '':
return
diagnostic('mesh_W','out')
###### Wire scans:
if 'wire' in kwargs['scanType']:
print("\n\n================== Slit 1A scans:")
#scanning
wire_scans(**kwargs)
#plotting
try:
scanNum_h = last_mda()-1
scanNum_v = last_mda()
plot_mda(scanNum_h,detH,scanNum_v,detV,title='wire-H (blue) & wire-V (orange)');plt.show()
except:
print('Unable to plot. Try:')
print("plot_mda("+str(scanNum_h)+","+str(detH)+","+str(scanNum_v)+","+str(detV)+",title='wire-H (blue) & wire-V (orange)');plt.show()")
flag = sotw_wire(detH,detV,**kwargs)
if flag == '':
return
###### Mono/slit scans:
if 'monoVslit' in kwargs['scanType']:
#checking that detDiode is in
if not kwargs['detDiode']:
foo=input('What is the detector number for mono scans (make sure it is IN!)? >')
detDiode=int(foo)
else:
foo=input('Is detector D'+str(kwargs['detDiode'])+' in direct beam (y or n)? >')
print("\n\n================== Mono/slit scans:")
for slit_name in ['slit2B','slit1A']:
# slit2B => M1 alignment
print('\n---------- Scanning '+slit_name+':\n')
flag=2
list_position = [grt,0,0,0,0]
while flag>1:
#scanning
if kwargs['monoVslit_quick']:
monoVslit_quick_scan(slit_name,**kwargs)
else:
monoVslit_full_profile_scan(slit_name,**kwargs)
#plotting
c = mono_grating_density_get()/1200
scanNum_v = last_mda()-1
scanNum_h = last_mda()
if kwargs['monoVslit_quick']:
flagfit, h = interactive_fit_mda('H_center',scanNum_h,detDiode,1,'gauss',xrange=[-1,1])
if flagfit == '':
return
flagfit, v = interactive_fit_mda('V_center',scanNum_v,detDiode,c,'gauss',xrange=[-1,1])
if flagfit == '':
return
flag = interactive_fct()
print('\nBeam position - '+slit_name[-2:]+':')
print(f" - vertical: V = {round(v,3)}")
print(f" - horizontal: H = {round(h,3)}")
if slit_name == 'slit2B':
#beam steering calculations
new_roll = M0M1_steering(h,v)
list_position[4] = v
list_position[3] = h
foo = input('\nDo you want to steer M1 (y or n)?')
if foo[0].lower() == 'y':
new_roll = input2float('New M1 roll value => ',new_roll)
try:
FMB_mirror_move(1,'RZ',new_roll)
sleep(2)
FMB_mirror_get(1)
print('\nrepeating scans...')
flag == 2
except:
print('\invalid input; unable to move M1')
flag = interactive_fct()
elif slit_name == 'slit1A':
list_position[2] = v
list_position[1] = h
if flag == '':
return
flag = 2
#update slit dictionary
print('\nBeam center fit @ ['+grt+',2V,2H,1V,1H]:'+str(list_position))
foo=input('Do you want to update the slit dictionary (y or n)? >')
if foo[0].lower() == 'y':
slit_list=input('do you want to use '+str(list_position)+' (y or n)? >')
if foo[0].lower() == 'y':
update_slit_dict(list_position)
else:
update_slit_dict()
#update M1 dictionary
foo=input('Do you want to update the M1 (y or n)? >')
if foo[0].lower() == 'y':
update_mirror_dict(1)
if flag == '':
return
sotw_slit_vs_mono(grt,slit_name,detDiode,**kwargs)
###### Check flux:
if 'flux' in kwargs['scanType']:
print("\n\n================== Check Flux:")
......
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