Startup
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
import os
|
||||
import traceback
|
||||
|
||||
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+"/"
|
||||
|
||||
|
||||
#Parameters
|
||||
"""
|
||||
E1 = 680
|
||||
E2 = 750
|
||||
TIME = 2 #min
|
||||
DELAY = 10.0 #s
|
||||
OFFSET1 = 1.0 #eV
|
||||
OFFSET2 = -1.0 #eV
|
||||
PREFIX = 'Data'
|
||||
RUNTYPE = "+/-"
|
||||
ROUNDS = 1
|
||||
PLOT_TYPE = 1
|
||||
"""
|
||||
print "\nStarting energy scan - Parameters: ",
|
||||
print E1,E2,TIME,DELAY,OFFSET1,OFFSET2,RUNTYPE,ALPHA1,ALPHA2
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Plotting
|
||||
###############################################################################
|
||||
|
||||
running = False
|
||||
quit_plot = False
|
||||
|
||||
def _startPlot(type):
|
||||
global running, quit_plot
|
||||
print "Starting plot: type " + str(type)
|
||||
quit_plot = False
|
||||
running = True
|
||||
p = plot(None,name="")[0]
|
||||
p.addSeries(LinePlotSeries("Energy"))
|
||||
s= p.getSeries(1)
|
||||
cur = 0
|
||||
while running:
|
||||
try:
|
||||
if otf_start.read() == 0:
|
||||
break
|
||||
e = energy.read()
|
||||
if (abs(e-cur)) > 0.1:
|
||||
v = keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() )
|
||||
p.getSeries(1).appendData(e,v)
|
||||
cur = e
|
||||
time.sleep(0.2)
|
||||
except:
|
||||
pass
|
||||
quit_plot = True
|
||||
print "Done Plotting"
|
||||
|
||||
|
||||
def startPlot(type = 1):
|
||||
ret = fork((_startPlot,(type,)),)
|
||||
|
||||
def stopPlot():
|
||||
global running, quit_plot
|
||||
running = False
|
||||
while quit_plot==False:
|
||||
time.sleep(0.001)
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
def switchpol(activeID, runtype):
|
||||
global pol_str
|
||||
if activeID == 1:
|
||||
caput(OTF_OFF1,OFFSET1)
|
||||
caput(OTF_OFF2,OFFSET2-40) #detune ID2
|
||||
if runtype in ["+/-", "+"]:
|
||||
pol_str = "circ +"
|
||||
elif runtype in ["LH/LV", "LH"]:
|
||||
pol_str = "Lin. Horizontal"
|
||||
elif activeID == 2:
|
||||
caput(OTF_OFF1,OFFSET1-40) #detune ID1
|
||||
caput(OTF_OFF2,OFFSET2)
|
||||
if runtype in ["+/-", "-"]:
|
||||
pol_str = "circ -"
|
||||
elif runtype in ["LH/LV", "LV"]:
|
||||
pol_str = "Lin. Vertical"
|
||||
else:
|
||||
raise Exception("Invalid parameter")
|
||||
|
||||
|
||||
pol_str = None
|
||||
polswitch = 1
|
||||
|
||||
fid = get_next_fid(input_path, "o" + file_prefix)
|
||||
|
||||
|
||||
|
||||
#Prepare scan
|
||||
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"]:
|
||||
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"]:
|
||||
switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
|
||||
time.sleep(1.0)
|
||||
|
||||
wait_channel(OTF_DONE, 1, type = 'i')
|
||||
|
||||
open_vg13()
|
||||
|
||||
for scan_no in range(number_of_scans):
|
||||
suffix = ("%03d" % fid)
|
||||
input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat"
|
||||
|
||||
caput(OTF_E1, E1)
|
||||
caput(OTF_E2, E2)
|
||||
caput(OTF_TIME, TIME)
|
||||
caput(OTF_FTS,file_prefix)
|
||||
caput(OTF_FID,fid)
|
||||
time.sleep(2.0)
|
||||
caput(OTF_ESET, E1)
|
||||
wait_channel(OTF_DONE, 1, type = 'i') #???
|
||||
time.sleep(DELAY)
|
||||
time.sleep(2.0)
|
||||
|
||||
startPlot(PLOT_TYPE)
|
||||
#Start the OTF scan
|
||||
caput(OTF_START, 'GO')
|
||||
|
||||
#Wait until scan is done
|
||||
wait_channel(OTF_START, 'STOP', type = 's')
|
||||
time.sleep(3.0)
|
||||
stopPlot()
|
||||
|
||||
#Convert file
|
||||
output_file = output_path+"os"+file_prefix+"_" + suffix + ".dat"
|
||||
|
||||
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))
|
||||
|
||||
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:
|
||||
raise Exception("running in one polarization mode, no switching")
|
||||
|
||||
time.sleep(3.0)
|
||||
fid = fid + 1
|
||||
|
||||
close_vg13()
|
||||
|
||||
print "Finished Energy scan"
|
||||
|
||||
print("Success")
|
||||
@@ -0,0 +1,27 @@
|
||||
###################################################################################################
|
||||
# Deployment specific global definitions - executed after startup.py
|
||||
###################################################################################################
|
||||
|
||||
|
||||
OTF_START = "X11MA-OTF:GO"
|
||||
OTF_E1 = "X11MA-OTF:E1"
|
||||
OTF_E2 = "X11MA-OTF:E2"
|
||||
OTF_TIME = "X11MA-OTF:TIME"
|
||||
OTF_FID = "X11MA-OTF:FID"
|
||||
OTF_FTS = "X11MA-OTF:FTSTAMP"
|
||||
OTF_FILE = "X11MA-OTF:FNAME"
|
||||
OTF_MODE1 = "X11MA-ID1:MODE"
|
||||
OTF_MODE2 = "X11MA-ID2:MODE"
|
||||
OTF_ALPHA1 = "X11MA-ID1:ALPHA"
|
||||
OTF_ALPHA2 = "X11MA-ID2:ALPHA"
|
||||
OTF_OFF1 = "X11MA-ID2:ENERGY-OFFS"
|
||||
OTF_OFF2 = "X11MA-ID2:ENERGY-OFFS"
|
||||
OTF_OPT = "X11PHS-E:OPT"
|
||||
OTF_ERBK = "X11MA-PGM:CERBK"
|
||||
OTF_DONE = "X11MA-PHS:ALL-DONE"
|
||||
OTF_ESET = "X11MA-PHS:E_SP"
|
||||
VG10 = "X11MA-EPS-VG10:SET"
|
||||
|
||||
|
||||
"""
|
||||
"""X11PHS-E:OPT
|
||||
Reference in New Issue
Block a user