92 lines
2.0 KiB
Python
92 lines
2.0 KiB
Python
#Script imported from: MgE_plus.xml
|
|
|
|
#Parameters
|
|
"""
|
|
E1 = 710
|
|
E2 = 720
|
|
TIME = 1 #min
|
|
DELAY = 10.0 #s
|
|
MODE = 'CIRC +'
|
|
OFFSET = -9.0
|
|
FOLDER = '2015_04/20150417'
|
|
FILE = 'Fe_plus'
|
|
ALPHA=0
|
|
"""
|
|
|
|
|
|
print "\nStarting energy scan - Parameters: ",
|
|
print E1,E2,TIME,DELAY,MODE ,OFFSET ,FOLDER ,FILE ,ALPHA
|
|
|
|
start = time.localtime()
|
|
|
|
folder = os.path.expanduser("~/Data1/") + FOLDER + "/";
|
|
def getNewestFile():
|
|
global folder
|
|
import glob
|
|
try:
|
|
return max(glob.iglob(folder+'/*.txt'), key=os.path.getctime)
|
|
except:
|
|
return None
|
|
newest = getNewestFile()
|
|
|
|
#Pre-actions
|
|
wait_beam()
|
|
|
|
pol_mode.write(MODE) #caput('X07MA-ID:MODE', MODE) #TODO: CAPUT
|
|
time.sleep(1.0) #TODO: Needed?
|
|
if MODE == 'LINEAR':
|
|
pol_angle.write(ALPHA) #TODO: CAPUT
|
|
pol_done.waitValue("DONE") #TODO: NEEDED?
|
|
pol_offset.write(OFFSET) #TODO: CAPUT
|
|
pol_done.waitValue("DONE")
|
|
|
|
caput('E1', E1)
|
|
caput('E2', E2)
|
|
caput('TIME', TIME)
|
|
caput('FOLDER', FOLDER)
|
|
set_energy (E1)
|
|
#caputq('X07MA-PHS-E:GO.A', E1)
|
|
#wait_channel('X07MA-PHS:alldone', '1', type = 's')
|
|
#time.sleep(0.5)
|
|
caput('FILE', FILE)
|
|
time.sleep(0.1)
|
|
|
|
open_valve()
|
|
open_valve(0.0) #TODO: WHY WRITING AGAIN???
|
|
#caput('X07MA-OP-VG13:WT_SET', 'Try open')
|
|
#time.sleep(5.0)
|
|
#caput('X07MA-OP-VG13:WT_SET', 'Try open')
|
|
|
|
time.sleep(DELAY)
|
|
|
|
caput('START', '1')
|
|
|
|
#Post-actions
|
|
wait_channel('START', 'STOP', type = 's')
|
|
|
|
time.sleep(2.0)
|
|
print "Finished Energy scan"
|
|
|
|
|
|
#File convertion
|
|
newName = folder + time.strftime("%Y%m%d_%H%M_", start) + FILE + "_0000.txt";
|
|
#name = caget("MSG").split(' ')[0]
|
|
name = getNewestFile()
|
|
|
|
if name == newest:
|
|
raise Exception("Data file not created")
|
|
|
|
if not os.path.isfile(name):
|
|
raise Exception("Data file not found: " + name)
|
|
|
|
#cmd = "/sls/X07MA/data/x07maop/bin/modify_otf.pl " + name + " " + newName;
|
|
#print("Converting data file: " + cmd);
|
|
#import os
|
|
#os.system(cmd)
|
|
|
|
convert_file(name, newName)
|
|
|
|
print("Success")
|
|
|
|
|