This commit is contained in:
@@ -102,5 +102,8 @@ def dummy_trigger_scienta():
|
||||
scienta.setIterations(iterations)
|
||||
print "Done"
|
||||
|
||||
def clear_output():
|
||||
App.getInstance().mainFrame.clearScanDisplays()
|
||||
def clear_scan_output():
|
||||
App.getInstance().mainFrame.clearScanDisplays(None)
|
||||
|
||||
def start_scan_output(scan):
|
||||
App.getInstance().mainFrame.setScanDisplays(scan, None)
|
||||
|
||||
@@ -4,7 +4,7 @@ if get_exec_pars().debug:
|
||||
print "Setting debug parameters"
|
||||
NAME = None
|
||||
FILE = None
|
||||
PASSES = 1
|
||||
PASSES = 2
|
||||
R1 = """{
|
||||
"scienta.acquisitionMode" : "Swept",
|
||||
"scienta.elementSet" : "HiPPHAXPES",
|
||||
@@ -17,7 +17,7 @@ if get_exec_pars().debug:
|
||||
"scienta.highEnergy" : 407.0,
|
||||
"scienta.slices" : 1.0,
|
||||
"scienta.stepSize" : 0.25,
|
||||
"scienta.stepTime" : 1.0,
|
||||
"scienta.stepTime" : 0.08,
|
||||
"scienta.iterations" : 1.0
|
||||
} """
|
||||
|
||||
@@ -30,14 +30,18 @@ if FILE:
|
||||
NAME , REGIONS, PASSES= cfg[0][0][0], cfg[1], cfg[2]
|
||||
print "FILE: ", FILE
|
||||
print "NAME: ", NAME
|
||||
#print "REGIONS: ", REGIONS
|
||||
print "REGIONS: ", [name for (name, val) in REGIONS]
|
||||
print "PASSES: ", PASSES
|
||||
|
||||
DUMMY_TRIGGER = False
|
||||
CURRENT_REGION = ""
|
||||
CURRENT_INDEX = -1
|
||||
PLOT_TYPES={"spectrum":1, "energy":1}
|
||||
SEQUENTIAL=False
|
||||
DEBUG=False
|
||||
|
||||
parallel = not (SEQUENTIAL or (PASSES<=1) or (len(REGIONS)<=1))
|
||||
|
||||
set_exec_pars(enabled_plots=["spectrum",], plot_types=PLOT_TYPES)
|
||||
|
||||
for r in REGIONS:
|
||||
name=r[0]
|
||||
@@ -77,34 +81,58 @@ def set_region_index(index):
|
||||
pars = json.loads(r[1])
|
||||
CURRENT_REGION = name
|
||||
CURRENT_INDEX = CURRENT_INDEX+1
|
||||
print "Region: ", name
|
||||
print "Pars: ", pars
|
||||
if DEBUG: print "Setting Region: ", name, " ", index
|
||||
apply_pars(pars)
|
||||
|
||||
def before_read(position, scan):
|
||||
#set_region_index(scan.getRecordIndexInPass()-1)
|
||||
#time.sleep(0.5)
|
||||
trigger_scienta()
|
||||
pass
|
||||
if parallel:
|
||||
start_scan_output(scan)
|
||||
|
||||
clear_output()
|
||||
|
||||
|
||||
|
||||
|
||||
scanning=False
|
||||
def scan(region):
|
||||
if DEBUG: print "Starting scan region ", region
|
||||
name=REGIONS[region][0]
|
||||
def before_pass(pass_num):
|
||||
global scanning
|
||||
if DEBUG: print "Waiting for pass: " , pass_num, " on region: ", region
|
||||
while (CURRENT_INDEX != (region-1)) or scanning:
|
||||
time.sleep(0.1)
|
||||
scanning = True
|
||||
if DEBUG: print "Starting pass: " , pass_num, " on region: ", region
|
||||
set_region_index(region)
|
||||
|
||||
def after_pass(pass_num):
|
||||
global scanning, CURRENT_INDEX
|
||||
if DEBUG: print "Finished pass: " , pass_num, " on region: ", region
|
||||
if CURRENT_INDEX>=(len(REGIONS)-1):
|
||||
CURRENT_INDEX=-1
|
||||
scanning = False
|
||||
|
||||
tscan(sensors, 1, 0.1, tag=name, passes=PASSES, #title=name, \
|
||||
before_read=before_read, after_read=after_readout, \
|
||||
before_pass = before_pass, after_pass=after_pass, \
|
||||
name=NAME, lazy=True)
|
||||
|
||||
clear_scan_output()
|
||||
|
||||
try:
|
||||
for i in range(len(REGIONS)):
|
||||
set_region_index(i)
|
||||
#tscan(sensors, len(REGIONS), 0.1, \
|
||||
#passes=PASSES, split=SPLIT_PASSES, \
|
||||
#before_read=before_read, after_read=after_readout, name = NAME)
|
||||
if DUMMY_TRIGGER:
|
||||
dummy_trigger_scienta()
|
||||
|
||||
tscan(sensors, PASSES, 0.1, tag=CURRENT_REGION, \
|
||||
before_read=before_read, after_read=after_readout, \
|
||||
name=NAME, lazy=not DUMMY_TRIGGER, plot_types=PLOT_TYPES)
|
||||
if not parallel:
|
||||
for i in range(len(REGIONS)):
|
||||
set_region_index(i)
|
||||
tscan(sensors, PASSES, 0.1, tag=CURRENT_REGION, \
|
||||
before_read=before_read, after_read=after_readout, \
|
||||
name=NAME, lazy=True )
|
||||
else:
|
||||
scans = [[scan,[i,]] for i in range(len(REGIONS))]
|
||||
parallelize(*scans)
|
||||
|
||||
finally:
|
||||
print "Finalizing"
|
||||
scienta.zeroSupplies()
|
||||
print "Quit script"
|
||||
if DEBUG: print "Quit script"
|
||||
|
||||
|
||||
|
||||
110
script/templates/XPS_seq.py
Normal file
110
script/templates/XPS_seq.py
Normal file
@@ -0,0 +1,110 @@
|
||||
import json
|
||||
|
||||
if get_exec_pars().debug:
|
||||
print "Setting debug parameters"
|
||||
NAME = None
|
||||
FILE = None
|
||||
PASSES = 1
|
||||
R1 = """{
|
||||
"scienta.acquisitionMode" : "Swept",
|
||||
"scienta.elementSet" : "HiPPHAXPES",
|
||||
"scienta.lensMode" : "T_HiPPHAXPES",
|
||||
"scienta.detectorMode" : "ADC",
|
||||
"scienta.energyMode" : "Kinetic",
|
||||
"scienta.passEnergy" : 2,
|
||||
"scienta.lowEnergy" : 387.0,
|
||||
"scienta.centerEnergy" : 397.0,
|
||||
"scienta.highEnergy" : 407.0,
|
||||
"scienta.slices" : 1.0,
|
||||
"scienta.stepSize" : 0.25,
|
||||
"scienta.stepTime" : 1.0,
|
||||
"scienta.iterations" : 1.0
|
||||
} """
|
||||
|
||||
REGIONS = [["R1", R1]]
|
||||
|
||||
if FILE:
|
||||
FILE = get_context().setup.expandPath("{home}/parameters/" + FILE)
|
||||
with open(FILE) as json_file:
|
||||
cfg = json.load(json_file)
|
||||
NAME , REGIONS, PASSES= cfg[0][0][0], cfg[1], cfg[2]
|
||||
print "FILE: ", FILE
|
||||
print "NAME: ", NAME
|
||||
#print "REGIONS: ", REGIONS
|
||||
print "PASSES: ", PASSES
|
||||
|
||||
DUMMY_TRIGGER = False
|
||||
CURRENT_REGION = ""
|
||||
CURRENT_INDEX = -1
|
||||
PLOT_TYPES={"spectrum":1, "energy":1}
|
||||
|
||||
|
||||
for r in REGIONS:
|
||||
name=r[0]
|
||||
pars = json.loads(r[1])
|
||||
for k,v in pars.items():
|
||||
if (v is None) or (v== float("NaN")):
|
||||
raise Exception ("Invalid value in region: ", r, " parameter: ", k)
|
||||
|
||||
set_device_alias(scienta.getSpectrum(), "spectrum")
|
||||
set_device_alias(scienta.getSpectrumScale(), "energy")
|
||||
set_device_alias(scienta.getDataMatrix(), "image")
|
||||
set_device_alias(scienta.stats[0], "sum")
|
||||
|
||||
sensors=[i0, scienta.stats[0], scienta.getSpectrum(), scienta.getSpectrumScale()] #), scienta.getDataMatrix()]
|
||||
|
||||
|
||||
def apply_pars(pars):
|
||||
scienta.elementSet = scienta.elementSet.valueOf(pars["scienta.elementSet"])
|
||||
scienta.lensMode = scienta.lensMode.valueOf(pars["scienta.lensMode"])
|
||||
scienta.detectorMode = scienta.detectorMode.valueOf(pars["scienta.detectorMode"])
|
||||
scienta.energyMode = scienta.energyMode.valueOf(pars["scienta.energyMode"])
|
||||
scienta.acquisitionMode = scienta.acquisitionMode.valueOf(pars["scienta.acquisitionMode"])
|
||||
scienta.passEnergy = pars["scienta.passEnergy"]
|
||||
scienta.getLowEnergy().writeAsync(pars["scienta.lowEnergy"])
|
||||
scienta.getCenterEnergy().writeAsync(pars["scienta.centerEnergy"])
|
||||
scienta.getHighEnergy().writeAsync(pars["scienta.highEnergy"])
|
||||
scienta.getSlices().writeAsync(pars["scienta.slices"])
|
||||
scienta.getStepSize().writeAsync(pars["scienta.stepSize"])
|
||||
scienta.getStepTime().writeAsync(pars["scienta.stepTime"])
|
||||
scienta.setIterations(int(pars["scienta.iterations"]))
|
||||
|
||||
|
||||
def set_region_index(index):
|
||||
global REGIONS, CURRENT_REGION, CURRENT_INDEX
|
||||
r=REGIONS[index]
|
||||
name=r[0]
|
||||
pars = json.loads(r[1])
|
||||
CURRENT_REGION = name
|
||||
CURRENT_INDEX = CURRENT_INDEX+1
|
||||
print "Region: ", name
|
||||
print "Pars: ", pars
|
||||
apply_pars(pars)
|
||||
|
||||
def before_read(position, scan):
|
||||
#set_region_index(scan.getRecordIndexInPass()-1)
|
||||
#time.sleep(0.5)
|
||||
trigger_scienta()
|
||||
pass
|
||||
|
||||
clear_output()
|
||||
|
||||
try:
|
||||
for i in range(len(REGIONS)):
|
||||
set_region_index(i)
|
||||
#tscan(sensors, len(REGIONS), 0.1, \
|
||||
#passes=PASSES, split=SPLIT_PASSES, \
|
||||
#before_read=before_read, after_read=after_readout, name = NAME)
|
||||
if DUMMY_TRIGGER:
|
||||
dummy_trigger_scienta()
|
||||
|
||||
tscan(sensors, PASSES, 0.1, tag=CURRENT_REGION, \
|
||||
before_read=before_read, after_read=after_readout, \
|
||||
name=NAME, lazy=not DUMMY_TRIGGER, plot_types=PLOT_TYPES)
|
||||
|
||||
finally:
|
||||
print "Finalizing"
|
||||
scienta.zeroSupplies()
|
||||
print "Quit script"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user