diff --git a/config/energy_scan.properties b/config/energy_scan.properties
index 1e1a3ed..168f6f6 100644
--- a/config/energy_scan.properties
+++ b/config/energy_scan.properties
@@ -1,12 +1,12 @@
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
+V=505.0;540.0;2.0;10.0;-7.5;-8.5
Ni=825.0;890.0;2.0;10.0;-3.5;3.0
Ni Linear=825.0;890.0;2.0;10.0;-3.5;-5.5
-O=500.0;560.0;2.0;10.0;-5.1;-5.7
+O=500.0;560.0;2.0;10.0;-7.5;-8.5
Gd=1170.0;1240.0;2.0;10.0;-13.0;-11.5
Cr=560.0;610.0;2.0;10.0;-6.2;-7.2
Co=750.0;825.0;2.0;10.0;-8.8;-9.5
Mn=620.0;670.0;2.0;10.0;-6.7;-8.1
-Fe=680.0;750.0;2.0;10.0;-7.2;-9.0
+Fe=680.0;750.0;2.0;10.0;-10.0;-11.5
Fe Linear=680.0;750.0;2.0;10.0;-1.5;-1.0
diff --git a/config/plugins.properties b/config/plugins.properties
index 474ce8e..3387ac6 100644
--- a/config/plugins.properties
+++ b/config/plugins.properties
@@ -1,4 +1,4 @@
-EnergyScan_TBT.java=enabled
+EnergyScan_TBT.java=disabled
DelayScan.java=enabled
EnergyScan.java=enabled
Test.java=disabled
diff --git a/plugins/DelayScan.form b/plugins/DelayScan.form
index fc8a37e..9c52da5 100644
--- a/plugins/DelayScan.form
+++ b/plugins/DelayScan.form
@@ -177,9 +177,6 @@
-
-
-
@@ -207,10 +204,7 @@
-
-
-
-
+
@@ -236,10 +230,7 @@
-
-
-
-
+
@@ -301,7 +292,7 @@
-
+
@@ -604,8 +595,11 @@
-
+
+
+
+
diff --git a/plugins/DelayScan.java b/plugins/DelayScan.java
index 932f2dd..2562d92 100644
--- a/plugins/DelayScan.java
+++ b/plugins/DelayScan.java
@@ -89,13 +89,13 @@ public class DelayScan extends Panel {
args.put("DELAY", (Double) spinnerDelay.getValue());
args.put("END", (Double) spinnerEnd.getValue());
args.put("FINEDELAY", (Double) spinnerFineDelay.getValue());
- args.put("SIZE", (Double) spinnerSize.getValue());
+ args.put("STEP", (Double) spinnerSize.getValue());
args.put("OFFSET1", (Double) spinnerOffset1.getValue());
args.put("OFFSET2", (Double) spinnerOffset2.getValue());
args.put("ACQTIME", (Double) spinnerAcqTime.getValue());
args.put("ENERGIES", jTextField1.getText());
args.put("RUNTYPE", comboRunType.getSelectedItem().toString());
- args.put("ROUNDS", (Double) spinnerRounds.getValue());
+ args.put("ROUNDS", (Integer) spinnerRounds.getValue());
args.put("SET_OFFSETS", jCheckBox1.isSelected() ? 1 : 2);
args.put("ID1", jRadioButton1.isSelected() ? 1 : 2);
args.put("ID2", jRadioButton2.isSelected() ? 1 : 2);
@@ -105,7 +105,7 @@ public class DelayScan extends Panel {
args.put("Cam_end", (Double) jSpinner2.getValue());
args.put("Save_array_data", jCheckBox4.isSelected() ? 1 : 2);
args.put("PATH", jTextField2.getText());
-
+
buttonAbort.setEnabled(true);
runAsync("DelayScan", args).handle((ok, ex) -> {
@@ -179,7 +179,6 @@ public class DelayScan extends Panel {
jLabel1.setText("Delay start (ns):");
spinnerStart.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
- spinnerStart.setValue(0);
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("LPP delay at t=0");
@@ -189,8 +188,7 @@ public class DelayScan extends Panel {
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Delay end (ns):");
- spinnerEnd.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
- spinnerEnd.setValue(50);
+ spinnerEnd.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(50.0d), null, null, Double.valueOf(1.0d)));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("LPP fine delay at t=0");
@@ -200,8 +198,7 @@ public class DelayScan extends Panel {
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("Step size (ns):");
- spinnerSize.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
- spinnerSize.setValue(1);
+ spinnerSize.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(1.0d), null, null, Double.valueOf(1.0d)));
jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel13.setText("Offset2:");
@@ -223,7 +220,7 @@ public class DelayScan extends Panel {
comboRunType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+/-", "+,-", "+", "-", "LH/LV", "LH,LV", "LH", "LV" }));
- spinnerRounds.setModel(new javax.swing.SpinnerNumberModel(1.0d, 1.0d, 10.0d, 1.0d));
+ spinnerRounds.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10, 1));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel5.setText("Nb of repetitions:");
@@ -475,7 +472,12 @@ public class DelayScan extends Panel {
jLabel10.setText("Saving path");
- jTextField2.setText("X:\\public");
+ jTextField2.setText("/sls/X11MA/data/X11MA/Desktop/");
+ jTextField2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField2ActionPerformed(evt);
+ }
+ });
javax.swing.GroupLayout panelSetupLayout = new javax.swing.GroupLayout(panelSetup);
panelSetup.setLayout(panelSetupLayout);
@@ -547,6 +549,10 @@ public class DelayScan extends Panel {
// TODO add your handling code here:
}//GEN-LAST:event_jTextField1ActionPerformed
+ private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jTextField2ActionPerformed
+
EditorDialog dlgConfig;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
diff --git a/plugins/Test.java b/plugins/Test.java
index 5b2de3e..f4e3d10 100644
--- a/plugins/Test.java
+++ b/plugins/Test.java
@@ -14,7 +14,7 @@ import javax.script.ScriptException;
/**
*
- *
+ *spinnerAcqTime.setModel(new javax.swing.SpinnerNumberModel(0.0d, -20.0d, 20.0d, 1.0d));
*/
public class Test extends Panel {
diff --git a/script/DelayScan.py b/script/DelayScan.py
index 5c9a67d..6fb72df 100644
--- a/script/DelayScan.py
+++ b/script/DelayScan.py
@@ -81,6 +81,8 @@ def Convert_LPP_Delays(NewDelay):
pol_str = None
polswitch = 1
number_of_scans = 1
+fid = get_next_fid(input_path, "d" + file_prefix)
+
if RUNTYPE in ["+/-","+,-", "+", "-"]:
caput(OTF_MODE1,1) # circ + in ID1
caput(OTF_MODE2,2) # circ - in ID2
@@ -114,30 +116,24 @@ caput (TIME_DELAY_SET, START)
caput (TIME_DELAY_START, 1)
if START == 0:
caput (LPP_DELAY, DELAY)
- caput (LPP_FINE_DELAY, FINE_DELAY)
+ caput (LPP_FINE_DELAY, FINEDELAY)
+ wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= 10)
else:
Convert_LPP_Delays(caget(TIME_DELAY_SET, type='d'))
caput (LPP_DELAY, LPP_DELAY_NEW)
caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW)
-wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
+ wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
def Timing(New_Time):
caput (TIME_DELAY_SET, New_Time)
caput (TIME_DELAY_START, 1)
Convert_LPP_Delays(New_Time)
caput (LPP_DELAY, LPP_DELAY_NEW)
- caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW)
- #wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
- try:
- wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
- #otf_start.waitValue(0, (15 + int(TIME*60)) *1000)
- except:
- print "******** DELAY STOP TIMEOUT **********"
- stopPlot()
-
+ caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW)
+ wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout=10+abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
-def Scan(Dtime):
+def Scan(Dtime,ser):
e = energy.read()
if (MCP_1 == 1 or MCP_2 == 1):
aK1=keithley_1a.read()
@@ -158,7 +154,7 @@ def Scan(Dtime):
a1r = []
for i in a1:
a1r.append(i)'''
- a1r = []
+ a1r = [0]*960
while time.time() < t_end:
a1t = MCPArray1.read().tolist()
a1r = [a1r[i]+a1t[i] for i in xrange(len(a1t))]
@@ -192,7 +188,7 @@ def Scan(Dtime):
a2r = []
for j in a2:
a2r.append(j)'''
- a2r = []
+ a2r = [0]*960
while time.time() < t_end:
a2t = MCPArray2.read().tolist()
a2r = [a2r[i]+a2t[i] for i in xrange(len(a2t))]
@@ -222,12 +218,14 @@ def Scan(Dtime):
if Save_array_data == 1:
MCP2.append(a2r)
#v = abs((keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() )))
- s.appendData(Dtime,Cam1a1)
+ ser.appendData(Dtime,Cam1a1)
else:
print "No MCP is selected for acquisition. Select at least one ! ! ! "
def SaveData():
+ global output_file_MCP1, output_file_MCP2
+ output_file_MCP1 = output_path+"MCP_1_"+"d"+file_prefix+"_" + suffix + ".dat"
+ output_file_MCP2 = output_path+"MCP_2_"+"d"+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)
sMCP1out = sep + "Delay_Time" + sep + "rbkenergy" + sep + "pol"+ sep + "Sum1" + sep + "Cam1" + sep + "Keithley1_norm"
@@ -240,7 +238,6 @@ def SaveData():
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
sMCP2out = sep + "Delay_Time" + sep + "rbkenergy"+ sep + "pol" + sep + "Sum1" + sep + "Cam1" + sep + "Keithley1_norm"
@@ -260,7 +257,7 @@ def SaveData():
sep = "\t"
line_sep = "\r\n"
-def _startPlot(type):
+def startPlot():
sep = "\t"
line_sep = "\r\n"
print "Starting plot"
@@ -272,35 +269,43 @@ def _startPlot(type):
else:
polperscan=1
- for Delay_Time in xrange(START, END+0.1, STEP):
+ while Delay_Time <= END:
Timing(Delay_Time)
for en in y:
caput(OTF_ESET,en)
wait_channel(OTF_DONE, 1, type = 'i')
- Scan(Delay_Time)
+ Scan(Delay_Time,s)
if polperscan==2:
switchpol(2,RUNTYPE)
- Scan(Delay_Time)
+ Scan(Delay_Time,s)
switchpol(1,RUNTYPE)
+ Delay_Time += STEP
SaveData()
print "Done Plotting and Saving Data"
-def startPlot(type = 1):
+'''def startPlot(type = 1):
global task
task = fork((_startPlot,(type,)),)
def stopPlot():
global task
- ret = join(task)
+ ret = join(task)'''
for scan_no in range(number_of_scans):
suffix = ("%03d" % fid)
MCP1 = []
MCP2 = []
- startPlot()
print "Running scan " + str(scan_no+1) + " out of " + str(number_of_scans)
- plot_file(output_file, file_prefix+"_" + suffix) #"Scan " + str(scan_no+1))
+ startPlot()
+ if MCP_1 == 1:
+ #output_file_MCP1 = output_path+"MCP_1_"+"d"+file_prefix+"_" + suffix + ".dat"
+ plot_file(output_file_MCP1, file_prefix+"_" + suffix)
+ elif MCP_2 == 1:
+ #output_file_MCP2 = output_path+"MCP_2_"+"d"+file_prefix+"_" + suffix + ".dat"
+ plot_file(output_file_MCP2, file_prefix+"_" + suffix)
+ else:
+ pass
print "Finished scan " + str(scan_no+1) + " out of " + str(number_of_scans)
if RUNTYPE in ["+/-", "LH/LV"]:
if polswitch == 1:
diff --git a/script/EnergyScan.py b/script/EnergyScan.py
index 079544a..ae7705f 100644
--- a/script/EnergyScan.py
+++ b/script/EnergyScan.py
@@ -309,9 +309,9 @@ for scan_no in range(number_of_scans):
time.sleep(5.0)
#TODO: wait for file instead of sleep
#Convert file
- output_file = output_path+"os"+file_prefix+"_" + suffix + ".dat"
+ output_file = output_path + "os" + file_prefix + "_" + suffix + ".dat"
- print("Converting data file: " + output_file);
+ print("Converticonvert_file(input_file, output_file, pol_str)ng 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)
diff --git a/script/backup_Delay_scan.py b/script/backup_Delay_scan.py
new file mode 100644
index 0000000..3119985
--- /dev/null
+++ b/script/backup_Delay_scan.py
@@ -0,0 +1,305 @@
+if str(SET_OFFSETS) == "1":
+ print "Setting offsets"
+ if RUNTYPE in ["+/-", "+" , "-"]:
+ caput(OTF_MODE1,1) # circ + in ID1
+ caput(OTF_MODE2,2) # circ - in ID2
+ elif RUNTYPE in ["LH/LV", "LH", "LV"]:
+ caput(OTF_MODE1,0)
+ caput(OTF_MODE2,0)
+ wait_channel(OTF_DONE, 1, type = 'i')
+ caput(OTF_ALPHA1, 0.0) # LH in ID1
+ caput(OTF_ALPHA2, 90.0) # LV in ID2
+ wait_channel(OTF_DONE, 1, type = 'i')
+ else:
+ raise Exception("Invalid run type: " + RUNTYPE)
+
+ caput(OTF_OFF1,OFFSET1)
+ caput(OTF_OFF2,OFFSET2-40) #detune ID2
+ wait_channel(OTF_DONE, 1, type = 'i')
+ print "Offsets are set"
+ import sys
+ sys.exit(0)
+else:
+ print "Running full script"
+
+'''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")'''
+
+file_prefix = time.strftime("%y%m%d")
+input_path = PATH+file_prefix+"/"
+output_path = input_path
+
+x=ENERGIES
+y = []
+x=x.split(',')
+for i in x:
+ y.append(float(i))
+
+def switchpol(activeID, runtype):
+ global pol_str
+ if activeID == 1:
+ caput(OTF_OFF1,OFFSET1)
+ caput(OTF_OFF2,OFFSET2-40) #detune ID2
+ wait_channel(OTF_DONE, 1, type = 'i')
+ if runtype in ["+/-","+,-", "+"]:
+ pol_str = "circ +"
+ elif runtype in ["LH/LV","LH,LV", "LH"]:
+ pol_str = "Lin. Horizontal"
+ elif activeID == 2:
+ caput(OTF_OFF1,OFFSET1-40) #detune ID1
+ caput(OTF_OFF2,OFFSET2)
+ wait_channel(OTF_DONE, 1, type = 'i')
+ if runtype in ["+/-","+,-", "+"]:
+ pol_str = "circ -"
+ elif runtype in ["LH/LV","LH,LV", "LH"]:
+ pol_str = "Lin. Vertical"
+ else:
+ raise Exception("Invalid parameter")
+
+'''LPP_DELAY_NEW = 0
+LPP_FINE_DELAY_NEW = 0'''
+def Convert_LPP_Delays(NewDelay):
+ global LPP_DELAY_NEW, LPP_FINE_DELAY_NEW
+ LPP_DELAY_NEW = math.trunc(((NewDelay*100.0+DELAY*BucketSize.read()*100+FINEDELAY)/100.0)/BucketSize.read())
+ LPP_FINE_DELAY_NEW = math.trunc(NewDelay*100.0+DELAY*BucketSize.read()*100+FINEDELAY-LPP_DELAY_NEW*BucketSize.read()*100.0)
+
+pol_str = None
+polswitch = 1
+number_of_scans = 1
+if RUNTYPE in ["+/-","+,-", "+", "-"]:
+ caput(OTF_MODE1,1) # circ + in ID1
+ caput(OTF_MODE2,2) # circ - in ID2
+ wait_channel(OTF_DONE, 1, type = 'i')
+ if RUNTYPE == "+/-":
+ number_of_scans = 2 * ROUNDS
+ else:
+ number_of_scans = ROUNDS
+elif RUNTYPE in ["LH/LV","LH,LV", "LH", "LV"]:
+ caput(OTF_MODE1,0)
+ caput(OTF_MODE2,0)
+ wait_channel(OTF_DONE, 1, type = 'i')
+ caput(OTF_ALPHA1, 0.0) # LH in ID1
+ caput(OTF_ALPHA2, 90.0) # LV in ID2
+ wait_channel(OTF_DONE, 1, type = 'i')
+ if RUNTYPE == "LH/LV":
+ number_of_scans = 2 * ROUNDS
+ else:
+ number_of_scans = ROUNDS
+else:
+ raise Exception("Invalid run type: " + RUNTYPE)
+
+if RUNTYPE in ["-", "LV"]:
+ switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV
+ polswitch = 0
+elif RUNTYPE in ["+/-","+,-", "+", "LH/LV","LH,LV", "LH"]:
+ switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
+time.sleep(1.0)
+
+caput (TIME_DELAY_SET, START)
+caput (TIME_DELAY_START, 1)
+if START == 0:
+ caput (LPP_DELAY, DELAY)
+ caput (LPP_FINE_DELAY, FINE_DELAY)
+else:
+ Convert_LPP_Delays(caget(TIME_DELAY_SET, type='d'))
+ caput (LPP_DELAY, LPP_DELAY_NEW)
+ caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW)
+wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
+
+def Timing(New_Time):
+ caput (TIME_DELAY_SET, New_Time)
+ caput (TIME_DELAY_START, 1)
+ Convert_LPP_Delays(New_Time)
+ caput (LPP_DELAY, LPP_DELAY_NEW)
+ caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW)
+ #wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
+ try:
+ wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
+ #otf_start.waitValue(0, (15 + int(TIME*60)) *1000)
+ except:
+ print "******** DELAY STOP TIMEOUT **********"
+ stopPlot()
+
+
+
+def Scan(Dtime):
+ e = energy.read()
+ if (MCP_1 == 1 or MCP_2 == 1):
+ aK1=keithley_1a.read()
+ aP=FillingPattern.read()
+ aPr = []
+ for z in aP:
+ aPr.append(z)
+ SumaP=0
+ CamaP=0
+ for z in xrange(0,480):
+ SumaP = SumaP + aPr[z]
+ for z in xrange(460,470):
+ CamaP = CamaP + aPr[z]
+ aK1norm = aK1 * CamaP / SumaP
+ t_end = time.time()+ACQTIME
+ if MCP_1 == 1:
+ '''a1=MCPArray1.read()
+ a1r = []
+ for i in a1:
+ a1r.append(i)'''
+ a1r = []
+ while time.time() < t_end:
+ a1t = MCPArray1.read().tolist()
+ a1r = [a1r[i]+a1t[i] for i in xrange(len(a1t))]
+ time.sleep(SamplingTime.read()*0.001)
+ Sum1a1 = 0
+ Cam1a1 = 0
+ Sum2a1 = 0
+ Cam2a1 = 0
+ MCP1.append(line_sep)
+ MCP1.append(Dtime)
+ MCP1.append(e)
+ MCP1.append(pol_str)
+ 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)
+ MCP1.append(aK1norm)
+ if NrCounters.read() > 460:
+ for i in xrange(480,960):
+ Sum2a1 = Sum2a1 + a1r[i]
+ for i in xrange(Cam_start+480,Cam_end+481):
+ Cam2a1 = Cam2a1 + a1r[i]
+ MCP1.append(Sum2a1)
+ MCP1.append(Cam2a1)
+ if Save_array_data == 1:
+ MCP1.append(a1r)
+ if MCP_2 == 1:
+ '''a2=MCPArray2.read()
+ a2r = []
+ for j in a2:
+ a2r.append(j)'''
+ a2r = []
+ while time.time() < t_end:
+ a2t = MCPArray2.read().tolist()
+ a2r = [a2r[i]+a2t[i] for i in xrange(len(a2t))]
+ time.sleep(SamplingTime.read()*0.001)
+ Sum1a2 = 0
+ Cam1a2 = 0
+ Sum2a2 = 0
+ Cam2a2 = 0
+ MCP2.append(line_sep)
+ MCP1.append(Dtime)
+ MCP2.append(e)
+ MCP2.append(pol_str)
+ 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)
+ MCP2.append(aK1norm)
+ if NrCounters.read() > 460:
+ for j in xrange(480,960):
+ Sum2a2 = Sum2a2 + a2r[j]
+ for j in xrange(Cam_start+480,Cam_end+481):
+ Cam2a2 = Cam2a2 + a2r[j]
+ MCP2.append(Sum2a2)
+ MCP2.append(Cam2a2)
+ if Save_array_data == 1:
+ MCP2.append(a2r)
+ #v = abs((keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() )))
+ s.appendData(Dtime,Cam1a1)
+ else:
+ print "No MCP is selected for acquisition. Select at least one ! ! ! "
+def SaveData():
+ 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)
+ sMCP1out = sep + "Delay_Time" + sep + "rbkenergy" + sep + "pol"+ sep + "Sum1" + sep + "Cam1" + sep + "Keithley1_norm"
+ 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
+ sMCP2out = sep + "Delay_Time" + sep + "rbkenergy"+ sep + "pol" + sep + "Sum1" + sep + "Cam1" + sep + "Keithley1_norm"
+ 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"
+
+###############################################################################
+# Scanning
+###############################################################################
+
+sep = "\t"
+line_sep = "\r\n"
+
+def _startPlot(type):
+ sep = "\t"
+ line_sep = "\r\n"
+ print "Starting plot"
+ p = plot(None,name="Delay")[0]
+ s = p.getSeries(0)
+ Delay_Time = START
+ if RUNTYPE in ["+,-", "LH,LV"]:
+ polperscan=2
+ else:
+ polperscan=1
+
+ for Delay_Time in xrange(START, END+0.1, STEP):
+ Timing(Delay_Time)
+ for en in y:
+ caput(OTF_ESET,en)
+ wait_channel(OTF_DONE, 1, type = 'i')
+ Scan(Delay_Time)
+ if polperscan==2:
+ switchpol(2,RUNTYPE)
+ Scan(Delay_Time)
+ switchpol(1,RUNTYPE)
+ SaveData()
+ print "Done Plotting and Saving Data"
+
+def startPlot(type = 1):
+ global task
+ task = fork((_startPlot,(type,)),)
+
+def stopPlot():
+ global task
+ ret = join(task)
+
+
+for scan_no in range(number_of_scans):
+ suffix = ("%03d" % fid)
+ MCP1 = []
+ MCP2 = []
+ startPlot()
+ print "Running scan " + str(scan_no+1) + " out of " + str(number_of_scans)
+ 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
+ polswitch = 0
+ else:
+ polswitch = 1
+ switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
+ else:
+ print "running in one polarization mode or in +,- mode"
+ fid = fid + 1
+
+print "Finished Delay scan"
\ No newline at end of file