Configuration change: Context

This commit is contained in:
gac-x07mb
2022-03-04 14:28:28 +01:00
commit 0defe64bda
105 changed files with 101731 additions and 0 deletions
+333
View File
@@ -0,0 +1,333 @@
import traceback
import imp
import os
from CaChannel import *
from epicsMotor import *
from epicsPV import *
import time
import string
import sys
import json
# TO DO: Energy scan has onlz 1 positioner
# need to generalize definition of scans to several paraller positiner,
# to be able to use Create_Channels, alteratively need a dedicate channel creation for each scan type
# tricky, code should stay simple
# options.
# Define channel generation for each chanenl separatelz
# generalze scand to 1d and 2d with seveal posittioner in each dimension.
# this will get complicated .....
import X_X07MB_Pscan as PS
import X_X07MB_lib as PL
imp.reload(PS) # always reload module
imp.reload(PL) # always reload module
NoRead=0
def before_pass():
get_context().dataManager.provider.embeddedAtributes = False
# Called at begining pf scan
print('before_pass')
SC.PerformActions('Pre_Actions')
pars=get_exec_pars()
print('pars.output : ')
print(pars.output)
print('pars.scanPath: ')
print(pars.scanPath)
print('pars.name: (filename) ')
print(pars.name)
# missing
# NEED TO SET path for Moench here
#end before_pass
def before_read():
# Cannot call routine in class in rscan call, need to go via local routine
#print('before_read')
# SC.DetectorActions() excecutes all standard action as defied in GUI
SC.PerformActions('Detector_Actions')
#print('.... done before_read ' )
# alternativly use caput here explicitly...
# if needed
#end before read
def after_read(rec,scan):
print('ENTER after_read .................' )
# Called after reading
# calculate default dead time corrections and writ to file
SC.after_read_dtc(rec,scan)
print('.... done after_read ' )
return
#end after_read init
def after_pass():
# Called after scan
print('after_pass')
SC.PerformActions('Post_Actions')
print('................ done after_pass')
#end after pass
def before_region(index,scan):
print (index)
# make some reset
try:
del SC
except:
SC=0
#endexept
# originbal tag for data saving
# '{data}/{year}/{month}/{day}/{year}_{month}{day}_{time}_{name}'
# ........... FIrst read the scan
#
# ====================================================
#
# SCRIPT STARTS HERE
#
# ====================================================
if NoRead==0:
try:
SD = 0
SD = PS.get_channels('SPECTRA') # READ SCAN DEFINITION FROM GUI USING OLD CODE
print('returned from PS.get_channels()')
SC=0
SC=PL.PscanLib(SD,Channel,caput,caputq,caget,cawait,get_exec_pars,create_table,append_table) # create instance of library
print('... done SC.Create_All_Sensors()')
SD.update({'All_Sensors':[]})
except:
traceback.print_tb(sys.exc_info()[2])
raise
# endexcept
# endif
# example add new sensor, similarly add pre and postactions to existing code
New_Sensors=[]
New_Sensors.append({'channel_name': 'X07MB-ES-MA1:ScanY.RBV'
, 'Subset_1': False
, 'Det_type': 'ScalarDetector'
, 'alias': 'MYSCANY_RBV'
, 'data_type': 'double'})
# examples add post action light on
SD['Post_Actions'].append({'channel_name': 'X07MB-ES1-PP2:VO5'
, 'data_type': 'String'
, 'alias': 'Light_ON'
, 'operation': 'put'
, 'delay' : 0.1
, 'value' : 5 })
# END OF USER INPUT
# .... add new sensors to list
try:
try:
del AllSensors
except:
AllSensors=0
#endecsept
All_Sensors = SC.Create_Sensor_List() # Create instance for all sensors
SC.Add_New_Sensors(New_Sensors) # Add user sensors
except:
traceback.print_tb(sys.exc_info()[2])
raise
# endexcept
# STRUCTUALR INCONSITENCY NEED TO CREATE List of sensors first
# without making Channel command.... !
#
# TEST SAVE SCAN DEFINITION...Needs to be before definition
# SD is full GUI definiton of the scan try to save and reread this definiton
SD.update({'New_Sensors' : New_Sensors})
f=open('scandef.dat','w')
# Method to save abnd restore full scan definition...
with open('BaseScanDefinition.json', 'w') as fp:
json.dump(SD, fp,ensure_ascii=True)
#endwith
with open('BaseScanDefinition.json', 'r') as dd:
SD_reread=json.load(dd)
# .. this works, reread is unicode not string, but code seems still to work if all entries are in unicode
# step I: CREATE ALL SENSORS AND STORE IN A LIST
print('++++++++++++++++++++++++++')
AllSensors=0
try:
# Code for beamline save......
SavePhoenix=PL.SavePhoenix(Channel,caput,caputq,caget,cawait) # Channel,caput,caputq,caget,cawait)
# SavePhoenix.write_beamline_data().. Works., move to before pass...
SC.noprint=0 # chose printing from SD on / off
# Now creat all epics instances. print('... done SC.Create_All_Sensors()')
SD.update({'All_Sensors':All_Sensors})
SC.Create_Channels('All_Sensors')
SC.Create_Channels('All_Positioner')
SC.Create_Channels('Detector_Actions')
SC.Create_Channels('Pre_Actions')
SC.Create_Channels('Post_Actions')
SC.Create_Channels('Energy_Scan')
except:
traceback.print_tb(sys.exc_info()[2])
raise
# endexcept
# ... create some abbreviations...
All_Sensors = SC.All_Sensors
All_Positioner = SD['All_Positioner']
Pre_Actions = SD['Pre_Actions']
Post_Actions = SD['Post_Actions']
Detector_Actions = SD['Detector_Actions']
Energy_Scan = SD['Energy_Scan']
#............SOME OUTPUT
#print('----------- All_Positioner ---')
#print(' ')
#print(SD['All_Positioner'])
#print(' ------------ Pre_Action -------- ')
#print(' ')
#print(SD['Pre_Actions'])
#print(' ------------ Post_Action -------- ')
#print(' ')
#print(SD['Post_Actions'])
#print(' ')
#print(' ----------- Detector_Action--------- ')
#print(' ')
#print(SD['Detector_Actions'])
## ............. MISSING CREATE POSTACTIONS::::::
# STEP II read the energy position
print('')
print('..................................... positioner Energy ID? readback automatically saved? ')
print('initial energies e_i ',SD['e_i'])
print('final energies e_f ',SD['e_f'])
print('DELTA E e_delta ',SD['e_delta'])
print('DWELL TIME e_n_cycles',SD['e_n_cycles'])
print(SD['Energy_Scan']['Energy_Ranges'])
#try:
# EnergyRanges,Cycles = SC.PositionerEnergyScan()
#except:
# traceback.print_tb(sys.exc_info()[2])
# raise
# endexcept nowcall
#print(EnergyRanges,Cycles)
# STEP II ... read the detector actions
# Step IV perform the Preaction
#P=SC.DetectorActions()
print(All_Sensors)
print('Energy_Ranges')
print(SD['Energy_Scan']['Energy_Ranges'])
pars=get_exec_pars()
print('pars.output')
print(pars.output)
print('pars.scanPath')
print(pars.scanPath)
print(' ')
print('---------------')
print(' ')
print(' CALL SCAN NOW ')
print(' ')
p=set_exec_pars(name=SD['filename'])
# This is one singe energy scan:
# save scan definition
get_context().dataManager.provider.embeddedAtributes = False
# .. now make individual scan for all positioners as defiens in GUI
# as we like want to have separete datasets for each scan \
#
for i in range(len(All_Positioner[0]['value'])): # loop in number of points
# set all positioner
for j in range(len(All_Positioner)): # set positioner
t0=time.time()
ThisPositioner = All_Positioner[j]['Channel']
ThisPosition = All_Positioner[j]['value'][i]
print('next,i,j',i,j)
print('name',All_Positioner[j]['channel_name'])
print('value',All_Positioner[j]['value'][i])
print(time.time()-t0)
# .............. SET NEW POSITIONER
#ThisPositioner.write(ThisPosition)
ThisPositioner.put(ThisPosition)
#ThisPositioner.putq(ThisPosition) # simultaneous walk no waiting..
print(time.time()-t0)
#endfor loop set positioner
# generate filename
p=set_exec_pars(name=SD['filename']+'_'+All_Positioner[0]['label'][i])
pars=get_exec_pars()
print('filename this run : ')
print(pars.name)
print('--------------- NEXT SCAN ----------------')
try:
#call rscan
print('cal rscan ')
#rscan(SD['Energy_Scan']['Channel']
# , SC.get_list(All_Sensors,'Channel')
# , regions=SD['Energy_Scan']['Energy_Ranges']
# , latency = 0.0, relative = False
# , before_pass = SC.PerformActions('Pre_Actions') # before_pass
# , before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
# , after_read = SC.after_read_dtc #after_read
# , after_pass = after_pass
# , before_region = before_region
# , enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
#vscan(SD['Energy_Scan']['Channel']
# , SC.get_list(All_Sensors,'Channel')
# , vector=SD['Energy_Scan']['Energy_Scan_Positions']
# , latency = 0.0, relative = False
# , before_pass = SC.PerformActions('Pre_Actions') # before_pass
# , before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
# , after_read = SC.after_read_dtc #after_read
# , after_pass = after_pass
# , before_region = before_region
# , enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
except:
traceback.print_tb(sys.exc_info()[2])
raise
# END EXecpt
#endfor
#endfor
print('... scan finished ')
#
#ret = lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, enabled_plots=['X07MB-OP2-SAI_07:MEAN'])
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
#def BeforeReadout(position, scan):
# print "In position: " + str(pposition)
#def AfterReadout(record, scan):
# print "Aquired record: " + str(record)
#lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
#ascan(["ca://X07MB-OP-MO:E-SET", "X07MB-ES-MA1:ScanX.VAL"], sensors, start=[2450, 1.6], end=[2460, 1.8], steps=[2.0,0.05], latency=0.0, relative = False, zigzag = True)
##
#
# Vizualization...............
#
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
pos = Channel('X07MB-OP-MO:E-SET', alias="POS", type='s')
c1 = Channel('X07MB-OP2-SAI_07:MEAN', alias="TEST")
c2 = Channel('X07MB-OP-MO:E-GET', alias="TEST2")
sensors = [c1,c2]
ret = lscan(pos, sensors, start=2450, end=2460, steps=10)
for c in sensors: c.close()
+139
View File
@@ -0,0 +1,139 @@
#Script imported from: Mono_pitch.xml
#Pre-actions
caput('X07MB-OP2:START-CSMPL', '0')
sleep(0.1)
caput('X07MB-XMAP:StopAll', '1')
sleep(0.1)
caput('X07MB-XMAP:PresetMode', '0')
sleep(0.1)
caput('X07MB-XMAP:PresetReal', '0')
sleep(0.1)
caput('X07MB-OP2:TOTAL-CYCLES', '1')
sleep(0.1)
print('dd')
#TODO: Set the diplay names of positioners and detectors
scan = ManualScan(['Pitch'], ['bm3', 'bm4', 'Filter_RY', 'Harmonic', 'TC_Y', 'TC_Z', 'T_THETA', 'Id_OFF', 'Id_energy', 'E_Mono', 'Bragg_Id_theo', 'Theta_rbv', 'Theta_offset', 'Delta_E', 'Delta_theta', 'XX'] , [-10700.0], [-10750.0], [25])
scan.start()
#Creating channels: dimension 1
#LinearPositioner Pitch
Pitch = Channel('X07MB-OP-MO:C2-ROX.VAL', type = 'd')
PitchReadback = Channel('X07MB-OP-MO:C2-ROX.RBV', type = 'd')
#ScalarDetector bm3
bm3 = Channel('X07MB-OP2-SAI_03:MEAN', type = 'd')
#ScalarDetector bm4
bm4 = Channel('X07MB-OP2-SAI_04:MEAN', type = 'd')
#ScalarDetector Filter_RY
Filter_RY = Channel('X07MB-OP-FI:ROY.VAL', type = 'd')
#ScalarDetector Harmonic
Harmonic = Channel('X07MA-ID:HARMONIC', type = 'd')
#ScalarDetector TC_Y
TC_Y = Channel('X07MB-OP-MOC2:TC_Y', type = 'd')
#ScalarDetector TC_Z
TC_Z = Channel('X07MB-OP-MOC2:TC_Z', type = 'd')
#ScalarDetector T_THETA
T_THETA = Channel('X07MB-OP-MOTHETA:TC1', type = 'd')
#ScalarDetector Id_OFF
Id_OFF = Channel('X07MA-ID:ENERGY-OFFS', type = 'd')
#ScalarDetector Id_energy
Id_energy = Channel('X07MA-ID:ENERGY', type = 'd')
#ScalarDetector E_Mono
E_Mono = Channel('X07MB-OP-MO:E-GET', type = 'd')
#ScalarDetector Bragg_Id_theo
Bragg_Id_theo = Channel('X07MB-OP-MO:BRAGG-CALC', type = 'd')
#ScalarDetector Theta_rbv
Theta_rbv = Channel('X07MB-OP-MO:THETA.RBV', type = 'd')
#ScalarDetector Theta_offset
Theta_offset = Channel('X07MB-OP-MO:THETA.OFF', type = 'd')
#Dimension 1
#Dimension Guard
cawait('ACOAU-ACCU:OP-MODE', 6, type = 'l')
#LinearPositioner Pitch
for setpoint1 in frange(-10700.0, -10750.0, -2.0, True):
if setpoint1 > -10700.0 or setpoint1 < -10750.0:
break
Pitch.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
readback1 = PitchReadback.get()
if abs(readback1 - setpoint1) > 10.0 : # TODO: Check accuracy
print readback1, setpoint1
raise Exception('Actor Pitch could not be set to the value ' + str(setpoint1))
#Detector bm3
#Detector X07MB-OP2-SAI_03:MEAN pre-actions
caput('X07MB-OP2:SMPL', '1')
sleep(0.1)
cawait('X07MB-OP2:SMPL-DONE', 1, type = 'l')
detector1 = bm3.get()
#Detector bm4
detector2 = bm4.get()
#Detector Filter_RY
detector3 = Filter_RY.get()
#Detector Harmonic
detector4 = Harmonic.get()
#Detector TC_Y
detector5 = TC_Y.get()
#Detector TC_Z
detector6 = TC_Z.get()
#Detector T_THETA
detector7 = T_THETA.get()
#Detector Id_OFF
detector8 = Id_OFF.get()
#Detector Id_energy
detector9 = Id_energy.get()
#Detector E_Mono
detector10 = E_Mono.get()
#Detector Bragg_Id_theo
detector11 = Bragg_Id_theo.get()
#Detector Theta_rbv
detector12 = Theta_rbv.get()
#Detector Theta_offset
detector13 = Theta_offset.get()
#Manipulation Delta_E
#Variable Mappings
a = detector10
b = detector9
Delta_E = a-b
#Manipulation Delta_theta
#Variable Mappings
a = detector11
b = detector12
Delta_theta = a-b
#Manipulation XX
#Variable Mappings
a = detector11
b = detector12
XX = a*b
print(XX)
scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, detector10, detector11, detector12, detector13, Delta_E, Delta_theta, E_Mono, XX])
#Closing channels
Pitch.close()
PitchReadback.close()
bm3.close()
bm4.close()
Filter_RY.close()
Harmonic.close()
TC_Y.close()
TC_Z.close()
T_THETA.close()
Id_OFF.close()
Id_energy.close()
E_Mono.close()
Bragg_Id_theo.close()
Theta_rbv.close()
Theta_offset.close()
scan.end()
#Post-actions
caput('X07MB-OP2:START-CSMPL', '1')
sleep(0.1)
caput('X07MB-OP2:START-CSMPL', '1')
sleep(0.3)
caput('X07MB-OP2:SMPL', '1')
sleep(0.3)
caput('X07MB-OP2:SMPL', '1')
sleep(0.3)
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
###################################################################################################
# Demonstrate use of Vector Scan: one or multiple positioners set with a list or generator.
###################################################################################################
class PseudoPositioner(Writable):
def write(self,pos):
print "Step = " + str(pos)
#caput()
#cawait()
positioner=PseudoPositioner()
class Clock(Readable):
def read(self):
return time.clock()
clock=Clock()
lscan(positioner,[clock], start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
+9
View File
@@ -0,0 +1,9 @@
set_exec_pars(format="h5", name="")
lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10)
sensors=['ca://X07MB-OP2-SAI_07:MEAN', 'ca://X07MB-OP-MO:E-GET']
ret = lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, enabled_plots=['X07MB-OP2-SAI_07:MEAN'])
@@ -0,0 +1,12 @@
def BeforeReadout(position, scan):
print "In position: " + str(position) + str(sensors)
def AfterReadout(record, scan):
print "Aquired record: " + str(record)
lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
+10
View File
@@ -0,0 +1,10 @@
d={'a':1,
'b':2}
print(d)
d.update({'c':5})
print(d)
print(type(d))
+26
View File
@@ -0,0 +1,26 @@
class test:
d=5
d1='d'
#endclass
def tt(a):
print('2')
#enddef
tt(9)
print(test.d)
print(test.d1)
box={ 'filename' : 'd'
, 'beamline' : 'dd'}
print(box)
f=[1,2,2]
plot(f,title='f')
f1=get_plot_snapshots()
print(f1)
import os
import numpy
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,543 @@
#! /usr/bin/env python
# ----------------------------------------------------------------------------------------
def write_xml_XAS_single_point(g,N_position,BASE_DIR):
# ==================================================================================
#
# THIS ROUTINE CREATES THE XML FILE FOR TAKING XAS SPECTRA ON VARIOUS DATA POINTS
#
#
# Author T. Huthwelker October 2011 ---
#
# =================================================================================
filename=str(g['filename']) + '_' + str(g['p_label'][N_position])
number_of_executions= str(g['number_of_executions'])
filename_xml=BASE_DIR+"points_q_" +str(N_position)+'_'+ str(g['p_label'][N_position]) + ".xml"
filename_xml=BASE_DIR+"points_q_" +str(N_position)+ ".xml"
print filename
print filename_xml
f = open(filename_xml, "w")
# ............. write header and open configuration ......................
f.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+'\n')
f.write('<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="'+str(1)+'" failOnSensorError="true">'+'\n')
# option to take the number o repeats on panel as number of excecutions for each individual run
#num_ex=get_epicsPV('X07MB-PC-PSCAN:FdaNexec')
#f.write('<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="'+str(int(num_ex))+'" failOnSensorError="true">'+'\n')
f.write('<data format="txt" fileName="'+'XAS_'+filename+'"/>'+'\n')
# define default Variable
Write_Variable_Definitions(f,g)
# -------------------------- general preactions..........
f.write('<scan> \n ')
write_preactions(f,g)
#___________________________________________ ______________ dimension 1 Energy
f.write('<dimension zigzag="false" dataGroup="false"> \n') # -..... open dimension 1
# ......... open positioner
write_start_positioner(f,{'Type' : 'RegionPositioner'
,'Ch_set' : g['e_channel']
,'Ch_done' : 'None'
,'Ch_readback' : g['e_channel_rbv']
,'Settling_time' : '0.2'
,'Id' : 'Energy'})
ch_preaction='X07MB-OP2:TOTAL-CYCLES'
#print g['e_i']
#print g['e_f']
#print g['e_active']
#print g['n_e']
for i in range(g['n_e']):
if g['e_active'][i] == 1:
print i
print g['e_active'][i]
print g['e_i'][i]
write_region(f,{'V_ini' : g['e_i'][i]
,'V_final' : g['e_f'][i]
,'V_delta' : g['e_delta'][i]
,'Ch_preaction' : ch_preaction
,'Ch_preaction_value' : g['e_n_cycles'][i]})
# endif
# endfor
# NOw add one positioner for EXAFS with a non-linear gris spacing Currently only one range
print 'kkkkkkkkkk'
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']
write_EXAFS_region(f,g)
f.write('</positioner> \n') # -..... close positoner
# ____________________________________________________ DETECTORS.............................
# ......actions for detectors for each measurement
write_detector_actions(f,g)
# ... write guard, must be in first loop after detector actions...
#write_guard(f,{'Channel' : 'ACOAU-ACCU:OP-MODE'
# ,'Value' : 6 })
# ...................create all entries for the detectors......
[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_all_detectors(f,g)
# .. other detectors...
#write_detector(f,{'Det_type' : 'ScalarDetector'
# ,'Data_type' : 'Double'
# ,'Channel' : 'X07MB-ES1:userCalc3.VAL'
# ,'Id' : 'T_heater_C '})
#write_detector(f,{'Det_type' : 'ScalarDetector'
# ,'Data_type' : 'Double'
# ,'Channel' : 'X07MB-ES1-PP3:PT1'
# ,'Id' : 'T_heater_V'})
#write_detector(f,{'Det_type' : 'ScalarDetector'
# ,'Data_type' : 'Double'
# ,'Channel' : 'X07MB-ES1-PP3:PT2'
# ,'Id' : 'T_sample_V'})
#write_detector(f,{'Det_type' : 'ScalarDetector'
# ,'Data_type' : 'Double'
# ,'Channel' : 'X07MB-ES1-PP2:VO1'
# ,'Id' : 'U_heater_SET'})
# use guard, stop DAQ if there is no light
# ____________________________________________________ dimension 2 position Manipulator
# write positioner for default chanels onlz if thez are defined...
print g['p_positioner_active']
print g['p_channel']
print g['p_id']
print g['p_id'][0]
print ' '
print 'g[p_data]'
print g['p_data']
print ' '
print g['p_data'][0]
f.write('</dimension> \n') # -..... close dimension 1
if sum(g['p_positioner_active']) > 0:
f.write('<dimension> \n ') # -..... open dimension 2
print g['p_channel']
print g['p_done_switch']
for i in range(len(g['p_id'])):
write_array_positioner(f,{'Channel' : g['p_channel'][i]
, 'Channel_rbv' : g['p_channel_rbv'][i]
, 'Id' : g['p_id'][i]
, 'Positions' : [g['p_data'][i][N_position]]
, 'Channel_done': g['p_done'][i]
, 'Use_done_value': g['p_done_switch'][i]
}
)
#endfor
# ... before closing dimensions, set a guard on the beam current
# 31.7.2012 temp commented out........
f.write('</dimension> \n') # -..... close dimension 2
#endif
# ....................postaction after detectors
f.write(post_action_channel_action('X07MB-OP2:START-CSMPL','1','put','String','0.1'))
write_default_postactions(f,g)
# ==============================================================================================
# ..........write all manipulations.... possible move away from hre into a standard routine
# ==============================================================================================
# first walk through all detectors....
for i in range(len(g['detectors'])): # outer loop: walk through all defined detector
# types. Only if type Vortex is defined, we write the
# manipulations needed for dead time correction of Vortex
#
if (g['detectors'][i] == 'Vortex') or (g['detectors'][i] == 'ROENTEC_XMAP') or (g['detectors'][i] == 'KETEK_XMAP'):
# ......o.k. Vortex s defined, now make dead time corrections for
# all rois from Vortex detector.
#print n_det_vortex,n_roi_vortex
print n_roi_vortex
print range(n_roi_vortex)
# manipulation to calulate the true ICR
for j in range(n_det_vortex):
write_manip_calc_TrueICR(f,{'Id_icr' : id_icr_vortex[j]
, 'Id_ocr' : id_ocr_vortex[j]
, 'Id_elapsedTime': id_ertm_vortex[j]
, 'Id_out' : id_trueicr_vortex[j]})
# endfor
# note at later stage use result from calculated true ice as input for subsequent manipulations.
for k in range(n_roi_vortex):
for j in range(n_det_vortex):
# create array with Id for all detectors for roi # k
if j ==0:
id_roi_for_det_sum=[id_roi_vortex[0][k]+'_corr']
else:
id_roi_for_det_sum.append(id_roi_vortex[j][k]+'_corr')
# endelse
print ' next in loop writin manipulator..'
print n_det_vortex,n_roi_vortex
print i,j,k
print id_roi_vortex[j][k]
print id_icr_vortex
# ... MISSING HERE OPTION TO SET ESTIMATE FOR DEAD TIME CORRECTION FOR DIFFERENT PEAKING TIMES .............
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_elapsedTime': id_ertm_vortex[j]
, 'Id_out' : id_roi_vortex[j][k]+'_corr'})
# write manipulations for division of roi by all user detector (only of user det = on is choosen..)
# need to add new flagg...
print g['User_detector_fda_id']
print g['detectors_to_plot']
if 'PL_USER_DET' in g['detectors_to_plot']:
for i_ud in range(len(g['User_detector_fda_id'])):
print i_ud
write_manip_divide_channels(f,{'Id_out': id_roi_vortex[j][k]+'_corr_over_'+g['User_detector_fda_id'][i_ud]
, 'Id_1': id_roi_vortex[j][k]+'_corr'
, 'Id_2': g['User_detector_fda_id'][i_ud]})
# endfor i_UD
# endif
# now manipulations for all detector for this rois
# now calculate ths sum of deadtime corrected
# detector data
# this_id_roi = id_roi_vortex[0][k][len(id_roi_vortex[0][k])-3:len(id_roi_vortex[0][k])] # remove D1_ from ID name
this_id_roi = id_roi_vortex[0][k][3:len(id_roi_vortex[0][k])] # remove D1_ from ID name
#print 'idroi ' ,id_roi_vortex
#print 'aaa',id_roi_vortex[0][k],'bbb'
#print 'len',len(id_roi_vortex[0][k])
#print 'this_id_roi ',this_id_roi
write_manip_sum_vortex(f,{'Id_roi' : id_roi_for_det_sum
, 'Id_out' : this_id_roi+'_sum_cps'})
# endfor
# endif
# endfor
f.write('</scan> \n ') # -..... close scan # END OF SCAN
# finally add the visualization .................
# plot ICR and OCR for all VORTEX DETECTORS....
# case I vortex 4-element detector
if ('Vortex' in g['detectors']):
#if n_det_vortex == 4 :
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : 'D1_ICR D2_ICR D3_ICR D4_ICR D1_TrueICR D2_TrueICR D3_TrueICR D4_TrueICR'
, 'Title' : 'ICR ' })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : 'D1_OCR D2_OCR D3_OCR D4_OCR'
, 'Title' : 'OCR ' })
#write_visualization(f,{ 'Type': 'LinePlot'
# , 'X' : 'Energy'
# , 'DATA' : 'I0_KEITHLEY1'
# , 'Title' : 'I0 (KEITHLEY 1)' })
#write_visualization(f,{ 'Type': 'LinePlot'
# , 'X' : 'Energy'
# , 'DATA' : 'I1_KEITHLEY 2'
# , 'Title' : 'I1 (KEITHLEY 2)' })
# now plot the roi for XAS
print 'id_roi_vortex[0]'
print id_roi_vortex[0]
print "g[n_roi_for_xas]"
print g['n_roi_for_xas']
print g['n_roi_for_xas_index']
print id_roi_vortex[0][g['n_roi_for_xas_index']]
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[0][g['n_roi_for_xas_index']]
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']] })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[1][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[1][g['n_roi_for_xas_index']]
, 'Title' : id_roi_vortex[1][g['n_roi_for_xas_index']] })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[2][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[2][g['n_roi_for_xas_index']]
, 'Title' : id_roi_vortex[2][g['n_roi_for_xas_index']] })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[3][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[3][g['n_roi_for_xas_index']]
, 'Title' : id_roi_vortex[3][g['n_roi_for_xas_index']] })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr'
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr' })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[1][g['n_roi_for_xas_index']]+'_corr'
, 'Title' : id_roi_vortex[1][g['n_roi_for_xas_index']]+'_corr' })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[2][g['n_roi_for_xas_index']]+'_corr'
, 'Title' : id_roi_vortex[2][g['n_roi_for_xas_index']]+'_corr' })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr'
, 'Title' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr' })
# now also vizualize roi over user detectors if user detectors are defined..
if (('PL_USER_DET' in g['detectors_to_plot']) and ('USER_DET' in g['detectors'])):
for i_ud in range(len(g['User_detector_fda_id'])):
print i_ud
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr_over_'+g['User_detector_fda_id'][i_ud]
, 'Title' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr_over_'+g['User_detector_fda_id'][i_ud]}
)
# endif
# case II Roentex via XMAP
if ('ROENTEC_XMAP' in g['detectors']):
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : 'D1_ICR D1_TrueICR'
, 'Title' : 'ICR ' })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : 'D1_OCR '
, 'Title' : 'OCR ' })
# now plot the roi for XAS
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[0][g['n_roi_for_xas_index']]
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']] })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr'
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr' })
# endif
if ('KETEK_XMAP' in g['detectors']):
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : 'D2_ICR D2_TrueICR'
, 'Title' : 'ICR ' })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : 'D2_OCR '
, 'Title' : 'OCR ' })
# now plot the roi for XAS
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']] +' '+ id_roi_vortex_dxp[0][g['n_roi_for_xas_index']]
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']] })
write_visualization(f,{ 'Type': 'LinePlot'
, 'X' : 'Energy'
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr'
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr' })
# endif
# finally add optional plots to data set
special_visualization(f,g,{'Id_X': 'Energy', 'Id_Y':'undefined', 'Type':'LinePlot' })
f.write('</configuration>'+'\n') # close configuration # END OF CONFIGURATION
# END ROUTINE
from X_X07MB_Pscan import *
import commands
import os
import subprocess
import time
# from subprocess import call
# HERE THE MaiN PRG STARTS.....
#detectors=[' ',' ',' ']
#n_e=5
#e_active = create_int_zeros(n_e)
#e_i = create_real_zeros(n_e)
#e_f = create_real_zeros(n_e)
#e_delta = create_real_zeros(n_e)
#n_p = 10
#p_active = create_int_zeros(n_p)
#p_scanx = create_real_zeros(n_p)
##p_scany = create_real_zeros(n_p)
#p_theta = create_real_zeros(n_p)
#p_trx = create_real_zeros(n_p)
#p_trz = create_real_zeros(n_p)
g=get_channels('SPECTRA_QUEUE')
beamline='X07MB'
# .... check if PHOENIX is ONLINE, if offline, diconnect undulator - mono coupling....
#dddd
if g['scan_type'] == 'SPECTRA_QUEUE':
print 'WRITE XML FILE'
#print g['p_positioner_active']
#print len(g['p_id'])
i=0
#print g['p_id']
#print g['p_channel']
# define base dir for tmp storage
#BASE_DIR='/sls/X07MB/data/settings/GUI_TMP/'
# writte directly into correct directory..
BASE_DIR='/sls/X07MB/data/x07mbop/operation/fda/scans/users/0_Scripted/'
for N_position in range(g['n_p']):
print ' write xml file for point' +str(N_position)
write_xml_XAS_single_point(g,N_position,BASE_DIR)
print '... done'
#endfor
print 'DONE WINDOW CLOSED in 3 sec '
time.sleep(3)
# now copy file to correct place...
commands.getstatusoutput('ls /bin/ls')
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
#!/usr/bin/env python
+21
View File
@@ -0,0 +1,21 @@
###################################################################################################
# Direct creation of plots
###################################################################################################
data_1d = [10.0, 20.0, 30.0, 50.0, 80.0]
data_2d = [ data_1d, data_1d, data_1d, data_1d, data_1d]
data_3d = [ data_2d, data_2d , data_2d, data_2d, data_2d]
data_x = [1.0, 2.0, 3.0, 4.0, 5.0]
data_y = [2.0, 4.0, 6.0, 8.0, 10.0]
#1d-plot with optional xdata
plot(data_1d, title = "1d", xdata = data_x)
#2d-plot with optional xdata and ydata
plot(data_2d, title = "2d", xdata = data_x, ydata = data_y)
#3d-plot
plot(data_3d, title = "3d")
#3 plots in the save panel
plot([data_1d, data_2d, data_3d], ["1d", "2d", "3d"])
+135
View File
@@ -0,0 +1,135 @@
Setting PHOENIX Beamline
time Mon Jul 27 15:49:54 2020
====================================================
Undulator 1
Undulator_Energy 2540.0 Undulator_Offset -1.0 Undulator_Harmonic 5
Undulator_Gap_Set 32.653426886 Undulator_Gap_Read 70.0000664062 Undulator_Shift_Set 0.0 Undulator_Shift_Read 0.00028125
==================================================
-------------------Bergoz XBPM
=================================================
Bergoz_FBPMU_X 0.0173412680247 Bergoz_FBPMU_Y 0.0279287403677 Bergoz_FBPMD_X 0.299239429313 Bergoz_FBPMD_Y -0.593922140841
===================================================
Slit Frontend
===================================================
Fe_Slit_Hor_Center 0.0535 Fe_Slit_Hor_Size 0.809
Fe_Slit_Ver_Center -0.18275 Fe_Slit_Ver_Size 1.0015
---------------- Slit Frontend Dvals -------------
Fe_Slit_Hor_Ring_TR1 -0.35 Fe_Slit_Hor_Ring_TR1_DVAL -0.35 Fe_Slit_Hor_Wall_TR2 0.45 Fe_Slit_Hor_Wall_TR2_DVAL -0.45
Fe_Slit_Ver_Top_TR1 0.317 Fe_Slit_Ver_Top_TR1_DVAL -0.317 Fe_Slit_Ver_Down_TR2 -0.683 Fe_Slit_Ver_Down_TR2_DVAL -0.683
----------------- Slit Frontend Offsets -----------
Fe_Slit_Hor_Ring_TR2_OFF 0.0 Fe_Slit_Hor_Ring_TR1_OFF 0.0 Fe_Slit_Ver_Top_TR1_OFF 0.0 Fe_Slit_Ver_Down_TR2_OFF 0.0
======================================================
Mirror 1
======================================================
------------- RAW VALUES (XTREME COORDINATES---------
M1_TRB 9.0 M1_TRB_DVAL 9.0
M1_ROX_DVAL 0.45 M1_ROY_DVAL -0.4336 M1_ROZ_DVAL 4.14 M1_TRY_DVAL 1.4499 M1_TRZ_DVAL -0.7501
M1_ROX 0.0 M1_ROY -0.03348 M1_ROZ 0.0 M1_TRY 0.0 M1_TRZ -0.55
M1_Y 0.0 M1_Z -0.55 M1_Rx 0.0 M1_Ry -0.108 M1_Rz -0.0
=======================================================
FILTER
=======================================================
FILTER_ROY_DVAL 1.3 FILTER_TRX_DVAL -0.6
========================================================
Slit 1 (Focus)r 1
========================================================
Focus_Slit_Hor_Center -0.21975 Focus_Slit_Hor_Size 0.1895
Focus_Slit_Ver_Center 0.51675 Focus_Slit_Ver_Size 0.5475
----------------------------Slit 1 (DVALS)r 1 ------------
Focus_Slit_Hor_Ring_TRX1 -0.314 Focus_Slit_Hor_Ring_TRX1_DVAL 19.8615 Focus_Slit_Hor_Wall_TRX2 -0.124 Focus_Slit_Hor_Wall_TRX2_DVAL 19.6885
Focus_Slit_Ver_Top_TRY1 0.792 Focus_Slit_Ver_Top_TRY1_DVAL -17.721 Focus_Slit_Ver_Down_TRY2 0.242 Focus_Slit_Ver_Down_TRY2_DVAL -20.916
----------------------------Slit 1 (OFFSETS) ------------
Focus_Slit_Hor_Ring_TRX1_OFF -20.1755 Focus_Slit_Hor_Wall_TRX2_OFF 19.5645 Focus_Slit_Ver_Top_TRY1_OFF 18.513 Focus_Slit_Ver_Down_TRY2_OFF -20.674
========================================================
Monochromator
========================================================
Energy_Mono_Set 3000.4 Energy_Mono_Get 3000.40409222
Bragg_set 41.2180011301
------------------------- Monochromator motors
Theta_set 41.2180011301 Theta_set_DVAL 41.3470011301
EC_Theta1 41.34688 EC_Theta2 41.3468014063 EC_Theta2 41.3468014063 EC_Theta2 41.3468014063
T1_set_DVAL 37.6197315303 T1_set 18.9702684697 T1_rbk 18.97
T2_set_DVAL -37.7172540351 T2_set 16.6177459649 T2_rbk 16.618
ROLL2 -2480.01730541 ROLL2_ENC 0.0703440909438 PITCH2 -10807.7008285 PITCH2_ENC -0.64255741207
ROLL1 780.43 ROLL1_ENC 0.0544747081712
Crystal_Position 3.4 Crystal_Position_DVAL -7.0325
===============================================================
BM 3
===============================================================
BM3_XRBV -5.0005 BM3_XDRBV -5.0005 BM3_XOFF 0.0
BM3_YRBV -17.4997 BM3_YDRBV 17.4997 BM3_YOFF 0.0
===========================================================
Slit 2 (Exp hutch)
===========================================================
Sl2_Hor_Center -0.60025 Sl2_Hor_Size 1.0005
Sl2_Ver_Center 11.55975 Sl2_Ver_Size 1.0005
----------------------------Slit 2 (DVALS)r 1 ------------
SL2_Hor_Ring_TRX1 -1.1 SL2_Hor_Ring_TRX1_DVAL -3.681 SL2_Hor_Wall_TRX2 -0.1 SL2_Hor_Wall_TRX2_DVAL -2.6535
SL2_Ver_Top_TRY1 12.06 SL2_Ver_Top_TRY1_DVAL -24.127 SL2_Ver_Down_TRY2 11.06 SL2_Ver_Down_TRY2_DVAL -1.514
----------------------------Slit 2 (OFFSETS) ------------
SL2_Hor_Ring_TRX1_OFF 2.581 SL2_Hor_Wall_TRX2_OFF -2.7535 SL2_Ver_Top_TRY1_OFF -12.067 SL2_Ver_Down_TRY2_OFF 12.574
===============================================================
BM 4
===============================================================
BM4_XRBV 33.6762 BM4_XDRBV -18.4504 BM4_XOFF 15.2258
BM4_YRBV -10.0159642435 BM4_YDRBV 9.6926642435 BM4_YOFF -0.3233
===============================================================
PHOENIX I KB System 1 (XRADIA)
===============================================================
PICOMOTORS
KB_Ver_TILT 0.0148012512398 KB_Ver_TRANS 0.0160219729915 KB_Ver_BUP 0.0148012512398 KB_Ver_BDO 0.0157167925536
KB_Hor_TILT 0.0148012512398 KB_Hor_TRANS 0.0141908903639 KB_Hor_BUP -0.0108339055467 KB_Hor_BDO 0.0950637064164
ADDITIONAL MOTORS
OP-KB:HTILT2.RBV 0.3770032 OP-KB:HTILT2.OFF -7.79
OP-KB:HTRX2.RBV -0.53125 OP-KB:HTRX2.OFF -13.775
OP-KB:VTILT2.RBV 0.3318672 OP-KB:VTILT2.OFF -6.54
OP-KB:VTRY2.VAL -0.87795 OP-KB:VTRY2.OFF -6.01
ES-MA1:ScanX.RBV 1.00005 ES-MA1:ScanX.OFF -6.905
ES-MA1:ScanY.RBV 0.31645 ES-MA1:ScanY.OFF -11.08
ES-MA1:ROT.RBV 70.00479 ES-MA1:ROT.OFF -32.03
ES-MA1:TRX1.RBV 0.47355 ES-MA1:TRX1.OFF -0.551
ES-MA1:TRZ1.RBV 7.8005 ES-MA1:TRZ1.OFF -16.68
===============================================================
PHOENIX I KB System 2 (IDT)
===============================================================
Soft motors
KB2_Ver_TILT 0.0997900456728 KB2_Ver_TRANS -1.695 KB2_Ver_FOCUS 1.5005 KB2_Ver_ELLIP -0.5595
KB2_Hor_TILT 0.00023873240807 KB2_Hor_TRANS -2.1355 KB2_Hor_FOCUS 2.741 KB2_Hor_ELLIP -0.195
===============================================================
Physical motors
ES2-KB2:HTRUP.RBV -2.136 ES2-KB2:HTRUP.OFF 0.0 ES2-KB2:HTRDN.RBV -2.135 ES2-KB2:HTRDN.OFF 0.0
ES2-KB2:VTRUP.RBV -1.904 ES2-KB2:VTRUP.OFF 0.0 ES2-KB2:VTRDN.RBV -1.486 ES2-KB2:VTRDN.OFF 0.0
===============================================================
========================================================
Status BE window (ES1): 5 = open / 2 = closed
Be_ES1_open CLOSED
Be_ES2_open CLOSED
========================================================
========================================================
Pressure KB and ES1
P_OP_KB1 9.3876712042e-08 P_ES1_MC1 0.000659409337437
P_ES1_RVMT1 0.0607930827683 P_ES1_MF1 1.15042686082e-06
Pressure KB2 and ES3 (Chemistry chamber)
P_ES2_KB2 2.83890335648 P_ES3_MC1 0.0475109792189
P_ES3_MF1 0.0547575046518 P_ES3_RVMT1 0.0522863481316
Pressure Adaptation KBS-user chamber )
P_ES2_KB2_MF3 2.10020304941e-07 P_ES2_MC2 0.0473135497201
View File
+145
View File
@@ -0,0 +1,145 @@
#Script imported from: Mono_pitch.xml
#Pre-actions
caput('X07MB-OP2:START-CSMPL', '0')
sleep(0.1)
caput('X07MB-XMAP:StopAll', '1')
sleep(0.1)
caput('X07MB-XMAP:PresetMode', '0')
sleep(0.1)
caput('X07MB-XMAP:PresetReal', '0')
sleep(0.1)
caput('X07MB-OP2:TOTAL-CYCLES', '1')
sleep(0.1)
print('dd')
x_min = -12.3
x_max = -12.2
delta = 0.01
N_step = int((x_max-x_min)/delta)
#TODO: Set the diplay names of positioners and detectors
scan = ManualScan(['Pitch'], ['bm3', 'bm4', 'Filter_RY', 'Harmonic', 'TC_Y', 'TC_Z', 'T_THETA', 'Id_OFF', 'Id_energy', 'E_Mono', 'Bragg_Id_theo', 'Theta_rbv', 'Theta_offset', 'Delta_E', 'Delta_theta', 'XX'] , [x_min], [x_max], [N_step])
scan.start()
#Creating channels: dimension 1
#LinearPositioner ScanX
Pitch = Channel('X07MB-ES-MA1:ScanX.VAL', type = 'd')
PitchReadback = Channel('X07MB-ES-MA1:ScanX.RBV', type = 'd')
#ScalarDetector bm3
bm3 = Channel('X07MB-OP2-SAI_03:MEAN', type = 'd')
#ScalarDetector bm4
bm4 = Channel('X07MB-OP2-SAI_04:MEAN', type = 'd')
#ScalarDetector Filter_RY
Filter_RY = Channel('X07MB-OP-FI:ROY.VAL', type = 'd')
#ScalarDetector Harmonic
Harmonic = Channel('X07MA-ID:HARMONIC', type = 'd')
#ScalarDetector TC_Y
TC_Y = Channel('X07MB-OP-MOC2:TC_Y', type = 'd')
#ScalarDetector TC_Z
TC_Z = Channel('X07MB-OP-MOC2:TC_Z', type = 'd')
#ScalarDetector T_THETA
T_THETA = Channel('X07MB-OP-MOTHETA:TC1', type = 'd')
#ScalarDetector Id_OFF
Id_OFF = Channel('X07MA-ID:ENERGY-OFFS', type = 'd')
#ScalarDetector Id_energy
Id_energy = Channel('X07MA-ID:ENERGY', type = 'd')
#ScalarDetector E_Mono
E_Mono = Channel('X07MB-OP-MO:E-GET', type = 'd')
#ScalarDetector Bragg_Id_theo
Bragg_Id_theo = Channel('X07MB-OP-MO:BRAGG-CALC', type = 'd')
#ScalarDetector Theta_rbv
Theta_rbv = Channel('X07MB-OP-MO:THETA.RBV', type = 'd')
#ScalarDetector Theta_offset
Theta_offset = Channel('X07MB-OP-MO:THETA.OFF', type = 'd')
#Dimension 1
#Dimension Guard
cawait('ACOAU-ACCU:OP-MODE', 6, type = 'l')
#LinearPositioner Pitch
for setpoint1 in frange(x_min ,x_max, delta, True):
if setpoint1 > x_max or setpoint1 < x_min:
break
Pitch.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
readback1 = PitchReadback.get()
if abs(readback1 - setpoint1) > 10.0 : # TODO: Check accuracy
print readback1, setpoint1
raise Exception('Actor Pitch could not be set to the value ' + str(setpoint1))
#Detector bm3
#Detector X07MB-OP2-SAI_03:MEAN pre-actions
caput('X07MB-OP2:SMPL', '1')
sleep(0.1)
cawait('X07MB-OP2:SMPL-DONE', 1, type = 'l')
detector1 = bm3.get()
#Detector bm4
detector2 = bm4.get()
#Detector Filter_RY
detector3 = Filter_RY.get()
#Detector Harmonic
detector4 = Harmonic.get()
#Detector TC_Y
detector5 = TC_Y.get()
#Detector TC_Z
detector6 = TC_Z.get()
#Detector T_THETA
detector7 = T_THETA.get()
#Detector Id_OFF
detector8 = Id_OFF.get()
#Detector Id_energy
detector9 = Id_energy.get()
#Detector E_Mono
detector10 = E_Mono.get()
#Detector Bragg_Id_theo
detector11 = Bragg_Id_theo.get()
#Detector Theta_rbv
detector12 = Theta_rbv.get()
#Detector Theta_offset
detector13 = Theta_offset.get()
#Manipulation Delta_E
#Variable Mappings
a = detector10
b = detector9
Delta_E = a-b
#Manipulation Delta_theta
#Variable Mappings
a = detector11
b = detector12
Delta_theta = a-b
#Manipulation XX
#Variable Mappings
a = detector11
b = detector12
XX = a*b
print(XX)
scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, detector10, detector11, detector12, detector13, Delta_E, Delta_theta, E_Mono, XX])
#Closing channels
Pitch.close()
PitchReadback.close()
bm3.close()
bm4.close()
Filter_RY.close()
Harmonic.close()
TC_Y.close()
TC_Z.close()
T_THETA.close()
Id_OFF.close()
Id_energy.close()
E_Mono.close()
Bragg_Id_theo.close()
Theta_rbv.close()
Theta_offset.close()
scan.end()
#Post-actions
caput('X07MB-OP2:START-CSMPL', '1')
sleep(0.1)
caput('X07MB-OP2:START-CSMPL', '1')
sleep(0.3)
caput('X07MB-OP2:SMPL', '1')
sleep(0.3)
caput('X07MB-OP2:SMPL', '1')
sleep(0.3)
+13
View File
@@ -0,0 +1,13 @@
chan='X07MB-ES-MA1:ScanX.VAL'
d=Channel(chan)
d.put(0)
caput('X07MB-ES-MA1:ScanX.VAL',0.1)
print('caput(X07MB-ES-MA1:ScanX.VAL,0.1)', d.read())
caput('X07MB-ES-MA1:ScanX.VAL','0.2')
print('caput(X07MB-ES-MA1:ScanX.VAL, str(0.2))', d.read() )
d.put(0.3)
print('d.put(0.3)',d.read())
d.put('0.4')
print('d.put(0.3)',d.read())
+25
View File
@@ -0,0 +1,25 @@
import time
C=Channel('X07MB-OP2:SMPL-DONE',type='i') # readback sampling finished
S=Channel('X07MB-OP2:SMPL') # star sampling (TTL signal)
wait_value=1
print(C.read)
print('Value before pressing button' ,C.read(),'wait for', wait_value)
print('press button, in 2 sec,X07MB-OP2:SMPL-DONE should turn from 0 to 1 ')
t0=time.time()
print('time',time.time()-t0)
S.putq(1)
print('Value after pressing button before .wait_for_value',C.read(),'wait for', wait_value)
print('time before wait ',(time.time()-t0))
# now wait for
#C.wait_for_value(wait_value,timeout=5)
cawait('X07MB-OP2:SMPL-DONE',wait_value,timeout=7)
print('time after wait ',(time.time()-t0))
print('Value after .wait_for_valuea',C.read())
print('..... done .... ')
print('read X07MB-OP2:SMPL-DONE with caget',caget('X07MB-OP2:SMPL-DONE','i'))
+25
View File
@@ -0,0 +1,25 @@
import time
c='X07MB-OP2:TOTAL-CYCLES'
c='X07MB-OP2:SMPL'
c='X07MB-OP2:SMPL'
c='X07MB-OP-WV1:WT_SET'
c='X07MB-OP-MO:E-SET.OUT'
c='X07MB-OP2:SMPL'
c='X07MB-OP-KEITH3:setGain'
c='X07MB-OP2:START-CSMPL'
c='X07MB-OP2:SMPL-DONE'
C=Channel(c)
print(c)
d=C.get()
print('read as such' ,d)
print(type(d))
C=Channel(c,type='i')
d=C.get()
print('as int',d)
print(type(d))
C=Channel(c,type='d')
d=C.get()
print('as double',d)
print(c)
+25
View File
@@ -0,0 +1,25 @@
import time
c='X07MB-OP2:TOTAL-CYCLES'
c='X07MB-OP2:SMPL'
c='X07MB-OP2:SMPL'
c='X07MB-OP-WV1:WT_SET'
c='X07MB-OP-MO:E-SET.OUT'
c='X07MB-OP2:SMPL'
c='X07MB-OP-KEITH3:setGain'
c='X07MB-OP2:START-CSMPL'
c='X07MB-OP2:SMPL-DONE'
C=Channel(c)
print(c)
d=C.get()
print('read as such' ,d)
print(type(d))
C=Channel(c,type='i')
d=C.get()
print('as int',d)
print(type(d))
C=Channel(c,type='d')
d=C.get()
print('as double',d)
print(c)
+14
View File
@@ -0,0 +1,14 @@
d=0
d=Channel('X07MB-OP2:SMPL-DONE')
#ee=caget('X07MB-OP2:SMPL-DONE')
#print(ee)
for i in range(1000):
time.sleep(4)
d=0
d=Channel('X07MB-OP2:SMPL-DONE')
e=d.read()
print(e)
#endfor
+7
View File
@@ -0,0 +1,7 @@
d=0
d=Channel('X07MB-OP2:SMPL-DONE')
#ee=caget('X07MB-OP2:SMPL-DONE')
#print(ee)
e=d.read()
print(e)
+4
View File
@@ -0,0 +1,4 @@
d={'a':1,
'b':2}
print(d)
+30
View File
@@ -0,0 +1,30 @@
data2d = [ [1.0, 2.0, 3.0, 4.0, 5.0], [2.0, 3.0, 4.0, 5.0, 6.0, ], [3.0, 4.0, 5.0, 6.0, 7.0]]
#Creating a 2D data FLOAT dataset adding lines one by one
path = "group/data1"
create_dataset(path, 'd', False, (0,0))
for row in data2d:
append_dataset(path, row)
#Creating a Table (compund type)
path = "group/data2"
names = ["a", "b", "c",]
types = ["d", "d", "d",]
table = [ [1,2,3],
[2,3,4],
[3,4,5,] ]
create_table(path, names, types)
for row in table:
append_table(path, row)
set_attribute("group/data2", "att", 2)
File diff suppressed because it is too large Load Diff
+331
View File
@@ -0,0 +1,331 @@
import traceback
import imp
import os
from CaChannel import *
from epicsMotor import *
from epicsPV import *
import time
import string
import sys
import json
# TO DO: Energy scan has onlz 1 positioner
# need to generalize definition of scans to several paraller positiner,
# to be able to use Create_Channels, alteratively need a dedicate channel creation for each scan type
# tricky, code should stay simple
# options.
# Define channel generation for each chanenl separatelz
# generalze scand to 1d and 2d with seveal posittioner in each dimension.
# this will get complicated .....
import X_X07MB_Pscan as PS
import X_X07MB_lib as PL
imp.reload(PS) # always reload module
imp.reload(PL) # always reload module
NoRead=0
def before_pass():
get_context().dataManager.provider.embeddedAtributes = False
# Called at begining pf scan
print('before_pass')
SC.PerformActions('Pre_Actions')
pars=get_exec_pars()
print('pars.output : ')
print(pars.output)
print('pars.scanPath: ')
print(pars.scanPath)
print('pars.name: (filename) ')
print(pars.name)
# missing
# NEED TO SET path for Moench here
#end before_pass
def before_read():
# Cannot call routine in class in rscan call, need to go via local routine
#print('before_read')
# SC.DetectorActions() excecutes all standard action as defied in GUI
SC.PerformActions('Detector_Actions')
#print('.... done before_read ' )
# alternativly use caput here explicitly...
# if needed
#end before read
def after_read(rec,scan):
print('ENTER after_read .................' )
# Called after reading
# calculate default dead time corrections and writ to file
SC.after_read_dtc(rec,scan)
print('.... done after_read ' )
return
#end after_read init
def after_pass():
# Called after scan
print('after_pass')
SC.PerformActions('Post_Actions')
print('................ done after_pass')
#end after pass
def before_region(index,scan):
print (index)
# make some reset
try:
del SC
except:
SC=0
#endexept
# originbal tag for data saving
# '{data}/{year}/{month}/{day}/{year}_{month}{day}_{time}_{name}'
# ........... FIrst read the scan
#
# ====================================================
#
# SCRIPT STARTS HERE
#
# ====================================================
if NoRead==0:
try:
SD = 0
SD = PS.get_channels('SPECTRA') # READ SCAN DEFINITION FROM GUI USING OLD CODE
print('returned from PS.get_channels()')
SC=0
SC=PL.PscanLib(SD,Channel,caput,caputq,caget,cawait,get_exec_pars,create_table,append_table) # create instance of library
print('... done SC.Create_All_Sensors()')
SD.update({'All_Sensors':[]})
except:
traceback.print_tb(sys.exc_info()[2])
raise
# endexcept
# endif
print('dddddddddddddddddddddddddd')
# example add new sensor, similarly add pre and postactions to existing code
New_Sensors=[]
New_Sensors.append({'channel_name': 'X07MB-ES-MA1:ScanY.RBV'
, 'Subset_1': False
, 'Det_type': 'ScalarDetector'
, 'alias': 'MYSCANY_RBV'
, 'data_type': 'double'})
# examples add post action light on
SD['Post_Actions'].append({'channel_name': 'X07MB-ES1-PP2:VO5'
, 'data_type': 'String'
, 'alias': 'Light_ON'
, 'operation': 'put'
, 'delay' : 0.1
, 'value' : 5 })
# END OF USER INPUT
# .... add new sensors to list
try:
try:
del AllSensors
except:
AllSensors=0
#endecsept
All_Sensors = SC.Create_Sensor_List() # Create instance for all sensors
SC.Add_New_Sensors(New_Sensors) # Add user sensors
except:
traceback.print_tb(sys.exc_info()[2])
raise
# endexcept
# STRUCTUALR INCONSITENCY NEED TO CREATE List of sensors first
# without making Channel command.... !
#
# TEST SAVE SCAN DEFINITION...Needs to be before definition
# SD is full GUI definiton of the scan try to save and reread this definiton
SD.update({'New_Sensors' : New_Sensors})
f=open('scandef.dat','w')
# Method to save abnd restore full scan definition...
with open('BaseScanDefinition.json', 'w') as fp:
json.dump(SD, fp,ensure_ascii=True)
#endwith
with open('BaseScanDefinition.json', 'r') as dd:
SD_reread=json.load(dd)
# .. this works, reread is unicode not string, but code seems still to work if all entries are in unicode
asd
# step I: CREATE ALL SENSORS AND STORE IN A LIST
print('++++++++++++++++++++++++++')
AllSensors=0
try:
# Code for beamline save......
SavePhoenix=PL.SavePhoenix(Channel,caput,caputq,caget,cawait) # Channel,caput,caputq,caget,cawait)
# SavePhoenix.write_beamline_data().. Works., move to before pass...
SC.noprint=0 # chose printing from SD on / off
# Now creat all epic s instances. print('... done SC.Create_All_Sensors()')
SD.update({'All_Sensors':All_Sensors})
SC.Create_Channels('All_Sensors')
SC.Create_Channels('All_Positioner')
SC.Create_Channels('Detector_Actions')
SC.Create_Channels('Pre_Actions')
SC.Create_Channels('Post_Actions')
SC.Create_Channels('Energy_Scan')
except:
traceback.print_tb(sys.exc_info()[2])
raise
# endexcept
# ... create some abbreviations...
All_Sensors = SC.All_Sensors
All_Positioner = SD['All_Positioner']
Pre_Actions = SD['Pre_Actions']
Post_Actions = SD['Post_Actions']
Detector_Actions = SD['Detector_Actions']
Energy_Scan = SD['Energy_Scan']
#............SOME OUTPUT
#print('----------- All_Positioner ---')
#print(' ')
#print(SD['All_Positioner'])
#print(' ------------ Pre_Action -------- ')
#print(' ')
#print(SD['Pre_Actions'])
#print(' ------------ Post_Action -------- ')
#print(' ')
#print(SD['Post_Actions'])
#print(' ')
#print(' ----------- Detector_Action--------- ')
#print(' ')
#print(SD['Detector_Actions'])
## ............. MISSING CREATE POSTACTIONS::::::
# STEP II read the energy position
print('')
print('..................................... positioner Energy ID? readback automatically saved? ')
print('initial energies e_i ',SD['e_i'])
print('final energies e_f ',SD['e_f'])
print('DELTA E e_delta ',SD['e_delta'])
print('DWELL TIME e_n_cycles',SD['e_n_cycles'])
print(SD['Energy_Scan']['Energy_Ranges'])
#try:
# EnergyRanges,Cycles = SC.PositionerEnergyScan()
#except:
# traceback.print_tb(sys.exc_info()[2])
# raise
# endexcept nowcall
#print(EnergyRanges,Cycles)
# STEP II ... read the detector actions
# Step IV perform the Preaction
#P=SC.DetectorActions()
print(All_Sensors)
print('Energy_Ranges')
print(SD['Energy_Scan']['Energy_Ranges'])
pars=get_exec_pars()
print('pars.output')
print(pars.output)
print('pars.scanPath')
print(pars.scanPath)
print(' ')
print('---------------')
print(' ')
print(' CALL SCAN NOW ')
print(' ')
p=set_exec_pars(name=SD['filename'])
# This is one singe energy scan:
# save scan definition
get_context().dataManager.provider.embeddedAtributes = False
asd
# .. now make individual scan for all positioners as defiens in GUI
# as we like want to have separete datasets for each scan \
#stop
for i in range(len(All_Positioner[0]['value'])): # loop in number of points
# set all positioner
for j in range(len(All_Positioner)): # set positioner
t0=time.time()
ThisPositioner = All_Positioner[j]['Channel']
ThisPosition = All_Positioner[j]['value'][i]
print('next,i,j',i,j)
print('name',All_Positioner[j]['channel_name'])
print('value',All_Positioner[j]['value'][i])
print(time.time()-t0)
# .............. SET NEW POSITIONER
#ThisPositioner.write(ThisPosition)
ThisPositioner.put(ThisPosition)
#ThisPositioner.putq(ThisPosition) # simultaneous walk no waiting..
print(time.time()-t0)
#endfor loop set positioner
# generate filename
p=set_exec_pars(name=SD['filename']+'_'+All_Positioner[0]['label'][i])
pars=get_exec_pars()
print('filename this run : ')
print(pars.name)
print('--------------- NEXT SCAN ----------------')
try:
rscan(SD['Energy_Scan']['Channel']
, SC.get_list(All_Sensors,'Channel')
, regions=SD['Energy_Scan']['Energy_Ranges']
, latency = 0.0, relative = False
, before_pass = SC.PerformActions('Pre_Actions') # before_pass
, before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
, after_read = SC.after_read_dtc #after_read
, after_pass = after_pass
, before_region = before_region
, enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
#vscan(SD['Energy_Scan']['Channel']
# , SC.get_list(All_Sensors,'Channel')
# , vector=SD['Energy_Scan']['Energy_Scan_Positions']
# , latency = 0.0, relative = False
# , before_pass = SC.PerformActions('Pre_Actions') # before_pass
# , before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
# , after_read = SC.after_read_dtc #after_read
# , after_pass = after_pass
# , before_region = before_region
# , enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
except:
traceback.print_tb(sys.exc_info()[2])
raise
# END EXecpt
#endfor
#endfor
print('... scan finished ')
#
#ret = lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, enabled_plots=['X07MB-OP2-SAI_07:MEAN'])
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
#def BeforeReadout(position, scan):
# print "In position: " + str(pposition)
#def AfterReadout(record, scan):
# print "Aquired record: " + str(record)
#lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
#ascan(["ca://X07MB-OP-MO:E-SET", "X07MB-ES-MA1:ScanX.VAL"], sensors, start=[2450, 1.6], end=[2460, 1.8], steps=[2.0,0.05], latency=0.0, relative = False, zigzag = True)
##
#
# Vizualization...............
#