diff --git a/config/devices.properties b/config/devices.properties index 1e5a236..de6e409 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -1,3 +1,4 @@ +FillingPattern=ch.psi.pshell.epics.ChannelDoubleArray|ACORF-FILL:UnsortComp|Read||true MCPArray1=ch.psi.pshell.epics.ChannelIntegerArray|X11MA-ES4:PHC-CTRWF1|Read||true SamplingTime=ch.psi.pshell.epics.ChannelDouble|X11MA-ES4:SAMPLE-TIME|Read||true MCPArray2=ch.psi.pshell.epics.ChannelIntegerArray|X11MA-ES4:PHC-CTRWF2|Read||true diff --git a/config/energy_scan.properties b/config/energy_scan.properties index b9c0283..d8d5915 100644 --- a/config/energy_scan.properties +++ b/config/energy_scan.properties @@ -1,4 +1,4 @@ -MCP test=778.0;779.0;0.5;10.0;-8.8;-9.5 +MCP test=778.0;779.0;0.2;0.0;-8.8;-9.5 Cr2x2=560.0;610.0;2.0;10.0;1.9;0.9 V=505.0;540.0;2.0;10.0;-5.1;-5.7 Ni=825.0;890.0;2.0;10.0;-8.6;-10.4 diff --git a/script/EnergyScan.py b/script/EnergyScan.py index 7929a25..3a5118e 100644 --- a/script/EnergyScan.py +++ b/script/EnergyScan.py @@ -3,6 +3,7 @@ import traceback import thread ############################PGM+ID1+ID2################################################### + if str(SET_OFFSETS) == "1": print "Setting offsets" if RUNTYPE in ["+/-", "+" , "-"]: @@ -26,7 +27,7 @@ if str(SET_OFFSETS) == "1": sys.exit(0) else: print "Running full script" - + file_prefix = time.strftime("%y%m%d") input_path = "/sls/X11MA/Data1/public/X11MA/temp/"+file_prefix+"/" output_path = input_path #+file_prefix+"/" #"/sls/X11MA/Data1/public/e10989/"+file_prefix+"/" @@ -55,6 +56,8 @@ print E1,E2,TIME,DELAY,OFFSET1,OFFSET2,RUNTYPE#,ALPHA1,ALPHA2 task = None running = False +MCP1 = [] +MCP2 = [] def _startPlot(type): global running @@ -66,71 +69,65 @@ 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): - MCP1 = [] - MCP2 = [] - a1r = [] - a2r = [] + if MCP_1 == 1: a1=MCPArray1.read() - a2=MCPArray2.read() - for i in a1: + a1r = [] + 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): + Sum1a1 = 0 + Cam1a1 = 0 + Sum2a1 = 0 + Cam2a1 = 0 + MCP1.append(line_sep) + MCP1.append(e) + for i in xrange(0,480): + Sum1a1 = Sum1a1 + a1r[i] + for i in xrange(Cam_start,Cam_end+1): + Cam1a1 = Cam1a1 + a1r[i] + MCP1.append(Sum1a1) + MCP1.append(Cam1a1) + if NrCounters.read() > 460: + for i in xrange(480,960): Sum2a1 = Sum2a1 + a1r[i] - for i in xrange(Cam_start+480,Cam_end+480): + for i in xrange(Cam_start+480,Cam_end+481): 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 = [] + if Save_array_data == 1: + MCP1.append(a1r) + if MCP_2 == 1: + a2=MCPArray2.read() + a2r = [] 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): + Sum1a2 = 0 + Cam1a2 = 0 + Sum2a2 = 0 + Cam2a2 = 0 + MCP2.append(line_sep) + MCP2.append(e) + for j in xrange(0,480): + Sum1a2 = Sum1a2 + a2r[j] + for j in xrange(Cam_start,Cam_end+1): + Cam1a2 = Cam1a2 + a2r[j] + MCP2.append(Sum1a2) + MCP2.append(Cam1a2) + if NrCounters.read() > 460: + for j in xrange(480,960): Sum2a2 = Sum2a2 + a2r[j] - for j in xrange(Cam_start+480,Cam_end+480): + for j in xrange(Cam_start+480,Cam_end+481): 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) - if (abs(e-cur)) > 0.00001: + if Save_array_data == 1: + MCP2.append(a2r) + time.sleep(SamplingTime.read()*0.001) + if (abs(e-cur)) > 0.1: v = abs((keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() ))) s.appendData(e,v) cur = e @@ -138,17 +135,32 @@ def _startPlot(type): except: pass print "Done Plotting" - if (MCP_1 == 1 or MCP_2 == 1): - output_file_MCP1 = output_path+"MCP1"+file_prefix+"_" + suffix + ".dat" + if MCP_1 == 1: + output_file_MCP1 = output_path+"MCP_1_"+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" + sMCP1out = sep + "rbkenergy" + sep + "Sum1" + sep + "Cam1" + if NrCounters.read() > 460: + sMCP1out = sMCP1out + sep + "Sum2" + sep + "Cam2" + if Save_array_data == 1: + sMCP1out = sMCP1out + sep + "Array" + sMCP1out = sMCP1out + line_sep + sMCP1 + MCP1out.write(sMCP1out) + MCP1out.close() + print "Saved MCP signal data" + if MCP_2 == 1: + output_file_MCP2 = output_path+"MCP_2_"+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() + sMCP2out = sep + "rbkenergy" + sep + "Sum1" + sep + "Cam1" + if NrCounters.read() > 460: + sMCP2out = sMCP2out + sep + "Sum2" + sep + "Cam2" + if Save_array_data == 1: + sMCP2out = sMCP2out + sep + "Array" + sMCP2out = sMCP2out + line_sep + sMCP2 + MCP2out.write(sMCP2out) + MCP2out.close() + print "Saved MCP I_0 data" def startPlot(type = 1): global task task = fork((_startPlot,(type,)),) @@ -192,13 +204,13 @@ fid = get_next_fid(input_path, "o" + file_prefix) ############################################################################### #Prepare scan ############################################################################### -'''if ID1 == 1: +if ID1 == 1: caput ("X11PHS-E:OPT","PGM+ID1") elif ID2 == 1: caput ("X11PHS-E:OPT","PGM+ID2") else: caput ("X11PHS-E:OPT","PGM+ID1+ID2") -''' + number_of_scans = 1 if RUNTYPE in ["+/-", "+", "-"]: caput(OTF_MODE1,1) # circ + in ID1 @@ -237,8 +249,8 @@ open_vg11() time.sleep(0.5) open_vg12() time.sleep(0.5) -open_vg13() -''' +open_vg13()''' + for scan_no in range(number_of_scans): suffix = ("%03d" % fid) input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat" @@ -259,7 +271,7 @@ for scan_no in range(number_of_scans): #caput(OTF_START, 'GO') otf_start.write(1) time.sleep(3.0) - + print "Running scan " + str(scan_no+1) + " out of " + str(number_of_scans) try: #wait_channel(OTF_START, 'STOP', timeout = int(TIME*60), type = 's') otf_start.waitValue(0, (15 + int(TIME*60)) *1000) @@ -277,7 +289,8 @@ for scan_no in range(number_of_scans): print("Converting data file: " + output_file); convert_file(input_file, output_file, pol_str) plot_file(output_file, file_prefix+"_" + suffix) #"Scan " + str(scan_no+1)) - + print "Finished scan " + str(scan_no+1) + " out of " + str(number_of_scans) + if RUNTYPE in ["+/-", "LH/LV"]: if polswitch == 1: switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV @@ -296,4 +309,5 @@ close_vg13() print "Finished Energy scan" -print("Success") +print("Success") +