Changes by Chris and project fixes
This commit is contained in:
@@ -10,6 +10,11 @@ if get_exec_pars().source == CommandSource.ui:
|
||||
STEPS = 10 #20
|
||||
NUM_SHOTS= 10 # 100
|
||||
PLOT=None
|
||||
# get current camera ROIs and then set to max for scan
|
||||
roi_min = psss_roi_min.read()
|
||||
roi_max = psss_roi_max.read()
|
||||
psss_roi_min.write(1)
|
||||
psss_roi_max.write(2000)
|
||||
|
||||
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
|
||||
p.clear()
|
||||
@@ -21,10 +26,10 @@ run("cpython/wrapper")
|
||||
|
||||
|
||||
#Setup and functions setup¶
|
||||
if not is_dry_run():
|
||||
xstal_height=Channel("SARFE10-PSSS059:MOTOR_Y3.VAL", name="xstal_height")
|
||||
else:
|
||||
xstal_height=DummyRegister("xstal_height")
|
||||
#if not is_dry_run(): # C.arrell commented out 20.01.21
|
||||
xstal_height=Channel("SARFE10-PSSS059:MOTOR_Y3.VAL", name="xstal_height")
|
||||
#else:
|
||||
# xstal_height=DummyRegister("xstal_height")
|
||||
|
||||
av = create_averager(psss_spectrum_y, NUM_SHOTS, interval=-1, name="spectrum_average")
|
||||
av_samples = av.samples
|
||||
@@ -54,25 +59,12 @@ if not (RANGE_FROM < mean_val < RANGE_TO or RANGE_TO < mean_val < RANGE_FROM):
|
||||
xstal_height.write(mean_val)
|
||||
xstal_height.close()
|
||||
|
||||
# return ROI to inital value
|
||||
psss_roi_min.write(roi_min)
|
||||
psss_roi_max.write(roi_max)
|
||||
|
||||
#Plots
|
||||
"""
|
||||
plt.figure(figsize=[10,5])
|
||||
plt.subplot(121)
|
||||
plt.title('PSSS scan of crystal height')
|
||||
plt.pcolormesh(energy_axis, xstal_range, Scan_spec.mean(axis=1),cmap='CMRmap')
|
||||
plt.xlim([energy_axis[0],energy_axis[-1]])
|
||||
plt.ylim([xstal_range[0], xstal_range[-1]])
|
||||
plt.xlabel('PSSS energy axis')
|
||||
plt.ylabel('Set crystal position [mm] \n'+PSSS_xstal_height_name[0:-4])
|
||||
plt.subplot(122)
|
||||
plt.plot(projection,xstal_range,linewidth = 2, color = 'orange',label ='projected signal')
|
||||
plt.plot(gaus(xstal_range_fit,*popt),xstal_range_fit,'r:',label='fit')
|
||||
plt.ylim([xstal_range[0], xstal_range[-1]])
|
||||
plt.title('Signal max at %.3f [mm] (from fit)'%popt[1])
|
||||
plt.xticks([])
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
"""
|
||||
|
||||
p.clear()
|
||||
p.setTitle("")
|
||||
plot_gauss_fit(xstal_range, projection, gauss_pars=(offset, amp, mean_val, sigma), p=p, title = "Data")
|
||||
|
||||
+13
-25
@@ -26,15 +26,19 @@ if RANGE_OFF is not None:
|
||||
|
||||
run("cpython/wrapper")
|
||||
|
||||
|
||||
# get current camera ROIs and then set to max for scan
|
||||
roi_min = psss_roi_min.read()
|
||||
roi_max = psss_roi_max.read()
|
||||
psss_roi_min.write(1)
|
||||
psss_roi_max.write(2000)
|
||||
|
||||
|
||||
#Scan and take data
|
||||
class PSSS_energy(Writable):
|
||||
def write(self, value):
|
||||
if not is_dry_run():
|
||||
psss_energy.write(value)
|
||||
exec_cpython("/ioc/modules/qt/PSSS_motion.py", args = ["-m1", "SARFE10-PSSS059"])
|
||||
#if not is_dry_run():
|
||||
psss_energy.write(value)
|
||||
exec_cpython("/ioc/modules/qt/PSSS_motion.py", args = ["-m1", "SARFE10-PSSS059"])
|
||||
# python / ioc / modules / qt / PSSS_motion.py - m1 SARFE10 - PSSS059
|
||||
time.sleep(1)
|
||||
print(value)
|
||||
@@ -53,10 +57,14 @@ def after_read(record, scan):
|
||||
|
||||
r = lscan(en, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, after_read = after_read, save=False )
|
||||
average, samples, energy_range = r.getReadable(0), r.getReadable(1), r.getPositions(0)
|
||||
# return ROI to inital value
|
||||
psss_roi_min.write(roi_min)
|
||||
psss_roi_max.write(roi_max)
|
||||
|
||||
[amp, mean_val, sigma, offset],centre_line_out = fit_energy(RANGE_FROM, RANGE_TO, STEPS+1, NUM_SHOTS, samples)
|
||||
[amp, mean_val, sigma, offset],centre_line_out = fit_energy(RANGE_FROM, RANGE_TO, STEPS+1, NUM_SHOTS, samples)
|
||||
|
||||
if not (RANGE_FROM < mean_val < RANGE_TO or RANGE_TO < mean_val < RANGE_FROM):
|
||||
|
||||
raise Exception ("Invalid fit mean: " + str(mean_val))
|
||||
|
||||
|
||||
@@ -67,26 +75,6 @@ print "measured offset", measured_offset
|
||||
en.write(mean_val)
|
||||
|
||||
|
||||
#Plot
|
||||
"""
|
||||
plt.figure(figsize=[10,5])
|
||||
plt.subplot(121)
|
||||
plt.title('PSSS scan of set photon energy')
|
||||
plt.pcolormesh(np.arange(0,Scan_spec.shape[2]), Energy_range, Scan_spec.mean(axis=1),cmap='CMRmap')
|
||||
plt.vlines(int(Scan_spec.shape[2]/2), Energy_range[0], Energy_range[-1],linestyles='--', colors='orange')
|
||||
plt.xlim([0,Scan_spec.shape[2]])
|
||||
plt.xlabel('Camera pixel')
|
||||
plt.ylabel('Set PSSS energy [eV] \n SARFE10-PSSS059:ENERGY')
|
||||
|
||||
plt.subplot(122)
|
||||
plt.title('At camera centre pixel %1i \nCalibrated energy = %.1f [eV]\n Offset from machine = %.1f [eV]'%(int(Scan_spec.shape[2]/2),popt[1],measured_offset))
|
||||
plt.plot(centre_line_out,Energy_range,linewidth = 2, color = 'orange',label ='measured')
|
||||
plt.plot(gaus(Energy_range_fit,*popt),Energy_range_fit,'r:',label='fit')
|
||||
plt.xticks([])
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
"""
|
||||
|
||||
p.clear()
|
||||
p.setTitle("")
|
||||
plot_gauss_fit(energy_range, centre_line_out, gauss_pars=(offset, amp, mean_val, sigma), p=PLOT, title = "Data")
|
||||
|
||||
Reference in New Issue
Block a user