#!/usr/bin/env python # # Main library for PHOENIX DAQ gui # # written by Thomas Huthwelker 2011- # # ........... other helping rouintes # Changes # # 2.12.2014 Add Ketek as a additional Fluorescence detector option (This is a detctor which uses only channel 2) (T.Huthwelker) # # 16.3.2015 Get some bugs out of software (T.Huthwelker) # # 16.3.2015 implenet Ketek properly now also for imaging (T.Huthwelker) # # 10.10.2015 # d_list_fluo =[-1] changed 10.10. Need to give initial definition for d_list_fluo, # as it will remain undefined of no Fluo detector is used. # Define channel -1 as number for no fluo detector ' # # 1.11.2015 # add INstall changes from 10.10.2015 # extend predefeind detector group for Mono encoders by adding values for T1, T2, Theta and # monitoring the differences values and encoder positions (field val,rbv,diff, rep), and voltages from LVDT # decrease delay for all preactions to 50 ms ste delays in detector DAQ to 75 ms (100 before) to be tested. # # 28.8.2017 put call to writing of header into backgournd preocess tro speed up measurements # ........... other helping rouintes import math import time def create_rbv_val(ch): ll=len(ch) print ll print ch[ll-4:ll] extension=ch[ll-4:ll] if extension == ".RBV": ch_rbv = ch ch_val = ch[0:ll-4]+".VAL" print 'Channel has extension .rbv' if extension == ".VAL": ch_rbv = ch[0:ll-4]+".RBV" ch_val = ch print 'Channel has extension .VAL' if (extension <> ".VAL") and (extension <> ".RBV"): ch_rbv = ch ch_val = ch print 'Channel has no extension, used chanel as it is for .VAl and .RBV ' # endif print ch_rbv print ch_val return [ch_rbv,ch_val] def get_epicsPV(channel): try: from CaChannel import * from epicsMotor import * from epicsPV import * import time import string except: try: sys.path.insert(0, os.path.expandvars("$SLSBASE/sls/lib/python22/CaChannel")) sys.path.insert(0, os.path.expandvars("/exchange/share/mXAS/pyth/mod")) from CaChannel import * from epicsPV import * except: os.system ("xkbbell") os.system ("xmessage -nearmouse -timeout 30 \ -buttons \"\" \"epicsPV or CaChannel module cannot be found\"") sys.exit(1) # endtry # endtry n_tries=0 tt=0 b=-1 while tt==0: try: #print ' try reading channel' ,channel,'Tr Nr ',tt b=epicsPV(channel).getw() tt=1 except: print ' \n ' print 'trouble reading epics PV..',channel,' try again ' print ' \n ' n_tries=n_tries+1 tt=0 time.sleep(.25) if n_tries==20: tt=1 print 'give up after 20 trying reading channel ' sys.exit("*** Program STOP ***") #endif #endtry #endwhile return b def error_stop(info_line): import time print ' --------------------------------------------- ' print ' ' print ' EMERGENCY STOP ' print ' ' print info_line print ' ' print ' ' print ' ' print ' ' print ' ' print ' script stops in 30 sec ' print ' ' print ' ' print ' Window can be closed or closes automatically' print ' --------------------------------------------- ' time.sleep(30) stop # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ def remove_blanks_from_str(xx): box='' for i in range(len(xx)): if xx[i:i+1] <> ' ': box=box+xx[i:i+1] #endif # endfor return box # =======================================++++++++++++++++++++++++++++++++++++++ def create_str_list(n): d=range(n) for i in range(len(d)): d[i]=' ' return d # ================================== def create_int_zeros(n): d=range(n) for i in range(len(d)): d[i]=d[i]-d[i] return d # .............................................. def create_real_zeros(n): d=range(n) for i in range(len(d)): d[i]=(d[i]-d[i])*0.0 return d # ............................ def array_to_string(array_in): print array_in positions_str=' ' for x in array_in: positions_str=positions_str+' ' + str(x) return positions_str # ............................ def write_guard(f,params): print params if get_epicsPV('X07MB-PC-PSCAN:GUARD') == 1: f.write(' \n ') # -..... close dimension 1 # =============================== XTREME ============================== f.write(' \n') # f.write(' \n') # f.write(' \n') # f.write(' \n') f.write(' \n ') # -..... close dimension 1 #endif #end write_guard # .......................... .VISUALIZATIONS ... def write_visualization(f,params): if params['Type'] <> "MatrixPlot": f.write(' \n ') # endif if params['Type'] == "MatrixPlot": print 'CREATE MATRIX PLOT' print params['DATA'] print params['DATA'].count(' ') if params['DATA'].count(' ') == 0: f.write(' \n ') # endif # endif # +++++++++++++ # ............................................. Special visualizations (1-D) def special_visualization(f,g,params): # Type may be 'LinePlot' or MatrixPlot # routine plots predefined and active detector sets as function of coordinate X (Must be FDA Id) if (('PL_KEITHLEY1' in g['detectors_to_plot']) and ('KEITHLEY1' in g['detectors'])): write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'I0_KEITHLEY1' , 'Title' : 'KEITHLEY1 (I0)'+'=f('+params['Id_X']+')'}) #endif if (('PL_KEITHLEY2' in g['detectors_to_plot']) and ('KEITHLEY2' in g['detectors'])): write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'I1_KEITHLEY2' , 'Title' : 'KEITHLEY2 (I1)'+'=f('+params['Id_X']+')'}) #endif if (('PL_KEITHLEY3' in g['detectors_to_plot']) and ('KEITHLEY3' in g['detectors'])): write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'KEITHLEY3' , 'Title' : 'KEITHLEY3'+'=f('+params['Id_X']+')'}) #endif if ('MOENCH' in g['detectors']): write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'KEITHLEY3' , 'Title' : 'KEITHLEY3'+'=f('+params['Id_X']+')'}) # ............................ BL PRESSURES ........................ print g['detectors_to_plot'] print g['detectors'] print 'type', params['Type'] if (('PL_CAM1_POS' in g['detectors_to_plot']) and ('CAM1_POS' in g['detectors'])): write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'CentroidX_RBV CentroidY_RBV' , 'Title' : 'Centroid X, Centroid Y '+'=f('+params['Id_X']+')'}) write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'SigmaX_RBV SigmaY_RBV' , 'Title' : 'Sigma X Sigma Y '+'=f('+params['Id_X']+')'}) #endif #'PLot user detector' if (('PL_USER_DET' in g['detectors_to_plot']) and ('USER_DET' in g['detectors'])): y_string='' for i in range(len(g['User_detector_fda_id'])): y_string=y_string+' '+g['User_detector_fda_id'][i] # endfor print write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'USER DETECTORS '+y_string}) # endif if (('PL_BL_PRESS' in g['detectors_to_plot']) and ('BL_PRESS' in g['detectors'])): print g['ID_BL_PRESS'] print len(g['ID_BL_PRESS']) y_string=' ' for i in range(len(g['ID_BL_PRESS'])): y_string=y_string+' '+g['ID_BL_PRESS'][i] write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'Beamline pressures'+'=f('+params['Id_X']+')'}) #endif if (('PL_BL_TEMP' in g['detectors_to_plot']) and ('BL_TEMP' in g['detectors'])): print g['ID_BL_TEMP'] print len(g['ID_BL_TEMP']) y_string=' ' for i in range(len(g['ID_BL_TEMP'])): y_string=y_string+' '+g['ID_BL_TEMP'][i] write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'Beamline temperatures'+'=f('+params['Id_X']+')'}) #endif # ................. MONO TEMPERATURES ............... if (('PL_MONO_TEMP' in g['detectors_to_plot']) and ('MONO_TEMP' in g['detectors'])): # plot first 4 important temperatures y_string=' ' for i in range(4): y_string=y_string+' '+g['ID_MONO_TEMP'][i] # endfor write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'Mono Temp (Theta,T1,T2,TRZ)'+'=f('+params['Id_X']+')'}) # plot all other Temperature sensors y_string=' ' for i in range(6,len(g['ID_MONO_TEMP'])): y_string=y_string+' '+g['ID_MONO_TEMP'][i] # endfor write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'Mono Temp '+'=f('+params['Id_X']+')'}) #endif # .......... encoders... if (('PL_MONO_ENC' in g['detectors_to_plot']) and ('MONO_ENC' in g['detectors'])): write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'ROLL1_V ROLL2_V PITCH2_V' , 'Title' : 'MONO LVDT [V]'+'=f('+params['Id_X']+')'}) write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'ROLL1_MUR ROLL2_MUR PITCH2_MUR' , 'Title' : 'MONO ROLL and PITCH [MUR]'+'=f('+params['Id_X']+')'}) write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'ROLL1_VOLT ROLL2_VOLT PITCH2_VOLT' , 'Title' : 'ROLL1 VOLT ROLL2_VOLT PITCH_VOLT [V]'+'=f('+params['Id_X']+')'}) write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'ROLL1_DIFF ROLL2_DIFF PITCH2_DIFF' , 'Title' : 'ROLL1 DIFF ROLL2_DIFF PITCH_DIFF [MUR]'+'=f('+params['Id_X']+')'}) write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : 'T1_DIFF T2_DIFF THETA_DIFF' , 'Title' : 'T1_DIFF T2_DIFF THETA_DIFF '+'=f('+params['Id_X']+')'}) #endif if (('PL_ES1_PRESS' in g['detectors_to_plot']) and ('ES1_PRESS' in g['detectors'])): y_string=' ' for i in range(len(g['ID_ES1_PRESS'])): y_string=y_string+' '+g['ID_ES1_PRESS'][i] # endfor print 'ystring' print y_string print 'pt',params['Type'] print 'idy',params['Id_X'] print 'py',params['Id_Y'] write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'XBPM4 '+'=f('+params['Id_X']+')'}) #endif if (('PL_XBPM4' in g['detectors_to_plot']) and ('XBPM4' in g['detectors'])): # first plot current on 4 pads y_string=' ' for i in range(len(g['ID_XBPM4'])): y_string=y_string+' '+g['ID_XBPM4'][i] # endfor print 'ystring' print y_string write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'XBPM4 '+'=f('+params['Id_X']+')'}) # plot position on XBPM y_string=' ' for i in range(len(g['ID_XBPM4_POS'])): y_string=y_string+' '+g['ID_XBPM4_POS'][i] # endfor print 'ystring' print y_string write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'Beam position on XBPM4 '+'=f('+params['Id_X']+')'}) #endif if (('PL_XBPM3' in g['detectors_to_plot']) and ('XBPM3' in g['detectors'])): y_string=' ' for i in range(len(g['ID_XBPM3'])): y_string=y_string+' '+g['ID_XBPM3'][i] # endfor write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'XBPM3 '+'=f('+params['Id_X']+')'}) # plot position on XBPM y_string=' ' for i in range(len(g['ID_XBPM3_POS'])): y_string=y_string+' '+g['ID_XBPM3_POS'][i] # endfor print 'ystring' print y_string write_visualization(f,{ 'Type': params['Type'] , 'X' : params['Id_X'] , 'Y' : params['Id_Y'] , 'DATA' : y_string , 'Title' : 'Beam position on XBPM3 '+'=f('+params['Id_X']+')'}) #endif # ............................................. END Special visualizations (1-D) # ................... write postactions channel type def post_action_channel_action(channel,value,operation,type,delay): post_action_channel_action=' \n ' return post_action_channel_action def post_action_shell_action(command,exitvalue): post_action_channel_action=' \n ' return post_action_channel_action # ______________ routine to creat strings for action and preaction def write_shell_action(f,command): f.write(' ') # end routine # _______________________________________________________________-- def write_action_channel_action(f,params): f.write(''+'\n') # end routine # _______________________________________________________________-- def write_preaction_channel_action(f,params): preaction_channel_action = ''+'\n' f.write(preaction_channel_action) # =========================================================== def Write_Variable_Definitions(f,g): # Write the default vaiables, to be defined in general f.write('') f.write('') f.write('') # end Write_Variable_Definitions # =========================================================== def write_preactions(f,g): print g['preactions'] print len(g['preactions']) # write write currentt data file name into EPICS channel # this is done by use of a shell script # TMP CHANGES TO CODE 10.11.2018 write_shell_action(f,"/sls/X07MB/data/settings/Scripts/GUI_X07MB/X_X07MB_fda_file_to_EPICS.sh ${FILENAME}") # old version obosolete 14.4.2014 : 10.11.2018 disabled.. # first write the header file (save_phoenix) (tmp disable 10.11.2018) write_shell_action(f,"/sls/X07MB/data/settings/Scripts/GUI_X07MB/X_X07MB_fda_write_header.py &") # write header file # write_shell_action(f,"/sls/X07MB/data/settings/Scripts/GUI_X07MB/X_X07MB_fda_write_header.py -F ${FILENAME}") # ............ Now write default preactions which arm the data aquisition for i in range(len(g['preactions'])): write_preaction_channel_action(f,g['preactions'][i]) # endfor if 'MOENCH' in g['detectors']: print(' finally create dir to make sure moench files are write to correct dir') #write_shell_action(f,"/sls/X07MB/data/x07mbop/Data1/Commissioning/Develop/Develop_Moench/X_X07MB_Moench.py &") write_shell_action(f,"/sls/X07MB/data/x07mbop/Data1/Commissioning/Develop/Develop_Moench/X_X07MB_Moench.py ") #endif # ............ second write the user defined preactions... if g['CH_INITIAL'][0] <> 'NO_INITIAL_VALUES': for i in range(len(g['CH_INITIAL'])): user_preaction={'channel' : g['CH_INITIAL'][i],'value' : str(g['CH_INITIAL_V'][i]) ,'operation' : 'put' ,'type' : 'String' ,'delay' : '.1'} print user_preaction write_preaction_channel_action(f,user_preaction) # endfor # endif # .................... write default post actions.... def write_default_postactions(f,g): f.write(post_action_shell_action('/sls/X07MB/data/settings/Scripts/GUI_X07MB/X_X07MB_write_filename_to_file.sh ${FILENAME} &','0')) # post action for MONCH reset f.write(post_action_shell_action('/sls/X07MB/data/x07mbop/Data1/Commissioning/Develop/Develop_Moench/X_X07MB_reset_Moench.py &','0')) f.write(post_action_channel_action('X07MB-OP2:START-CSMPL','1','put','String','0.1')) # finally close shutter PHOENIX I f.write(post_action_channel_action('X07MB-OP-WV1:WT_SET','0','put','String','0.1')) f.write(post_action_channel_action('X07MB-ES1:userCalc4.INPL','0','put','String','2')) if 'MOENCH' in g['detectors']: print('missing...') #endif #endif # ========================================================== def write_detector_actions(f,g): print g['detector_actions'] print len(g['detector_actions']) for i in range(len(g['detector_actions'])): write_action_channel_action(f,g['detector_actions'][i]) # endfor write_guard(f,{'Channel' : 'ACOAU-ACCU:OP-MODE' ,'Value' : 6 }) # For PHOENIX II chek whether MONO is initialzed #f.write(' \n') #f.write(' \n') #f.write(' \n') #f.write(' \n') # ______________ routine to write positioner # ........................... def write_start_positioner(f,params): # routine opens positioner (needed to write region positioner with several regions..) # later add possibility to have different regions here.. # f.write(' \n') if params['Ch_done'] <> 'None': f.write(' \n') else: f.write(' \n') # ______________ routine to write individual regions for region positioner.. def write_region(f,params): f.write(' \n') f.write(' \n ') f.write('' + str(params['V_ini']) + ' \n ' ) f.write(''+str(params['V_final'])+'') f.write(''+str(params['V_delta'])+' \n') print params.keys() print 'Not_close_region' in params.keys() if 'Not_close_region' in params.keys(): print 'do not write region close ' else: print 'close region (Default)' f.write(' \n') # endif # .......................................................... def write_EXAFS_region(f,g): # this routine just adds the region definitione needed to define a constant k spacing scan # print 'in write_EXAFS' print g['n_exafs'] print g['e_ex_e_i'] print g['e_ex_e_f'] # Eini print g['e_ex_k_i'] # k ini print g['e_ex_k_f'] # k final print g['e_ex_d_i'] # Delta_E (at begin) print g['e_ex_ncy'] print g['e_ex_ncy_f'] print g['e_ex_nst'] print g['e_ex_t'] print 'sart loop' ch_preaction='X07MB-OP2:TOTAL-CYCLES' for i in range(g['n_exafs']): print i # first write region (for now stet # cycles to, # set cycles to initial value of e_ex_ncy write_region(f,{'V_ini' : g['e_ex_k_i'][i] ,'V_final' : g['e_ex_k_f'][i] ,'V_delta' : g['e_ex_d_i'][i] ,'Ch_preaction' : ch_preaction ,'Ch_preaction_value' : g['e_ex_ncy'][i] ,'Not_close_region' : 0}) # close region later as we need to add a function here... #endfor # Now write the function for EXAFS f.write(' \n') f.write('') f.write('') f.write(' \n') f.write(' \n') f.write(' \n') # end write_EXAFS_region # .......................................................... def write_array_positioner(f,params): print params # case 1 use readback value for positioner (this is the default) if params['Use_done_value'] == 0: f.write('\n') # endif # case 2 use done value for positioner (e.g. for soft motors) # case II use done value must be 1 if positioner is finished. Use settling time of 0.05 sec. This is the time likely needed to change the done field to 'moving' state. if params['Use_done_value'] == 1: f.write('\n') # endif f.write('' + array_to_string(params['Positions']) + ' \n') # write preactions... if params.has_key('Ch_preaction'): f.write(' \n ') #endif f.write(' \n') #, 'Channel_done': g['p_done'][i] #, 'Use_done_value': g['p_done_switch'][i] def write_linear_positioner(f,params): # ... routine write linear positioner. # # f----- file object for writing... # # keys in list params for input are: # # 'Channel' # 'Channel_rbv' # 'Settling_time' # 'Id' # 'V_ini' # 'V_final' # 'V_delta' # # # ================================================= if params['Use_done_value'] == 0: f.write('' ) # endif if params['Use_done_value'] == 1: f.write('' ) # endif f.write('' + str(params['V_ini']) + ' \n') f.write('' + str(params['V_final']) + ' \n') f.write('' + str(params['V_delta']) + ' \n') f.write(' \n') def write_function_positioner_MOENCH(f,params): # ... routine write fcuntion positioner. # # f----- file object for writing... # # keys in list params for input are: # # 'Channel' # 'Channel_rbv' # 'Settling_time' # 'Id' # 'V_ini' # 'V_final' # 'V_delta' # # # ================================================= if params['Use_done_value'] == 0: f.write('' ) # endif if params['Use_done_value'] == 1: f.write('' ) # endif f.write('' + str(params['V_ini']) + ' \n') f.write('' + str(params['V_final']) + ' \n') f.write('' + str(params['V_delta']) + ' \n') f.write(' \n') f.write('') f.write('') f.write(' \n') f.write(' \n') f.write(' \n') # end fucntion_positiner_MOENCH def write_all_detectors(f,g): print g['detectors'] # .............. First store set values of standard positioner: for i in range(len(g['p_channel'])): if g['p_id'][i] <> ' ': # change 3.5.2012: do not write positioniner, # if there is not positioner write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['p_channel'][i] ,'Id' : g['p_id'][i] +'_set'}) #endif # endfor # the write a few other standard detectors as well: # in case CCD's are used write the number of the image if 'MOENCH' in g['detectors']: # special case for using Moench detector plot also the file number of general file write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-ES1-SD1:cam1:FileNumber_RBV' ,'Id' : 'MOENCH_FN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-ES1-SD1:TIFF1:FileNumber_RBV' ,'Id' : 'MOENCH_TIFF_FN'}) #endif write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['e_channel'] ############## general g ,'Channel' : 'X07MB-OP-MO:E-SET' ############## PHOENIX ########### # ,'Channel' : 'X07MA-PHS-E:GO.A' ############## XTREME ########### ,'Id' : 'Energy_set'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP-MO:BEAM-OFS' ,'Id' : 'Mono_offset'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'ARIDI-PCT:CURRENT' ,'Id' : 'I_SLS'}) # write user defined detectors if g['CH_User_detector'] <> ['noUserDetector']: for i in range(len(g['CH_User_detector'])): print i write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['CH_User_detector'][i] ,'Id' : g['User_detector_fda_id'][i]}) #endfor #endif # write fluo detectors................... # first set some default values for the case of no FLUO detector n_det_vortex = 0 n_roi_vortex = -1 channel_roi_vortex = -1 id_roi_vortex = '-1' id_trueicr_vortex = '-1' id_icr_vortex = '-1' id_ocr_vortex = '-1' id_eltm_vortex = -1 id_ertm_vortex = -1 # write Keithleys............ if 'KEITHLEY1' in g['detectors']: print ' write Detector Keithley 1' write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_07:MEAN' ,'Id' : 'I0_KEITHLEY1'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP-KEITH1:setGain' ,'Id' : 'KEITHLEY1_GAIN'}) #endif if 'KEITHLEY2' in g['detectors']: print ' write Detector Keithley 2' write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_08:MEAN' ,'Id' : 'I1_KEITHLEY2'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP-KEITH2:setGain' ,'Id' : 'KEITHLEY2_GAIN'}) #endif if 'KEITHLEY3' in g['detectors']: print ' write Detector Keithley 3' write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_06:MEAN' ,'Id' : 'KEITHLEY3'}) #write_detector(f,{'Det_type' : 'ScalarDetector' # ,'Data_type' : 'Double' # ,'Channel' : 'X07MB-OP-KEITH3:setGain' # ,'Id' : 'KEITHLEY3_GAIN'}) #endif if 'XBPM3' in g['detectors']: print ' write Detector XBPM3 ' write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2:LCAD3-GAIN' ,'Id' : 'XBPM3_GAIN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_14:CUR-MEAN' ,'Id' : 'XBPM3_SAI14_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_15:CUR-MEAN' ,'Id' : 'XBPM3_SAI15_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_16:CUR-MEAN' ,'Id' : 'XBPM3_SAI16_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_17:CUR-MEAN' ,'Id' : 'XBPM3_SAI17_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP-BPM3:POSX' ,'Id' : 'XBPM3_POSX'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP-BPM3:POSY' ,'Id' : 'XBPM3_POSY'}) #endif if 'XBPM4' in g['detectors']: print ' write Detector XBPM 4' write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2:LCAD3-GAIN' ,'Id' : 'XBPM4_GAIN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_19:CUR-MEAN' ,'Id' : 'XBPM4_SAI19_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_20:CUR-MEAN' ,'Id' : 'XBPM4_SAI20_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_21:CUR-MEAN' ,'Id' : 'XBPM4_SAI21_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP2-SAI_22:CUR-MEAN' ,'Id' : 'XBPM4_SAI22_CUR_MEAN'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP-BPM4:POSX' ,'Id' : 'XBPM4_POSX'}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : 'X07MB-OP-BPM4:POSY' ,'Id' : 'XBPM4_POSY'}) #endif # ........... vortex 4-element if 'Vortex' in g['detectors']: n_det = 4 [n_det_vortex,n_roi_vortex,channel_roi_vortex ,id_roi_vortex,channel_roi_vortex_dxp,id_roi_vortex_dxp,id_icr_vortex,id_trueicr_vortex,id_ocr_vortex ,id_eltm_vortex,id_ertm_vortex]=write_vortex(f,g,n_det) else: # The next line makes sure that the variables will be defined in any case . # The will be overwriten with reasonable numbers, in case either KETEK or ROENTEK are chosen [n_det,n_det_vortex,n_roi_vortex,channel_roi_vortex,id_roi_vortex,channel_roi_vortex_dxp,id_roi_vortex_dxp,id_icr,id_true_icr_vortex,id_ocr,id_eltm,id_ertm]=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1] #endif print n_roi_vortex # ........... Roentex via XMAP 1-element if 'ROENTEC_XMAP' in g['detectors']: n_det=1 [n_det_vortex,n_roi_vortex,channel_roi_vortex ,id_roi_vortex,channel_roi_vortex_dxp,id_roi_vortex_dxp,id_icr_vortex,id_trueicr_vortex,id_ocr_vortex ,id_eltm_vortex,id_ertm_vortex]=write_vortex(f,g,n_det) #endif print id_roi_vortex print n_det # ........... KETEK via XMAP 1-element if 'KETEK_XMAP' in g['detectors']: n_det=1 [n_det_vortex,n_roi_vortex,channel_roi_vortex ,id_roi_vortex,channel_roi_vortex_dxp,id_roi_vortex_dxp,id_icr_vortex,id_trueicr_vortex,id_ocr_vortex ,id_eltm_vortex,id_ertm_vortex]=write_vortex(f,g,n_det) #endif print id_roi_vortex print n_det # beamline pressures if 'BL_PRESS' in g['detectors']: for i in range(len(g['ID_BL_PRESS'])): print i,g['CH_BL_PRESS'][i],g['ID_BL_PRESS'][i] write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['CH_BL_PRESS'][i] ,'Id' : g['ID_BL_PRESS'][i]}) # endif if 'BL_TEMP' in g['detectors']: for i in range(len(g['ID_BL_TEMP'])): print i,g['CH_BL_TEMP'][i],g['ID_BL_TEMP'][i] write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['CH_BL_TEMP'][i] ,'Id' : g['ID_BL_TEMP'][i]}) # endif if 'MONO_TEMP' in g['detectors']: for i in range(len(g['ID_MONO_TEMP'])): print i,g['CH_MONO_TEMP'][i],g['ID_MONO_TEMP'][i] write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['CH_MONO_TEMP'][i] ,'Id' : g['ID_MONO_TEMP'][i]}) # endif if 'MONO_ENC' in g['detectors']: for i in range(len(g['ID_MONO_ENC'])): print i,g['CH_MONO_ENC'][i],g['ID_MONO_ENC'][i] write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['CH_MONO_ENC'][i] ,'Id' : g['ID_MONO_ENC'][i]}) # endif if 'ES1_PRESS' in g['detectors']: for i in range(len(g['ID_ES1_PRESS'])): print i,g['CH_ES1_PRESS'][i],g['ID_ES1_PRESS'][i] write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['CH_ES1_PRESS'][i] ,'Id' : g['ID_ES1_PRESS'][i]}) # endif # write detector group microscope position if 'CAM1_POS' in g['detectors']: for i in range(len(g['ID_CAM1_POS'])): print i print i,g['CH_CAM1_POS'][i],g['ID_CAM1_POS'][i] write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : g['CH_CAM1_POS'][i] ,'Id' : g['ID_CAM1_POS'][i]}) # endif return n_det_vortex,n_roi_vortex,channel_roi_vortex,id_roi_vortex,channel_roi_vortex_dxp,id_roi_vortex_dxp,id_icr_vortex,id_trueicr_vortex,id_ocr_vortex,id_eltm_vortex,id_ertm_vortex #............................... end ........ def write_detector(f,params): print params if params['Det_type'] =='ScalarDetector': f.write(' \n ') # endif if params['Det_type'] =='ArrayDetector': f.write(' \n ') if params['Det_type'] =='String': f.write(' \n ') # end routine # ============================================================= def write_vortex(f,g,n_det): # this routine write all detectors for the VORTEX detector # Author T.Huthwelker, October 2011 # ------------------------------------------------ # input # f file object (xml file) # g readout from user gui as defined in routine get_channels # g is a structures variable (i.e. variable with directory) # from g we need these entries # g['n_roi_for_xas'] : Roi number, which is used in XAS measurements # ------------------------------------------------ # -------- configuration parameter for thie routine, might be added as input parameter later. n_roi = g['n_roi'] # get number of rois as determined from XMAP software..... # the number of rois from the actual entries in the XMAP software ch_base_vortex=g['beamline']+'-XMAP:mca' ch_base_vortex_dxp=g['beamline']+'-XMAP:dxp' #..variable channel_roi contains epics channels fo all rois available # now create 2-D list to store all rois for all detectors and # as the corresponding id as used in XML script. Here we nake sure that we define only the ID values for the rois used later # This will alow in later use of these variable, just to work through the list id_roi_this_detector. # for the case XMAP_save_only_xas_roi, we reduce the list to one single value in list id_roi_this_detector. # UNfortunatly, we need to reset the variable n_roi to 1, as we use only one single roi here... # It is a quite bad looking code... # g['Id_XMAP_roi_by_name'] stores roi names ast list # g[XMAP_roi_numbers'] stores number of rois in Id list as as list # new list based code... print '......... use all rois as detectors...' print g['XMAP_save_only_xas_roi'] print g['Id_XMAP_roi_by_name'] print g['XMAP_roi_numbers'] print g['n_roi'] d_list =g['d_list_fluo'] # get the list, which contains the numbers of the choosen detectors n_det_from_list = len(d_list) # only local variable. In principle g['n_det_fluo'] should contain the same number... #for i in range(n_det): # =============== CHANGE # 16.4.2015 start adding roi readout from SCA variable det_nr=-1 # counts detectors used, if zero start ne list, if higher, add elemenst to list print 'ddddddddddddddddd' #print ch_base_vortex for i in d_list: det_nr=det_nr+1 # inner loop: walk through all regions of interest.... for j in range(len(g['XMAP_roi_numbers'])): print 'j',j print 'list',g['XMAP_roi_numbers'] if j == 0: # create 1st element of list rois_this_detector = [ch_base_vortex+str(i)+'.R'+str( g['XMAP_roi_numbers'][j] )] rois_this_detector_dxp = [ch_base_vortex_dxp+str(i)+':SCA'+str( g['XMAP_roi_numbers'][j] )+'Counts'] if g['XMAP_name_convention'].lower() == 'roi': id_roi_this_detector=['D'+str(i)+'_'+g['Id_XMAP_roi_by_name'][j]] id_roi_this_detector_dxp=['D'+str(i)+'_'+g['Id_XMAP_roi_by_name'][j] +'_dxp'] else: id_roi_this_detector=['D'+str(i)+'_ROI_'+str( g['XMAP_roi_numbers'][j] )] id_roi_this_detector_dxp=['D'+str(i)+'_ROI_'+str( g['XMAP_roi_numbers'][j] ) +'_dxp'] #endelse else: # for list for det i rois_this_detector.append(ch_base_vortex+str(i)+'.R'+str( g['XMAP_roi_numbers'][j] )) rois_this_detector_dxp.append(ch_base_vortex_dxp+str(i)+':SCA'+str( g['XMAP_roi_numbers'][j] )+'Counts' ) if g['XMAP_name_convention'].lower() == 'roi': id_roi_this_detector.append('D'+str(i)+'_'+g['Id_XMAP_roi_by_name'][j]) id_roi_this_detector_dxp.append('D'+str(i)+'_'+g['Id_XMAP_roi_by_name'][j] +'_dxp') else: id_roi_this_detector.append('D'+str(i)+'_ROI_'+str( g['XMAP_roi_numbers'][j] )) id_roi_this_detector_dxp.append('D'+str(i)+'_ROI_'+str( g['XMAP_roi_numbers'][j] ) +'_dxp' # endfor ) # endelse # endelse # endfor # now add rois to fill 2-D list if det_nr == 0: channel_roi_vortex = [rois_this_detector] id_roi_vortex = [id_roi_this_detector] channel_roi_vortex_dxp = [rois_this_detector_dxp] id_roi_vortex_dxp = [id_roi_this_detector_dxp] else: channel_roi_vortex.append(rois_this_detector) id_roi_vortex.append(id_roi_this_detector) channel_roi_vortex_dxp.append(rois_this_detector_dxp) id_roi_vortex_dxp.append(id_roi_this_detector_dxp) # endelse # endfor # now we have created a list with all chhoses detectors from the list det_nr print 'channel_roi_vortex',channel_roi_vortex print ' id_roi_vortex' ,id_roi_vortex print 'channel_roi_vortex_dxp',channel_roi_vortex_dxp print 'id_roi_vortex_dxp',id_roi_vortex_dxp print 'det_nr',det_nr # now write all detectors to file... # #for i in range(n_det): # =============== CHANGE # Now loop goes through the list which is generated above and contains only the channels/detectors choosen # Therefore here we count only in range n_det_from_list, the index i is here lits number of the generated lists. for i in range(n_det_from_list): for j in range(len(g['XMAP_roi_numbers'])): print 'next j',j print g['XMAP_roi_numbers'] print range(len(g['XMAP_roi_numbers'])) print i,j,'000000000000000000000000000000000' # write MCA channel detector write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : channel_roi_vortex[i][j] ,'Id' : id_roi_vortex[i][j]}) # write sca channel roi detector write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : channel_roi_vortex_dxp[i][j] ,'Id' : id_roi_vortex_dxp[i][j]}) # endif # endfor # endfor print channel_roi_vortex print id_roi_vortex # Finally write all detector parameters relevant to standard user. # create FDA Id for ICR, OCR, ELTIM and ERTIM # 19.5.2012 add dead time to default detectors. # give names with DD to technical parameters to ease data extraction ... # next loop loops needs to adress the physical number of the detectors in the index again there fore loop # loop thorugh the entries of the full list. #for i in range(n_det): # =============== CHANGE det_nr=-1 # counts detectors used, if zero start ne list, if higher, add elemenst to list for i in d_list: det_nr=det_nr+1 #print i if det_nr == 0: # creat the ID' for the different channels id_trueicr = [ 'D'+str(i)+'_TrueICR' ] id_icr = [ 'D'+str(i)+'_ICR' ] id_ocr = [ 'D'+str(i)+'_OCR' ] id_eltm = [ 'DD'+str(i)+'_ELTM' ] id_ertm = [ 'DD'+str(i)+'_ERTM' ] id_dtim = [ 'DD'+str(i)+'_DTIM' ] id_dtim = [ 'DD'+str(i)+'_DTIM' ] # create a list with the channels for the id's ch_icr = [ g['beamline']+'-XMAP:dxp'+str(i)+':InputCountRate' ] ch_ocr = [ g['beamline']+'-XMAP:dxp'+str(i)+':OutputCountRate' ] ch_eltm = [ g['beamline']+'-XMAP:mca'+str(i)+'.ELTM' ] ch_ertm = [ g['beamline']+'-XMAP:mca'+str(i)+'.ERTM' ] ch_dtim = [ g['beamline']+'-XMAP:mca'+str(i)+'.DTIM' ] else: # ADD ID's id_trueicr.append('D'+str(i)+'_TrueICR') id_icr.append('D'+str(i)+'_ICR') id_ocr.append('D'+str(i)+'_OCR') id_eltm.append('DD'+str(i)+'_ELTM') id_ertm.append('DD'+str(i)+'_ERTM') id_dtim.append('DD'+str(i)+'_DTIM') # ADD Channels ch_icr.append( g['beamline']+'-XMAP:dxp'+str(i)+':InputCountRate' ) ch_ocr.append( g['beamline']+'-XMAP:dxp'+str(i)+':OutputCountRate' ) ch_eltm.append( g['beamline']+'-XMAP:mca'+str(i)+'.ELTM' ) ch_ertm.append( g['beamline']+'-XMAP:mca'+str(i)+'.ERTM' ) ch_dtim.append( g['beamline']+'-XMAP:mca'+str(i)+'.DTIM' ) # endelse # endfor print id_icr print ch_icr print 'kkkkkkkkkkkkk' print id_ocr # #Now loop goes through the list which is generated above and contains only the channels/detectors choosen # Therefore here we count only in range n_det_from_list, the index i is here lits number of the generated lists. for i in range(n_det_from_list): write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : ch_icr[i] ,'Id' : id_icr[i]}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : ch_ocr[i] ,'Id' : id_ocr[i]}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : ch_eltm[i] ,'Id' : id_eltm[i]}) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : ch_ertm[i] ,'Id' : id_ertm[i] }) write_detector(f,{'Det_type' : 'ScalarDetector' ,'Data_type' : 'Double' ,'Channel' : ch_dtim[i] ,'Id' : id_dtim[i] }) #endfor #print n_det,n_roi,channel_roi_vortex,id_roi_vortex,id_icr,id_ocr,id_eltm,id_ertm #.......... finally generate detectors for the full spectra.......... print g['XMAP_save_spectra'] if g['XMAP_save_spectra'] == 1: print ' write detector to save Flourescence spectra' for i in d_list: print i write_detector(f,{'Det_type' : 'ArrayDetector' ,'arraySize' : '2048' ,'Channel' : g['beamline']+'-XMAP:mca'+str(i)+'.VAL' ,'Id' : 'Spec_'+str(i)}) # endfor # endif return n_det,n_roi,channel_roi_vortex,id_roi_vortex,channel_roi_vortex_dxp,id_roi_vortex_dxp,id_icr,id_trueicr,id_ocr,id_eltm,id_ertm # end routine write_vortex # ================================================================== # # # MANIPULATIONS.. # # # # =================================================================== def write_manip_calc_TrueICR(f,params): # .... call of routine: # # write_manip_calc_TrueICR(f,{ , 'Id_icr':'Det1_icr' # , 'Id_ocr':'DET1_ocr' # , 'id_elapsedLT:'Elap_real'' # , 'Id_out':'Det_corr'}) # f File object for xml output # 'id_roi' ------ ID (in FDA) for ROI, which is processed (input manipulation) # 'id_icr' ------ ID for ICR :'Det1_icr' (input manipulation) # 'id_ocr' ------ ID for OCR (input manipulation) # 'id_elapsedTR' ------ ID elapsed real time for detector which is processed(input manipulation) # # 'id_out ------ ID of results (ouput manipulation) f.write(' \n ') f.write(' \n') f.write(' \n') f.write(' \n') f.write(' \n') f.write('\n') f.write(' \n ') def write_manip_dead_time_roi(f,params): # .... call of routine: # # write_manip_dead_time_peamp(f,{'Id_roi':'Det1ROI1' # , 'Id_icr':'Det1_icr' # , 'Id_ocr':'DET1_ocr' # , 'id_elapsedLT:'Elap_real'' # , 'Id_out':'Det_corr'}) # # f File object for xml output # 'id_roi' ------ ID (in FDA) for ROI, which is processed (input manipulation) # 'id_icr' ------ ID for ICR :'Det1_icr' (input manipulation) # 'id_ocr' ------ ID for OCR (input manipulation) # 'id_elapsedTR' ------ ID elapsed real time for detector which is processed(input manipulation) # # 'id_out ------ ID of results (ouput manipulation) f.write(' \n ') f.write(' \n') f.write(' \n') f.write(' \n') f.write(' \n') f.write(' \n') f.write('\n') f.write(' \n ') def write_manip_fyxas(f,params): f.write('') f.write(' \n') f.write(' \n') f.write(' \n') f.write(' \n') f.write(' \n ') f.write(' \n ') # -------------------------------------- def write_manip_divide_channels(f,params): print params f.write('') f.write(' \n') f.write(' \n') f.write(' \n ') f.write(' \n ') # ---------------------------------------------------------------------------------------- def write_manip_sum_vortex(f,params): # # # routine calculates the summ of all four vortex detctors # .... call of routine: # # write_manip_dead_time_roi(f,{'Id_roi' : id_roi_vortex[j][k] # , 'Id_icr' : id_icr_vortex[j] # , 'Id_ocr' : id_ocr_vortex[j] # , 'Id_elapsedLT': id_eltm_vortex[j] # , 'Id_out' : id_roi_vortex[j][k]+'_corr'}) print 'routine write_manip_sum_vortex' print params f.write(' \n ') # define the mapping of all variables... string_for_params='' n_det=0 for ID_ROI in params['Id_roi']: f.write(' \n') string_for_params=string_for_params+ID_ROI+' , ' n_det=n_det+1 #endfor ##for Id_elapsedLT in params['Id_elapsedLT']: ## print Id_elapsedLT ## f.write(' \n') ## string_for_params=string_for_params+Id_elapsedLT+' , ' # endfor # remove coma at end of string_for_params string_for_params=string_for_params[0:len(string_for_params)-3] f.write(' \n') f.write('\n') f.write(' \n ') # =================================================================== def read_list(detectors, e_active,e_i,E_f,Delta_e, p_active,Scanx, Scany, Theta, Trx, TRZ ): f = open('list.txt', "r") box=' ' box = f.readline() #print 'box',box # .............................. read 2 detectors.......... detectors[0]=f.readline() detectors[1]=f.readline() detectors[0] =detectors[0][0:len(detectors[0])-2] detectors[1] =detectors[1][0:len(detectors[1])-2] #print 'detectors',detectors # .............................. read energy arrays .......... box = f.readline() #print box # r_box=create_real_zeros(5) for i in range(5): box = f.readline() r_box=box.split() #print 'r_box',r_box e_active[i]=r_box[0] e_i[i]=r_box[1] e_f[i]=r_box[2] e_delta[i]=r_box[3] #print e_active #print e_i #print e_f #print e_delta # ...................................................................... # o.k. tro here def get_channels(scan_type): # # This routine reads the epics chanels and stores the inout data into the correct # variables in the python script epics chanels to be defined later. # detectors, e_active,e_i,E_f,Delta_e, p_active,Scanx, Scany, Theta, Trx, TRZ ): # # Author T.Huthwelker October 2011 # # # INPUT scan_type defines the type of scan. # needs to be defined in the scan # currently we have # # 'IMAGE' (for imaging) X_X07MB_regions.py # # 'SPECTRA' spectra, all data sets into one single data file (file X_X07MB_XAS_points.py) # # 'SPETRA_QUEUE' spectra, but each spectrum into a singl data file # # currently only used to check for consistencies of data input. # On long term, we can minimize the number of chanles to be read #import os ##os.system ("ls -altr") #try: # from CaChannel import * # from epicsMotor import * # from epicsPV import * # import time # import string #except: # try: # sys.path.insert(0, os.path.expandvars("$SLSBASE/sls/lib/python22/CaChannel")) # sys.path.insert(0, os.path.expandvars("/exchange/share/mXAS/pyth/mod")) # from CaChannel import * # from epicsPV import * # except: # os.system ("xkbbell") # os.system ("xmessage -nearmouse -timeout 30 \ # -buttons \"\" \"epicsPV or CaChannel module cannot be found\"") # sys.exit(1) # # endtry # endtry beamline='X07MB' filename = get_epicsPV(beamline+'-PC-PSCAN:FdaFname') # .... remove all blanks from filenam filename=filename.replace(' ', '') # ......... define general Channels.... # ........ define scan type #scan_type=['XAS_several_points'] # options are # 'XAS_several_points' : several XAS spectra # at different points # 'E_Image' : image for a given (or several energies) n_roi_for_xas = int(get_epicsPV(beamline+'-PC-PSCAN:FdaXasRoi')) # this is the roi we are choosing # for taking the XAS spectrum (starts at 0) XMAP_save_only_xas_roi = int(get_epicsPV(beamline+'-PC-PSCAN:FdaSRoi')) # if 1 we store ony roi choosen for XAS, # other wise store all rois defined. XMAP_save_spectra = int(get_epicsPV(beamline+'-PC-PSCAN:FdaSSpec')) # flag whether we store fluo spectra or not. # ........... number of scans number_of_executions = int(get_epicsPV(beamline+'-PC-PSCAN:FdaNexec')) # number of repetitions in scan # ............ read detectors.... # create a list of detetectors used in experiment detectors=['no_Detector'] # define list of detectors by creating dumma if 1==int(get_epicsPV(beamline+'-PC-PSCAN:USE_ES1_SD1')): detectors.append('MOENCH') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:USE_PS1_CAM1')): detectors.append('PS1_CAM1') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:USE_PS2_CAM1')): detectors.append('PS1_CAM2') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:VORT_XM')): detectors.append('Vortex') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:ROENT_XM')): detectors.append('ROENTEC_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KETEK_XM')): # Add KETK as option. This detector uses only Channel 2 of 4 XMAP Channels detectors.append('KETEK_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KEITH1')): detectors.append('KEITHLEY1') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KEITH2')): detectors.append('KEITHLEY2') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KEITH3')): detectors.append('KEITHLEY3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:BL_PRESS')): detectors.append('BL_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:BL_TEMP')): detectors.append('BL_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:ES1_PRESS')): detectors.append('ES1_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:MO_ENC')): detectors.append('MONO_ENC') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:MO_TEMP')): detectors.append('MONO_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:XBPM3')): detectors.append('XBPM3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:XBPM4')): detectors.append('XBPM4') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:XBPM3')): detectors.append('XBPM3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:CAM1_POS')): detectors.append('CAM1_POS') #endif print get_epicsPV(beamline+'-PC-PSCAN:PL_USER_DET') if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_USER_DET')): print 'gggggggg' detectors.append('USER_DET') #endif #print detectors if len(detectors) == 1: error_stop('!!!!!!!!!!! no detector choosen') # endif # create a list of plots to be choosen detectors_to_plot=['no_Plot'] # define list of detectors by creating dumma if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_VORT_XM')): detectors_to_plot.append('PL_Vortex') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_ROENT_XM')): detectors_to_plot.append('PL_ROENTEC_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KETEK_XM')): detectors_to_plot.append('PL_KETEK_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KEITH1')): detectors_to_plot.append('PL_KEITHLEY1') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KEITH2')): detectors_to_plot.append('PL_KEITHLEY2') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KEITH3')): detectors_to_plot.append('PL_KEITHLEY3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_BL_PRESS')): detectors_to_plot.append('PL_BL_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_BL_TEMP')): detectors_to_plot.append('PL_BL_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_ES1_PRESS')): detectors_to_plot.append('PL_ES1_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_MO_ENC')): detectors_to_plot.append('PL_MONO_ENC') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_MO_TEMP')): detectors_to_plot.append('PL_MONO_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_XBPM3')): detectors_to_plot.append('PL_XBPM3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_XBPM4')): detectors_to_plot.append('PL_XBPM4') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_CAM1_POS')): detectors_to_plot.append('PL_CAM1_POS') if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_USER_DET')): detectors_to_plot.append('PL_USER_DET') # GET NAMING CONVENTION FOR FDA # if channel X07MB-PC-PSCAN:FdaNConv = 1 get names from XMAP rois # other wise use standard definition det_i_roi_j if get_epicsPV(beamline+'-PC-PSCAN:FdaNConv') == 1: XMAP_name_convention= 'ROI' # if ROI is choosen, the column name in data file is the else: XMAP_name_convention= ' ' # endelse #... if XMAP is used determine the number of ROIS chosen: if ('Vortex' in detectors) and ('ROENTEC_XMAP' in detectors) and ('KETEK_XMAP' in detectors): error_stop('!!!!!!!!!!! ERROR CANNOT USE BOTH VORTEX AND ROENTEC WITH XMAP ') # endif if ('Vortex' in detectors) and ('KETEK_XMAP' in detectors): error_stop('!!!!!!!!!!! ERROR CANNOT USE BOTH VORTEX AND ROENTEC WITH XMAP ') # endif if ('ROENTEC_XMAP' in detectors) and ('KETEK_XMAP' in detectors): error_stop('!!!!!!!!!!! ERROR CANNOT USE BOTH VORTEX AND ROENTEC WITH XMAP ') # endif n_roi=-1 # set to -1 as not yet defined, will be reset if XMAP is used, otherwise -1 means error n_det_fluo = -1 # set to -1 as not yet defined, will be reset if XMAP is used, otherwise -1 means error Id_XMAP_roi_by_name=-1 d_list_fluo =[-1] # changed 10.10. Need to give initial definition for d_list_fluo, # as it will remain undefined of no Fluo detector is used. # Define channel 0 as number for unused channel' XMAP_roi_numbers =-1 if ('Vortex' in detectors) or ('ROENTEC_XMAP' in detectors) or ('KETEK_XMAP' in detectors): if ('Vortex' in detectors): n_det_fluo = 4 # do script for 4 detectors (VORTEX) d_list_fluo =[1,2,3,4] # endif if ('ROENTEC_XMAP' in detectors): n_det_fluo = 1 # do script for 1 detector (ROENTEC ) d_list_fluo =[1] # roentek by default in XMAP Channel # 1 # endif if ('KETEK_XMAP' in detectors): n_det_fluo = 1 # do script for 1 detector (Ketek ) d_list_fluo =[2] # Ketek by default in XMAP channel # 2 # endif print 'analyse XMAP ' # case 1 roentec and vortex, use ROI's as defined for detector 1 if ('Vortex' in detectors) or ('ROENTEC_XMAP' in detectors): print 'vortex assuming that rois defined for detector 1 are equal for all detectors...' n_roi=0 for i1 in range(31): this_name=get_epicsPV(beamline+'-XMAP:mca1.R'+str(i1)+'NM') # note that this assumes that the # same roi name is choosen for all four spectra. # XMAP allow different labels for each roi and each detector. # ..... remove blanks from string box='' for i2 in range(len(this_name.split())): box=box+this_name.split()[i2] # endfor if box <> '': n_roi=n_roi+1 if n_roi ==1: Id_XMAP_roi_by_name=[box] XMAP_roi_numbers=[i1] else: Id_XMAP_roi_by_name.append(box) XMAP_roi_numbers.append(i1) # endelse # endif # endfor # endif # case 2 Ketek, which is by defalut defined on channel 2 if ('KETEK_XMAP' in detectors): print 'KETEC assuming that channel 2 is used in XMAP ' n_roi=0 for i1 in range(31): this_name=get_epicsPV(beamline+'-XMAP:mca2.R'+str(i1)+'NM') # note that this assumes that the # same roi name is choosen for all four spectra. # XMAP allow different labels for each roi and each detector. # ..... remove blanks from string box='' for i2 in range(len(this_name.split())): box=box+this_name.split()[i2] # endfor if box <> '': n_roi=n_roi+1 if n_roi ==1: Id_XMAP_roi_by_name=[box] XMAP_roi_numbers=[i1] else: Id_XMAP_roi_by_name.append(box) XMAP_roi_numbers.append(i1) # endelse # endif # endfor # endif print n_roi if n_roi == 0 : error_stop('! NO ROI DEFINED IN XMAP (GOTO Phoenix user panel --> CHOOSE SDD/FLUO and ADD ROI ') #endif if n_roi_for_xas > n_roi: print 'stop inconsistent input ' print ' value for n_roi_for_xas is larger that maximum value of defines roi' print Id_XMAP_roi_by_name print ' Use name convention: ',XMAP_name_convention #endif #endif print Id_XMAP_roi_by_name # finally define variable which contains the roi used fro XAs in the list of rois we use n_roi_for_xas_index=n_roi_for_xas # now, for case use onlz XAS roi, create the subset from ID_XMAP # default is to store all ROI to data files. Now treat case where we need a data subset n_roi_for_xas_index=n_roi_for_xas print Id_XMAP_roi_by_name if XMAP_save_only_xas_roi == 1: # create list for headers for subset Id_XMAP_roi_by_name=[Id_XMAP_roi_by_name[n_roi_for_xas]] # create list with indices for roi chosen. by this prepare solution to make a list of rois to store XMAP_roi_numbers=[n_roi_for_xas] # set n_roi to 1 as we now consider only one region of interest n_roi_for_xas_index=0 n_roi=1 # ............... now store the 21 possible regions for the energy scans # once chanels are defined create array with chanle names and go through loop n_e = 21 # start with maximun, reset number later ch_e_base=beamline+'-PC-PSCAN:E-' # faster code reads only active channels..... i_0=0 if ('SPECTRA' == scan_type) or ('SPECTRA_QUEUE' == scan_type) or ('STACK' == scan_type): # read parameter only if a spectrum is to be taken for i in range(n_e): print 'read energy points'+str(i) this_active = get_epicsPV(ch_e_base+'ACT'+str(i)) if (i_0 ==0 ) and ( this_active== 1) : print ' first region active' e_active = [this_active] # must be one or zero e_i = [get_epicsPV(ch_e_base+'I'+str(i))] e_f = [get_epicsPV(ch_e_base+'F'+str(i))] e_delta = [get_epicsPV(ch_e_base+'D'+str(i))] e_n_cycles = [int(get_epicsPV(ch_e_base+'NCY'+str(i)))] i_0=i_0+1 else: if ( this_active== 1): e_active.append(this_active) # must be one or zero e_i.append(get_epicsPV(ch_e_base+'I'+str(i))) e_f.append(get_epicsPV(ch_e_base+'F'+str(i))) e_delta.append(get_epicsPV(ch_e_base+'D'+str(i))) e_n_cycles.append(int(get_epicsPV(ch_e_base+'NCY'+str(i)))) i_0=i_0+1 # endif # endelse if i_0 == 0 : box='!choose at least one ENERGY range with constant energy' box2=box+'spacing for taking SPECTRA (Menue XAS SCANS)' #error stop as no energy is defined for energy scan error_stop(box2) #error stop as no energy is defined for energy scan # endif else: # case data set is not a spectrum assign dummy values e_active = ['undefined'] e_i = ['undefined'] e_f = ['undefined'] e_delta = ['undefined'] e_n_cycles = ['undefined'] i_0 = 0 # endelse print e_f,e_i,i_0 # now READ POSITIONER FOR exafs DATA.. n_e = i_0 # reset n_e to number of real data points ch_ex_base=beamline+'-PC-PSCAN:EX-' e_ex_E_edge = [get_epicsPV(ch_ex_base+'E-EDGE')] # do not check whether i_0 is zero, program assumes that at least # on range with constant range is chosen. n_exafs=2 # currently allow for 2 region i_0 = 0 e_ex_active=[-1] # set to -1. If there is no active region for EXAFS scans, e_ex_active = -1 print n_exafs for i in range(n_exafs): this_active = get_epicsPV(ch_ex_base+'ACT'+str(i)) if (i_0 ==0 ) and ( this_active== 1) : e_ex_active = [this_active] # must be one or zero e_ex_e_i = [get_epicsPV(ch_ex_base+'E-I'+str(i)) ] e_ex_e_f = [get_epicsPV(ch_ex_base+'E-F'+str(i)) ] e_ex_k_i = [get_epicsPV(ch_ex_base+'K-I'+str(i)) ] e_ex_k_f = [get_epicsPV(ch_ex_base+'K-F'+str(i)) ] e_ex_d_i = [get_epicsPV(ch_ex_base+'D'+str(i)) ] e_ex_ncy = [get_epicsPV(ch_ex_base+'NCY'+str(i)) ] e_ex_ncy_f = [get_epicsPV(ch_ex_base+'NCY-F'+str(i)) ] e_ex_icy = [get_epicsPV(ch_ex_base+'ICY'+str(i)) ] e_ex_nst = [get_epicsPV(ch_ex_base+'NST'+str(i)) ] e_ex_t = [get_epicsPV(ch_ex_base+'T'+str(i)) ] i_0=i_0+1 else: if ( this_active== 1): e_ex_active.append(this_active) # must be one or zero e_ex_e_i.append(get_epicsPV(ch_ex_base+'E-I'+str(i)) ) e_ex_e_f.append(get_epicsPV(ch_ex_base+'E-F'+str(i)) ) e_ex_k_i.append(get_epicsPV(ch_ex_base+'K-I'+str(i)) ) e_ex_k_f.append(get_epicsPV(ch_ex_base+'K-F'+str(i)) ) e_ex_d_i.append(get_epicsPV(ch_ex_base+'D'+str(i)) ) e_ex_ncy.append(get_epicsPV(ch_ex_base+'NCY'+str(i)) ) e_ex_ncy_f.append(get_epicsPV(ch_ex_base+'NCY-F'+str(i))) e_ex_icy.append(get_epicsPV(ch_ex_base+'ICY'+str(i))) e_ex_nst.append(get_epicsPV(ch_ex_base+'NST'+str(i))) e_ex_t.append(get_epicsPV(ch_ex_base+'T'+str(i))) i_0=i_0+1 # endif # endelse # endfor n_exafs = i_0 # determine the number of EXAFS ranegs choosen. if i_0 == 0 : print 'NO EXAFS REABGE CHOOSEN ' e_ex_e_i = [-1] e_ex_e_f = [-1] e_ex_k_i = [-1] e_ex_k_f = [-1] e_ex_d_i = [-1] e_ex_ncy = [-1] e_ex_ncy_f = [-1] e_ex_icy = [-1] e_ex_nst = [-1] e_ex_t = [-1] # endif #print e_ex_e_i #print e_ex_e_f #print e_ex_k_i #print e_ex_k_f #print e_ex_d_i #print e_ex_ncy #print e_ex_ncy_f #print e_ex_nst #print e_ex_t # Now read also the parameters for the region with non equi distant energy spacing #print n_e #print e_active #print e_i #print e_f #print e_delta # ............ now store the various data point for the energy scans.... # ............ put these names into a configuration file ???? ch_p_base=beamline+'-PC-PSCAN:P-' # first read all positions for standard detectors for regions # to do read only active columns ... n_p = 21 # set first to max number of datapoints, reset later # faster code read only active chanels ........(but still all positioner, even if undefined..) i_0_tmp=0 p_label='undefined_label' for i in range(n_p): print ' read positions for point scans '+str(i)+str(n_p) this_active = int(get_epicsPV(ch_p_base+'ACT'+str(i))) # read channel with active / inactive... print i, this_active if (i_0_tmp ==0 ) and ( this_active== 1) : p_label = [get_epicsPV(ch_p_base+'LABEL'+str(i))] p_active = [this_active] p_0 = [get_epicsPV(ch_p_base+'P0D'+str(i))] p_1 = [get_epicsPV(ch_p_base+'P1D'+str(i))] p_2 = [get_epicsPV(ch_p_base+'P2D'+str(i))] p_3 = [get_epicsPV(ch_p_base+'P3D'+str(i))] p_4 = [get_epicsPV(ch_p_base+'P4D'+str(i))] p_5 = [get_epicsPV(ch_p_base+'P5D'+str(i))] print 'First found' i_0_tmp=i_0_tmp+1 else: if ( this_active== 1): print 'next found ' print i p_label.append(get_epicsPV(ch_p_base+'LABEL'+str(i))) p_active.append(this_active) p_0.append(get_epicsPV(ch_p_base+'P0D'+str(i))) p_1.append(get_epicsPV(ch_p_base+'P1D'+str(i))) p_2.append(get_epicsPV(ch_p_base+'P2D'+str(i))) p_3.append(get_epicsPV(ch_p_base+'P3D'+str(i))) p_4.append(get_epicsPV(ch_p_base+'P4D'+str(i))) p_5.append(get_epicsPV(ch_p_base+'P5D'+str(i))) i_0_tmp=i_0_tmp+1 #endif #endif if i_0_tmp == 0 : print 'error stop removed' #error_stop('!!!!! INCONSISTENT INPUT: choose at least one POSITION # for SPECTRA (MENUE XAS SCANS)') # create mark in positioner variables that no position has been chosen p_0='no pos' p_1='no pos' p_2='no pos' p_3='no pos' p_4='no pos' p_5='no pos' # set count of data points to 1, this is the case where we take a spectrum # at all current positioners without moving the positioner i_0_tmp = 1 # endif print p_label n_p = i_0_tmp # reset n_p to real number of data points print n_p # put all data into one full list p_data_full=[[p_0],[p_1],[p_2],[p_3],[p_4],[p_5]] #print i_0_tmp # ........... done reading all positions for standard positioner ... # .... get epics chanels of defau;lt positioner (set value) print ' read actuators' # CHANNEL NEEDED .rbv is as default in channel.remove .rbv and create .val for p_channel_full here # case 1 extension of ch0 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN0') ch1 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN1') ch2 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN2') ch3 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN3') ch4 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN4') ch5 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN5') [ch0_rbv,ch0_val] = create_rbv_val(ch0) [ch1_rbv,ch1_val] = create_rbv_val(ch1) [ch2_rbv,ch2_val] = create_rbv_val(ch2) [ch3_rbv,ch3_val] = create_rbv_val(ch3) [ch4_rbv,ch4_val] = create_rbv_val(ch4) [ch5_rbv,ch5_val] = create_rbv_val(ch5) p_channel_full = [ch0_val,ch1_val,ch2_val,ch3_val,ch4_val,ch5_val] print ' read actuator rbv ' # .... get epics chanels of default positioner (rbv value) p_channel_rbv_full = [ch0_rbv,ch1_rbv,ch2_rbv,ch3_rbv,ch4_rbv,ch5_rbv] #print p_channel_full #print p_channel_rbv_full # names for identifier for 6 default positioner in point scans..) print ' read actuator FDA ID ' p_id_full = [get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID0'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID1'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID2'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID3'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID4'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID5') ] # read done channels for positioner p_done_full = [get_epicsPV(beamline+'-PC-PSCAN:POS-RBC0'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC1'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC2'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC3'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC4'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC5') ] #print p_done_full # read on / off for done mode done channels for positioner p_done_switch_full = [get_epicsPV(beamline+'-PC-PSCAN:POS-DN0-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN1-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN2-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN3-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN4-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN5-ACT') ] #print p_done_switch_full # ................................... read additional predefined user detectors i_tmp=0 CH_User_detector = ['noUserDetector'] User_detector_fda_id = ['noUserDetector'] for i in range(10): User_detector_box = get_epicsPV(beamline+'-PC-PSCAN:UDET'+str(i)) User_detector_fda_id_box = get_epicsPV(beamline+'-PC-PSCAN:UDET'+str(i)+'-FDAID') if (remove_blanks_from_str(User_detector_box) <> '') : if i_tmp == 0 : CH_User_detector = [remove_blanks_from_str(User_detector_box)] if User_detector_box <> '': User_detector_fda_id = [remove_blanks_from_str(User_detector_fda_id_box)] else: User_detector_fda_id = ['User_det_'+str(i)] #endelse i_tmp = i_tmp + 1 else: CH_User_detector.append(remove_blanks_from_str(User_detector_box)) User_detector_fda_id.append(remove_blanks_from_str(User_detector_fda_id_box)) # endelse # endif # endfor print CH_User_detector print User_detector_fda_id # get the active detectors now... p_positioner_active=[0,0,0,0,0,0] # variable which of the default positioner is active p_positioner_active[0] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT0')) # Default scanx p_positioner_active[1] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT1')) # Default scany p_positioner_active[2] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT2')) # Default ROT p_positioner_active[3] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT3')) # Default TRX p_positioner_active[4] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT4')) # Default TRZ p_positioner_active[5] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT5')) # Default DETECTOR print p_positioner_active # stop # create array with Id values and EPICS channels for fda... p_data_full=[p_0,p_1,p_2,p_3,p_4,p_5] if sum(p_positioner_active) == 0 : # case I no positioner defined p_channel=[' '] p_channel_rbv=[' '] p_id =[' '] p_data =[' '] p_done =[' '] p_done_switch =[' '] else: # case II no positioner are defined i_0_tmp=0 for i in range(len(p_positioner_active)): #print i_0_tmp #print i if (i_0_tmp == 0) and (p_positioner_active[i] == 1 ): p_channel=[p_channel_full[i]] p_channel_rbv= [p_channel_rbv_full[i]] p_id = [p_id_full[i]] p_data = [p_data_full[i]] p_done = [p_done_full[i]] p_done_switch =[p_done_switch_full[i]] i_0_tmp =i_0_tmp+1 else: if (p_positioner_active[i] == 1 ): p_channel.append(p_channel_full[i]) p_channel_rbv.append(p_channel_rbv_full[i]) p_id.append(p_id_full[i]) p_data.append(p_data_full[i]) p_done.append(p_done_full[i]) p_done_switch.append(p_done_switch_full[i]) i_0_tmp =i_0_tmp+1 #endif #endelse #endfor #endelse #print 'i_0_tmp' #print i_0_tmp #print 'p_data' #print p_data #print p_done #print p_done_switch # now after we have stored all positions (including the non-active data sets...) into the matrices # we create an array containing the complete data set...(Positioner ID and positions data) # #print 'p_positioner_active' #print p_positioner_active #print 'p0' #print p_0 #print 'p_id' #print p_id # .................... done creation of full array for all positions... # now connect the data to one variable with dictionary # ----------------------------------------------------------------- # # ............set up data for image regions ....... # # ------------------------------------------------------------------ # ........... first the energies (currently as a few fixed energy values, # we can think about stacks as well later ch_r_base=beamline+'-PC-PSCAN:R' r_n_e = 20 # start with max number of data points i_0=0 for i in range(r_n_e): print 'read energies for regions'+str(i) #print ch_r_base+'-EACT'+str(i) this_active = get_epicsPV(ch_r_base+'-EACT'+str(i)) #print 'this_active' #xprint this_active if (i_0 ==0 ) and ( this_active== 1) : r_energies_active = [this_active] time.sleep(0.05) r_energies = [(get_epicsPV(ch_r_base+'-E'+str(i)))] time.sleep(0.05) r_energy_cycles = [int(get_epicsPV(ch_r_base+'-E-NCY'+str(i)))] i_0 = i_0 + 1 #print 'first found ' else: if (this_active == 1): #print 'next found ' r_energies_active.append(1) time.sleep(0.05) r_energies.append( (get_epicsPV(ch_r_base+ '-E' +str(i)))) time.sleep(0.05) r_energy_cycles.append( int(get_epicsPV(ch_r_base+ '-E-NCY' +str(i)))) i_0 = i_0 + 1 #print 'energies',r_energies #endif #endelse # endfor # ___________ stop, if there are no energies chosen..... if i_0 == 0 : # error_stop('!!!!! INCONSISTENT INPUT: choose at least one ENERGY for taking images') # in case there no energy is chosen, work with current status of the beamline r_energies = 'undefined' r_energy_cycles = 'undefined' r_energies_active = 'undefined' #endif r_n_e=i_0 # reset r_n_e print r_energies print r_energy_cycles # ....................................... finally the image coordinates n_r = 21 # maximum 10 images at current # allow for scanx, scany and detector for now. Default for taking 2-D images # this is by default in actuator 0,1, and 5. (ScanX, ScanY and Detector) # the following code is historically grown and extremly unnice # detector movement prepared, but not implemented yet in IOC # TO DO REMOVE DETECTOR AS THIS IS USELESS:.. r_indices=[p_id_full[0] ,p_id_full[1] ,p_id_full[5] ] r_channel = { p_id_full[0] : p_channel_full[0] ,p_id_full[1] : p_channel_full[1] ,p_id_full[5] :p_channel_full[5] } r_channel_rbv = { p_id_full[0] : p_channel_rbv_full[0] ,p_id_full[1] : p_channel_rbv_full[1] ,p_id_full[5] : p_channel_rbv_full[5]} r_id = { p_id_full[0] : p_id_full[0] ,p_id_full[1] : p_id_full[1] ,p_id_full[5] : p_id_full[5]} r_done = {p_id_full[0] : p_done_full[0] ,p_id_full[1] : p_done_full[1] ,p_id_full[5] : p_done_full[5] } r_done_switch = {p_id_full[0] : p_done_switch_full[0] ,p_id_full[1] : p_done_switch_full[1] ,p_id_full[5] : p_done_switch_full[5] } #print r_channel # faster code , reads only active chanels i_0 = 0 for i in range(n_r): print 'read region'+str(i) this_active = get_epicsPV(ch_r_base+'-ACT'+str(i)) if (i_0 ==0 ) and ( this_active== 1) : #print ' first region active' r_active = [this_active] time.sleep(0.05) r_ll_x = [get_epicsPV(ch_r_base+'-XLL'+str(i))] time.sleep(0.05) r_ll_y = [get_epicsPV(ch_r_base+'-YLL'+str(i))] time.sleep(0.05) r_ur_x = [get_epicsPV(ch_r_base+'-XUR'+str(i))] time.sleep(0.05) r_ur_y = [get_epicsPV(ch_r_base+'-YUR'+str(i))] time.sleep(0.05) r_delta_x = [get_epicsPV(ch_r_base+'-DX'+str(i))] time.sleep(0.05) r_delta_y = [get_epicsPV(ch_r_base+'-DY'+str(i))] r_num = [i+1] # runing number for region to generate the numbering of filename i_0=i_0+1 else: if ( this_active== 1): #print 'next found ' r_active.append( this_active) r_ll_x.append( get_epicsPV(ch_r_base+'-XLL'+str(i))) time.sleep(0.05) r_ll_y.append( get_epicsPV(ch_r_base+'-YLL'+str(i))) time.sleep(0.05) r_ur_x.append( get_epicsPV(ch_r_base+'-XUR'+str(i))) time.sleep(0.05) r_ur_y.append( get_epicsPV(ch_r_base+'-YUR'+str(i))) time.sleep(0.05) r_delta_x.append( get_epicsPV(ch_r_base+'-DX'+str(i))) time.sleep(0.05) r_delta_y.append( get_epicsPV(ch_r_base+'-DY'+str(i))) r_num.append(i+1) # endif #endelse if (i_0 == 0 ): error_stop('!!!!! INCONSISTENT INPUT: choose at least one REGION for taking images') # endif n_r=i_0 # reset number of data points # ..... configure general preactions (configure at end, # ..... as preaction in later version wil be derived from general input. # This is the case if KEthley and Vortex are used add distinction for case w/o keithley # ... preactions for DAQ with XMAP ................ # First check whether we need XMAP Actions: if (('Vortex' in detectors) or ('ROENTEC_XMAP' in detectors) or ('KETEK_XMAP' in detectors) ): DAQ_XMAP = 1 else: DAQ_XMAP = 0 # endif_else preaction_1={'channel' : 'X07MB-OP2:START-CSMPL','value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_2={'channel' : 'X07MB-XMAP:StopAll' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} # set to mca spectac mode (later add option for OTF mapping) preaction_2a={'channel' : 'X07MB-XMAP:CollectMode' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} # force application of collection mode setting. preaction_2b={'channel' : 'X07MB-XMAP:Apply' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_3={'channel' : 'X07MB-XMAP:PresetReal' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_4={'channel' : 'X07MB-OP2:TOTAL-CYCLES' ,'value' : '2' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} # 7.5.2018 press once start sampling to allow system to reset delay = 0.7 sec to maske sure # that there is sufficient time to count up once for 2 cycles. This is a backup # to ensure that the trigger EPIC setup does not hand when the system starts preaction_4a={'channel' : 'X07MB-OP2:SMPL' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.7'} preaction_5={'channel' : 'X07MB-ES1-PP2:VO5' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.01'} # preaction: open local shutter automatically preaction_6={'channel' : 'X07MB-OP-WV1:WT_SET' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_Moench_1={'channel' : 'X07MB-ES1-SD1:cam1:FileNumber' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} #Moench 2 and 3 DO NOT WORK WOTH FDA FDA CANNOT WRITE A STRING preaction_Moench_2={'channel' : 'X07MB-ES1-SD1:cam1:FilePath' ,'value' : '/tmp' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_Moench_3={'channel' : 'X07MB-ES1-SD1:cam1:FileName' ,'value' : 'moench_' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_MO_ID_Off={'channel' : 'X07MB-OP-MO:E-SET.OUT' ,'value' : ' ' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.2'} preaction_MO_ID_on={'channel' : 'X07MB-OP-MO:E-SET.OUT' ,'value' : 'X07MA-ID:ENERGY NPP NMS' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.2'} # general case ... if DAQ_XMAP == 1: # IDCOUPLING preactions=[preaction_1 ,preaction_2 ,preaction_2a ,preaction_2b ,preaction_3 ,preaction_4 ,preaction_4a # ,preaction_5 # 4.10 take light out tmp # ,preaction_MO_ID_Off # ,preaction_MO_ID_on ] # endif DAQ_XMAP = 1 # case no XMAP in data aquisition if DAQ_XMAP == 0: preactions=[preaction_1,preaction_4,preaction_4a] # endif DAQ_XMAP = 0 # add shutter auto opening if chosen if get_epicsPV('X07MB-PC-PSCAN:MBWV1_OPEN') == 1: preactions.append(preaction_6) # endif # NOw add ccd detectort id needed # Case 1 Moenche deetctor if 'MOENCH' in detectors: print(' no Moench preaction for now...') preactions.append(preaction_Moench_1) #preactions.append(preaction_Moench_2) THESE DO NOT WORK WOTH FDA FDA CANNOT WRITE A STRING #preactions.append(preaction_Moench_3) #endif # ... preactions for DAQ without XMAP ................ # Define actions to be taken for each measurement detector_action_1 = { 'Channel' : 'X07MB-XMAP:EraseStart' ,'Value' : '1' ,'Operation' : 'putq' ,'Data_type' : 'String' ,'Delay' : '0.075' } detector_action_2 = { 'Channel' : 'X07MB-OP2:SMPL' ,'Value' : '1' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.075' } detector_action_3 = { 'Channel' : 'X07MB-OP2:SMPL-DONE' ,'Value' : '1' ,'Operation' : 'wait' ,'Data_type' : 'Integer' ,'Delay' : '0.03' } detector_action_4 = { 'Channel' : 'X07MB-XMAP:StopAll' ,'Value' : '1' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.05' } detector_action_moench_aquire = { 'Channel' : 'X07MB-ES1-SD1:cam1:Acquire' ,'Value' : '1' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.05' } detector_action_moench_wait = { 'Channel' : 'X07MB-ES1-SD1:cam1:Acquire' ,'Value' : '0' ,'Operation' : 'wait' ,'Data_type' : 'Integer' ,'Delay' : '0.03' } detector_action_MO_ID_Off={'Channel' : 'X07MB-OP-MO:E-SET.OUT' ,'Value' : ' ' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.1'} detector_action_MO_ID_on={'Channel' : 'X07MB-OP-MO:E-SET.OUT' ,'Value' : 'X07MA-ID:ENERGY NPP NMS' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.1'} # now walk through different cases if DAQ_XMAP == 1: # IDCOUPLING detector_actions=[detector_action_1 ,detector_action_2 ,detector_action_3 ,detector_action_4 # ,detector_action_MO_ID_Off # ,detector_action_MO_ID_on ] print detector_actions # endif DAQ_XMAP = 1 if DAQ_XMAP == 0: detector_actions=[detector_action_2 ,detector_action_3] print detectors if (DAQ_XMAP == 1) and ('MOENCH' in detectors): detector_actions=[detector_action_1 ,detector_action_2 ,detector_action_moench_aquire ,detector_action_3 ,detector_action_moench_wait ,detector_action_4] # establish predefined detector groups.... # group 1 beamline pressures... CH_BL_PRESS = ['X07MA-FE-CH2MP1:PRESSURE' ,'X07MB-OP-MI1MP1:PRESSURE' ,'X07MA-OP-CMMP:PRESSURE' ,'X07MA-OP-SCMP:PRESSURE' ,'X07MB-OP-IP1MP1:PRESSURE' ,'X07MB-OP-SL1MP1:PRESSURE' ,'X07MB-OP-FI1MP1:PRESSURE' ,'X07MB-OP-BM1MP1:PRESSURE' ,'X07MB-OP-IP2MP1:PRESSURE' ,'X07MB-OP-BM2MF1:PRESSURE' ,'X07MB-OP-MOMF1:PRESSURE' ] ID_BL_PRESS = ['CH2MP1' ,'MI1MP' ,'CMMP' ,'SCMP' ,'IP1MP1' ,'SL1MP1' ,'FI1MP1' ,'BM1MP1' ,'IP2MP1' ,'BM2MF1' ,'MOMF1'] # group BL temperatures temperatures... CH_BL_TEMP=['X07MB-OP-MI1:TC1' ,'X07MB-OP-MI1:TC3' ,'X07MA-OP-CMMI:TC1' ,'X07MA-OP-CMB:TC1' ,'X07MA-OP-SC:TC1' ,'X07MA-FE-SH1:TC1' ,'X07MA-FE-SH1:TC2' ,'X07MA-FE-SH1:TC3' ,'X07MA-FE-SH1:TC4' ,'X07MA-FE-SV1:TC1' ,'X07MA-FE-SV1:TC2' ,'X07MA-FE-SV1:TC3' ,'X07MA-FE-SV1:TC4' ,'X07MB-OP-SH1:TC_X1' ,'X07MB-OP-SH1:TC_X2' ,'X07MB-OP-SV1:TC_Y1' ,'X07MB-OP-SV1:TC_Y2' ] ID_BL_TEMP=['MI1TC1' ,'MI1TC3' ,'CMMITC1' ,'CMBTC1' ,'SCTC1' ,'FE_SH1TC1' ,'FE_SH1TC2' ,'FE_SH1TC3' ,'FE_SH1TC4' ,'FE_SV1TC1' ,'FE_SV1TC2' ,'FE_SV1TC3' ,'FE_SV1TC4' ,'SL1_SH1TC_X1' ,'SL1_SH1TC_X2' ,'SL1_SV1TC_Y1' ,'SL1_SV1TC_Y2' ] # DETECTOR GROUP .......... Mono temperatures CH_MONO_TEMP=['X07MB-OP-MOTHETA:TC1' ,'X07MB-OP-MOTRX:TC1' ,'X07MB-OP-MOC2:TC_Z' ,'X07MB-OP-MOC2:TC_Y'] ID_MONO_TEMP=['MONO_THETA_TC1' ,'MONO_TRX_TC1' ,'MONO_C2_TC_Z' ,'MONO_C2_TC_Y'] for i in range(16): CH_MONO_TEMP.append('X07MB-OP-MO:TC'+str(i+1)) ID_MONO_TEMP.append('MONO_TC'+str(i+1)) #endfor # ............DETECTOR GROUP MONO ENCODERS ... CH_MONO_ENC = [ 'X07MB-OP-MO:C1-EC_ROZ' , 'X07MB-OP-MO:C2-EC_ROX' , 'X07MB-OP-MO:C2-EC_ROZ' ,'X07MB-OP-MO:C1-ROZ.DRBV','X07MB-OP-MO:C2-ROX.DRBV','X07MB-OP-MO:C2-ROZ.DRBV' ,'X07MB-OP-MO:C1-ROZ.DIFF','X07MB-OP-MO:C2-ROX.DIFF','X07MB-OP-MO:C2-ROZ.DIFF' ,'X07MB-OP-MO:C1-EC_ROZ.VAL','X07MB-OP-MO:C2-EC_ROX.VAL','X07MB-OP-MO:C2-EC_ROZ.VAL' ,'X07MB-OP-MO:C2-TRZ.VAL' ,'X07MB-OP-MO:C2-TRZ.RBV' ,'X07MB-OP-MO:C2-TRZ.DIFF' ,'X07MB-OP-MO:C2-TRZ.REP' ,'X07MB-OP-MO:C2-TRY.VAL' ,'X07MB-OP-MO:C2-TRY.RBV' ,'X07MB-OP-MO:C2-TRY.DIFF' ,'X07MB-OP-MO:C2-TRY.REP' ,'X07MB-OP-MO:THETA.VAL' ,'X07MB-OP-MO:THETA.RBV' ,'X07MB-OP-MO:THETA.DIFF' ,'X07MB-OP-MO:THETA.REP'] ID_MONO_ENC = [ 'ROLL1_V' , 'PITCH2_V' , 'ROLL2_V' ,'ROLL1_MUR' , 'PITCH2_MUR' , 'ROLL2_MUR' ,'ROLL1_DIFF','PITCH2_DIFF','ROLL2_DIFF' ,'ROLL1_VOLT','PITCH2_VOLT','ROLL2_VOLT' ,'T1_VAL' ,'T1_RBV' ,'T1_DIFF' ,'T1_REP' ,'T2_VAL' ,'T2_RBV' ,'T2_DIFF' ,'T2_REP' ,'THETA_VAL' ,'THETA_RBV' ,'THETA_DIFF' ,'THETA_REP'] # .................... Detector group Pressures endstation ............................. CH_ES1_PRESS=['X07MB-ES1-MF1:PRESSURE' ,'X07MB-ES1-MC1:PRESSURE' ,'X07MB-OP-KBMF1:PRESSURE' ,'X07MB-OP-SL2MF1:PRESSURE' ] ID_ES1_PRESS=['ES1MF1' ,'ES1MC1' ,'OPKBMF1' ,'OPSL2MF1' ] # .................... Detector group XBPM and microscope missing ............................. # ........................................... XBPM 3 CH_XBPM4=['X07MB-OP2-SAI_19:CUR-MEAN' ,'X07MB-OP2-SAI_20:CUR-MEAN' ,'X07MB-OP2-SAI_21:CUR-MEAN' ,'X07MB-OP2-SAI_22:CUR-MEAN'] ID_XBPM4=['XBPM4_SAI19_CUR_MEAN' ,'XBPM4_SAI20_CUR_MEAN' ,'XBPM4_SAI21_CUR_MEAN' ,'XBPM4_SAI22_CUR_MEAN'] CH_XBPM4_POS=['X07MB-OP-BPM4:POSX' ,'X07MB-OP-BPM4:POSY'] ID_XBPM4_POS=['XBPM4_POSX' ,'XBPM4_POSY'] # ........................................... XBPM 4 CH_XBPM3=['X07MB-OP2-SAI_14:CUR-MEAN' ,'X07MB-OP2-SAI_15:CUR-MEAN' ,'X07MB-OP2-SAI_16:CUR-MEAN' ,'X07MB-OP2-SAI_17:CUR-MEAN'] ID_XBPM3=['XBPM3_SAI14_CUR_MEAN' ,'XBPM3_SAI15_CUR_MEAN' ,'XBPM3_SAI16_CUR_MEAN' ,'XBPM3_SAI17_CUR_MEAN'] CH_XBPM3_POS=['X07MB-OP-BPM3:POSX' ,'X07MB-OP-BPM3:POSY'] ID_XBPM3_POS=['XBPM3_POSX' ,'XBPM3_POSY'] # ........................................... XBPM 3 CH_CAM1_POS=['X07MB-PS1:Stats1:CentroidX_RBV' ,'X07MB-PS1:Stats1:CentroidY_RBV' ,'X07MB-PS1:Stats1:SigmaX_RBV' ,'X07MB-PS1:Stats1:SigmaY_RBV' ,'X07MB-PS1:Stats1:SigmaXY_RBV' ] ID_CAM1_POS=['CentroidX_RBV' ,'CentroidY_RBV' ,'SigmaX_RBV' ,'SigmaY_RBV' ,'SigmaXY_RBV' ] # read channel and initial values for ch_ini_base=beamline+'-PC-PSCAN:' N_initial=6 # for now limit to 5 initial channels i_0 = 0 for i in range(N_initial): print 'read initial value ' + str(i) #print ch_ini_base+'ChInit'+str(i)+'-ACT' this_active = get_epicsPV(ch_ini_base+'ChInit'+str(i)+'-ACT') time.sleep(0.05) #print this_active if (i_0 ==0 ) and ( this_active== 1) : #print ' first region active' CH_INITIAL = [get_epicsPV(ch_ini_base+'ChInit'+str(i))] time.sleep(0.05) CH_INITIAL_V = [get_epicsPV(ch_ini_base+'VChInit'+str(i))] time.sleep(0.05) i_0=i_0+1 else: if ( this_active== 1): #print 'next found ' time.sleep(0.05) CH_INITIAL.append(get_epicsPV(ch_ini_base+'ChInit'+str(i))) time.sleep(0.05) CH_INITIAL_V.append(get_epicsPV(ch_ini_base+'VChInit'+str(i))) # endif # endelse # endfor if (i_0 == 0 ): CH_INITIAL = ['NO_INITIAL_VALUES'] CH_INITIAL_V = [0] #print CH_INITIAL #print CH_INITIAL_V # ________________ finally do consistency checks on the input data # CASE 1 emergengy stop if number of choosen roi is larger that the number of available rois if ((n_roi_for_xas >= n_roi) and (n_roi <> -1) and (n_roi_for_xas <> -1)) and (XMAP_save_only_xas_roi <> 1 ) : # if values are negative, XMAP is not used.. error_stop('!!!!! INCONSISTENT INPUT: Number of Roi for XAS larger than choosen roi !!!') # endif # CASE 2 emergengy stop if there are no active regions # finally collect all read data into one structure, which completely defines the scan. # This structure is returned as result of thie routine. # All all readouts of this structure are adressed by the structure names, and never by indices, # the structure can be extendened in a very general way # on the longterm one could envision that the python routine just monitors all chanels, and # creates a regular update... this would avoid the -time consuming- rereading of all # chanels for every creation # of the measurements scripts. box={ 'filename' : filename , 'beamline' : beamline , 'preactions' : preactions , 'detector_actions' : detector_actions , 'scan_type' : scan_type , 'n_roi_for_xas' : n_roi_for_xas , 'n_roi_for_xas_index' : n_roi_for_xas_index , 'n_roi' : n_roi , 'n_det_fluo' : n_det_fluo , 'd_list_fluo' : d_list_fluo , 'Id_XMAP_roi_by_name' : Id_XMAP_roi_by_name , 'XMAP_roi_numbers' : XMAP_roi_numbers , 'XMAP_name_convention' : XMAP_name_convention , 'XMAP_save_only_xas_roi' : XMAP_save_only_xas_roi , 'XMAP_save_spectra' : XMAP_save_spectra , 'number_of_executions' : number_of_executions , 'detectors' : detectors , 'detectors_to_plot' : detectors_to_plot , 'n_e' : n_e , 'e_active' : e_active , 'e_i' : e_i , 'e_f' : e_f , 'e_delta' : e_delta , 'e_n_cycles' : e_n_cycles , 'n_exafs' : n_exafs , 'e_ex_E_edge' : e_ex_E_edge , 'e_ex_active' : e_ex_active , 'e_ex_e_i' : e_ex_e_i , 'e_ex_e_f' : e_ex_e_f , 'e_ex_k_i' : e_ex_k_i , 'e_ex_k_f' : e_ex_k_f , 'e_ex_d_i' : e_ex_d_i , 'e_ex_ncy' : e_ex_ncy , 'e_ex_ncy_f' : e_ex_ncy_f , 'e_ex_icy' : e_ex_icy , 'e_ex_nst' : e_ex_nst , 'e_ex_t' : e_ex_t # , 'e_channel' : 'X07MB-OP-MO:E-SET' # PHOENIX I NEED A CHECK that we canonly run the right mono in the script! # , 'e_channel_rbv' : 'X07MB-OP-MO:E-GET' #, 'e_channel' : 'X07MA-PHS-E:GO.A' # XTREME #, 'e_channel_rbv' : 'X07MA-PGM:CERBK' , 'e_channel' : 'X07MB-OP:userCalc1.L' # test write energy in calc record , 'e_channel_rbv' : 'X07MB-OP:userCalc1.L' , 'n_p' : n_p , 'p_channel' : p_channel , 'p_channel_rbv' : p_channel_rbv , 'p_id' : p_id , 'p_positioner_active': p_positioner_active , 'p_label' : p_label , 'p_data' : p_data , 'p_done' : p_done , 'p_done_switch' : p_done_switch , 'r_energy_cycles' : r_energy_cycles , 'r_energies' : r_energies , 'r_energies_active' : r_energies_active , 'r_channel' : r_channel , 'r_channel_rbv' : r_channel_rbv , 'r_indices' : r_indices , 'r_id' : r_id , 'r_active' : r_active , 'r_ll_x' : r_ll_x , 'r_ll_y' : r_ll_y , 'r_ur_x' : r_ur_x , 'r_ur_y' : r_ur_y , 'r_delta_x' : r_delta_x , 'r_delta_y' : r_delta_y , 'r_num' : r_num , 'r_done' : r_done , 'r_done_switch' : r_done_switch , 'CH_CAM1_POS' : CH_CAM1_POS , 'ID_CAM1_POS' : ID_CAM1_POS , 'CH_BL_PRESS' : CH_BL_PRESS , 'ID_BL_PRESS' : ID_BL_PRESS , 'CH_BL_TEMP' : CH_BL_TEMP , 'ID_BL_TEMP' : ID_BL_TEMP , 'CH_MONO_TEMP' : CH_MONO_TEMP , 'ID_MONO_TEMP' : ID_MONO_TEMP , 'CH_MONO_ENC' : CH_MONO_ENC , 'ID_MONO_ENC' : ID_MONO_ENC , 'CH_ES1_PRESS' : CH_ES1_PRESS , 'ID_ES1_PRESS' : ID_ES1_PRESS , 'CH_XBPM3' : CH_XBPM3 , 'ID_XBPM3' : ID_XBPM3 , 'CH_XBPM3_POS' : CH_XBPM3_POS , 'ID_XBPM3_POS' : ID_XBPM3_POS , 'CH_XBPM4' : CH_XBPM4 , 'ID_XBPM4' : ID_XBPM4 , 'CH_XBPM4_POS' : CH_XBPM4_POS , 'ID_XBPM4_POS' : ID_XBPM4_POS , 'DAQ_XMAP' : DAQ_XMAP , 'CH_INITIAL' : CH_INITIAL , 'CH_INITIAL_V' : CH_INITIAL_V , 'CH_User_detector' : CH_User_detector , 'User_detector_fda_id' : User_detector_fda_id } print box print detectors print('preactions') print preactions return box