From 571ead1c9eb92497da5300ad1546edbfe619c455 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 24 Sep 2018 08:35:56 +0200 Subject: [PATCH] --- config/config.properties | 5 +- config/devices.properties | 4 +- devices/Beam phase.properties | 3 +- devices/Camera Server.properties | 3 +- devices/CurrentCamera.properties | 17 +-- devices/Gun Phase.properties | 3 +- devices/Phase.properties | 3 +- devices/WireScanner motor.properties | 7 +- devices/cam_server.properties | 11 +- devices/energy_AR.properties | 9 ++ devices/fampltms.properties | 3 +- plugins/ScreenPanel3.java | 6 + plugins/WireScanCalibration.java | 2 +- script/Diagnostics/ICT_timing_fine.py | 8 +- script/Diagnostics/ICT_timing_rough.py | 8 +- script/Diagnostics/WireScan.py | 1 + script/Diagnostics/WireScanCalibration.py | 1 + script/Diagnostics/WireScannersStatus.py | 2 +- script/RFscan/GunEnergyScan.py | 152 ---------------------- script/RFscan/GunEnergyScanLasSetNew.py | 13 +- script/RFscan/GunEnergyScanNew.py | 19 +-- script/RFscan/GunEnergyScanRfSetNew.py | 4 +- script/RFscan/GunEnergyScanSet.py | 24 ---- script/RFscan/SchottkyICT.py | 9 -- script/RFscan/SchottkyScan.py | 15 +-- script/RFscan/SchottkyScanSet.py | 27 ---- script/RFscan/phase_scan_caqtdm.py | 2 +- script/RFscan/phase_scan_caqtdm_set.py | 6 +- script/local.py | 9 +- 29 files changed, 98 insertions(+), 278 deletions(-) create mode 100644 devices/energy_AR.properties delete mode 100644 script/RFscan/GunEnergyScan.py delete mode 100644 script/RFscan/GunEnergyScanSet.py delete mode 100644 script/RFscan/SchottkyICT.py delete mode 100644 script/RFscan/SchottkyScanSet.py diff --git a/config/config.properties b/config/config.properties index 2a63ffe..cd712e1 100755 --- a/config/config.properties +++ b/config/config.properties @@ -1,7 +1,8 @@ -#Mon Feb 26 14:07:13 CET 2018 +#Fri Sep 14 08:42:13 CEST 2018 autoSaveScanData=true +commandExecutionEvents=false createSessionFiles=false -dataLayout=default +dataLayout=sf dataPath={data}/{year}/{month}/{day}/{date}_{time}_{name} dataProvider=default dataScanFlushRecords=false diff --git a/config/devices.properties b/config/devices.properties index bbbb115..c62be74 100755 --- a/config/devices.properties +++ b/config/devices.properties @@ -2,8 +2,8 @@ dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf||| cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889||| charge=ch.psi.pshell.epics.ProcessVariable|SINEG01-DICT215:B1_CHARGE_AVERAGE-OP||| rep_rate=ch.psi.pshell.epics.ProcessVariable|SIN-TIMAST-TMA:Beam-Appl-Freq-RB||| -destination_B1=ch.psi.pshell.epics.ChannelString|SF-MODE:MODE_B1 false||| -energy_B1=ch.psi.pshell.epics.ProcessVariable|SF-MODE:ENERGY_B1||| +destination_AR=ch.psi.pshell.epics.ChannelString|SF:MODE_AR false||| +energy_AR=ch.psi.pshell.epics.ProcessVariable|SF:ENERGY_AR||| laser=ch.psi.pshell.epics.ChannelString|SLG-LGEN:WHICH_LASER false||| virtual_accelerator_set=ch.psi.pshell.epics.ChannelDouble|VA-SINBC01-MCRX070:I-SET|||true virtual_accelerator_read=ch.psi.pshell.epics.ChannelDouble|VA-SINBC01-DBPM100:X1|||true diff --git a/devices/Beam phase.properties b/devices/Beam phase.properties index a37e95c..0599f85 100644 --- a/devices/Beam phase.properties +++ b/devices/Beam phase.properties @@ -1,4 +1,4 @@ -#Mon Apr 16 16:03:57 CEST 2018 +#Thu Sep 13 16:59:40 CEST 2018 maxValue=360.0 minValue=-360.0 offset=0.0 @@ -6,4 +6,5 @@ precision=3 resolution=0.1 rotation=true scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/Camera Server.properties b/devices/Camera Server.properties index d643da5..28c8079 100644 --- a/devices/Camera Server.properties +++ b/devices/Camera Server.properties @@ -1,6 +1,7 @@ -#Tue Aug 22 11:21:58 CEST 2017 +#Fri Sep 21 10:47:02 CEST 2018 colormap=Grayscale colormapAutomatic=false +colormapLogarithmic=false colormapMax=NaN colormapMin=NaN flipHorizontally=false diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 10e56bf..76720cb 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,10 +1,11 @@ -#Wed Jul 25 17:06:36 CEST 2018 +#Sun Sep 23 23:38:05 CEST 2018 \u0000= \u0000\u0000\u0000\u0000= -colormap=Rainbow +colormap=Flame colormapAutomatic=true -colormapMax=6000.0 -colormapMin=81.0 +colormapLogarithmic=false +colormapMax=40000.0 +colormapMin=98.0 flipHorizontally=false flipVertically=false grayscale=false @@ -23,10 +24,10 @@ rotation=0.0 rotationCrop=false scale=1.0 serverURL=null -spatialCalOffsetX=-50.03903200624512 -spatialCalOffsetY=-50.048780487804876 -spatialCalScaleX=-1.0 -spatialCalScaleY=-1.0 +spatialCalOffsetX=-1285.5021743822372 +spatialCalOffsetY=-1063.492325271727 +spatialCalScaleX=-17.12279119040641 +spatialCalScaleY=-17.316017253358037 spatialCalUnits=null t= transpose=false diff --git a/devices/Gun Phase.properties b/devices/Gun Phase.properties index be91ea7..3303bf2 100644 --- a/devices/Gun Phase.properties +++ b/devices/Gun Phase.properties @@ -1,4 +1,4 @@ -#Mon May 28 16:52:27 CEST 2018 +#Thu Sep 13 21:20:39 CEST 2018 maxValue=360.0 minValue=-90.0 offset=0.0 @@ -6,4 +6,5 @@ precision=4 resolution=0.5 rotation=true scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/Phase.properties b/devices/Phase.properties index 3d3fbf8..7952059 100644 --- a/devices/Phase.properties +++ b/devices/Phase.properties @@ -1,4 +1,4 @@ -#Mon Jul 10 21:24:29 CEST 2017 +#Fri Sep 14 08:59:10 CEST 2018 maxValue=180.0 minValue=-180.0 offset=0.0 @@ -6,4 +6,5 @@ precision=3 resolution=0.01 rotation=false scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/WireScanner motor.properties b/devices/WireScanner motor.properties index e6e0760..d2e00c0 100644 --- a/devices/WireScanner motor.properties +++ b/devices/WireScanner motor.properties @@ -1,10 +1,10 @@ -#Wed Jun 27 13:42:28 CEST 2018 -defaultSpeed=6000.0 +#Mon Sep 24 08:33:00 CEST 2018 +defaultSpeed=707.1067811865476 estbilizationDelay=0 hasEnable=false homingType=None maxSpeed=8000.0 -maxValue=64000.0 +maxValue=68500.0 minSpeed=50.0 minValue=-47600.0 offset=0.0 @@ -12,5 +12,6 @@ precision=1 resolution=0.1 rotation=false scale=1.0 +sign_bit=0 startRetries=1 unit=um diff --git a/devices/cam_server.properties b/devices/cam_server.properties index 12e7277..1080e02 100644 --- a/devices/cam_server.properties +++ b/devices/cam_server.properties @@ -1,6 +1,7 @@ -#Wed Jul 25 14:36:06 CEST 2018 +#Sat Sep 22 11:42:58 CEST 2018 colormap=Flame colormapAutomatic=true +colormapLogarithmic=false colormapMax=NaN colormapMin=NaN flipHorizontally=false @@ -16,9 +17,9 @@ roiY=0 rotation=0.0 rotationCrop=false scale=1.0 -spatialCalOffsetX=-50.03909304143862 -spatialCalOffsetY=-50.048875855327466 -spatialCalScaleX=-1.0 -spatialCalScaleY=-1.0 +spatialCalOffsetX=-109.42248161877063 +spatialCalOffsetY=-133.52987980134057 +spatialCalScaleX=-17.122791378997093 +spatialCalScaleY=-17.3160171812749 spatialCalUnits=mm transpose=false diff --git a/devices/energy_AR.properties b/devices/energy_AR.properties new file mode 100644 index 0000000..76c8144 --- /dev/null +++ b/devices/energy_AR.properties @@ -0,0 +1,9 @@ +#Fri Aug 17 10:25:25 CEST 2018 +maxValue=NaN +minValue=NaN +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +sign_bit=0 +unit=MeV diff --git a/devices/fampltms.properties b/devices/fampltms.properties index 383651d..ee4fb3e 100644 --- a/devices/fampltms.properties +++ b/devices/fampltms.properties @@ -1,6 +1,7 @@ -#Wed Dec 07 15:12:51 CET 2016 +#Thu Aug 23 09:26:45 CEST 2018 colormap=Grayscale colormapAutomatic=false +colormapLogarithmic=false colormapMax=NaN colormapMin=NaN flipHorizontally=false diff --git a/plugins/ScreenPanel3.java b/plugins/ScreenPanel3.java index 4c07fbf..be6a857 100644 --- a/plugins/ScreenPanel3.java +++ b/plugins/ScreenPanel3.java @@ -42,6 +42,7 @@ import ch.psi.pshell.imaging.Renderer; import ch.psi.pshell.imaging.RendererListener; import ch.psi.pshell.imaging.RendererMode; import ch.psi.pshell.imaging.Source; +import ch.psi.pshell.plot.PlotBase; import ch.psi.pshell.scripting.InterpreterResult; import ch.psi.pshell.scripting.ScriptManager; import ch.psi.pshell.swing.DeviceValueChart; @@ -2385,6 +2386,11 @@ public class ScreenPanel3 extends Panel { dev.setPolling(1000); chart.setDevice(dev); JDialog dlg = SwingUtils.showDialog(dataTableDialog, cameraName + " " + id, null, chart); + //TODO: + //PlotBase plot = chart.getPlot(); + //if (plot!=null){ + // plot.setPlotBackgroundColor(Color.BLACK); + //} } } } diff --git a/plugins/WireScanCalibration.java b/plugins/WireScanCalibration.java index cc9c01f..aab4246 100644 --- a/plugins/WireScanCalibration.java +++ b/plugins/WireScanCalibration.java @@ -20,7 +20,7 @@ public class WireScanCalibration extends Panel { public WireScanCalibration() { initComponents(); - }c.getSetting( + } //Overridable callbacks @Override diff --git a/script/Diagnostics/ICT_timing_fine.py b/script/Diagnostics/ICT_timing_fine.py index 64b365a..4160b16 100644 --- a/script/Diagnostics/ICT_timing_fine.py +++ b/script/Diagnostics/ICT_timing_fine.py @@ -2,8 +2,8 @@ import ch.psi.pshell.epics.ChannelDouble as ChannelDouble dry_run = False do_elog = True -base_name = "SARMA01-DICT482" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599 -dev_name = "SARMA01-DICT090" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030 +base_name = "SATDI01-DICT344" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599 +dev_name = "SATDI01-DICT020" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030 run("CPython/wrapper") @@ -22,10 +22,10 @@ V.initialize() t0 = t.read() -start = 4 +start = 2.2 stop = 12 step = 0.1 -nb = 10 +nb = 5 lat = 0.150 plt = plot(None, title="Output")[0] diff --git a/script/Diagnostics/ICT_timing_rough.py b/script/Diagnostics/ICT_timing_rough.py index a087c88..46da05e 100644 --- a/script/Diagnostics/ICT_timing_rough.py +++ b/script/Diagnostics/ICT_timing_rough.py @@ -2,8 +2,8 @@ import ch.psi.pshell.epics.ChannelDouble as ChannelDouble dry_run = False do_elog = True -base_name = "SINEG01-DICT009" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599 -dev_name = "SINEG01-DICT215" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030 +base_name = "SATDI01-DICT344" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599 +dev_name = "SATDI01-DICT020" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030 if dry_run: t = ChannelDouble("fine delay (us)", "SINEG01-DICT215:Pul1-Delay-SP-SIM") @@ -20,8 +20,8 @@ V.initialize() t0 = t.read() -start = 1001.035 -stop = 1001.050 +start = 1002.140 +stop = 1002.22 step = 0.002 nb = 4 lat = 0.150 diff --git a/script/Diagnostics/WireScan.py b/script/Diagnostics/WireScan.py index e95cf88..7fc2f86 100644 --- a/script/Diagnostics/WireScan.py +++ b/script/Diagnostics/WireScan.py @@ -8,6 +8,7 @@ run("Devices/Elements") run("Devices/WireScanner") run("Diagnostics/sig_process_wrapper") +set_exec_pars(layout="default") #Paramter parsing prefix = args[0] if has_args else "S10DI01-DWSC010" #"S10CB07-DWSC440" #"SINDI01-DWSC090" diff --git a/script/Diagnostics/WireScanCalibration.py b/script/Diagnostics/WireScanCalibration.py index 1aea591..baa4550 100644 --- a/script/Diagnostics/WireScanCalibration.py +++ b/script/Diagnostics/WireScanCalibration.py @@ -6,6 +6,7 @@ run("Devices/Elements") run("Devices/WireScanner") run("Diagnostics/sig_process_wrapper") +set_exec_pars(layout="default") ################################################################################################### # Arguments and constants diff --git a/script/Diagnostics/WireScannersStatus.py b/script/Diagnostics/WireScannersStatus.py index 025a46e..026fd96 100644 --- a/script/Diagnostics/WireScannersStatus.py +++ b/script/Diagnostics/WireScannersStatus.py @@ -7,7 +7,7 @@ for scanner in get_wire_scanners(): else: pos = caget(scanner + ":MOTOR_1.RBV", 's') if (caget(scanner + ":WIRE_SP", 'i') != 0) or (caget(scanner + ":INIT_DONE", 'i') != 1): - print scanner + " is not parked - pos: " + pos + " - Parking..." + print scanner + " is not parked - pos: " + pos else: print scanner + " is parked - pos: " + pos except: diff --git a/script/RFscan/GunEnergyScan.py b/script/RFscan/GunEnergyScan.py deleted file mode 100644 index 6cfa42c..0000000 --- a/script/RFscan/GunEnergyScan.py +++ /dev/null @@ -1,152 +0,0 @@ -import ch.psi.pshell.epics.Positioner as Positioner - -dry_run = False -do_elog = True -is_panel = get_exec_pars().source != CommandSource.ui #must be check before run - -USE_SCREEN_PANEL = True - -run("CPython/wrapper") - -#Parameters -if is_panel: - start = args[0] - stop = args[1] - step = args[2] - nb = int(args[3]) - lat = args[4] - disp = args[5] - p0 = args[6] - plt = args[7] -else: - start = 85.0 - stop = 95.0 - step = 0.5 - nb = 20 - lat = 0.3 - disp = -0.387 - p0 = 7.1 - plt = plot(None, title="Output")[0] - -A = p0 / disp / 1e6 -B = p0 - -#Plot setup -plt.clear() -plt.removeMarker(None) -plt.setStyle(plt.Style.ErrorY) -plt.addSeries(LinePlotErrorSeries("Momentum", Color.red)) -plt.addSeries(LinePlotErrorSeries("Momentum Spread", Color.yellow, 2)) -plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)") -plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)") -plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)") -plt.setLegendVisible(True) - -#Creating Phase positioner -if dry_run: - phase = Positioner("SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM") - camera_name = "simulation" -else: - phase = Positioner("SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE") - camera_name = "SINBD01-DSCR010" -phase.config.minValue = -360.0 -phase.config.maxValue = 360.0 -phase.config.precision = 3 -phase.config.resolution = 0.1 -phase.config.rotation = False -phase.config.save() -phase.initialize() -phase0 = phase.read() - -#Camera setup -if USE_SCREEN_PANEL: - cam_server.start(camera_name+"_sp1", True) #True for shared pipeline -else: - cam_server.start(camera_name) -wait_cam_server_message() -x = cam_server.stream.getChild("x_center_of_mass") -dx = cam_server.stream.getChild("x_rms") -cam_server.setThreshold(750) - -#Creating averagers -x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value -dx_averager = create_averager(dx, nb, -1) -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, 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 - dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev - plt.getSeries(0).appendData(record.positions[0], p_mean, p_stdev) - plt.getSeries(1).appendData(record.positions[0], dp_mean, dp_stdev) - -#The scan loop -try: - phase.write(start) - time.sleep(2.0) - r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample) -finally: - phase.write(phase0) - phase.close() - cam_server.stop() # stops cam_server but does not close it cam_server is a global object - -ph = r.getPositions(0) -p = [A * val.mean + B for val in r.getReadable(0)] -dp = [abs(A) * val.mean for val in r.getReadable(1)] - -#Fitting and plotting -try: - i_max = p.index(max(p)) - i_min = dp.index(min(dp)) - min_i, max_i = max(i_max-8, 0), min(i_max+8, len(p)) - (ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[min_i:max_i], p[min_i:max_i]) - min_i, max_i = max(i_min-8, 0), min(i_min+8, len(dp)) - (ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[min_i:max_i], dp[min_i:max_i]) - plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color)) - plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2)) - 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, "%3.2f" % ph_p_max, plt.getSeries(0).color) - plt.addMarker(ph_dp_min, plt.AxisId.X, "%3.2f" % ph_dp_min, plt.getSeries(1).color) -except: - raise Exception("Fit failure") - -#Saving metadata -save_dataset(get_exec_pars().group + "/processed/p", p) -set_attribute(get_exec_pars().group + "/processed/p", "p max", p_max) -set_attribute(get_exec_pars().group + "/processed/p", "p max phase", ph_p_max) -set_attribute(get_exec_pars().group + "/processed/p", "p fit R2", p_R2) -save_dataset(get_exec_pars().group + "/processed/dp", dp) -set_attribute(get_exec_pars().group + "/processed/dp", "dp min", dp_min) -set_attribute(get_exec_pars().group + "/processed/dp", "dp min phase", ph_dp_min) -set_attribute(get_exec_pars().group + "/processed/dp", "dp fit R2", dp_R2) - -#Elog entry -if do_elog: - if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes": - Laser = str(caget("SLG-LGEN:WHICH_LASER")) - log_msg = "Data file: " + get_exec_pars().path + "\n\n" - log_msg = log_msg + "Laser: " + Laser + "\n" - if Laser == "Alcor": - log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n" - else: - log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n" - if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS": - log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n" - else: - log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n" - log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n" - log_msg = log_msg + "p-max: %0.2f" % p_max + " MeV/c at %0.2f" % ph_p_max + " deg beam phase\n" - log_msg = log_msg + "dp-min: %0.2f" % dp_min + " MeV/c at %0.2f" % ph_dp_min + " deg beam phase\n" - sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition - file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png") - plt.saveSnapshot(file_name , "png") - elog("Gun Energy Scan", log_msg, [file_name,]) - - -set_return(ph_dp_min) \ No newline at end of file diff --git a/script/RFscan/GunEnergyScanLasSetNew.py b/script/RFscan/GunEnergyScanLasSetNew.py index f3aef84..38f4556 100644 --- a/script/RFscan/GunEnergyScanLasSetNew.py +++ b/script/RFscan/GunEnergyScanLasSetNew.py @@ -7,6 +7,7 @@ if get_exec_pars().source == CommandSource.ui: else: las_offset_deg = args[0] plt = args[1] +Laser = caget("SLG-LGEN:WHICH_LASER") cur_las_delay = 0.0 if Laser == "Alcor": cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T") @@ -15,18 +16,18 @@ elif Laser == "Jaguar": new_las_delay = cur_las_delay - 333.467 * las_offset_deg / 360.0 if not dry_run: if Laser == "Alcor": - caput("SLGOS01-TSPL-ALC:NEW_DELTA_T" , new_las_delay ) - caput("SLGOS01-TSPL-ALC:SET_NEW_PHASE.PROC" , 1 ) + caput("SLGOS01-TSPL-ALC:NEW_DELTA_T" , new_las_delay ) + caput("SLGOS01-TSPL-ALC:SET_NEW_PHASE.PROC" , 1 ) elif Laser == "Jaguar": - caput("SLGJG-TSPL-JAG:NEW_DELTA_T" , new_las_delay ) - caput("SLGJG-TSPL-JAG:SET_NEW_PHASE.PROC" , 1 ) + caput("SLGJG-TSPL-JAG:NEW_DELTA_T" , new_las_delay ) + caput("SLGJG-TSPL-JAG:SET_NEW_PHASE.PROC" , 1 ) if do_elog: title = "Set laser delay" log_msg = "" if Laser == "Alcor": - log_msg = "SLGOS01-TSPL-ALC:NEW_DELTA_T: %0.4f" % new_las_delay + " ps (was %0.2f" % cur_las_delay + " ps)\n" + log_msg = "SLGOS01-TSPL-ALC:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n" elif Laser == "Jaguar": - log_msg = "SLGJG-TSPL-JAG:NEW_DELTA_T: %0.4f" % new_las_delay + " ps (was %0.2f" % cur_las_delay + " ps)\n" + log_msg = "SLGJG-TSPL-JAG:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n" attachments = [] if plt is not None: sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition diff --git a/script/RFscan/GunEnergyScanNew.py b/script/RFscan/GunEnergyScanNew.py index dc87d3e..66083f8 100644 --- a/script/RFscan/GunEnergyScanNew.py +++ b/script/RFscan/GunEnergyScanNew.py @@ -2,9 +2,8 @@ import ch.psi.pshell.epics.Positioner as Positioner dry_run = False do_elog = True -set_exec_pars(layout="sf") is_panel = get_exec_pars().source != CommandSource.ui #must be check before run -USE_SCREEN_PANEL = True +USE_SCREEN_PANEL = False run("CPython/wrapper") @@ -66,6 +65,10 @@ else: wait_cam_server_message() x = cam_server.stream.getChild("x_center_of_mass") dx = cam_server.stream.getChild("x_rms") +cam_server.setThreshold(500) +#cam_server.captureBackground(10) #Capturing background +cam_server.setBackgroundSubtraction(True) +cam_server.setRoi([144,1431,482,706]) #X, Y, W, H #Creating averagers x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value @@ -101,12 +104,12 @@ dp = [abs(A) * val.mean for val in r.getReadable(1)] #Fitting and plotting try: - i_max = p.index(max(p)) - i_min = dp.index(min(dp)) - min_i, max_i = max(i_max-6, 0), min(i_max+6, len(p)) - (ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[min_i:max_i], p[min_i:max_i]) - min_i, max_i = max(i_min-6, 0), min(i_min+6, len(dp)) - (ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[min_i:max_i], dp[min_i:max_i]) + i = p.index(max(p)) + a, b = max(i-6, 0), min(i+6, len(p)) + (ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[a:b], p[a:b]) + i = dp.index(min(dp)) + a, b = max(i-6, 0), min(i+6, len(dp)) + (ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[a:b], dp[a:b]) plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color)) plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2)) plt.getSeries(2).setData(ph_p_fit, p_fit) diff --git a/script/RFscan/GunEnergyScanRfSetNew.py b/script/RFscan/GunEnergyScanRfSetNew.py index 3ba1bd3..03fb403 100644 --- a/script/RFscan/GunEnergyScanRfSetNew.py +++ b/script/RFscan/GunEnergyScanRfSetNew.py @@ -8,13 +8,13 @@ else: bph_ref_user = args[0] plt = args[1] phase_offset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE") -phase_offset_new = 90 - bph_ref_user + phase_offset_old +phase_offset_new = phase_offset_old - (bph_ref_user - 90.0) if not dry_run: caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE" , phase_offset_new ) caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM" , 1 ) if do_elog: title = "Set gun phase" - log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset_new + " deg (was %0.2f" % phase_offset_old + " deg)\n" + log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %8.2f" % phase_offset_new + " deg (was %8.2f" % phase_offset_old + " deg)\n" attachments = [] if plt is not None: sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition diff --git a/script/RFscan/GunEnergyScanSet.py b/script/RFscan/GunEnergyScanSet.py deleted file mode 100644 index cd0fc99..0000000 --- a/script/RFscan/GunEnergyScanSet.py +++ /dev/null @@ -1,24 +0,0 @@ -dry_run = False -do_elog = True - -if get_exec_pars().source == CommandSource.ui: - bph_ref_user = 19.0 - plt = None -else: - bph_ref_user = args[0] - plt = args[1] -phase_offset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE") -phase_offset_new = 90 - bph_ref_user + phase_offset_old -if not dry_run: - caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset_new) - caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM", 1) -if do_elog: - log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset_new + " deg (was %0.2f" % phase_offset_old + " deg)\n" - attachments = [] - if plt is not None: - sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition - file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanSet.png") - plt.saveSnapshot(file_name , "png") - attachments = [file_name] - elog("Set gun phase", log_msg, attachments) -show_message("Success setting phase reference") diff --git a/script/RFscan/SchottkyICT.py b/script/RFscan/SchottkyICT.py deleted file mode 100644 index 5baaf3e..0000000 --- a/script/RFscan/SchottkyICT.py +++ /dev/null @@ -1,9 +0,0 @@ -import datetime - -knob = Channel("SINEG01-RSYS:SET-BEAM-PHASE", 'd', alias = "RF phase") -instrument = Channel("SINEG01-DICT215:B1_CHARGE", 'd', alias = "Bunch Charge (ICT)") - -r = lscan(knob, [instrument], 0, 360., 10.,2.0) - - -elog("SchottkyICT", "Data file: " + get_exec_pars().path + "\n\n" + r.print() , get_plot_snapshots()) diff --git a/script/RFscan/SchottkyScan.py b/script/RFscan/SchottkyScan.py index 7fabe54..cf61459 100644 --- a/script/RFscan/SchottkyScan.py +++ b/script/RFscan/SchottkyScan.py @@ -3,6 +3,7 @@ import ch.psi.pshell.epics.ChannelDouble as ChannelDouble dry_run = False do_elog = True + is_panel = get_exec_pars().source != CommandSource.ui #must be check before run if is_panel: start = args[0] @@ -37,11 +38,6 @@ if dry_run: else: bph = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE") rph = ChannelDouble("RF phase", "SINEG01-RSYS:SET-VSUM-PHASE") - #st = Stream("ICTstream", dispatcher) - #q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0) - #st.initialize() - #st.start() - #st.waitValueChange(10000) q = ChannelDouble("Charge", "SINEG01-DICT215:B1_CHARGE") q.initialize() q.monitored=True @@ -55,7 +51,6 @@ bph.initialize() rph.initialize() rph.monitored=True bph0 = bph.read() -rph0 = rph.read() #Creating averagers rph_averager = create_averager(rph, nb, 0.1) @@ -68,9 +63,11 @@ def after_sample(record, scan): #The scan loop try: + bph.write(start) + time.sleep(1.0) r = lscan(bph, (rph_averager, q_averager), start, stop, step, latency=lat, after_read = after_sample) finally: - rph.write(rph0) + bph.write(bph0) bph.close() rph.close() q.close() @@ -106,12 +103,12 @@ set_return([bph_ref_guess]) #Elog entry if do_elog: if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes": - Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS")) + Laser = str(caget("SLG-LGEN:WHICH_LASER")) log_msg = "Data file: " + get_exec_pars().path + "\n\n" log_msg = log_msg + "Laser: " + Laser + "\n" if Laser == "Alcor": log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n" - else: + elif Laser == "Jaguar": log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n" if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS": log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n" diff --git a/script/RFscan/SchottkyScanSet.py b/script/RFscan/SchottkyScanSet.py deleted file mode 100644 index e26aa6e..0000000 --- a/script/RFscan/SchottkyScanSet.py +++ /dev/null @@ -1,27 +0,0 @@ -dry_run = False -do_elog = True - -if get_exec_pars().source == CommandSource.ui: - bph_ref_user = 0.0 - plt = None -else: - bph_ref_user = args[0] - plt = args[1] -phaseOffset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE") -phaseOffset_new = phaseOffset_old - bph_ref_user -if not dry_run: - caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phaseOffset_new) - caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM", 1) -if do_elog: - log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE \n" - log_msg = log_msg + "Old: %0.1f" % phaseOffset_old + " deg \n" - log_msg = log_msg + "New: %0.1f" % phaseOffset_new + " deg \n" - log_msg = log_msg + "Charge on-set at %0.1f" % -phaseOffset_new + " deg RF phase (0.0 deg beam phase)\n" - attachments = [] - if plt is not None: - sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition - file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanSetPlot.png") - plt.saveSnapshot(file_name , "png") - attachments = [file_name] - elog("Set gun phase", log_msg, attachments) -show_message("Success setting phase reference") diff --git a/script/RFscan/phase_scan_caqtdm.py b/script/RFscan/phase_scan_caqtdm.py index 005d779..7b8ea42 100644 --- a/script/RFscan/phase_scan_caqtdm.py +++ b/script/RFscan/phase_scan_caqtdm.py @@ -3,7 +3,7 @@ import ch.psi.pshell.epics.ChannelDouble as ChannelDouble dry_run = False do_elog = True -set_exec_pars(layout="sf") + is_panel = get_exec_pars().source != CommandSource.ui if is_panel: diff --git a/script/RFscan/phase_scan_caqtdm_set.py b/script/RFscan/phase_scan_caqtdm_set.py index f04ddc1..bc00b91 100644 --- a/script/RFscan/phase_scan_caqtdm_set.py +++ b/script/RFscan/phase_scan_caqtdm_set.py @@ -28,8 +28,8 @@ if n > 0: if do_elog == True: title = "Set RF calibration:" + station log_msg = "" - if (phase_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset + " deg (was %0.2f" % phase_offset_old + " deg)\n" - if (ampli_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-AMPLT-SCALE: %0.3f" % amplitude_scale + " MV (was %0.3f" % amplitude_scale_old + " MV)\n" - if (power_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VOLT-POWER-SCALE: %0.7f" % power_scale + " MW/MV^2 (was %0.5f" % power_scale_old + " MW/MV^2)" + if (phase_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %12.2f" % phase_offset + " deg (was %12.2f" % phase_offset_old + " deg)\n" + if (ampli_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-AMPLT-SCALE: %12.3f" % amplitude_scale + " MV (was %12.3f" % amplitude_scale_old + " MV)\n" + if (power_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VOLT-POWER-SCALE: %12.7f" % power_scale + " MW/MV^2 (was %12.5f" % power_scale_old + " MW/MV^2)" attachments = [] elog(title, log_msg, attachments) diff --git a/script/local.py b/script/local.py index 753f9c4..e3d7aaf 100755 --- a/script/local.py +++ b/script/local.py @@ -15,7 +15,7 @@ import java.awt.Color as Color ################################################################################################### import ch.psi.pshell.data.LayoutSF as LayoutSF -LayoutSF.setExperimentArguments([charge, laser, rep_rate, destination_B1, energy_B1]) +LayoutSF.setExperimentArguments([charge, laser, rep_rate, destination_AR, energy_AR]) @@ -214,12 +214,16 @@ def add_convex_hull_plot(title, x,y, name=None, clear = False, x_range = None, y # Tools ################################################################################################### -def elog(title, message, attachments = [], author = None, category = "Info", domain = "", logbook = "SwissFEL commissioning data", encoding=1): +def elog(title, message, attachments = [], application = None, author = None, category = "Info", domain = "", logbook = "SwissFEL commissioning data", encoding=1): """ Add entry to ELOG. """ if author is None: author = "pshell" #get_context().user.name + + if application is None: + application = get_exec_pars().name + typ = "pshell" entry = "" @@ -230,6 +234,7 @@ def elog(title, message, attachments = [], author = None, category = "Info", dom cmd = cmd + '-a "Title=' + title + '" ' cmd = cmd + '-a "Category=' + category + '" ' cmd = cmd + '-a "Domain=' + domain + '" ' + cmd = cmd + '-a "Application=' + application + '" ' for attachment in attachments: cmd = cmd + '-f "' + attachment + '" ' cmd = cmd + '-n ' + str(encoding)