111 lines
3.6 KiB
Python
111 lines
3.6 KiB
Python
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_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)
|
|
|
|
finally:
|
|
print "Finalizing"
|
|
scienta.zeroSupplies()
|
|
print "Quit script"
|
|
|
|
|