From c1cabe0ecdd8510a62f42d5c428977d02e5f413d Mon Sep 17 00:00:00 2001 From: X11MA Date: Fri, 5 Feb 2016 20:41:55 +0100 Subject: [PATCH] Script execution --- script/EnergyScan.py | 136 +++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 71 deletions(-) diff --git a/script/EnergyScan.py b/script/EnergyScan.py index 7b7ae62..7929a25 100644 --- a/script/EnergyScan.py +++ b/script/EnergyScan.py @@ -56,71 +56,6 @@ print E1,E2,TIME,DELAY,OFFSET1,OFFSET2,RUNTYPE#,ALPHA1,ALPHA2 task = None running = False -def readMCP1(): - MCP1 = [] - a1r = [] - output_file_MCP1 = output_path+"MCP1"+file_prefix+"_" + suffix + ".dat" - MCP1out = open(output_file_MCP1, "a+") - a1=MCPArray1.read() - for i in a1: - a1r.append(i) - Sum1a1 = 0 - Cam1a1 = 0 - Sum2a1 = 0 - Cam2a1 = 0 - for i in xrange(0,479): - Sum1a1 = Sum1a1 + a1r[i] - for i in xrange(Cam_start,Cam_end): - Cam1a1 = Cam1a1 + a1r[i] - for i in xrange(480,959): - Sum2a1 = Sum2a1 + a1r[i] - for i in xrange(Cam_start+480,Cam_end+480): - Cam2a1 = Cam2a1 + a1r[i] - MCP1.append(line_sep) - MCP1.append(e) - MCP1.append(Sum1a1) - MCP1.append(Cam1a1) - MCP1.append(Sum2a1) - MCP1.append(Cam2a1) - if Save_array_data == 1: - MCP1.append(a1r) - a1r = [] - sMCP1 = sep.join(str(x) for x in MCP1) + line_sep # MCP1.write("%s" + sep % i) - MCP1out.write(sep + "rbkenergy" + sep + "Sum1" + sep + "Sum2" + sep + "Cam1" + sep + "Cam2" + sep + "Array" + line_sep + sMCP1) - -def readMCP2(): - MCP2 = [] - a2r = [] - output_file_MCP2 = output_path+"MCP2"+file_prefix+"_" + suffix + ".dat" - MCP2out = open(output_file_MCP2, "a+") - a2=MCPArray2.read() - for j in a2: - a2r.append(j) - Sum1a2 = 0 - Cam1a2 = 0 - Sum2a2 = 0 - Cam2a2 = 0 - for j in xrange(0,479): - Sum1a2 = Sum1a2 + a2r[j] - for j in xrange(Cam_start,Cam_end): - Cam1a2 = Cam1a2 + a2r[j] - for j in xrange(480,959): - Sum2a2 = Sum2a2 + a2r[j] - for j in xrange(Cam_start+480,Cam_end+480): - Cam2a2 = Cam2a2 + a2r[j] - MCP2.append(line_sep) - MCP2.append(e) - MCP2.append(Sum1a2) - MCP2.append(Cam1a2) - MCP2.append(Sum2a2) - MCP2.append(Cam2a2) - if Save_array_data == 1: - MCP2.append(a2r) - a2r = [] - sMCP2 = sep.join(str(y) for y in MCP2) + line_sep - MCP2out.write(sep + "rbkenergy" + sep + "Sum1" + sep + "Sum2" + sep + "Cam1" + sep + "Cam2" + sep + "Array" + line_sep + sMCP2) - - def _startPlot(type): global running sep = "\t" @@ -131,19 +66,70 @@ def _startPlot(type): s = p.getSeries(0) cur = 0 time.sleep(3.0) + #MCP1out.write("rbkenergy" + sep + "Sum1" + sep + "Sum2" + sep + "Cam1" + sep + "Cam2" + sep + "Array" + line_sep) + #MCP2out.write("rbkenergy" + sep + "Sum1" + sep + "Sum2" + sep + "Cam1" + sep + "Cam2" + sep + "Array" + line_sep) while running: try: if otf_start.read() == 0: break e = energy.read() if (MCP_1 == 1 or MCP_2 == 1): - threadA = Thread(target = readMCP1) - threadB = Thread(target = readMCP2) - threadA.run() - threadB.run() + MCP1 = [] + MCP2 = [] + a1r = [] + a2r = [] + a1=MCPArray1.read() + a2=MCPArray2.read() + for i in a1: + a1r.append(i) + Sum1a1 = 0 + Cam1a1 = 0 + Sum2a1 = 0 + Cam2a1 = 0 + for i in xrange(0,479): + Sum1a1 = Sum1a1 + a1r[i] + for i in xrange(Cam_start,Cam_end): + Cam1a1 = Cam1a1 + a1r[i] + for i in xrange(480,959): + Sum2a1 = Sum2a1 + a1r[i] + for i in xrange(Cam_start+480,Cam_end+480): + Cam2a1 = Cam2a1 + a1r[i] + MCP1.append(line_sep) + MCP1.append(e) + MCP1.append(Sum1a1) + MCP1.append(Cam1a1) + MCP1.append(Sum2a1) + MCP1.append(Cam2a1) + if Save_array_data == 1: + MCP1.append(a1r) + print "FUCK1" + a1r = [] + for j in a2: + a2r.append(j) + Sum1a2 = 0 + Cam1a2 = 0 + Sum2a2 = 0 + Cam2a2 = 0 + for j in xrange(0,479): + Sum1a2 = Sum1a2 + a2r[j] + for j in xrange(Cam_start,Cam_end): + Cam1a2 = Cam1a2 + a2r[j] + for j in xrange(480,959): + Sum2a2 = Sum2a2 + a2r[j] + for j in xrange(Cam_start+480,Cam_end+480): + Cam2a2 = Cam2a2 + a2r[j] + MCP2.append(line_sep) + MCP2.append(e) + MCP2.append(Sum1a2) + MCP2.append(Cam1a2) + MCP2.append(Sum2a2) + MCP2.append(Cam2a2) + if Save_array_data == 1: + MCP2.append(a2r) + print MCP2 + print "FUCK2" + a2r = [] time.sleep(SamplingTime.read()*0.001) - threadA.join() - threadB.join() if (abs(e-cur)) > 0.00001: v = abs((keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() ))) s.appendData(e,v) @@ -153,7 +139,15 @@ def _startPlot(type): pass print "Done Plotting" if (MCP_1 == 1 or MCP_2 == 1): + output_file_MCP1 = output_path+"MCP1"+file_prefix+"_" + suffix + ".dat" + MCP1out = open(output_file_MCP1, "a+") + sMCP1 = sep.join(str(x) for x in MCP1) + line_sep # MCP1.write("%s" + sep % i) + MCP1out.write(sep + "rbkenergy" + sep + "Sum1" + sep + "Sum2" + sep + "Cam1" + sep + "Cam2" + sep + "Array" + line_sep + sMCP1) MCP1out.close() + output_file_MCP2 = output_path+"MCP2"+file_prefix+"_" + suffix + ".dat" + MCP2out = open(output_file_MCP2, "a+") + sMCP2 = sep.join(str(y) for y in MCP2) + line_sep + MCP2out.write(sep + "rbkenergy" + sep + "Sum1" + sep + "Sum2" + sep + "Cam1" + sep + "Cam2" + sep + "Array" + line_sep + sMCP2) MCP2out.close() def startPlot(type = 1): global task