102 lines
1.8 KiB
Python
Executable File
102 lines
1.8 KiB
Python
Executable File
|
|
import numpy as np
|
|
import epics
|
|
import time
|
|
|
|
from collections import deque
|
|
import numpy as np
|
|
import time
|
|
import pickle
|
|
import os
|
|
import epics
|
|
import matplotlib.pyplot as plt
|
|
from slic.gui.widgets import LabeledMathEntry
|
|
from slic.gui.widgets import make_filled_hbox, make_filled_vbox, EXPANDING
|
|
from slic.gui.widgets.plotting import PlotPanel
|
|
|
|
|
|
|
|
|
|
from bstrd import BS, bsstream
|
|
|
|
from epics import caget, caput, cainfo
|
|
|
|
|
|
|
|
|
|
|
|
channel_TOF = "SATES21-CAMS154-M1.projection_signal"
|
|
ch_TOF = BS(channel_TOF)
|
|
temp_TOF = ch_TOF.get()
|
|
|
|
|
|
monitor_ch = 'SATES20-CMOV-M022:MOT.VAL'
|
|
|
|
|
|
current_ch = caget(monitor_ch)
|
|
|
|
#### Set scan values:
|
|
|
|
start =29#uS
|
|
end = 69#uS
|
|
|
|
wait_time = 15
|
|
|
|
step_size = 5
|
|
num_shots = 2000
|
|
|
|
scan_axis = np.arange(start, end+step_size, step_size)
|
|
|
|
TOF_map = np.zeros((len(scan_axis), len(temp_TOF)), dtype=float)
|
|
|
|
temp_TOF = np.zeros_like(temp_TOF,dtype=float)
|
|
next(bsstream)
|
|
|
|
plt.figure()
|
|
plt.subplot(1,3,1)
|
|
|
|
for s,i in enumerate(scan_axis):
|
|
temp_TOF = np.zeros_like(temp_TOF)
|
|
|
|
next(bsstream)
|
|
caput(monitor_ch, i)
|
|
time.sleep(wait_time)
|
|
print("Moved %s to %0.2f"%(monitor_ch, i) )
|
|
shot_counter = 0
|
|
while shot_counter <num_shots:
|
|
next(bsstream)
|
|
temp_TOF += ch_TOF.get()/(1.0*num_shots)
|
|
shot_counter += 1
|
|
if s ==0:
|
|
bkg = temp_TOF.copy()
|
|
# TOF_map[s,:] = temp_TOF
|
|
TOF_map[s,:] = temp_TOF #- bkg
|
|
plt.plot(temp_TOF - bkg, label = i)
|
|
plt.legend()
|
|
|
|
|
|
|
|
|
|
plt.subplot(1,3,2)
|
|
plt.pcolormesh(np.arange(0, len(temp_TOF)),scan_axis, TOF_map)
|
|
|
|
|
|
|
|
ratios = 1/(TOF_map[:,836:864].sum(1)/TOF_map[:,901:932].sum(1))
|
|
|
|
|
|
plt.subplot(1,3,3)
|
|
plt.plot(scan_axis,ratios)
|
|
plt.show()
|
|
|
|
#dic = {
|
|
# 'map': TOF_map,
|
|
# 'scan axis': scan_axis,
|
|
#}
|
|
|
|
|
|
#with open(r"run0022_HND_TOF_Delay_Scan_20bar_10K_30us.pickle", "wb") as output_file:
|
|
# pickle.dump(dic, output_file)
|
|
|
|
|