From 9547784e17ac0c8bfc454672c3583e04843c3607 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 14 Aug 2020 16:25:14 +0200 Subject: [PATCH] Version 1.14 --- config/variables.properties | 4 +- devices/CurrentCamera.properties | 55 ++++++++++--------- devices/Image Averager.properties | 14 ++--- devices/WireScanner motor.properties | 2 +- devices/cam_server.properties | 2 +- devices/image.properties | 35 +++++++----- plugins/ScreenPanel6.java | 7 ++- script/Devices/Elements.py | 2 + script/Diagnostics/ICT_timing_fine.py | 4 +- script/Diagnostics/ICT_timing_rough.py | 12 ++-- script/Diagnostics/WireScan.py | 9 +-- script/RFscan/phase_scan_caqtdm.py | 2 +- script/Tools/RfEnergyCalib.py | 17 +++--- script/Undulators/{K-calc.py => K-calc_AR.py} | 10 +--- script/Undulators/K-calc_AT.py | 38 +++++++++++++ script/local.py | 4 ++ script/test/scale_ECOL_MCOR_MSEX.py | 4 +- script/test/test_stream.py | 17 ++++++ 18 files changed, 152 insertions(+), 86 deletions(-) rename script/Undulators/{K-calc.py => K-calc_AR.py} (71%) create mode 100644 script/Undulators/K-calc_AT.py create mode 100644 script/test/test_stream.py diff --git a/config/variables.properties b/config/variables.properties index 6045bfe..5b4af19 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,2 +1,2 @@ -#Fri Feb 07 11:46:23 CET 2020 -FileSequentialNumber=1251 +#Mon Aug 03 14:24:23 CEST 2020 +FileSequentialNumber=2478 diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index de37aa9..c08ff70 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,41 +1,44 @@ -#Fri Feb 07 11:39:15 CET 2020 -\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= -\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= -\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= -\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= -\u0000\u0000\u0000\u0000\u0000\u0000= -\u0000\u0000\u0000\u0000= -\u0000= +#Thu Aug 13 08:13:01 CEST 2020 \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= -spatialCalOffsetY=-50.048875855327466 -spatialCalOffsetX=-50.03909304143862 +\u0000= +\u0000\u0000\u0000\u0000= +\u0000\u0000\u0000\u0000\u0000\u0000= +\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= +\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= +\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= +\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= +\u0000\u0000\u0000\u0000\u0000= +\u0000\u0000\u0000= colormapLogarithmic=false -scale=1.0 -grayscale=false spatialCalScaleX=-1.0 spatialCalScaleY=-1.0 serverURL=null -colormapMax=6283.0 rescaleOffset=0.0 roiWidth=-1 colormap=Flame -imageWidth=1744 +imageWidth=2560 invert=false -spat= -colormapMin=46.0 +colormapMin=814.0 rotationCrop=false -rotation=0.0 -rescaleFactor=1.0 -imageHeight=1680 -spatialCalUnits=null -flipVertically=false -r= roiHeight=-1 -t= -flipHorizontally=false colormapAutomatic=true roiY=0 roiX=0 +spatialCalOffsetY=-50.048780487804876 +spatialCalOffsetX=-50.03903200624512 +scale=1.0 +regionStart= +grayscale=false +colormapMax=3092.0 +spat= +rotation=0.0 +rescaleFactor=1.0 +imageHeight=2160 +spatialCalUnits=null +flipVertically=false +r= +t= +flipHorizontally=false transpose=false -regionStartX=433 -regionStartY=241 +regionStartX=1 +regionStartY=1 diff --git a/devices/Image Averager.properties b/devices/Image Averager.properties index c1aea4d..4f924f8 100644 --- a/devices/Image Averager.properties +++ b/devices/Image Averager.properties @@ -1,18 +1,18 @@ -#Sat Jan 25 10:00:39 CET 2020 -spatialCalOffsetY=-283.472459616368 -spatialCalOffsetX=-508.635792340687 +#Tue May 12 17:41:26 CEST 2020 +spatialCalOffsetY=-371.75254447653117 +spatialCalOffsetX=-371.5638424602207 colormapLogarithmic=false scale=1.0 grayscale=false -spatialCalScaleX=-11.968979779411764 -spatialCalScaleY=-10.638298123826168 -colormapMax=45095.0 +spatialCalScaleX=-11.494253419452887 +spatialCalScaleY=-11.494253533848884 +colormapMax=1000.0 rescaleOffset=0.0 roiWidth=-1 colormap=Flame imageWidth=659 invert=false -colormapMin=74.0 +colormapMin=0.0 rotationCrop=false rotation=0.0 rescaleFactor=1.0 diff --git a/devices/WireScanner motor.properties b/devices/WireScanner motor.properties index 5fd46e9..8228cc5 100644 --- a/devices/WireScanner motor.properties +++ b/devices/WireScanner motor.properties @@ -1,4 +1,4 @@ -#Tue Feb 04 11:46:29 CET 2020 +#Tue Apr 28 11:13:53 CEST 2020 offset=0.0 maxValue=51500.0 precision=1 diff --git a/devices/cam_server.properties b/devices/cam_server.properties index d82f7e5..6fc7257 100644 --- a/devices/cam_server.properties +++ b/devices/cam_server.properties @@ -1,4 +1,4 @@ -#Thu Feb 06 15:36:29 CET 2020 +#Mon May 04 11:45:54 CEST 2020 spatialCalOffsetY=-820.4883730911062 spatialCalOffsetX=-861.4939970777481 colormapLogarithmic=false diff --git a/devices/image.properties b/devices/image.properties index 09d5673..45ffffa 100644 --- a/devices/image.properties +++ b/devices/image.properties @@ -1,20 +1,25 @@ -#Fri Jul 21 15:08:25 CEST 2017 -flipHorizontally=false -flipVertically=false -grayscale=true -invert=true -rescaleFactor=1.0 -rescaleOffset=0.0 -roiHeight=-1 -roiWidth=-1 -roiX=0 -roiY=0 -rotation=0.0 -rotationCrop=false -scale=1.0 -spatialCalOffsetX=NaN +#Fri Jun 05 14:13:17 CEST 2020 spatialCalOffsetY=NaN +spatialCalOffsetX=NaN +colormapLogarithmic=false +scale=1.0 +grayscale=true spatialCalScaleX=NaN spatialCalScaleY=NaN +colormapMax=NaN +rescaleOffset=0.0 +roiWidth=-1 +colormap=null +invert=true +colormapMin=NaN +rotation=0.0 +rotationCrop=false +rescaleFactor=1.0 spatialCalUnits=mm +flipVertically=false +roiHeight=-1 +flipHorizontally=false +colormapAutomatic=false +roiY=0 +roiX=0 transpose=false diff --git a/plugins/ScreenPanel6.java b/plugins/ScreenPanel6.java index 1487432..86ca079 100644 --- a/plugins/ScreenPanel6.java +++ b/plugins/ScreenPanel6.java @@ -2297,10 +2297,10 @@ public class ScreenPanel6 extends Panel { System.out.println("Setting laser state: " + value + " - bunch" + bunch); //Epics.putq("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", value ? 0 : 1); if ((bunch<=0) || (bunch==1)){ - Epics.putq("SWISSFEL-STATUS:Bunch-1-OnDelay-Sel", value ? 0 : 1); + Epics.putq("SIN-TIMAST-TMA:Bunch-1-OnDelay-Sel", value ? 0 : 1); } if ((bunch<=0) || (bunch==2)){ - Epics.putq("SWISSFEL-STATUS:Bunch-2-OnDelay-Sel", value ? 0 : 1); + Epics.putq("SIN-TIMAST-TMA:Bunch-2-OnDelay-Sel", value ? 0 : 1); } Epics.putq("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1); @@ -4269,6 +4269,9 @@ public class ScreenPanel6 extends Panel { if (ret == OptionResult.No) { laserOn2= false; } + if (ret == OptionResult.Cancel) { + return; + } } } else { ret = SwingUtils.showOption(getTopLevel(), "Capture Background", "Do you want to capture background now?", OptionType.OkCancel); diff --git a/script/Devices/Elements.py b/script/Devices/Elements.py index 76c04ba..4048c79 100644 --- a/script/Devices/Elements.py +++ b/script/Devices/Elements.py @@ -318,6 +318,7 @@ def stop_blm_ws(blm): caput(blm + ":WS_STOP.PROC", 1) def set_blm_ws_gain(blm, gain): + print "set_blm_ws_gain ", blm, gain caput(blm + ":WS_PMT_GAIN_VOLTS", float(gain)) def get_blm_ws_gain(blm): @@ -325,6 +326,7 @@ def get_blm_ws_gain(blm): def set_blm_ws_att(blm, att): + print "set_blm_ws_att ", blm, gain caput(blm + ":WS_PMT_ATT_VOLTS", att) def get_blm_ws_att(blm): diff --git a/script/Diagnostics/ICT_timing_fine.py b/script/Diagnostics/ICT_timing_fine.py index 8db25b9..6914ec0 100644 --- a/script/Diagnostics/ICT_timing_fine.py +++ b/script/Diagnostics/ICT_timing_fine.py @@ -41,8 +41,8 @@ plt.setLegendVisible(True) def plot_point(record, scan): global plt - q_mean, q_stdev = record.values[0].mean, record.values[0].stdev - V_mean, V_stdev = record.values[1].mean, record.values[1].stdev + q_mean, q_stdev = record.readables[0].mean, record.readables[0].stdev + V_mean, V_stdev = record.readables[1].mean, record.readables[1].stdev plt.getSeries(0).appendData(record.positions[0], q_mean, q_stdev) plt.getSeries(1).appendData(record.positions[0], V_mean, V_stdev) diff --git a/script/Diagnostics/ICT_timing_rough.py b/script/Diagnostics/ICT_timing_rough.py index 1004d3d..d92576f 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 = "SATBD02-DICT499" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599 -dev_name = "SATBD02-DICT020" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030 +base_name = "SINEG01-DICT009" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599 +dev_name = "SINEG01-DICT215" # 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.000 -stop = 1002.200 +start = 1000.000 +stop = 1001.200 step = 0.01 nb = 5 lat = 0.150 @@ -40,13 +40,13 @@ plt.setLegendVisible(True) def plot_point(record, scan): global plt q_mean, q_stdev = record.values[0].mean, record.values[0].stdev - V_mean, V_stdev = record.values[1].mean, record.values[1].stdev + V_mean, V_stdev = record.values[1].mean, recFd.values[1].stdev plt.getSeries(0).appendData(record.positions[0], q_mean, q_stdev) plt.getSeries(1).appendData(record.positions[0], V_mean, V_stdev) try: q_averager = create_averager(q, nb, lat) - V_averager = create_averager(V, nb, lat) + V_averager = create_averager(V,F nb, lat) V_averager.monitored=True r = lscan(t, (q_averager, V_averager), start, stop, step, latency=lat, after_read = plot_point) delay = r.getPositions(0) diff --git a/script/Diagnostics/WireScan.py b/script/Diagnostics/WireScan.py index 559cdcc..311e709 100644 --- a/script/Diagnostics/WireScan.py +++ b/script/Diagnostics/WireScan.py @@ -38,7 +38,7 @@ INCREMENT_FACTOR = 0.5 SCAN_RANGE_FACTOR = 6 MAX_RANGE_STEP = 300 -SET_BLM_WS_MODE = False +SET_BLM_WS_MODE = True SET_BLM_WS_SETTLING_TIME = 2.0 SET_BLM_WS_BS_READBACK_TIMEOUT = 10000 #ms @@ -234,8 +234,8 @@ def do_scan(index): else: plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3]) - - set_blm_gain(scan_type, index) + if adaptive>0: + set_blm_gain(scan_type, index) scanner.init(wait=True) scanner.curr_cycl.write(0) @@ -474,7 +474,8 @@ finally: except: pass if SET_BLM_WS_MODE and len(blms)>0: - stop_blm_ws(blms[0]) + for i in range(len(blms)): + stop_blm_ws(blms[i]) print "Closing scanner" scanner.close() print "Closing stream" diff --git a/script/RFscan/phase_scan_caqtdm.py b/script/RFscan/phase_scan_caqtdm.py index aae26f2..69ace73 100644 --- a/script/RFscan/phase_scan_caqtdm.py +++ b/script/RFscan/phase_scan_caqtdm.py @@ -73,7 +73,7 @@ def after(rec): #scan and plot try: phase.write(start) - time.sleep(1.0) + time.sleep(2.0) x_averager = create_averager(x, nb, lat) r = lscan(phase, x_averager, start, stop, step, latency=lat, after_read = after) rf_phase = r.getPositions(0) diff --git a/script/Tools/RfEnergyCalib.py b/script/Tools/RfEnergyCalib.py index b610441..952f1f8 100644 --- a/script/Tools/RfEnergyCalib.py +++ b/script/Tools/RfEnergyCalib.py @@ -1,11 +1,12 @@ -E1 = 3722.0 # old energy -E2 = 3789.0 # new energy +E1 = 3493.0 # old energy +E2 = 3752.0 # new energy do_elog = True -#stationlist = ("S10CB01","S10CB02","S10CB03","S10CB04","S10CB05","S10CB06","S10CB07","S10CB08","S10CB09") + +stationlist = ("S10CB01","S10CB02","S10CB03","S10CB04","S10CB05","S10CB06","S10CB07","S10CB08","S10CB09") #stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04") -stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04","S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13") +#stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04","S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13") A1, A2 = {}, {} P1, P2 = {}, {} @@ -16,16 +17,12 @@ for station in stationlist: A2[station] = A * E2 / E1 P1[station] = P P2[station] = P * (E1 / E2)**2 -# set RF on-delay -caput("SIN-TIMAST-TMA:Beam-RF-Delay-Sel",1) -caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1) + for station in stationlist: caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", A2[station]) caput(station + "-RSYS:SET-VOLT-POWER-SCALE", P2[station]) caput(station + "-RSYS:CMD-LOAD-CALIB-BEAM", 1) -# set RF on-beam -caput("SIN-TIMAST-TMA:Beam-RF-Delay-Sel",0) -caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1) + #Elog entry if do_elog: title = "Energy calibration scaling" diff --git a/script/Undulators/K-calc.py b/script/Undulators/K-calc_AR.py similarity index 71% rename from script/Undulators/K-calc.py rename to script/Undulators/K-calc_AR.py index 629094c..039adf5 100644 --- a/script/Undulators/K-calc.py +++ b/script/Undulators/K-calc_AR.py @@ -1,5 +1,5 @@ -Eph1 = 11.312 # actual photon energy -Eph2 = 12.00 # desired photon energy +Eph1 = 11.65 # actual photon energy +Eph2 = 12.05 # desired photon energy do_elog = True @@ -11,9 +11,6 @@ for und in undlist: K1[und] = K K2[und] = ((Eph1 / Eph2 * (K**2 + 2) - 2))**0.5 print K1,K2 -#if Eph2 > Eph1 : -# for und in undlist: caput(und + "-UIND030:K_SET", 1.1) -# time.sleep(40.0) for und in undlist: caput(und + "-UIND030:K_SET", K2[und]) #Elog entry @@ -21,5 +18,4 @@ if do_elog: title = "Wavelength change" log_msg = "Old photon energy: %0.2f" % Eph1 + " kev\n" log_msg = log_msg + "New photon energy: %0.2f" % Eph2 + " keV\n" - attachments = None - elog(title, log_msg, attachments) \ No newline at end of file + elog(title, log_msg) \ No newline at end of file diff --git a/script/Undulators/K-calc_AT.py b/script/Undulators/K-calc_AT.py new file mode 100644 index 0000000..18f1d2f --- /dev/null +++ b/script/Undulators/K-calc_AT.py @@ -0,0 +1,38 @@ +undlist = ("SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22") + +### getting current photon energy: +Eph1 = caget(undlist[0] + "-UIND030:FELPHOTENE") +#Eph1 = 0.530 # actual photon energy in keV +print("Photon energy at start (at ", undlist[0],") : ", round(Eph1,4)) + +### give desired photon energy via relative or absolute method. +### please comment the other out! + +### relative change in photon energy: +#step = -0.002 # desired step to scale in keV +#Eph2 = Eph1 + step + +### absolute change in photon energy: +Eph2 = 0.540 # desired photon energy in keV + +print("Photon energy at end: ", round(Eph2,4)) + +do_elog = True + + +### actual code: +K1, K2 = {}, {} +for und in undlist: + K = caget(und + "-UIND030:K_SET") + K1[und] = K + K2[und] = ((Eph1 / Eph2 * (K**2 + 2) - 2))**0.5 +print(K1) +print(K2) +for und in undlist: caput(und + "-UIND030:K_SET", K2[und]) + +### create Elog entry +if do_elog: + title = "Athos wavelength change" + log_msg = "Old photon energy: %0.4f" % Eph1 + " kev\n" + log_msg = log_msg + "New photon energy: %0.4f" % Eph2 + " keV\n" + elog(title, log_msg) diff --git a/script/local.py b/script/local.py index 15c8a9c..c6b11cf 100755 --- a/script/local.py +++ b/script/local.py @@ -292,6 +292,10 @@ def elog(title, message, attachments = [], application = None, author = None, ca if (err is not None) and err!="": raise Exception(err) print out + import ch.psi.pshell.ui.App as App + if not App.isOutputRedirected(): + import java.lang.System as System + System.out.println(out) try: return int(out[out.find("ID=") +3 : ]) except: diff --git a/script/test/scale_ECOL_MCOR_MSEX.py b/script/test/scale_ECOL_MCOR_MSEX.py index 2f1fe01..36cc2fc 100644 --- a/script/test/scale_ECOL_MCOR_MSEX.py +++ b/script/test/scale_ECOL_MCOR_MSEX.py @@ -4,8 +4,8 @@ devlist = ['SARCL02-MCRX100:I-SET', 'SARCL02-MCRX120:I-SET', 'SARCL02-MCRX200:I- 'SARCL02-MCRX320:I-SET', 'SARCL02-MCRX340:I-SET', 'SARCL02-MCRX450:I-SET' ] #SARCL02-MCRY120:I-SET, SARCL02-MCRY230:I-SET, SARCL02-MCRY240:I-SET, SARCL02-MCRY480:I-SET, #SARCL02-MCRY320:I-SET, SARCL02-MCRY340:I-SET, SARCL02-MCRY450:I-SET -energy = 2840.0 -energynew = 3398.0 +energy = 4500.0 +energynew = 4040.0 efactor = energynew / energy print(efactor) diff --git a/script/test/test_stream.py b/script/test/test_stream.py new file mode 100644 index 0000000..0b0c93e --- /dev/null +++ b/script/test/test_stream.py @@ -0,0 +1,17 @@ +#cam_server.stop() +#cam_server.start("stream_example") +cam_server.start("bs_timing_test") +cam_server.stream.waitCacheChange(3000) + +bscan (cam_server.stream, 100, save=False) + +names=[] +data=[] +for k,v in cam_server.value.items(): + names.append(k) + data.append(v) + +plot(data, names) + + +