Script execution

This commit is contained in:
gobbo_a
2017-05-04 18:24:11 +02:00
parent b19ddecbcb
commit 15a3e44d0b

View File

@@ -2,6 +2,7 @@ is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before c
run("Devices/Elements")
run("Devices/WireScanner")
run("Diagnostics/sig_process_wrapper")
BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)
@@ -104,18 +105,7 @@ def do_background():
bkg_mean, bkg_sigma = mean(d), stdev(d)
path = get_exec_pars().group + "/"+ r.getReadables()[i].name
set_attribute(path, "Mean", bkg_mean)
set_attribute(path, "Sigma", bkg_sigma)
def calculate():
global cycles, wire, blms
for i in range (cycles):
for j in range(len(blms)):
path = wire+"_" + ("%04d" % (i+1)) + "/blm" + str(j+1)
print "Path = ", path
x =load_data(path)
print x
set_attribute(path, "Sigma", bkg_sigma)
#Scan
def do_scan(index):
@@ -146,8 +136,7 @@ def do_scan(index):
scanner.abort()
if not scan_complete:
raise
finally:
calculate()
finally:
#TODO: Display average of cycles
#Combining data of multiple series
@@ -166,7 +155,7 @@ try:
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
do_scan(0)
if scan_type in [WireScanner.Set1, WireScanner.Set2]:
do_scan(1)
do_scan(1)
finally:
print "Closing scanner"
scanner.close()
@@ -174,6 +163,20 @@ finally:
st.close()
for i in range (cycles):
for j in range(len(blms)):
path = wire+"_" + ("%04d" % (i+1)) + "/blm" + str(j+1)
d = load_data(path)
d = blm_remove_spikes(d)
if bkg_mean is not None:
d = [v-bkg_mean for v in d]
[com, rms] = profile_rms_stats(x, nor,noise_std=0, n_sigma=3.5)
set_attribute(path, "RMS", rms)
set_attribute(path, "RMS centroid", com)
[off, amp, com, sigma] = profile_gauss_stats(x, nor, off=None, amp=None, com=None, sigma=None)
set_attribute(path, "Gauss COM", com)
set_attribute(path, "Gauss Sigma", sigma)
# save the entry in the logbook
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\nSave to ELOG?", "YesNo") == "Yes":