PSSS improvements

This commit is contained in:
gac-bernina
2021-05-07 15:43:37 +02:00
parent 2bcbb2b157
commit a0fb826e6f
5 changed files with 62 additions and 19 deletions
+11 -1
View File
@@ -12,7 +12,10 @@ if get_exec_pars().source == CommandSource.ui:
PLOT=None
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
p.removeMarker(None)
p.setLegendVisible(True)
p.addSeries(LinePlotSeries("PSSS Spectrum Average"))
run("cpython/wrapper")
@@ -25,8 +28,13 @@ av = create_averager(psss_spectrum_y, NUM_SHOTS, interval=-1, name="spectrum_ave
av_samples = av.samples
av_samples.alias = "spectrum_samples"
#Scan and take data
r = lscan(cam_x, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, save=False )
def after_read(record, scan):
p.getSeries(0).setData(psss_spectrum_x.take(), record[av])
p.setTitle("Cam X = %1.3f" %(record[cam_x]))
r = lscan(cam_x, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, after_read = after_read, save=False)
average, samples, cam_range = r.getReadable(0), r.getReadable(1), r.getPositions(0)
signal_centre, projection = get_signal_centre(samples, cam_range)
@@ -56,6 +64,8 @@ plt.grid(True)
#plot_data(PLOT, projection, "Data", xdata=cam_range, show_points = True, color=Color.BLUE)
#p,pars = plot_gauss_fit(cam_range, projection, gauss_pars=None, p=PLOT, title = "Data")
p.clear()
p.setTitle("")
plot_data(p, projection, "Projection", xdata=cam_range, show_points = True, color=Color.BLUE)
p.addMarker(signal_centre, None, "Signal Centre=" + str(round(signal_centre,2)), Color.LIGHT_GRAY)
+15 -6
View File
@@ -11,9 +11,11 @@ if get_exec_pars().source == CommandSource.ui:
NUM_SHOTS= 10 # 100
PLOT=None
if PLOT:
PLOT.clear()
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
p.removeMarker(None)
p.setLegendVisible(True)
p.addSeries(LinePlotSeries("PSSS Spectrum Average"))
run("cpython/wrapper")
@@ -27,9 +29,14 @@ else:
av = create_averager(psss_spectrum_y, NUM_SHOTS, interval=-1, name="spectrum_average")
av_samples = av.samples
av_samples.alias = "spectrum_samples"
#Scan and take data
r = lscan(xstal_height, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=2.0, save=False )
def after_read(record, scan):
p.getSeries(0).setData(psss_spectrum_x.take(), record[av])
p.setTitle("Xtal Height = %1.3f" %(record[xstal_height]))
r = lscan(xstal_height, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=2.0, after_read = after_read, save=False)
#User inputs - define travel range of crystal
#It is unlikely these values need to be changed
average, samples, xstal_range = r.getReadable(0), r.getReadable(1), r.getPositions(0)
@@ -66,7 +73,9 @@ plt.xticks([])
plt.legend()
plt.grid(True)
"""
plot_gauss_fit(xstal_range, projection, gauss_pars=(offset, amp, mean_val, sigma), p=PLOT, title = "Data")
p.clear()
p.setTitle("")
plot_gauss_fit(xstal_range, projection, gauss_pars=(offset, amp, mean_val, sigma), p=p, title = "Data")
set_return(mean_val)
+16 -4
View File
@@ -14,6 +14,11 @@ if get_exec_pars().source == CommandSource.ui:
STEPS = 5 #60
NUM_SHOTS= 10 #100
PLOT=None
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
p.removeMarker(None)
p.setLegendVisible(True)
p.addSeries(LinePlotSeries("PSSS Spectrum Average"))
if RANGE_OFF is not None:
RANGE_FROM = energy_machine.read()-RANGE_OFF
@@ -21,8 +26,7 @@ if RANGE_OFF is not None:
run("cpython/wrapper")
if PLOT:
PLOT.clear()
#Scan and take data
@@ -41,8 +45,13 @@ en.alias = "energy"
av = create_averager(psss_spectrum_y, NUM_SHOTS, interval=-1, name="spectrum_average")
av_samples = av.samples
av_samples.alias = "spectrum_samples"
r = lscan(en, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, save=False )
def after_read(record, scan):
p.getSeries(0).setData(psss_spectrum_x.take(), record[av])
p.setTitle("Energy = %1.3f" %(record[en]))
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)
[amp, mean_val, sigma, offset],centre_line_out = fit_energy(RANGE_FROM, RANGE_TO, STEPS+1, NUM_SHOTS, samples)
@@ -77,6 +86,9 @@ 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")