Files
x11ma/script/local.py
2016-03-17 11:37:39 +01:00

135 lines
4.1 KiB
Python

###################################################################################################
# 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-ID1: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_SET = "X11MA-EPS-VG10:SET"
VG10_GET = "X11MA-OP-VG10:OPEN"
VG11_SET = "X11MA-EPS-VG11:SET"
VG11_GET = "X11MA-OP-VG11:OPEN"
VG12_SET = "X11MA-EPS-VG12:SET"
VG12_GET = "X11MA-OP-VG12:OPEN"
VG13_SET = "X11MA-EPS-VG13:SET"
VG13_GET = "X11MA-OP-VG13:OPEN"
LPP_DELAY = "X11MA-ES2-4CHT:SET2-DELAY"
LPP_FINE_DELAY = "X11MA-ES2-4CHT:SET2-FINE"
TIME_DELAY_SET = "X11MA-ES2:Theta-New.A"
TIME_DELAY_VAL = "X11MA-ES2:Theta-Cur.VAL"
TIME_DELAY_START = "X11MA-ES2:SCAN-START"
TIME_DELAY_COMPLETE = "X11MA-ES2-scan1.SMSG"
FST = time.strftime("%y%m%d")
FID = 0
"""
X11PHS-E:OPT
"""
def get_next_fid(folder, prefix):
try:
import glob
files = glob.glob(folder + prefix + '*_*.dat')
last = max(files)
index = int (last[last.rfind('_')+1 : last.rfind('.')]) + 1
return index
except:
return 0
def wait_channel(name, value, timeout =None, type='s'):
print "Waiting " + str(name) + " = " + str(value)
cawait(name, value, timeout = timeout, type=type)
print "Done"
def convert_file(input_file_name, output_file_name, field = 0, pol = 0, keithley_3 = False):
sep = "\t"
line_sep = "\r\n"
with open(input_file_name) as inp:
lines = inp.readlines()
with open(output_file_name, "wb") as out:
out.write("Energy" + sep + "rbkenergy" + sep + "Mag" + sep + "Pol" + sep + "Io" + sep + "TEY" + sep + "Norm" + line_sep)
s = sep + " " #File format has a space before numeric values
for line in lines[1:]:
line = line.strip()
if line=="": break
try:
(Ecrbk,CADC1, CADC2, NORM, CADC3, CADC4, MCurr, cffrbk, ID1Erbk, ID2Erbk, vTime) = line.split(" ")
#out.write(Ecrbk + sep + Ecrbk + sep + str(field) + sep + str(pol) + sep + CADC1 + sep + CADC2 + sep + (CADC3 if keithley_3 else NORM) + line_sep)
out.write(" " + Ecrbk + s + Ecrbk + s + str(field) + s + str(pol) + s + CADC1 + s + CADC2 + s + (CADC3 if keithley_3 else NORM) + line_sep)
except:
traceback.print_exc()
def open_vg10():
if caget (VG10_GET,'i') != 1:
caput(VG10_SET, 0)
time.sleep(0.1)
caput(VG10_SET, 1)
def close_vg10():
if caget (VG10_GET,'i') == 1:
caput(VG10_SET, 0)
time.sleep(0.1)
caput(VG10_SET, 1)
def open_vg11():
if caget (VG11_GET,'i') != 1:
caput(VG11_SET, 0)
time.sleep(0.1)
caput(VG11_SET, 1)
def close_vg11():
if caget (VG11_GET,'i') == 1:
caput(VG11_SET, 0)
time.sleep(0.1)
caput(VG11_SET, 1)
def open_vg12():
if caget (VG12_GET,'i') != 1:
caput(VG12_SET, 0)
time.sleep(0.1)
caput(VG12_SET, 1)
def close_vg12():
if caget (VG12_GET,'i') == 1:
caput(VG12_SET, 0)
time.sleep(0.1)
caput(VG12_SET, 1)
def open_vg13():
if caget (VG13_GET,'i') != 1:
caput(VG13_SET, 0)
time.sleep(0.1)
caput(VG13_SET, 1)
def close_vg13():
if caget (VG13_GET,'i') == 1:
caput(VG13_SET, 0)
time.sleep(0.1)
caput(VG13_SET, 1)
def plot_file(file, ctxt = None):
"""
"""
sep = "\t"
table = Table.load(file, sep, '#')
plots = plot(table, title = ctxt)