From 8fe0078cf9e7bfe3719c08f6a2629257ef008043 Mon Sep 17 00:00:00 2001 From: voulot_d Date: Thu, 19 Jan 2017 15:33:37 +0100 Subject: [PATCH] Closedown --- script/RFscan/SchottkyICT.py | 4 +- script/RFscan/gun_scan1.py | 2 +- script/RFscan/gun_scan_caqtdm.py | 92 -------------------------------- 3 files changed, 3 insertions(+), 95 deletions(-) delete mode 100644 script/RFscan/gun_scan_caqtdm.py diff --git a/script/RFscan/SchottkyICT.py b/script/RFscan/SchottkyICT.py index 2929919..5baaf3e 100644 --- a/script/RFscan/SchottkyICT.py +++ b/script/RFscan/SchottkyICT.py @@ -1,7 +1,7 @@ import datetime -knob = Channel("SINEG01-RSYS:SET-BEAM-PHASE", 'd', alias = "RF phase") -instrument = Channel("SINEG01-DICT215:B1_CHARGE", 'd', alias = "Bunch Charge (ICT)") +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) diff --git a/script/RFscan/gun_scan1.py b/script/RFscan/gun_scan1.py index 23369e7..7dda448 100644 --- a/script/RFscan/gun_scan1.py +++ b/script/RFscan/gun_scan1.py @@ -31,6 +31,6 @@ finally: #st.close() # Here the user needs to pick a phase as reference phase (onset of charge emission) -phase_ref = 120.0 +phase_ref = 80.0 phase_offset = - phase_ref caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset) diff --git a/script/RFscan/gun_scan_caqtdm.py b/script/RFscan/gun_scan_caqtdm.py deleted file mode 100644 index ddc67f1..0000000 --- a/script/RFscan/gun_scan_caqtdm.py +++ /dev/null @@ -1,92 +0,0 @@ -import ch.psi.pshell.epics.ControlledVariable as ControlledVariable - -if get_exec_pars().source == CommandSource.ui: - station = "SINEG01" -else: - station = args[0] - -start = caget(station + "-RSYS:SET-SCAN-START") -stop = caget(station + "-RSYS:SET-SCAN-STOP") -step = caget(station + "-RSYS:SET-SCAN-STEP") -lat = caget(station + "-RSYS:SET-SCAN-WAIT-TIME") -nb = caget(station + "-RSYS:SET-NUM-AVERAGE") -scr_ch = caget(station + "-RSYS:DSCR") -disp = caget(scr_ch + ":DISPERSION") -energy0 = caget(scr_ch + ":ENERGY") - -phase = ControlledVariable("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:GET-VSUM-PHASE") -phase.config.minValue =-45.0 -phase.config.maxValue = 360.0 -phase.config.resolution = 0.5 -phase.initialize() - -V = Channel(station + "-RSYS:GET-VSUM-AMPLT", type = 'd', alias='Amplitude Readback') -P = Channel(station + "-RSYS:GET-KLY-POWER", type = 'd', alias='Power Readback') -q = Channel("SINEG01-DICT215:B1_CHARGE", type = 'd', alias='Charge') -x = Stream(scr_ch + ":camtool.pipeline.x_stats_gr.com_egu", type = 'd', alias='SCR-X') -dx = Stream(scr_ch + ":camtool.pipeline.x_stats_gr.rms_egu", type = 'd', alias='SCR-DX') - -caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", to_array([0.0],'d')) -caput(station + "-RSYS:GET-FIT-CHARGE-ARRAY", to_array([0.0],'d')) -caput(station + "-RSYS:GET-REF-VSUM-PHASE", float('nan')) -caput(station + "-RSYS:CALC-VSUM-PHASE-OFFSET", float('nan')) - -#update the plot dynamically -arr_phase,arr_charge = [],[] -def after(rec): - global disp, energy0 - arr_phase.append(rec.positions[0]) - arr_charge.append(rec.values[1].mean) - caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(arr_phase, 'd')) - caput(station + "-RSYS:GET-CHARGE-ARRAY", to_array(arr_charge,'d')) - -try: - Vb = create_averager(V, nb, 0.100) - qb = create_averager(q, nb, 0.100) - r = lscan(phase, [Vb, qb], start, stop, step , latency=lat, after_read = after) - rf_phase = r.getPositions(0) - charge = [val.mean for val in r.getReadable(1)] - caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d')) - caput(station + "-RSYS:GET-CHARGE-ARRAY", to_array(charge, 'd')) - phase_fit_max = None - try: - (energy_max, angular_frequency, phase0, in_range, phase_fit_max, fit_x, fit_y) = hfit(energy , xdata = rf_phase) - except: - raise Exception("Fit failure") - caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", phase_fit_max) - caput(station + "-RSYS:GET-ONCREST-E-GAIN", energy_max) - caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", fit_x) - caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", fit_y) - phase_min, phase_max = min(rf_phase), max(rf_phase) - if not (phase_min <= phase_fit_max <= phase_max): - raise Exception("Fit maximum outside scan range") - phase.write(phase_fit_max) - time.sleep(lat) - Ampl = V.read() - Power = P.read() - caput(station + "-RSYS:GET-ONCREST-VSUM-AMPLT", Ampl) - caput(station + "-RSYS:GET-ONCREST-KLY-POWER", Power) -finally: - phase.close() - V.close() - P.close() - x.close() - -print ("------------------------------------") -print ("Valid fit") - -energy_gain = energy_max -phase_offset = 90 - phase_fit_max -amplitude_scale = energy_gain / Ampl -power_scale = Power / math.pow(Ampl,2) - -caput(station + "-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset) -caput(station + "-RSYS:CALC-VSUM-AMPLT-SCALE" , amplitude_scale) -caput(station + "-RSYS:CALC-VOLT-POWER-SCALE" , power_scale) - -#title="Phase scan "+str(station) -#message=("Energy Gain: %0.3f" % energy_gain + "MeV\n" + -# "Phase Offset: %0.2f" % phase_offset + "deg\n" + -# "Amplitude Scale: %0.3f" % amplitude_scale + "MV\n" + -# "Power Scale: %0.3f" % power_scale) + "1/ohm" -#elog(title, message)