Files
x11ma/script/local.py
2015-12-02 18:23:59 +01:00

89 lines
2.8 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 = "X11MA-EPS-VG10:SET"
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, type):
print "Waiting " + str(name) + " = " + str(value)
cawait(name, value, 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 ("X11MA-OP-VG10:OPEN",'i') != 1:
caput(VG10, 0)
time.sleep(0.1)
caput(VG10, 1)
def close_vg10():
if caget ("X11MA-OP-VG10:OPEN",'i') == 1:
caput(VG10, 0)
time.sleep(0.1)
caput(VG10, 1)
def plot_file(file, ctxt = None):
"""
"""
sep = "\t"
table = Table.load(file, sep, '#')
plots = plot(table, context = ctxt)