From 77efdf64fe0a8bfb5c0be8dc45df28ca0659c612 Mon Sep 17 00:00:00 2001 From: voulot_d Date: Tue, 15 Aug 2017 15:11:45 +0200 Subject: [PATCH] Startup --- devices/CurrentCamera.properties | 4 +-- devices/camtool.properties | 10 +++---- script/RFscan/phase_scan_caqtdm.py | 21 +++++++------- script/test/GunEnergyScan_dv.py | 46 +++++++++++++++++++----------- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 96a9494..eb4d953 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,5 +1,5 @@ -#Tue Aug 15 10:16:59 CEST 2017 -colormap=Flame +#Tue Aug 15 14:23:53 CEST 2017 +colormap=Rainbow colormapAutomatic=false colormapMax=700.0 colormapMin=0.0 diff --git a/devices/camtool.properties b/devices/camtool.properties index 38153fe..c97e99c 100644 --- a/devices/camtool.properties +++ b/devices/camtool.properties @@ -1,4 +1,4 @@ -#Tue Aug 15 09:56:35 CEST 2017 +#Tue Aug 15 14:10:23 CEST 2017 colormap=Flame colormapAutomatic=true colormapMax=578.797 @@ -18,9 +18,9 @@ roiY=0 rotation=0.0 rotationCrop=false scale=1.0 -spatialCalOffsetX=-861.4939970777481 -spatialCalOffsetY=-820.4883730911062 -spatialCalScaleX=-18.90359092620482 -spatialCalScaleY=-19.37984500632817 +spatialCalOffsetX=487.729537366548 +spatialCalOffsetY=405.94160583941607 +spatialCalScaleX=1.0 +spatialCalScaleY=1.0 spatialCalUnits=mm transpose=false diff --git a/script/RFscan/phase_scan_caqtdm.py b/script/RFscan/phase_scan_caqtdm.py index 8db4b39..d5b7e2c 100644 --- a/script/RFscan/phase_scan_caqtdm.py +++ b/script/RFscan/phase_scan_caqtdm.py @@ -2,7 +2,7 @@ import ch.psi.pshell.epics.Positioner as Positioner import ch.psi.pshell.epics.ChannelDouble as ChannelDouble dry_run = True -do_elog = FalseTrue +do_elog = True if get_exec_pars().source == CommandSource.ui: station = "STEST01" @@ -71,15 +71,16 @@ try: (fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(energy , rf_phase) except: raise Exception("Fit failure") - plt = plot([energy, fit_y], ["data", "fit"], [rf_phase, fit_x]) - #plt = plot(None,name="data")[0] - #plt.getSeries(0).setData(to_array(rf_phase,'d'), to_array(energy,'d')) - #plt.getSeries(0).setPointSize(8) - #plt.getSeries(0).setLinesVisible(False) - #plt.addSeries(LinePlotSeries("fit")) - #plt.getSeries(1).setData(fit_x, fit_y) - #plt.getSeries(1).setPointsVisible(False) - #plt.setLegendVisible(True) + #plt = plot([energy, fit_y], ["data", "fit"], [rf_phase, fit_x])[0] + plt = plot(None,name="data")[0] + plt.getSeries(0).setData(to_array(rf_phase,'d'), to_array(energy,'d')) + plt.getSeries(0).setPointSize(8) + plt.getSeries(0).setLinesVisible(False) + plt.addSeries(LinePlotSeries("fit")) + plt.getSeries(1).setData(fit_x, fit_y) + plt.getSeries(1).setPointsVisible(False) + plt.setLegendVisible(True) + caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", ph_crest) caput(station + "-RSYS:GET-ONCREST-E-GAIN", fit_amplitude) caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", fit_x) diff --git a/script/test/GunEnergyScan_dv.py b/script/test/GunEnergyScan_dv.py index 1cef900..226cf22 100644 --- a/script/test/GunEnergyScan_dv.py +++ b/script/test/GunEnergyScan_dv.py @@ -1,19 +1,12 @@ import ch.psi.pshell.epics.Positioner as Positioner import ch.psi.pshell.epics.Camtool as Camtool +is_panel = get_exec_pars().source != CommandSource.ui #must be check before run +run("CPython/wrapper") #Parameters dry_run = True do_elog = False -if get_exec_pars().source == CommandSource.ui: - start = 45.0 - stop = 55.0 - step = 1.0 - nb = 3 - lat = 0.3 - disp = -0.387 - p0 = 7.1 - plt = plot(None, title="Output")[0] -else: +if is_panel: start = args[0] stop = args[1] step = args[2] @@ -22,6 +15,15 @@ else: disp = args[5] p0 = args[6] plt = args[7] +else: + start = 45.0 + stop = 55.0 + step = 1.0 + nb = 3 + lat = 0.3 + disp = -0.387 + p0 = 7.1 + plt = plot(None, title="Output")[0] A = p0 / disp / 1e6 B = p0 @@ -67,7 +69,7 @@ dx_averager.monitored = True # not blocking, will return last nb values #Record callback: uptate of output plot def after_sample(record, scan): - global A, B + global A, B, plt x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev @@ -91,14 +93,26 @@ p = [A * val.mean + B for val in r.getReadable(0)] dp = [abs(A) * val.mean for val in r.getReadable(1)] save_dataset(get_exec_pars().group + "/p", p) save_dataset(get_exec_pars().group + "/dp", dp) + try: - run("CPython/wrapper") + plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color)) + plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2)) + i_max = p.index(max(p)) i_min = dp.index(min(dp)) - (ph_p_max, p_max, ph_p_fit, p_fit) = extremum(ph[i_max-5:i_max+6], p[i_max-5:i_max+6]) - (ph_dp_min, dp_min, ph_dp_fit, dp_fit) = extremum(ph[i_min-5:i_min+6], dp[i_min-5:i_min+6]) - plt.getSeries(2).appendData(ph_p_fit, p_fit) - plt.getSeries(3).appendData(ph_dp_fit, dp_fit) + min_i, max_i = max(i_max-5, 0), min(i_max+6, len(p)) + print min_i, max_i + (ph_p_max, p_max, ph_p_fit, p_fit) = extremum(ph[min_i:max_i], p[min_i:max_i]) + min_i, max_i = max(i_min-5, 0), min(i_min+6, len(p)) + print min_i, max_i + (ph_dp_min, dp_min, ph_dp_fit, dp_fit) = extremum(ph[min_i:max_i], dp[min_i:max_i]) + plt.getSeries(2).setData(ph_p_fit, p_fit) + plt.getSeries(3).setData(ph_dp_fit, dp_fit) + plt.getSeries(2).setPointsVisible(False) + plt.getSeries(3).setPointsVisible(False) + + plt.addMarker(ph_p_max, plt.AxisId.X, "%2.2f" % ph_p_max, plt.getSeries(0).color) + plt.addMarker(ph_dp_min, plt.AxisId.X, "%2.2f" % ph_dp_min, plt.getSeries(1).color) except: raise Exception("Fit failure")