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

debug

parent e3e77f7e
No related branches found
No related tags found
No related merge requests found
......@@ -329,12 +329,12 @@ def ARPES_get_all(verbose=True):
#endstation/branch pvs
extra_pvs = ARPES_extra_pvs()
for key in extra_pvs.keys():
vals.update(key,caget(extra_pvs[key]))
vals.update({key:caget(extra_pvs[key])})
if BLconfig_xrays():
vals.update('exit_slit',slit3C_get())
vals.update({'exit_slit':slit3C_get()})
if verbose:
for key in vals:
print(key+" = "+vals[key])
print(key+" = "+str(vals[key]))
#beamline info
if BLconfig_xrays():
......
......@@ -397,9 +397,9 @@ def kappa_get_all(verbose=True):
#endstation/branch pvs
extra_pvs = kappa_extra_pvs()
for key in extra_pvs.keys():
vals.update(key,caget(extra_pvs[key]))
vals.update({key:caget(extra_pvs[key])})
if BLconfig_xrays():
vals.update('exit_slit',slit3D_get())
vals.update({'exit_slit':slit3D_get()})
mesh.get()
vals.update({'mesh':mesh.current_Amp})
......@@ -411,7 +411,7 @@ def kappa_get_all(verbose=True):
if verbose:
print("-----------------------------------------------------------")
for key in vals:
print(key+" = "+vals[key])
print(key+" = "+str(vals[key]))
print("-----------------------------------------------------------")
return vals
......@@ -975,7 +975,7 @@ def kappa_safe_state(**kwargs):
shutter_close = True; closes the D-shutter
valve_close = True; closes the D-valve
"""
kwargs.setdefault("MPA_off",True)
kwargs.setdefault("mpa_off",True)
kwargs.setdefault("shutter_close",True)
kwargs.setdefault("valve_close",True)
......@@ -984,13 +984,29 @@ def kappa_safe_state(**kwargs):
mpa.HV_off()
except:
print('MPA is not running')
branch = 'd'
if kwargs['shutter_close']:
branch_shutter_close()
branch_shutter_close(branch=branch)
if kwargs['valve_close']:
branch_valve_close()
branch_valve_close(branch=branch)
##############################################################################################################
############################## macros additional scans ##############################
##############################################################################################################
def det_set(det_name):
"""
sets the tth detector and moves the motor to tth value for the new detecotr
det_names
d3: large diode
d4: small diode
mcp: for the mpa
apd: avalanche photodiode (not currently installed)
yag: yag 'fluorescence screen'
"""
tthdet.set(det_name,move=False)
### uan moves tth and th simultaneously
def uan(tth,th):
......
......@@ -2,7 +2,6 @@ from time import sleep
from epics import caget, caput
##############################################################################################################
################################ Kappa detector class ##############################
##############################################################################################################
......@@ -24,8 +23,8 @@ class Kappa_Detector:
det_name, tth_val
"""
#det_name = caget('29idKappa:userStringSeq6.STR1')
det_name = caget(det_set_pv)
#det_name = c
det_name = caget(det_set_pv,as_string=True)
self.name = det_name
tth_val = self.motors.get('tth')
return det_name, tth_val
......
......@@ -348,9 +348,9 @@ def Octupole_get_all(verbose=True):
#endstation/branch pvs
extra_pvs = Octupole_extra_pvs()
for key in extra_pvs.keys():
vals.update(key,caget(extra_pvs[key]))
vals.update({key:caget(extra_pvs[key])})
if BLconfig_xrays():
vals.update('exit_slit',slit3D_get())
vals.update({'exit_slit':slit3D_get()})
mesh.get()
vals.update({'mesh':mesh.current})
......@@ -362,7 +362,7 @@ def Octupole_get_all(verbose=True):
if verbose:
print("-----------------------------------------------------------")
for key in vals:
print(key+" = "+vals[key])
print(key+" = "+str(vals[key]))
print("-----------------------------------------------------------")
return vals
......@@ -602,12 +602,13 @@ def Octupole_safe_state(**kwargs):
"""
kwargs.setdefault("shutter_close",True)
kwargs.setdefault("valve_close",True)
if kwargs['shutter_close']:
branch_shutter_close()
branch_shutter_close(branch='d')
if kwargs['valve_close']:
branch_valve_close()
branch_valve_close(branch='d')
branch_valve_close(branch='e')
\ No newline at end of file
from cgi import print_arguments
from iexcode.instruments.VLS_PGM import mono_energy_get
from epics import caget, caput
from iexcode.instruments.utilities import print_warning_message
from iexcode.instruments.FMB_mirrors import *
##############################################################################################################
################################ M3R ##############################
##############################################################################################################
......@@ -113,9 +114,6 @@ def m3r_switch_branch(branch,verbose=True):
sleep(.1)
FMB_mirror_get(3,verbose=True)
##############################################################################################################
################################ M3R alignment obsolete now in data base lives in 29idKappa ###########
##############################################################################################################
def m3r_centroid(acq_time=None,verbose=False):
'''
......@@ -132,26 +130,4 @@ def m3r_centroid(acq_time=None,verbose=False):
m3rRY = round(caget(M3R_pitch),4)
if verbose:
print('(position, sigma, total intensity, integration time (s), mirror pitch):')
return position,sigma,intensity,acq_time,m3rRY
def _m3r_align_start(pxl=None):
if pxl == None:
pxl = caget(M3R_align_pv+'desired_pixel')
caput(M3R_align_pv+'desired_pixel',pxl)
caput(M3R_align_pv+'startAlign',1,wait=True,timeout=180)
def m3r_align(pxl=None):
if iex.BL.branch == 'd':
print('\nalign_m3r()')
try:
_m3r_align_start()
sleep(1)
if mono_energy_get()>2100:
_m3r_align_start()
sleep(1)
sleep(1)
min_m3r=caget(M3R_align_pv+'motor_min')
if m3r_RY_pos_sp_get() == min_m3r:
_m3r_align_start()
except:
print('Unable to align; check camera settings.')
\ No newline at end of file
return position,sigma,intensity,acq_time,m3rRY
\ No newline at end of file
from cgi import print_arguments
from epics import caget, caput
import iexcode.instruments.cfg as iex
from iexcode.instruments.VLS_PGM import mono_energy_get
from iexcode.instruments.m3r import *
from iexcode.instruments.shutters import *
##############################################################################################################
### piezo based m3R alignment ###
##############################################################################################################
def m3r_align_pv_dictionary():
cam_PR = '29id_ps6:cam1:'
cam_stats_pv = '29id_ps6:Stats1:'
piezo_pv = '29idb:piezo1:Voltage'
desired_pixel= '29idKappa:align_m3r:desired_pixel'
d = {
'desired_pixel':desired_pixel,
'centroid_x':cam_stats_pv+'CentroidX_RBV',
'max_value':cam_stats_pv+'MaxValue_RBV',
'acquire_time':cam_PR+"AcquireTime",
'acquire':cam_PR+"Acquire",
'piezo_voltage': piezo_pv
}
return d
### camera functions
def m3r_align_stats_centroid_posx():
"""
gets the current pixel value
"""
val=caget(m3r_align_pv_dictionary()['centroid_x'])
return(val)
def m3r_align_max_value():
"""
gets the maximum number of counts on camera image
"""
val = caget(m3r_align_pv_dictionary()['max_value'])
return val
def m3r_align_acq_time_get():
"gets the acquisition time for the camera"
val = caget(m3r_align_pv_dictionary()['acquire_time'])
return val
def m3r_align_acq_time_set(time_sec):
"""
sets the acquisition time for the camera
"""
caput(m3r_align_pv_dictionary()['acquire_time'],time_sec,wait=True,timeout=180)
def m3r_align_acq_time_optimize(int_min=140, int_max=240):
"""
adjusts the camera acquisition time to have the max intensity between int_min, and int_max
"""
while True:
max_int = m3r_align_max_value()
if int_min > max_int > int_max:
current_acq=m3r_align_acq_time_get()
if max_int > int_max:
m3r_align_acq_time_set(current_acq/2)
if max_int<int_min:
m3r_align_acq_time_set(current_acq*1.5)
sleep(1)
def m3r_align_piezo_get():
"""
gets the current piezo voltage
"""
val = caget(m3r_align_pv_dictionary()['piezo_voltage'])
return(val)
def m3r_align_piezo_set(voltage):
"""
sets the current piezo voltage
"""
caput(m3r_align_pv_dictionary()['piezo_voltage'],voltage,wait=True,timeout=180)
def m3r_align_pixel2voltage(pixel):
# 0.14V = 1 pxl
# higher voltage lowers pixel
voltage = pixel*0.14
return(voltage)
def m3r_align_move_pitch_piezo(pixel):
"""
sets the m3r piezo voltage to shift by the desired number of pixels on the camera images
"""
voltage = m3r_align_pixel2voltage(pixel)
m3r_align_piezo_set(voltage)
sleep(0.5)
return m3r_align_stats_centroid_posx()
def m3r_align_check_requirements(target_pixel):
"""
checks the following:
- the target pixel is within the camera range
- d-shutter is open
returns True/False if ready
"""
pixel_min = 30
pixel_max = 210
if pixel_min < target_pixel < pixel_max :
print_warning_message('m3r target pixel is outside of limits.')
return False
shutter_open = branch_shutter_status(branch='d')
if shutter_open == False:
foo=input_d('Shutter D is closed, do you want to open it (Y or N)? >')
if foo == 'Y'.lower() or foo == 'y' or foo == 'yes'.lower():
branch_shutter_open('d')
else:
print('Aborting...')
return False
if caget(m3r_align_pv_dictionary()['acquire']) == 'Done':
caput(m3r_align_pv_dictionary()['acquire'],'Acquire')
def m3r_align(target_pixel=None, precision=0.5, num_tries=10, verbose=True):
"""
aligns m3r to target_pixel (if None then uses the desired pixel from the database)
precision = how close the actual and the target value need to be in pixels
try_num = maximum number of trys to get there
"""
if target_pixel == None:
target_pixel = m3r_align_pv_dictionary()['desired_pixel']
if iex.BL.branch()=='d':
# coarse aligment
pixel_delta = m3r_align_stats_centroid_posx()-target_pixel
voltage_delta = m3r_align_pixel2voltage(pixel_delta)
target_voltage = m3r_align_piezo_get() - voltage_delta
if not 0 < target_voltage < 30:
print_warning_message('m3r align voltage outside of limits.')
return
else:
m3r_align_move_pitch_piezo(target_voltage)
try_num = 1
while True:
pixel_delta = m3r_align_stats_centroid_posx()-target_pixel
if (pixel_delta) <= precision:
break
elif try_num > num_tries:
break
else:
#fine alignment
if pixel_delta<0:
m3r_align_move_pitch_piezo(starting_v-0.05)
sleep(0.5)
if pixel_delta>0:
m3r_align_move_pitch_piezo(starting_v+0.05)
sleep(0.5)
if verbose:
print('m3r pixel =',round(m3r_align_stats_centroid_posx(),1))
print('m3r voltage =',round(m3r_align_piezo_get(),2))
##############################################################################################################
################################ M3R alignment obsolete now in data base lives in 29idKappa ###########
##############################################################################################################
"""
def _m3r_align_start(pxl=None):
if pxl == None:
pxl = caget(M3R_align_pv+'desired_pixel')
caput(M3R_align_pv+'desired_pixel',pxl)
caput(M3R_align_pv+'startAlign',1,wait=True,timeout=180)
def m3r_align(pxl=None):
if iex.BL.branch == 'd':
print('\nalign_m3r()')
try:
_m3r_align_start()
sleep(1)
if mono_energy_get()>2100:
_m3r_align_start()
sleep(1)
sleep(1)
min_m3r=caget(M3R_align_pv+'motor_min')
if m3r_RY_pos_sp_get() == min_m3r:
_m3r_align_start()
except:
print('Unable to align; check camera settings.') """
\ No newline at end of file
......@@ -5,6 +5,7 @@ import iexcode.instruments.cfg as iex
branch_GVs={
'c':('10'),
'd':('14'),
'e':('18'),
}
def branch_valve_close(branch=None):
......
......@@ -15,13 +15,13 @@ from iexcode.instruments.Keithley_current_amplifiers import *
from iexcode.instruments.diagnostics import *
from iexcode.instruments.FMB_mirrors import FMB_mirror_get
from iexcode.instruments.IEX_VPU import *
from iexcode.instruments.m3r import m3r_align,m3r_branch,m3r_switch_branch,m3r_position_dictionary
from iexcode.instruments.m3r import m3r_branch,m3r_switch_branch,m3r_position_dictionary
from iexcode.instruments.shutters import *
from iexcode.instruments.slits import *
from iexcode.instruments.utilities import print_warning_message,make_table
from iexcode.instruments.valves import *
from iexcode.instruments.VLS_PGM import *
from iexcode.instruments.m3r_align import m3r_align
mpa = iex.mpa
def safe_state():
......
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