Closedown

This commit is contained in:
gac-x03da
2019-07-15 14:49:07 +02:00
parent 0c702b235e
commit 5e17d2a4ac
26 changed files with 0 additions and 3783 deletions

View File

@@ -1,57 +0,0 @@
"""
Continuous 2D Manipulator scan
set manipulator scan parameters below.
set analyser parameters separately!
"""
import math
import math
# adjust the following parameters
DISTANCE = 2.0
ANGLE = -30.0 # move sample across beam
#ANGLE = +60.0 # move sample along beam
# minimum speed 0.01, maximum speed 0.125 mm/s
SPEED = 0.1
LATENCY = 0.0
ENDSCAN = False
# do not edit below
DISTANCE_X = DISTANCE * math.cos(math.radians(ANGLE))
DISTANCE_Y = DISTANCE * math.sin(math.radians(ANGLE))
SPEED_X = SPEED * math.cos(math.radians(ANGLE))
SPEED_Y = SPEED * math.sin(math.radians(ANGLE))
MOTORS = (ManipulatorX, ManipulatorY)
SENSORS = (Counts, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution)
#SENSORS = (Counts, Scienta.spectrum, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution)
#SENSORS = (Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution)
STARTPOS = (-DISTANCE_X / 2.0, -DISTANCE_Y / 2.0)
ENDPOS = (DISTANCE_X / 2.0, DISTANCE_Y / 2.0)
RELATIVE = True
adjust_sensors()
set_adc_averaging()
# time per scienta acquisition in seconds
time1 = time.time()
trig_scienta()
time2 = time.time()
scienta_time = (time2 - time1)
print "scienta time: ", scienta_time
# time for one Y scan in seconds
fly_time = DISTANCE / SPEED
STEPS = int(fly_time / scienta_time) + 1
print "fly time: ", fly_time
try:
cscan(MOTORS, SENSORS, STARTPOS, ENDPOS, STEPS, time=fly_time, before_read=before_readout, after_read = after_readout, check_positions = False)
finally:
if ENDSCAN:
after_scan()

View File

@@ -1,164 +0,0 @@
"""
Arguments:
"""
LATENCY = 0.0
PHI_RANGE = (0, 160.0) # (tuple (min, max))
THETA_RANGE = (-9, 81) # (tuple (min, max))
STEPS = (40.0, 1.0) # (tuple (phi, theta))
ZIGZAG = True
REGION1 = {'name': 'Pt4f', 'elo': 1016, 'ehi': 1028, 'estep': 0.2, 'epass': 100, 'tstep': 0.05, 'iter': 1, 'cis': True, 'slit': 40}
REGION2 = {'name': 'B1s', 'elo': 901, 'ehi': 909, 'estep': 0.2, 'epass': 100, 'tstep': 0.5, 'iter': 1, 'cis': True, 'slit': 210}
REGION3 = {'name': 'C1s', 'elo': 808, 'ehi': 813, 'estep': 0.2, 'epass': 100, 'tstep': 0.5, 'iter': 1, 'cis': True, 'slit': 210}
REGION4 = {'name': 'N1s', 'elo': 694, 'ehi': 701, 'estep': 0.2, 'epass': 100, 'tstep': 0.5, 'iter': 1, 'cis': True, 'slit': 210}
REGIONS = [REGION1, REGION2, REGION3, REGION4]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
#Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
self.slit_dataset_name = path + "ExitSlit"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
create_dataset(self.slit_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}".format(self.scan_index)
elo = self.region['elo']
ehi = self.region['ehi']
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
ExitSlit.write(self.region['slit'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
append_dataset(self.slit_dataset_name, self.region['slit'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Acquiring spectrum {elo}-{ehi} eV.".format(elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(regions, latency):
global SENSORS, PHI_RANGE, THETA_RANGE
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
ascan((ManipulatorPhi, ManipulatorTheta), SENSORS, (PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS, LATENCY, False, zigzag = ZIGZAG, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
try:
setup_live_plots(REGIONS)
task = fork(update_live_plots)
do_scan(REGIONS, LATENCY)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,169 +0,0 @@
"""
Arguments:
"""
LATENCY = 0.0
PHI_RANGE = (-160.0, 160.0) # (tuple (min, max))
THETA_RANGE = (-9.0, 81.0) # (tuple (min, max))
STEPS = (40.0, 1.0) # (tuple (phi, theta))
ZIGZAG = True
REGION1 = {'name': 'Pt 4f', 'elo': 522.0, 'ehi': 917.0, 'estep': 0.075, 'epass': 100, 'tstep': 5, 'iter': 1, 'cis': True, 'slit': 40}
REGION2 = {'name': 'C 1s', 'elo': 310.5, 'ehi': 1003.0, 'estep': 0.05, 'epass': 100, 'tstep': 20, 'iter': 1, 'cis': True, 'slit': 130}
REGION3 = {'name': 'B 1s', 'elo': 405.0, 'ehi': 1003.0, 'estep': 0.05, 'epass': 100, 'tstep': 25, 'iter': 1, 'cis': True, 'slit': 200}
REGION4 = {'name': 'N 1s', 'elo': 198.0, 'ehi': 1003.0, 'estep': 0.05, 'epass': 100, 'tstep': 25, 'iter': 1, 'cis': True, 'slit': 200}
REGIONS = [REGION1, REGION2, REGION3, REGION4]
CLOSE_SHUTTER_AT_END = True
#Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.channel_center_dataset_name = path + "ScientaChannelCenter"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
self.slit_dataset_name = path + "ExitSlit"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.channel_center_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
create_dataset(self.slit_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}".format(self.scan_index)
elo = self.region['elo']
ehi = self.region['ehi']
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.centerEnergy.write(elo)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
ExitSlit.write(self.region['slit'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.channel_center_dataset_name, elo)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
append_dataset(self.slit_dataset_name, self.region['slit'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Acquiring spectrum {elo} eV.".format(elo=Scienta.centerEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
#nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
nx = 992
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
#nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
nx = 992
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(regions, latency):
global SENSORS, PHI_RANGE, THETA_RANGE
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
ascan((ManipulatorPhi, ManipulatorTheta), SENSORS, (PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS, LATENCY, False, zigzag = ZIGZAG, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
try:
setup_live_plots(REGIONS)
task = fork(update_live_plots)
do_scan(REGIONS, LATENCY)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -132,7 +132,6 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def setup(self):
# print("spectrum.setup")
print(self.region)
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
@@ -205,7 +204,6 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
print("done spectrum.read")
return sp
def getSize(self):

View File

@@ -1,252 +0,0 @@
"""
Discrete scan (vector scan) of multiple spectral regions
"""
PHI_RANGE = (-160.0, 160.0) # (tuple (min, max))
THETA_RANGE = (-9.0, 81.0) # (tuple (min, max))
STEPS = (40.0, 1.0) # (tuple (phi, theta))
ZIGZAG = True
# scan positioner: Eph = photon energy
#MOTORS = (ManipulatorPhi, ManipulatorTheta)
#MOTORS = [ManipulatorPhi]
MOTORS = [dummy]
# comma-separated discrete list of scan positions
#POSITIONS = [(PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS]
#POSITIONS = [-175., 180., 5.]
POSITIONS = [0.]
# seconds to wait between positioning command and triggering the detector
LATENCY = 0.0
# region setup
#
# for each region, define a python dictionary with the following items.
# optional items can be left unspecified and will default to the indicated values.
# for swept mode, include 'elo', 'ehi', 'estep', 'iter' values, but do not include 'efix'.
# for fixed mode, include 'efix' value, but do not include 'elo', 'ehi', 'estep', 'iter'.
#
# 'name': user-specific name of the region (for graph title and RegionName attribute in data file)
# 'elo': lower kinetic energy boundary of the spectrum
# 'ehi': upper kinetic energy boundary of the spectrum
# 'estep': energy step size
# 'efix': center kinetic energy in fixed mode
# 'epass': pass energy
# 'tstep': dwell time in seconds
# 'iter': number of iterations/sweeps (default 1)
# 'cis': True = constant initial state (photoemission line), False = constant final state (Auger peak), (default False)
# 'slit': exit slit (default current value)
#REGION1 = {'name': 'test1', 'ephot': 1000, 'efix': 954.5, 'epass': 100., 'tstep': 20., 'iter': 1, 'cis': False}
REGION1 = {'name': 'test2', 'ephot': 120, 'elo': 70, 'ehi': 80,'estep': 0.02, 'epass': 20., 'tstep': 0.4, 'iter': 1, 'cis': False}
REGION2 = {'name': 'test2', 'ephot': 120, 'elo': 95, 'ehi': 105,'estep': 0.02, 'epass': 20., 'tstep': 0.4, 'iter': 1, 'cis': False}
#REGION1 = {'name': 'secondary', 'elo': 9.0, 'ehi': 11.0, 'estep': 0.02, 'epass': 2, 'tstep': 0.20, 'iter': 1, 'cis': False}
#REGION2 = {'name': 'fermi', 'elo': 23.5, 'ehi': 27.5, 'estep': 0.02, 'epass': 2, 'tstep': 0.35, 'iter': 1, 'cis': False}
# list of region dictionaries to execute at each scan position
REGIONS = [REGION1, REGION2]
# close beam shutter and turn off analyser at the end of the scan
CLOSE_SHUTTER_AT_END = True
# --- DO NOT EDIT BELOW THIS LINE! ---
set_exec_pars(keep=False)
def check_region(region):
"""
check region dictionary items and apply defaults where necessary
"""
region['fixed'] = 'efix' in region
if region['fixed']:
region['elo'] = region['efix']
region['ehi'] = region['efix']
if 'iter' not in region:
region['iter'] = 1
print("region {0}: setting default iter = {1}".format(region['name'], region['iter']))
if 'cis' not in region:
region['cis'] = False
print("region {0}: setting default cis = {1}".format(region['name'], region['cis']))
if 'slit' not in region:
region['slit'] = ExitSlit.read()
print("region {0}: setting default slit = {1}".format(region['name'], region['slit']))
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.channel_center_dataset_name = path + "ScientaChannelCenter"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
self.slit_dataset_name = path + "ExitSlit"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.channel_center_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
create_dataset(self.slit_dataset_name, 'd')
def setup(self):
print("spectrum.setup")
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}".format(self.scan_index)
#ephot = Eph.read()
#try:
# if self.region['cis']:
# edelta = ephot - self.ephot_start
# else:
# edelta = 0.0
#except AttributeError:
# self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
if self.region['fixed']:
Eph.write(self.region['ephot'])
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed)
Scienta.centerEnergy.write(elo)
else:
Eph.write(self.region['ephot'])
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
#Scienta.setPassEnergy(self.region['epass'])
#Scienta.stepTime.write(self.region['tstep'])
#Scienta.setIterations(self.region['iter'])
#ExitSlit.write(self.region['slit'])
#Scienta.update()
if self.region['fixed']:
append_dataset(self.channel_center_dataset_name, elo)
else:
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
append_dataset(self.slit_dataset_name, self.region['slit'])
def read(self):
print("spectrum.read")
global current_region_index
current_region_index = self.region_index
self.setup()
print("Acquiring region {0}.".format(self.region['name']))
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
if self.region['fixed']:
nx = 992
else:
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
print("image.read")
return Scienta.getDataMatrix().read()
def getWidth(self):
if self.region['fixed']:
nx = 992
else:
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
check_region(region)
reader = SpectrumReader()
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
#ascan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, zigzag = True, before_read=wait_beam, after_read = after_readout)
#lscan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, before_read=wait_beam, after_read = after_readout)
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
try:
setup_live_plots(REGIONS)
task = fork(update_live_plots)
do_scan(MOTORS, POSITIONS, REGIONS, LATENCY)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,250 +0,0 @@
"""
Discrete scan (vector scan) of multiple spectral regions
"""
PHI_RANGE = (-160.0, 160.0) # (tuple (min, max))
THETA_RANGE = (-9.0, 81.0) # (tuple (min, max))
STEPS = (40.0, 1.0) # (tuple (phi, theta))
ZIGZAG = True
# scan positioner: Eph = photon energy
#MOTORS = (ManipulatorPhi, ManipulatorTheta)
#MOTORS = [ManipulatorPhi]
MOTORS = [dummy]
# comma-separated discrete list of scan positions
#POSITIONS = [(PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS]
POSITIONS = [0., 100., 1.]
#POSITIONS = [0.]
# seconds to wait between positioning command and triggering the detector
LATENCY = 0.0
# region setup
#
# for each region, define a python dictionary with the following items.
# optional items can be left unspecified and will default to the indicated values.
# for swept mode, include 'elo', 'ehi', 'estep', 'iter' values, but do not include 'efix'.
# for fixed mode, include 'efix' value, but do not include 'elo', 'ehi', 'estep', 'iter'.
#
# 'name': user-specific name of the region (for graph title and RegionName attribute in data file)
# 'elo': lower kinetic energy boundary of the spectrum
# 'ehi': upper kinetic energy boundary of the spectrum
# 'estep': energy step size
# 'efix': center kinetic energy in fixed mode
# 'epass': pass energy
# 'tstep': dwell time in seconds
# 'iter': number of iterations/sweeps (default 1)
# 'cis': True = constant initial state (photoemission line), False = constant final state (Auger peak), (default False)
# 'slit': exit slit (default current value)
REGION1 = {'name': 'test1', 'ephot': 120, 'elo': 74, 'ehi': 75,'estep': 0.02, 'epass': 20., 'tstep': 0.4, 'iter': 1, 'cis': False}
REGION2 = {'name': 'test2', 'ephot': 120, 'elo': 98, 'ehi': 99,'estep': 0.02, 'epass': 20., 'tstep': 0.4, 'iter': 1, 'cis': False}
#REGION1 = {'name': 'secondary', 'elo': 9.0, 'ehi': 11.0, 'estep': 0.02, 'epass': 2, 'tstep': 0.20, 'iter': 1, 'cis': False}
#REGION2 = {'name': 'fermi', 'elo': 23.5, 'ehi': 27.5, 'estep': 0.02, 'epass': 2, 'tstep': 0.35, 'iter': 1, 'cis': False}
# list of region dictionaries to execute at each scan position
REGIONS = [REGION1, REGION2]
# close beam shutter and turn off analyser at the end of the scan
CLOSE_SHUTTER_AT_END = True
# --- DO NOT EDIT BELOW THIS LINE! ---
set_exec_pars(keep=False)
def check_region(region):
"""
check region dictionary items and apply defaults where necessary
"""
region['fixed'] = 'efix' in region
if region['fixed']:
region['elo'] = region['efix']
region['ehi'] = region['efix']
if 'iter' not in region:
region['iter'] = 1
print("region {0}: setting default iter = {1}".format(region['name'], region['iter']))
if 'cis' not in region:
region['cis'] = False
print("region {0}: setting default cis = {1}".format(region['name'], region['cis']))
if 'slit' not in region:
region['slit'] = ExitSlit.read()
print("region {0}: setting default slit = {1}".format(region['name'], region['slit']))
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.channel_center_dataset_name = path + "ScientaChannelCenter"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
self.slit_dataset_name = path + "ExitSlit"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.channel_center_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
create_dataset(self.slit_dataset_name, 'd')
def setup(self):
print("spectrum.setup")
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}".format(self.scan_index)
#ephot = Eph.read()
#try:
# if self.region['cis']:
# edelta = ephot - self.ephot_start
# else:
# edelta = 0.0
#except AttributeError:
# self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
if self.region['fixed']:
Eph.write(self.region['ephot'])
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed)
Scienta.centerEnergy.write(elo)
else:
Eph.write(self.region['ephot'])
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
#Scienta.setPassEnergy(self.region['epass'])
#Scienta.stepTime.write(self.region['tstep'])
#Scienta.setIterations(self.region['iter'])
#ExitSlit.write(self.region['slit'])
#Scienta.update()
if self.region['fixed']:
append_dataset(self.channel_center_dataset_name, elo)
else:
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
append_dataset(self.slit_dataset_name, self.region['slit'])
def read(self):
print("spectrum.read")
global current_region_index
current_region_index = self.region_index
self.setup()
print("Acquiring region {0}.".format(self.region['name']))
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
if self.region['fixed']:
nx = 992
else:
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
print("image.read")
return Scienta.getDataMatrix().read()
def getWidth(self):
if self.region['fixed']:
nx = 992
else:
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
check_region(region)
reader = SpectrumReader()
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
#ascan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, zigzag = True, before_read=wait_beam, after_read = after_readout)
lscan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, before_read=wait_beam, after_read = after_readout)
#vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
try:
setup_live_plots(REGIONS)
task = fork(update_live_plots)
do_scan(MOTORS, POSITIONS, REGIONS, LATENCY)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,63 +0,0 @@
"""
Continuous 2D Manipulator scan (experimental)
set manipulator scan parameters below.
set analyser parameters separately!
"""
import math
MOTORS = (ManipulatorY)
#SENSORS = (Counts, Scienta.spectrum, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution)
SENSORS = (Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution)
RANGE_Y = (-5., +5)
RANGE_Z = (114., 116.)
STEPS_Y = 20
SPEED_Y = 0.1
STEPS_Z = 2
RELATIVE = False
LATENCY = 0.0
ENDSCAN = False
ZIGZAG = False
#set_preference(Preference.ENABLED_PLOTS, [ManipulatorPhi, ManipulatorTheta, Scienta.dataMatrix, ImageIntegrator])
#set_preference(Preference.PLOT_TYPES,{'ImageIntegrator':1})
adjust_sensors()
set_adc_averaging()
#set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
# time per scienta acquisition in seconds
time1 = time.time()
trig_scienta()
time2 = time.time()
scienta_time = (time2 - time1)
print "scienta_time: ", scienta_time
# time for one Y scan in seconds
fly_time = (RANGE_Y[1] - RANGE_Y[0]) / SPEED_Y
#speed = (RANGE_Y[1] - RANGE_Y[0]) / scienta_time / STEPS_Y
#speed = min(max(speed, ManipulatorY.getMinSpeed()), ManipulatorY.getMaxSpeed())
STEPS_Y = int(fly_time / scienta_time) + 1
#fly_time = scienta_time * STEPS_Y
print "Y time: ", fly_time
STEP_Z = (RANGE_Z[1] - RANGE_Z[0]) / STEPS_Z
positions_z = [RANGE_Z[0] + STEP_Z * i for i in range(STEPS_Z)]
print "Z positions: ", positions_z
def before_pass(index, scan):
global positions_z
print "Starting pass: ", index
z = positions_z[index-1]
ManipulatorZ.write(z)
print "z = ", z
ManipulatorZ.waitValueInRange(z, 1.0, 100)
try:
cscan(MOTORS, SENSORS, RANGE_Y[0], RANGE_Y[1], STEPS_Y, time=fly_time, passes=len(positions_z), zigzag=ZIGZAG, before_read=before_readout, after_read = after_readout, before_pass = before_pass, check_positions = False)
finally:
if ENDSCAN:
after_scan()

View File

@@ -1,98 +0,0 @@
"""
Arguments:
SENSORS (list)
PHI_RANGE (tuple (min, max))
THETA_RANGE (tuple (min, max))
STEPS (tuple (phi, theta))
LATENCY (double)
RELATIVE (BOOLEAN)
ZIGZAG (BOOLEAN)
"""
import math
global VECTOR, SENSORS
MODE = "swept"
LATENCY = 0.0
SENSORS = [Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent]
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
writables = (ManipulatorTheta, ManipulatorX, ManipulatorY)
adjust_sensors()
SampleCurrentAveraging.write(1660)
RefCurrentAveraging.write(1660)
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
try:
# C
Scienta.getLowEnergy().write(190.0)
Scienta.getHighEnergy().write(222.0)
Scienta.getStepSize().write(0.1)
Scienta.getStepTime().write(0.2)
Scienta.setIterations(1)
Eph.move(505.0)
theta = [-9.0]
#theta = [-9.0,6.0,21.0,31.0,41.0,51.0,61.0,71.0]
x = [2.32*math.cos((th+9.0)*math.pi/180.0)-2.67 for th in theta]
y = [2.32*math.sin((th+9.0)*math.pi/180.0)-0.2 for th in theta]
VECTOR = [[theta[i], x[i], y[i]] for i in range(len(theta))]
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
# C - to avoid Zn2p secondary features
Scienta.getLowEnergy().write(210.0)
Scienta.getHighEnergy().write(240.0)
Scienta.getStepSize().write(0.1)
Scienta.getStepTime().write(0.2)
Scienta.setIterations(1)
Eph.move(520.0)
theta = [-9.0]
#theta = [-9.0,6.0,21.0,31.0,41.0,51.0,61.0,71.0]
x = [2.32*math.cos((th+9.0)*math.pi/180.0)-2.67 for th in theta]
y = [2.32*math.sin((th+9.0)*math.pi/180.0)-0.2 for th in theta]
VECTOR = [[theta[i], x[i], y[i]] for i in range(len(theta))]
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
# Zn
Scienta.getLowEnergy().write(175.0)
Scienta.getHighEnergy().write(220.0)
Scienta.getStepSize().write(0.1)
Scienta.getStepTime().write(1.0)
Scienta.setIterations(1)
Eph.move(1240.0)
theta = [-9.0]
#theta = [-9.0,6.0,21.0,31.0,41.0,51.0,61.0,71.0]
x = [2.37*math.cos((th+9.0)*math.pi/180.0)-2.67 for th in theta]
y = [2.37*math.sin((th+9.0)*math.pi/180.0)-0.2 for th in theta]
VECTOR = [[theta[i], x[i], y[i]] for i in range(len(theta))]
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
"""# Fe
Scienta.getLowEnergy().write(180.0)
Scienta.getHighEnergy().write(225.0)
Scienta.getStepSize().write(0.1)
Scienta.getStepTime().write(1.0)
Scienta.setIterations(4)
Eph.move(925.0)
theta = [-9.0]
theta = [-9.0,6.0,21.0,31.0,41.0,51.0,61.0,71.0]
x = [2.32*math.cos((th+9.0)*math.pi/180.0)-2.67 for th in theta]
y = [2.32*math.sin((th+9.0)*math.pi/180.0)-0.2 for th in theta]
VECTOR = [[theta[i], x[i], y[i]] for i in range(len(theta))]
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)"""
# Mn
Scienta.getLowEnergy().write(175.0)
Scienta.getHighEnergy().write(235.0)
Scienta.getStepSize().write(0.1)
Scienta.getStepTime().write(1.0)
Scienta.setIterations(1)
Eph.move(860.0)
theta = [-9.0]
#theta = [-9.0,6.0,21.0,31.0,41.0,51.0,61.0,71.0]
x = [2.32*math.cos((th+9.0)*math.pi/180.0)-2.67 for th in theta]
y = [2.32*math.sin((th+9.0)*math.pi/180.0)-0.2 for th in theta]
VECTOR = [[theta[i], x[i], y[i]] for i in range(len(theta))]
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
finally:
after_scan()

View File

@@ -1,25 +0,0 @@
set_adc_averaging()
ENERGY_LOW = 136.0
ENERGY_HIGH = 350.5
SETTLING_TIME = 0.0
STEPS = 1000
SENSORS = [Counts, MachineCurrent, SampleCurrent, RefCurrent, EnergyDistribution, Scienta.getDataMatrix()]
ENDSCAN = False
#dummy.initialize()
Scienta.stepTime.write(5.0)
setup_plotting(line_plots = (Counts, MachineCurrent, SampleCurrent, RefCurrent,))
try:
ascan( [dummy,Scienta.getCenterEnergy()],
SENSORS,
[0.0, ENERGY_HIGH],
[0.001 * STEPS, ENERGY_LOW],
[STEPS, 1],
latency = SETTLING_TIME,
before_read = before_readout, after_read = after_readout)
finally:
if ENDSCAN:
after_scan()

View File

@@ -1,43 +0,0 @@
import ch.psi.pshell.device.DummyPositioner as DummyPositioner
#Energy #Pass Energy #Step Time
STEPS = [ ( 136.2, 100 , 5.0),
( 220.5, 100 , 5.0),
( 350.8, 100 , 5.0),
]
SETTLING_TIME = 0.0
SENSORS = [Counts, MachineCurrent, SampleCurrent, RefCurrent, EnergyDistribution, Scienta.getDataMatrix()]
ENDSCAN = False
STEP_TIME = 5.0
class PassEnergy(Writable):
def write(self, value):
Scienta.setPassEnergy(100)
POSITIONERS = [Scienta.getCenterEnergy(), PassEnergy(), Scienta.getChild("Scienta step time")]
def scan_gen():
while True:
for step in STEPS:
yield step
set_adc_averaging()
Scienta.stepTime.write(STEP_TIME)
try:
vscan( POSITIONERS,
SENSORS,
scan_gen(),
line = True,
latency=SETTLING_TIME,
domain_axis = "Index",
enabled_plots = POSITIONERS + SENSORS,
line_plots = [EnergyDistribution,],
before_read = before_readout,
after_read = after_readout
)
finally:
if ENDSCAN:
after_scan()

View File

@@ -1,54 +0,0 @@
"""
Arguments:
SENSORS (list)
PHI_RANGE (tuple (min, max))
THETA_RANGE (tuple (min, max))
STEPS (tuple (phi, theta))
LATENCY (double)
RELATIVE (BOOLEAN)
ZIGZAG (BOOLEAN)
"""
import math
global VECTOR, SENSORS
MODE = "swept"
LATENCY = 0.0
SENSORS = [Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent]
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
writables = (ManipulatorPhi, ManipulatorTheta, ManipulatorX, ManipulatorY)
adjust_sensors()
SampleCurrentAveraging.write(1660)
RefCurrentAveraging.write(1660)
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
try:
# N-B
#VECTOR = [[425.0 + i * 2.5, 19.0 + i * 2.5, 29.0 + i * 2.5] for i in range(121)]
#ManipulatorPhi.move(+21.1)
#ManipulatorTilt.move(+0.5)
#Scienta.getStepTime().write(0.824)
#print VECTOR
#vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
# N-N
#ManipulatorPhi.move(-8.9)
#ManipulatorTilt.move(+0.5)
#Scienta.getStepTime().write(0.824)
#vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
# B-Cu
phi = [int(i/46)*36.0-165.0 for i in range(460)]
theta = [(i%46)*2.0-9.0 for i in range(460)]
x = [2.37*math.cos((th+9.0)*math.pi/180.0)-2.67 for th in theta]
y = [2.37*math.sin((th+9.0)*math.pi/180.0)-0.2 for th in theta]
#VECTOR = [phi, theta, x, y]
VECTOR = [[phi[i], theta[i], x[i], y[i]] for i in range(460)]
# ManipulatorPhi.move(-8.9)
#ManipulatorTilt.move(+25.5)
#Scienta.getStepTime().write(1.47)
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
finally:
after_scan()

View File

@@ -1,46 +0,0 @@
"""
Arguments:
SENSORS (list)
PHI_RANGE (tuple (min, max))
THETA_RANGE (tuple (min, max))
STEPS (tuple (phi, theta))
LATENCY (double)
RELATIVE (BOOLEAN)
ZIGZAG (BOOLEAN)
"""
import math
global VECTOR, SENSORS
MODE = "swept"
LATENCY = 0.0
SENSORS = [Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent]
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
writables = (ManipulatorTheta)
adjust_sensors()
SampleCurrentAveraging.write(10)
RefCurrentAveraging.write(10)
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
try:
#phi = [int(i/46) * 36.0 - 165.0 for i in range(460)]
#theta = [(i%46)*2.0-9.0 for i in range(460)]
NPOINTS = 61
#phi = [0.5 for i in range(NPOINTS)]
phi=30.5
theta = [i * 1.0 - 9.0 for i in range(NPOINTS)]
x = [3.0 * math.cos((th+9.0) * math.pi/180.0) - 1.69 for th in theta]
y = [3.0 * math.sin((th+9.0) * math.pi/180.0) - 0.933 for th in theta]
#x = [0.65]
#y = [0.0179 * th for th in theta]
#VECTOR = [phi, theta, x, y]
VECTOR= [theta[i] for i in range(NPOINTS)]
# ManipulatorPhi.move(-8.9)
#ManipulatorTilt.move(+25.5)
#Scienta.getStepTime().write(1.47)
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
finally:
after_scan()

View File

@@ -1,54 +0,0 @@
"""
Arguments:
SENSORS (list)
PHI_RANGE (tuple (min, max))
THETA_RANGE (tuple (min, max))
STEPS (tuple (phi, theta))
LATENCY (double)
RELATIVE (BOOLEAN)
ZIGZAG (BOOLEAN)
"""
import math
global VECTOR, SENSORS
MODE = "swept"
LATENCY = 0.0
SENSORS = [Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent]
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
writables = (ManipulatorTheta)
adjust_sensors()
SampleCurrentAveraging.write(1660)
RefCurrentAveraging.write(1660)
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
try:
# N-B
#VECTOR = [[425.0 + i * 2.5, 19.0 + i * 2.5, 29.0 + i * 2.5] for i in range(121)]
#ManipulatorPhi.move(+21.1)
#ManipulatorTilt.move(+0.5)
#Scienta.getStepTime().write(0.824)
#print VECTOR
#vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
# N-N
#ManipulatorPhi.move(-8.9)
#ManipulatorTilt.move(+0.5)
#Scienta.getStepTime().write(0.824)
#vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
# B-Cu
phi = [30.5]
theta = [i * 1.0 - 11.0 for i in range(61)]
x = [3.0 * math.cos((th+9.0) * math.pi/180.0) - 1.69 for th in theta]
y = [3.0 * math.sin((th+9.0) * math.pi/180.0) - 0.933 for th in theta]
#VECTOR = [phi, theta, x, y]
VECTOR = [[theta[i]] for i in range(61)]
# ManipulatorPhi.move(-8.9)
#ManipulatorTilt.move(+25.5)
#Scienta.getStepTime().write(1.47)
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
finally:
after_scan()

View File

@@ -1,50 +0,0 @@
"""
Arguments:
VECTOR (Double[][], Scan vector: Eph,Elow,Ehigh or Eph,Ecenter)
SENSORS (list)
LATENCY (double)
MODE ('fixed' or 'swept')
TYPE ('CIS' or 'CFS')
STEP (double)
"""
SENSORS = (Scienta.spectrum, Scienta.dataMatrix, Counts, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution)
LATENCY = 0.0
ENDSCAN = True
def get_vector(ephot_lo, ephot_hi, ephot_step, ekin_lo, ekin_hi):
NSTEPS = int(round((ephot_hi - ephot_lo) / ephot_step) + 1)
EPHOT_STEP = (ephot_hi - ephot_lo) / (NSTEPS - 1)
ephot = [ephot_lo + ephot_step * i for i in range(NSTEPS)]
eshift = [ephot_step * i for i in range(NSTEPS)]
ekin_lo = [ekin_lo + eshift[i] for i in range(NSTEPS)]
ekin_hi = [ekin_hi + eshift[i] for i in range(NSTEPS)]
v = [[ephot[i], ekin_lo[i], ekin_hi[i]] for i in range(NSTEPS)]
return v
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
writables = (Eph, Scienta.lowEnergy, Scienta.highEnergy)
adjust_sensors()
set_adc_averaging()
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
# Mn 3p
# 330 s
v1 = get_vector(78.5, 188.5, 2.0, 23.0, 33.0)
#v1 = get_vector(78.5, 188.5, 2.0, 21.0, 29.5)
print v1
# Ge 3p
# 450 s
v2 = get_vector(160.0, 270.0, 2.0, 27.0, 41.0)
#v2 = get_vector(160.0, 270.0, 2.0, 25.0, 39.0)
print v2
vscan(writables, SENSORS, v2, True, LATENCY,False, before_read=before_readout, after_read = after_readout)
vscan(writables, SENSORS, v1, True, LATENCY,False, before_read=before_readout, after_read = after_readout)
after_scan()

View File

@@ -1,43 +0,0 @@
"""
Arguments:
SENSORS (list)
PHI_RANGE (tuple (min, max))
THETA_RANGE (tuple (min, max))
STEPS (tuple (phi, theta))
LATENCY (double)
RELATIVE (BOOLEAN)
ZIGZAG (BOOLEAN)
"""
SENSORS = (Counts, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution,Scienta.dataMatrix)
MOTORS = (ManipulatorPhi)
RANGE = (-90.0, +90.0)
STEPS = (2.0)
LATENCY = 0.0
ENDSCAN = True
RELATIVE = False
adjust_sensors()
set_adc_averaging()
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
#photon_energies = [60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0, 100.0, 105.0]
photon_energies = [95.0, 105.0, 115.0, 125.0]
try:
for ephot in photon_energies:
Eph.move(ephot)
print ephot
Scienta.getLowEnergy().write(55.0 + ephot - 65.0)
Scienta.getCenterEnergy().write(60.0 + ephot - 65.0)
Scienta.getHighEnergy().write(61.0 + ephot - 65.0)
#Scienta.getStepSize().write(0.1)
#Scienta.getStepTime().write(0.2)
#Scienta.setIterations(1)
lscan(MOTORS, SENSORS, RANGE[0], RANGE[1], STEPS, LATENCY, RELATIVE, before_read=before_readout, after_read = after_readout)
finally:
if ENDSCAN:
after_scan()

View File

@@ -1,190 +0,0 @@
"""
Arguments:
VECTOR (Double[][], Scan vector: Eph,Elow,Ehigh or Eph,Ecenter)
SENSORS (list)
LATENCY (double)
MODE ('fixed' or 'swept')
TYPE ('CIS' or 'CFS')
STEP (double)
"""
LATENCY = 0.0
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def doRead(self):
global VECTOR
self.offset = Eph.getSetpoint().take() - VECTOR[0]
self.setup()
trig_scienta()
time.sleep(0.5)
return Scienta.getSpectrum().read()
def getSize(self):
return len(Scienta.getSpectrumX())
class SpectrumReader1(SpectrumReader):
def setup(self):
global energy_scale_array, initial_energy_range
Scienta.getLowEnergy().write(initial_energy_range[0][0] + self.offset)
Scienta.getHighEnergy().write(initial_energy_range[0][1] + self.offset)
Scienta.getStepSize().write(initial_energy_range[0][2])
energy_scale_array = [Scienta.getLowEnergy().take(), Scienta.getHighEnergy().take(), Scienta.getStepSize().take()]
class SpectrumReader2(SpectrumReader):
def setup(self):
global energy_scale_array, initial_energy_range
Scienta.getLowEnergy().write(initial_energy_range[1][0] + self.offset)
Scienta.getHighEnergy().write(initial_energy_range[1][1] + self.offset)
Scienta.getStepSize().write(initial_energy_range[1][2])
energy_scale_array = energy_scale_array + [Scienta.getLowEnergy().take(), Scienta.getHighEnergy().take(), Scienta.getStepSize().take()]
append_dataset(energy_scale_table,energy_scale_array)
class SpectrumReader3(SpectrumReader):
def setup(self):
global initial_energy_range,energy_scale_array, energy_scale_table
Scienta.getLowEnergy().write(initial_energy_range[2][0] + self.offset)
Scienta.getHighEnergy().write(initial_energy_range[2][1] + self.offset)
Scienta.getStepSize().write(initial_energy_range[2][2])
energy_scale_array = energy_scale_array + [Scienta.getLowEnergy().take(), Scienta.getHighEnergy().take(), Scienta.getStepSize().take()]
append_dataset(energy_scale_table,energy_scale_array)
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def doRead(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
global initial_energy_range
return int( (initial_energy_range[self.index][1] - initial_energy_range[self.index][0]) / initial_energy_range[self.index][2])
def getHeight(self):
return Scienta.getDataMatrix().getHeight()
def measure_stuff():
global energy_scale_array, energy_scale_table, VECTOR,pass_energy_hold,angle_time,angle_range,azi_range,bb
reader1 = SpectrumReader1(); reader1.initialize()
reader2 = SpectrumReader2(); reader2.initialize()
#reader3 = SpectrumReader3(); reader3.initialize()
image1 = ImageReader(); image1.initialize(); image1.index=0; set_device_alias(image1, "Image1")
image2 = ImageReader(); image2.initialize(); image2.index=1; set_device_alias(image2, "Image2")
#image3 = ImageReader(); image3.initialize(); image3.index=2; set_device_alias(image3, "Image3")
Scienta.getDataMatrix()
SENSORS = [RefCurrent, reader1, image1, reader2, image2]#, reader3, image3]
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
adjust_sensors()
set_adc_averaging()
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
for ll in range(len(azi_range)):
ManipulatorPhi.move(azi_range[ll])
for jj in range(len(angle_range)):
tic = time.time()
ManipulatorTheta.move(angle_range[jj])
print 'current theta is ', ManipulatorTheta.take(), ' and current azimuth is ' , ManipulatorPhi.take()
Scienta.setPassEnergy(pass_energy_hold)
#print ' Flag 1'
Scienta.getStepTime().write(angle_time[jj])
#print ' Flag 2'
sleep(1)
bb = bb+1
energy_scale_table = "scan " + str(bb) + "/EnergyScale"
print energy_scale_table
create_dataset(energy_scale_table, 'd', dimensions=[0,9])
vscan(Eph, SENSORS, VECTOR, True, LATENCY,False, before_read=wait_beam, after_read = after_readout)
toc = time.time()
tictoc = round((toc-tic)/60*100)/100
print 'time taken is ', tictoc, ' minutes'
global initial_energy_range,energy_scale_array, energy_scale_table, VECTOR,pass_energy_hold,angle_time,angle_range,azi_range,SENSORS
bb = 0
SENSORS = []
#################### O 1s PhD scan ##############################
print ' ######################################################'
print ' ** Begin O 1s PhD **'
tic_whole = time.time()
VECTOR = [ 638.0]
for nn in range(63):
VECTOR.append(VECTOR[-1]+4)
pass_energy_hold = 100
initial_energy_range = [[95.5, 105.0, 0.1],
[105.1, 115.0, 0.5]]
angle_time = [0.4, 0.5, 0.6]
energy_scale_array = []
azi_range = [-45.0]
angle_range = [-9.2+20.0, -9.2+40.0, -9.2+60.0]
#measure_stuff()
toc_whole = time.time()
tictoc = round(toc_whole-tic_whole)
print ' ** End O 1s PhD **'
print ' ** time taken was ', math.floor(tictoc/3600), ' hours and ', round((tictoc-math.floor(tictoc/3600)*3600)/60), ' minutes.'
print ' ######################################################'
#################### C 1s PhD scan ##############################
print ' ######################################################'
print ' ** Begin C 1s PhD **'
tic_whole = time.time()
VECTOR = [ 340.0]
for nn in range(63):
VECTOR.append(VECTOR[-1]+4)
#nn = 0
initial_energy_range = [[45.0, 53.0, 0.1],
[53.5, 63.0, 0.5]]
pass_energy_hold = 50
angle_time = [0.4,0.4,0.5]
azi_range = [-90.0, -45.0]
angle_range = [-9.2+30.0, -9.2+60.0]
measure_stuff()
toc_whole = time.time()
tictoc = round(toc_whole-tic_whole)
print ' ** time taken was ', math.floor(tictoc/3600), ' hours and ', round((tictoc-math.floor(tictoc/3600)*3600)/60), ' minutes.'
print ' ** End C 1s PhD **'
print ' ######################################################'
#################### Si 2p PhD scan ##############################
print ' ######################################################'
print ' ** Begin Si 2p PhD **'
tic_whole = time.time()
VECTOR = [ 170.0]
for nn in range(63):
VECTOR.append(VECTOR[-1]+4)
#nn = 0
initial_energy_range = [[62.0, 67.0, 0.1],
[67.5, 77, 0.5]]
pass_energy_hold = 20
angle_time = [0.4,0.4,0.5]
azi_range = [-90.0,-45.0]
angle_range = [-9.2, -9.2+30.0, -9.2+60.0]
measure_stuff()
toc_whole = time.time()
tictoc = round(toc_whole-tic_whole)
print ' ** time taken was ', math.floor(tictoc/3600), ' hours and ', round((tictoc-math.floor(tictoc/3600)*3600)/60), ' minutes.'
print ' ** End Si 2p PhD **'
print ' ######################################################'
#toc = time.time()

View File

@@ -1,188 +0,0 @@
"""
Arguments:
VECTOR (Double[][], Scan vector: Eph,Elow,Ehigh or Eph,Ecenter)
SENSORS (list)
LATENCY (double)
MODE ('fixed' or 'swept')
TYPE ('CIS' or 'CFS')
STEP (double)
"""
LATENCY = 0.0
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def doRead(self):
global VECTOR
self.offset = Eph.getSetpoint().take() - VECTOR[0]
self.setup()
trig_scienta()
time.sleep(0.5)
return Scienta.getSpectrum().read()
def getSize(self):
return len(Scienta.getSpectrumX())
class SpectrumReader1(SpectrumReader):
def setup(self):
global energy_scale_array, initial_energy_range
Scienta.getLowEnergy().write(initial_energy_range[0][0] + self.offset)
Scienta.getHighEnergy().write(initial_energy_range[0][1] + self.offset)
Scienta.getStepSize().write(initial_energy_range[0][2])
energy_scale_array = [Scienta.getLowEnergy().take(), Scienta.getHighEnergy().take(), Scienta.getStepSize().take()]
append_dataset(energy_scale_table,energy_scale_array)
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def doRead(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
global initial_energy_range
return int( (initial_energy_range[self.index][1] - initial_energy_range[self.index][0]) / initial_energy_range[self.index][2])
def getHeight(self):
return Scienta.getDataMatrix().getHeight()
def measure_stuff():
global energy_scale_array, energy_scale_table, VECTOR,pass_energy_hold,angle_time,angle_range,azi_range,bb
reader1 = SpectrumReader1(); reader1.initialize()
#reader2 = SpectrumReader2(); reader2.initialize()
#reader3 = SpectrumReader3(); reader3.initialize()
image1 = ImageReader(); image1.initialize(); image1.index=0; set_device_alias(image1, "Image1")
#image2 = ImageReader(); image2.initialize(); image2.index=1; set_device_alias(image2, "Image2")
#image3 = ImageReader(); image3.initialize(); image3.index=2; set_device_alias(image3, "Image3")
Scienta.getDataMatrix()
SENSORS = [RefCurrent, reader1, image1]#, reader2, image2]#, reader3, image3]
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
bb = bb+1
energy_scale_table = "scan " + str(bb) + "/EnergyScale"
print energy_scale_table
create_dataset(energy_scale_table, 'd', dimensions=[0,3])
adjust_sensors()
set_adc_averaging()
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
tic = time.time()
#print ' Flag 1'
Scienta.getStepTime().write(angle_time[0])
#print ' Flag 2'
sleep(1)
vscan(Eph, SENSORS, VECTOR, True, LATENCY,False, before_read=wait_beam, after_read = after_readout)
toc = time.time()
tictoc = round((toc-tic)/60*100)/100
print 'time taken is ', tictoc, ' minutes'
global initial_energy_range,energy_scale_array, energy_scale_table, VECTOR,pass_energy_hold,angle_time,angle_range,azi_range,SENSORS
bb = 0
SENSORS = []
#################### C 1s XPS scan ##############################
print ' ######################################################'
print ' ** Begin C 1s XPS **'
tic_whole = time.time()
VECTOR = [ 450.0]
#for nn in range(63):
# VECTOR.append(VECTOR[-1]+4)
#pass_energy_hold = 100
initial_energy_range = [[155., 165., 0.05]]
angle_time = [0.5]
energy_scale_array = []
measure_stuff()
initial_energy_range = [[344.,348., 0.05]]
angle_time = [0.5]
energy_scale_array = []
measure_stuff()
toc_whole = time.time()
tictoc = round(toc_whole-tic_whole)
print ' ** End C 1s XPS **'
print ' ** time taken was ', math.floor(tictoc/3600), ' hours and ', round((tictoc-math.floor(tictoc/3600)*3600)/60), ' minutes.'
print ' ######################################################'
#################### Overview scan ##############################
print ' ######################################################'
print ' ** Begin Overview XPS **'
tic_whole = time.time()
VECTOR = [ 800.0]
#for nn in range(63):
# VECTOR.append(VECTOR[-1]+4)
#pass_energy_hold = 100
initial_energy_range = [[100., 805., 0.5]]
angle_time = [0.5]
energy_scale_array = []
measure_stuff()
toc_whole = time.time()
tictoc = round(toc_whole-tic_whole)
print ' ** End Overview XPS **'
print ' ** time taken was ', math.floor(tictoc/3600), ' hours and ', round((tictoc-math.floor(tictoc/3600)*3600)/60), ' minutes.'
print ' ######################################################'
#################### O 1s XPS scan ##############################
print ' ######################################################'
print ' ** Begin O 1s XPS **'
tic_whole = time.time()
VECTOR = [ 650.0]
#for nn in range(63):
# VECTOR.append(VECTOR[-1]+4)
#pass_energy_hold = 100
initial_energy_range = [[108., 119., 0.05]]
angle_time = [0.1]
energy_scale_array = []
measure_stuff()
initial_energy_range = [[544.,548., 0.05]]
angle_time = [0.1]
energy_scale_array = []
measure_stuff()
toc_whole = time.time()
tictoc = round(toc_whole-tic_whole)
print ' ** End O 1s XPS **'
print ' ** time taken was ', math.floor(tictoc/3600), ' hours and ', round((tictoc-math.floor(tictoc/3600)*3600)/60), ' minutes.'
print ' ######################################################'
#################### Si 2p XPS scan ##############################
print ' ######################################################'
print ' ** Begin Si 2p XPS **'
tic_whole = time.time()
VECTOR = [ 200.]
#for nn in range(63):
# VECTOR.append(VECTOR[-1]+4)
#pass_energy_hold = 100
initial_energy_range = [[93., 98., 0.05]]
angle_time = [0.1]
energy_scale_array = []
measure_stuff()
print ' ** End Si 2p XPS **'
print ' ** time taken was ', math.floor(tictoc/3600), ' hours and ', round((tictoc-math.floor(tictoc/3600)*3600)/60), ' minutes.'
print ' ######################################################'

View File

@@ -1,196 +0,0 @@
"""
Arguments:
"""
LATENCY = 0.0
MOTORS = [Eph]
#workfunction ~ 5eV
#262eV : KE = 70eV for B 1s
#200eV : KE = 70eV for Ge 3p
POSITIONS_B = [300]
for nn in range(56):
POSITIONS_B.append(POSITIONS_B[-1]+4)
# BORON 1s
REGION_B = {'name': 'Ge 3s peak+tail', 'elo': 99., 'ehi': 112., 'estep': 0.13, 'epass': 100, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_B = [REGION_B]
# XSP check for beam damage
POSITIONB = [550]
REGION3 = {'name': 'N 1s peak', 'elo': 134., 'ehi': 154, 'estep': 0.05, 'epass': 50, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONSB = [REGION3]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}: Polar = {pol}, Azimuth = {azm}, x = {X}, y = {Y}, z = {Z}".format(self.scan_index,pol=self.sample_pos[0],azm=self.sample_pos[1],X=self.sample_pos[2],Y=self.sample_pos[3],Z=self.sample_pos[4])
ephot = Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
else:
edelta = 0.0
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency, sample_position):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.sample_pos = sample_position
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
#set_attribute(get_exec_pars().scanPath + + "region{0}/Polar".format(index + 1), "Polar", polar)
#set_attribute(get_exec_pars().scanPath + + "region{0}/Azimuth".format(index + 1), "Azimuth", azimuth)
try:
setup_live_plots(REGIONS_B)
task = fork(update_live_plots)
# theta (polar), phi (azimuth), x, y, z
sample_pos = [[-9.1,-105.0,0.5, 0.0, 115.0],
[21.0,-105.0,0.8, 0.1, 115.0],
[51.0,-105.0,0.45, 1.4, 115.0]]
#[21.0,-75.0, 0.8, 0.1, 115.0],
#[51.0,-75.0, 0.45, 1.4, 115.0],
#[-9.1,-75.0,0.5, 0.0, 115.0]]
for nn in sample_pos:
polar = nn[0]
azimuth = nn[1]
ManipulatorX.move(nn[2])
ManipulatorY.move(nn[3])
ManipulatorZ.move(nn[4])
ManipulatorTheta.move(polar)
#ManipulatorPhi.move(nn[1])
#do_scan(MOTORS, POSITIONB, REGIONSB, LATENCY) #XPS before PhD
do_scan(MOTORS, POSITIONS_B, REGIONS_B, LATENCY, nn) #PhD
#do_scan(MOTORS, POSITIONB, REGIONSB, LATENCY) #XPS after PhD
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,219 +0,0 @@
"""
Arguments:
"""
LATENCY = 0.0
MOTORS = [Eph]
#workfunction = 4.3eV
#262eV : KE = 70eV for B 1s
#200eV : KE = 70eV for Ge 3p
POSITIONS_1 = [435]
#for nn in range(0):
# POSITIONS_1.append(POSITIONS_1[-1]+4)
# BORON 1s
REGION_1 = {'name': 'Ge 3d', 'elo': 398., 'ehi': 405., 'estep': 0.025, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_1 = [REGION_1]
POSITIONS_2 = [435]
#for nn in range(0):
# POSITIONS_2.append(POSITIONS_2[-1]+4)
# BORON 1s
REGION_2 = {'name': 'Cu 3p', 'elo': 349., 'ehi': 360., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_2 = [REGION_2]
POSITIONS_3 = [70]
#for nn in range(0):
# POSITIONS_3.append(POSITIONS_3[-1]+4)
# BORON 1s
REGION_3 = {'name': 'VB', 'elo': 55., 'ehi': 68., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_3 = [REGION_3]
# XSP check for beam damage
POSITIONB = [550]
REGION3 = {'name': 'N 1s peak', 'elo': 134., 'ehi': 154, 'estep': 0.05, 'epass': 50, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONSB = [REGION3]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}: Polar = {pol}, Azimuth = {azm}, x = {X}, y = {Y}, z = {Z}".format(self.scan_index,pol=self.sample_pos[0],azm=self.sample_pos[1],X=self.sample_pos[2],Y=self.sample_pos[3],Z=self.sample_pos[4])
ephot = Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
else:
edelta = 0.0
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency, sample_position):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.sample_pos = sample_position
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
#set_attribute(get_exec_pars().scanPath + + "region{0}/Polar".format(index + 1), "Polar", polar)
#set_attribute(get_exec_pars().scanPath + + "region{0}/Azimuth".format(index + 1), "Azimuth", azimuth)
try:
setup_live_plots(REGIONS_B)
task = fork(update_live_plots)
# theta (polar), phi (azimuth), x, y, z
#sample_pos = [#[-9.1,-105.0,0.5, 0.0, 115.0],
#[21.0,-105.0,0.8, 0.1, 115.0],
#[51.0,-105.0,0.45, 1.4, 115.0]]
#[21.0,-75.0, 0.8, 0.1, 115.0],
#[51.0,-75.0, 0.45, 1.4, 115.0],
#[-9.1,-75.0,0.5, 0.0, 115.0]]
sample_pos = [[-9.1,-90.0,0.5,-0.5,115.0]]
for nn in sample_pos:
polar = nn[0]
azimuth = nn[1]
ManipulatorX.move(nn[2])
ManipulatorY.move(nn[3])
ManipulatorZ.move(nn[4])
ManipulatorTheta.move(polar)
#ManipulatorPhi.move(nn[1])
#do_scan(MOTORS, POSITIONB, REGIONSB, LATENCY) #XPS before PhD
do_scan(MOTORS, POSITIONS_2, REGIONS_2, LATENCY, nn) #PhD
do_scan(MOTORS, POSITIONS_1, REGIONS_1, LATENCY, nn) #PhD
do_scan(MOTORS, POSITIONS_3, REGIONS_3, LATENCY, nn) #PhD
#do_scan(MOTORS, POSITIONB, REGIONSB, LATENCY) #XPS after PhD
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,241 +0,0 @@
"""
Arguments:
"""
LATENCY = 0.0
MOTORS = [Eph]
#workfunction = 4.3eV
#262eV : KE = 70eV for B 1s
#200eV : KE = 70eV for Ge 3p
POSITIONS_dummy = [300]
REGION_dummy = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_dummy = [REGION_dummy]
POSITIONS_1 = [435]
REGION_1 = {'name': 'Ge 3d', 'elo': 398., 'ehi': 405., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_1 = [REGION_1]
POSITIONS_2 = [435]
REGION_2 = {'name': 'Cu 3p', 'elo': 349., 'ehi': 360., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_2 = [REGION_2]
POSITIONS_3 = [300]
REGION_3 = {'name': 'Si 2p', 'elo': 193., 'ehi': 200., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_3 = [REGION_3]
POSITIONS_4 = [300]
REGION_4 = {'name': 'Si 2s', 'elo': 140., 'ehi': 150., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_4 = [REGION_4]
POSITIONS_5 = [300]
REGION_5 = {'name': 'Cu 3p', 'elo': 210., 'ehi': 230., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 8, 'cis': True}
REGIONS_5 = [REGION_5]
POSITIONS_6 = [300]
REGION_6 = {'name': 'Ge 3s', 'elo': 110., 'ehi': 119., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 8, 'cis': True}
REGIONS_6 = [REGION_6]
POSITIONS_7 = [70]
REGION_7 = {'name': 'VB', 'elo': 55., 'ehi': 68., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_7 = [REGION_7]
POSITIONS_dummy2 = [650]
REGION_dummy2 = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_dummy2 = [REGION_dummy2]
POSITIONS_8 = [650]
REGION_8 = {'name': 'O 1s', 'elo': 109., 'ehi': 119., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 8, 'cis': True}
REGIONS_8 = [REGION_8]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}: Polar = {pol}, Azimuth = {azm}, x = {X}, y = {Y}, z = {Z}".format(self.scan_index,pol=self.sample_pos[0],azm=self.sample_pos[1],X=self.sample_pos[2],Y=self.sample_pos[3],Z=self.sample_pos[4])
ephot = Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
else:
edelta = 0.0
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency, sample_position):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.sample_pos = sample_position
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
#set_attribute(get_exec_pars().scanPath + + "region{0}/Polar".format(index + 1), "Polar", polar)
#set_attribute(get_exec_pars().scanPath + + "region{0}/Azimuth".format(index + 1), "Azimuth", azimuth)
try:
setup_live_plots(REGIONS_B)
task = fork(update_live_plots)
# theta (polar), phi (azimuth), x, y, z
sample_pos = [[-9.1,-90.0,0.7, -0.4, 115.0],
[-9.1,-90.0,0.6, -0.4, 116.0],
[-9.1,-90.0,0.5, -0.5, 116.0],
[-9.1,-90.0,0.5, -0.4, 116.0]]
for (index, nn) in enumerate(sample_pos):
polar = nn[0]
azimuth = nn[1]
ManipulatorX.move(nn[2])
ManipulatorY.move(nn[3])
ManipulatorZ.move(nn[4])
ManipulatorTheta.move(polar)
#ManipulatorPhi.move(nn[1])
if index == 0:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_1, REGIONS_1, LATENCY, nn)
do_scan(MOTORS, POSITIONS_2, REGIONS_2, LATENCY, nn)
elif index == 1:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_dummy, REGIONS_dummy, LATENCY, nn)
do_scan(MOTORS, POSITIONS_3, REGIONS_3, LATENCY, nn)
elif index == 2:
do_scan(MOTORS, POSITIONS_4, REGIONS_4, LATENCY, nn)
do_scan(MOTORS, POSITIONS_5, REGIONS_5, LATENCY, nn)
elif index == 3:
do_scan(MOTORS, POSITIONS_6, REGIONS_6, LATENCY, nn)
do_scan(MOTORS, POSITIONS_7, REGIONS_7, LATENCY, nn)
do_scan(MOTORS, POSITIONS_dummy2, REGIONS_dummy2, LATENCY, nn)
do_scan(MOTORS, POSITIONS_8, REGIONS_8, LATENCY, nn)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,274 +0,0 @@
"""
Arguments:
"""
LATENCY = 0.0
MOTORS = [Eph]
#workfunction = 4.3eV
#262eV : KE = 70eV for B 1s
#200eV : KE = 70eV for Ge 3p
#POSITIONS_dummy = [300]
#REGION_dummy = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
#REGIONS_dummy = [REGION_dummy]
POSITIONS_1 = [137]
REGION_1 = {'name': 'VB', 'elo': 123., 'ehi': 134.5, 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 20, 'cis': True}
REGIONS_1 = [REGION_1]
POSITIONS_2 = [135]
REGION_2 = {'name': 'VB', 'elo': 121., 'ehi': 132.5, 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 20, 'cis': True}
REGIONS_2 = [REGION_2]
POSITIONS_3 = [70]
REGION_3 = {'name': 'VB', 'elo': 55., 'ehi': 68., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_3 = [REGION_3]
POSITIONS_4 = [137]
REGION_4 = {'name': 'VB', 'elo': 123., 'ehi': 134.5, 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 20, 'cis': True}
REGIONS_4 = [REGION_4]
POSITIONS_5 = [135]
REGION_5 = {'name': 'VB', 'elo': 121., 'ehi': 132.5, 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 20, 'cis': True}
REGIONS_5 = [REGION_5]
POSITIONS_6 = [70]
REGION_6 = {'name': 'VB', 'elo': 55., 'ehi': 68., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_6 = [REGION_6]
POSITIONS_7 = [435]
REGION_7 = {'name': 'Ag3d', 'elo': 60.5, 'ehi': 64.5, 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_7 = [REGION_7]
POSITIONS_8 = [400]
REGION_8 = {'name': 'C1s', 'elo': 107.5, 'ehi': 113.5, 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_8 = [REGION_8]
POSITIONS_10 = [300]
REGION_10 = {'name': 'Si2p', 'elo': 193., 'ehi': 199., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_10 = [REGION_10]
POSITIONS_11 = [250]
REGION_11 = {'name': 'Si2p', 'elo': 143., 'ehi': 149., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_11 = [REGION_11]
POSITIONS_12 = [200]
REGION_12 = {'name': 'Ge3d', 'elo': 162.5, 'ehi': 168., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_12 = [REGION_12]
POSITIONS_13 = [120]
REGION_13 = {'name': 'Ge3d', 'elo': 84., 'ehi': 88., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_13 = [REGION_13]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}: Polar = {pol}, Azimuth = {azm}, x = {X}, y = {Y}, z = {Z}".format(self.scan_index,pol=self.sample_pos[0],azm=self.sample_pos[1],X=self.sample_pos[2],Y=self.sample_pos[3],Z=self.sample_pos[4])
ephot = Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
else:
edelta = 0.0
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency, sample_position):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.sample_pos = sample_position
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
#set_attribute(get_exec_pars().scanPath + + "region{0}/Polar".format(index + 1), "Polar", polar)
#set_attribute(get_exec_pars().scanPath + + "region{0}/Azimuth".format(index + 1), "Azimuth", azimuth)
try:
setup_live_plots(REGIONS_1)
task = fork(update_live_plots)
# theta (polar), phi (azimuth), x, y, z
sample_pos = [[-9.1,-90.0,0.9, 0.35, 114.5],
[50.9,-90.0,-1.4, 2.6, 114.2],
[-9.1,-90.0,0.9, 0.35, 114.5]]
for (index, nn) in enumerate(sample_pos):
polar = nn[0]
azimuth = nn[1]
ManipulatorX.move(nn[2])
ManipulatorY.move(nn[3])
ManipulatorZ.move(nn[4])
ManipulatorTheta.move(polar)
#ManipulatorPhi.move(nn[1])
if index == 0:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_1, REGIONS_1, LATENCY, nn)
do_scan(MOTORS, POSITIONS_2, REGIONS_2, LATENCY, nn)
do_scan(MOTORS, POSITIONS_3, REGIONS_3, LATENCY, nn)
elif index == 1:
do_scan(MOTORS, POSITIONS_4, REGIONS_4, LATENCY, nn)
do_scan(MOTORS, POSITIONS_5, REGIONS_5, LATENCY, nn)
do_scan(MOTORS, POSITIONS_6, REGIONS_6, LATENCY, nn)
do_scan(MOTORS, POSITIONS_7, REGIONS_7, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_dummy, REGIONS_dummy, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_3, REGIONS_3, LATENCY, nn)
elif index == 2:
do_scan(MOTORS, POSITIONS_8, REGIONS_8, LATENCY, nn)
do_scan(MOTORS, POSITIONS_10, REGIONS_10, LATENCY, nn)
do_scan(MOTORS, POSITIONS_11, REGIONS_11, LATENCY, nn)
do_scan(MOTORS, POSITIONS_12, REGIONS_12, LATENCY, nn)
do_scan(MOTORS, POSITIONS_13, REGIONS_13, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_4, REGIONS_4, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_5, REGIONS_5, LATENCY, nn)
#elif index == 3:
#do_scan(MOTORS, POSITIONS_6, REGIONS_6, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_7, REGIONS_7, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_dummy2, REGIONS_dummy2, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_8, REGIONS_8, LATENCY, nn)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,217 +0,0 @@
"""
Arguments:
"""
LATENCY = 0.0
MOTORS = [Eph]
#workfunction = 4.3eV
#262eV : KE = 70eV for B 1s
#200eV : KE = 70eV for Ge 3p
#POSITIONS_dummy = [300]
#REGION_dummy = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
#REGIONS_dummy = [REGION_dummy]
POSITIONS_1 = [400]
REGION_1 = {'name': 'c1s', 'elo': 102., 'ehi': 114., 'estep': 0.075, 'epass': 20, 'tstep': 0.5, 'iter': 4, 'cis': True}
REGIONS_1 = [REGION_1]
POSITIONS_2 = [500]
REGION_2 = {'name': 'N1s', 'elo': 89., 'ehi': 101., 'estep': 0.075, 'epass': 20, 'tstep': 0.5, 'iter': 4, 'cis': True}
REGIONS_2 = [REGION_2]
POSITIONS_3 = [640]
REGION_3 = {'name': 'o1s', 'elo': 99., 'ehi': 111., 'estep': 0.075, 'epass': 20, 'tstep': 0.5, 'iter': 6, 'cis': True}
REGIONS_3 = [REGION_3]
POSITIONS_4 = [810]
REGION_4 = {'name': 'Fe2p', 'elo': 90., 'ehi': 103., 'estep': 0.075, 'epass': 20, 'tstep': 0.5, 'iter': 4, 'cis': True}
REGIONS_4 = [REGION_4]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}: Polar = {pol}, Azimuth = {azm}, x = {X}, y = {Y}, z = {Z}".format(self.scan_index,pol=self.sample_pos[0],azm=self.sample_pos[1],X=self.sample_pos[2],Y=self.sample_pos[3],Z=self.sample_pos[4])
ephot = Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
else:
edelta = 0.0
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency, sample_position):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.sample_pos = sample_position
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
#set_attribute(get_exec_pars().scanPath + + "region{0}/Polar".format(index + 1), "Polar", polar)
#set_attribute(get_exec_pars().scanPath + + "region{0}/Azimuth".format(index + 1), "Azimuth", azimuth)
try:
setup_live_plots(REGIONS_1)
task = fork(update_live_plots)
# theta (polar), phi (azimuth), x, y, z
sample_pos = [[-9.1,-90.0,0.9, 0.35, 114.5]]
for (index, nn) in enumerate(sample_pos):
polar = nn[0]
azimuth = nn[1]
ManipulatorX.move(nn[2])
ManipulatorY.move(nn[3])
ManipulatorZ.move(nn[4])
ManipulatorTheta.move(polar)
#ManipulatorPhi.move(nn[1])
if index == 0:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_1, REGIONS_1, LATENCY, nn)
do_scan(MOTORS, POSITIONS_2, REGIONS_2, LATENCY, nn)
do_scan(MOTORS, POSITIONS_3, REGIONS_3, LATENCY, nn)
do_scan(MOTORS, POSITIONS_4, REGIONS_4, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_4, REGIONS_4, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_5, REGIONS_5, LATENCY, nn)
#elif index == 3:
#do_scan(MOTORS, POSITIONS_6, REGIONS_6, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_7, REGIONS_7, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_dummy2, REGIONS_dummy2, LATENCY, nn)
#do_scan(MOTORS, POSITIONS_8, REGIONS_8, LATENCY, nn)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,235 +0,0 @@
"""
Arguments:
Ge/Si/Cu
"""
LATENCY = 0.0
MOTORS = [Eph]
POSITIONS_1 = [435]
REGION_1 = {'name': 'Ge 3d', 'elo': 398., 'ehi': 405., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_1 = [REGION_1]
POSITIONS_2 = [435]
REGION_2 = {'name': 'Ag 3d', 'elo': 53., 'ehi': 67., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_2 = [REGION_2]
POSITIONS_dummy = [300]
REGION_dummy = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_dummy = [REGION_dummy]
POSITIONS_3 = [300]
REGION_3 = {'name': 'Si 2p', 'elo': 193., 'ehi': 200., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_3 = [REGION_3]
POSITIONS_4 = [300]
REGION_4 = {'name': 'Si 2s', 'elo': 140., 'ehi': 150., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_4 = [REGION_4]
POSITIONS_5 = [300]
REGION_5 = {'name': 'Ag 4s', 'elo': 198., 'ehi': 208., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 3, 'cis': True}
REGIONS_5 = [REGION_5]
POSITIONS_6 = [300]
REGION_6 = {'name': 'Ge 3s', 'elo': 110., 'ehi': 119., 'estep': 0.05, 'epass': 100, 'tstep': 0.5, 'iter': 8, 'cis': True}
REGIONS_6 = [REGION_6]
POSITIONS_7 = [70]
REGION_7 = {'name': 'VB', 'elo': 55., 'ehi': 68., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_7 = [REGION_7]
POSITIONS_dummy2 = [650]
REGION_dummy2 = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_dummy2 = [REGION_dummy2]
POSITIONS_8 = [650]
REGION_8 = {'name': 'O 1s', 'elo': 109., 'ehi': 119., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 4, 'cis': True}
REGIONS_8 = [REGION_8]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}: Polar = {pol}, Azimuth = {azm}, x = {X}, y = {Y}, z = {Z}".format(self.scan_index,pol=self.sample_pos[0],azm=self.sample_pos[1],X=self.sample_pos[2],Y=self.sample_pos[3],Z=self.sample_pos[4])
ephot = Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
else:
edelta = 0.0
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency, sample_position):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.sample_pos = sample_position
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
#set_attribute(get_exec_pars().scanPath + + "region{0}/Polar".format(index + 1), "Polar", polar)
#set_attribute(get_exec_pars().scanPath + + "region{0}/Azimuth".format(index + 1), "Azimuth", azimuth)
try:
setup_live_plots(REGIONS_B)
task = fork(update_live_plots)
#theta (polar), phi (azimuth), x, y, z
sample_pos = [[-9.1,-90.0,0.7, -0.4, 115.0],
[-9.1,-90.0,0.6, -0.4, 116.0],
[-9.1,-90.0,0.5, -0.5, 116.0],
[-9.1,-90.0,0.5, -0.4, 116.0]]
for (index, nn) in enumerate(sample_pos):
polar = nn[0]
azimuth = nn[1]
ManipulatorX.move(nn[2])
ManipulatorY.move(nn[3])
ManipulatorZ.move(nn[4])
ManipulatorTheta.move(polar)
#ManipulatorPhi.move(nn[1])
if index == 0:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_1, REGIONS_1, LATENCY, nn)
do_scan(MOTORS, POSITIONS_2, REGIONS_2, LATENCY, nn)
elif index == 1:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_dummy, REGIONS_dummy, LATENCY, nn)
do_scan(MOTORS, POSITIONS_3, REGIONS_3, LATENCY, nn)
elif index == 2:
do_scan(MOTORS, POSITIONS_4, REGIONS_4, LATENCY, nn)
do_scan(MOTORS, POSITIONS_5, REGIONS_5, LATENCY, nn)
elif index == 3:
#do_scan(MOTORS, POSITIONS_6, REGIONS_6, LATENCY, nn)
do_scan(MOTORS, POSITIONS_7, REGIONS_7, LATENCY, nn)
do_scan(MOTORS, POSITIONS_dummy2, REGIONS_dummy2, LATENCY, nn)
do_scan(MOTORS, POSITIONS_8, REGIONS_8, LATENCY, nn)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,239 +0,0 @@
"""
Arguments:
Ge/Si/Cu
"""
LATENCY = 0.0
MOTORS = [Eph]
#workfunction = 4.3eV
#262eV : KE = 70eV for B 1s
#200eV : KE = 70eV for Ge 3p
POSITIONS_1 = [435]
REGION_1 = {'name': 'Ge 3d', 'elo': 398., 'ehi': 405., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_1 = [REGION_1]
POSITIONS_2 = [435]
REGION_2 = {'name': 'Cu 3p', 'elo': 349., 'ehi': 360., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_2 = [REGION_2]
POSITIONS_dummy = [300]
REGION_dummy = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_dummy = [REGION_dummy]
POSITIONS_3 = [300]
REGION_3 = {'name': 'Si 2p', 'elo': 193., 'ehi': 200., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_3 = [REGION_3]
POSITIONS_4 = [300]
REGION_4 = {'name': 'Si 2s', 'elo': 140., 'ehi': 150., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_4 = [REGION_4]
POSITIONS_5 = [300]
REGION_5 = {'name': 'Cu 3p', 'elo': 210., 'ehi': 230., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 8, 'cis': True}
REGIONS_5 = [REGION_5]
POSITIONS_6 = [300]
REGION_6 = {'name': 'Ge 3s', 'elo': 110., 'ehi': 119., 'estep': 0.05, 'epass': 100, 'tstep': 0.5, 'iter': 8, 'cis': True}
REGIONS_6 = [REGION_6]
POSITIONS_7 = [70]
REGION_7 = {'name': 'VB', 'elo': 55., 'ehi': 68., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 10, 'cis': True}
REGIONS_7 = [REGION_7]
POSITIONS_dummy2 = [650]
REGION_dummy2 = {'name': 'dummy', 'elo': 398., 'ehi': 405., 'estep': 1, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': True}
REGIONS_dummy2 = [REGION_dummy2]
POSITIONS_8 = [650]
REGION_8 = {'name': 'O 1s', 'elo': 109., 'ehi': 119., 'estep': 0.05, 'epass': 10, 'tstep': 0.5, 'iter': 8, 'cis': True}
REGIONS_8 = [REGION_8]
CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}: Polar = {pol}, Azimuth = {azm}, x = {X}, y = {Y}, z = {Z}".format(self.scan_index,pol=self.sample_pos[0],azm=self.sample_pos[1],X=self.sample_pos[2],Y=self.sample_pos[3],Z=self.sample_pos[4])
ephot = Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
else:
edelta = 0.0
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
Scienta.update()
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency, sample_position):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.sample_pos = sample_position
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
#set_attribute(get_exec_pars().scanPath + + "region{0}/Polar".format(index + 1), "Polar", polar)
#set_attribute(get_exec_pars().scanPath + + "region{0}/Azimuth".format(index + 1), "Azimuth", azimuth)
try:
setup_live_plots(REGIONS_B)
task = fork(update_live_plots)
# theta (polar), phi (azimuth), x, y, z
sample_pos = [[-9.1,-90.0,0.7, -0.4, 115.0],
[-9.1,-90.0,0.6, -0.4, 116.0],
[-9.1,-90.0,0.5, -0.5, 116.0],
[-9.1,-90.0,0.5, -0.4, 116.0]]
for (index, nn) in enumerate(sample_pos):
polar = nn[0]
azimuth = nn[1]
ManipulatorX.move(nn[2])
ManipulatorY.move(nn[3])
ManipulatorZ.move(nn[4])
ManipulatorTheta.move(polar)
#ManipulatorPhi.move(nn[1])
if index == 0:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_1, REGIONS_1, LATENCY, nn)
do_scan(MOTORS, POSITIONS_2, REGIONS_2, LATENCY, nn)
elif index == 1:
#do_scan(MOTORS, POSITIONS_QUICK, REGIONS_QUICK, LATENCY, nn)
do_scan(MOTORS, POSITIONS_dummy, REGIONS_dummy, LATENCY, nn)
do_scan(MOTORS, POSITIONS_3, REGIONS_3, LATENCY, nn)
elif index == 2:
do_scan(MOTORS, POSITIONS_4, REGIONS_4, LATENCY, nn)
do_scan(MOTORS, POSITIONS_5, REGIONS_5, LATENCY, nn)
elif index == 3:
do_scan(MOTORS, POSITIONS_6, REGIONS_6, LATENCY, nn)
do_scan(MOTORS, POSITIONS_7, REGIONS_7, LATENCY, nn)
do_scan(MOTORS, POSITIONS_dummy2, REGIONS_dummy2, LATENCY, nn)
do_scan(MOTORS, POSITIONS_8, REGIONS_8, LATENCY, nn)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()

View File

@@ -1,41 +0,0 @@
"""
parallel photon energy and manipulator scan
"""
import math
global VECTOR, SENSORS
MODE = "swept"
LATENCY = 0.0
SENSORS = [Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent]
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
#writables = (Eph, Scienta.lowEnergy, Scienta.highEnergy, ManipulatorZ)
writables = (Eph, Scienta.lowEnergy, Scienta.highEnergy, ManipulatorZ)
adjust_sensors()
set_adc_averaging()
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
n = 36
Estep=2.0
#Zstart=114.9
#Zstep=-0.00
Estart=130.0
Ewidth=19.5
try:
eph = [Estart + i * Estep for i in range(n)]
elo = [Estart-Ewidth + i * Estep for i in range(n)]
ehi = [Estart-0.5 + i * Estep for i in range(n)]
#z = [Zstart + i * Zstep for i in range(n)]
z = [111.6]*10+[111.7]*10+[111.8]*10+[111.9]*6
VECTOR = [[eph[i], elo[i], ehi[i], z[i]] for i in range(len(eph))]
vscan(writables, SENSORS, VECTOR, True, LATENCY, False, before_read=before_readout, after_read = after_readout)
finally:
after_scan()

View File

@@ -1,373 +0,0 @@
"""
Discrete scan (vector scan) of multiple spectral regions
"""
PHI_RANGE = (-160.0, 160.0) # (tuple (min, max))
THETA_RANGE = (-9.0, 81.0) # (tuple (min, max))
STEPS = (40.0, 1.0) # (tuple (phi, theta))
ZIGZAG = True
# scan positioner: Eph = photon energy
#MOTORS = (ManipulatorPhi, ManipulatorTheta)
#MOTORS = [ManipulatorPhi]
MOTORS = [dummy]
# comma-separated discrete list of scan positions
#POSITIONS = [(PHI_RA
#POSITIONS = [(PNGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS]
#POSITIONS = [-175., 180., 5.]
POSITIONS = [0.]
# seconds to wait between positioning command and triggering the detector
LATENCY = 0.0
# region setup
#
# for each region, define a python dictionary with the following items.
# optional items can be left unspecified and will default to the indicated values.
# for swept mode, include 'elo', 'ehi', 'estep', 'iter' values, but do not include 'efix'.
# for fixed mode, include 'efix' value, but do not include 'elo', 'ehi', 'estep', 'iter'.
#
# 'name': user-specific name of the region (for graph title and RegionName attribute in data file)
# 'elo': lower kinetic energy boundary of the spectrum
# 'ehi': upper kinetic energy boundary of the spectrum
# 'estep': energy step size
# 'efix': center kinetic energy in fixed mode
# 'epass': pass energy
# 'tstep': dwell time in seconds
# 'iter': number of iterations/sweeps (default 1)
# 'cis': True = constant initial state (photoemission line), False = constant final state (Auger peak), (default False)
# 'slit': exit slit (default current value)
#REGION1 = {'name': 'VB62eV', 'ephot': 62, 'efix': 1222.1, 'epass': 200., 'tstep': 20., 'iter': 1, 'cis': False}
#REGION2 = {'name': 'off-resonance', 'ephot': 1235.0, 'efix': 1219.4, 'epass': 200., 'tstep': 20., 'iter': 1, 'cis': False}
#REGION1 = {'name': 'VB62eV', 'ephot': 62, 'elo': 49.0, 'ehi': 58.0, 'estep': 0.002, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': False}
#REGION1 = {'name': 'VB62eVzoom', 'elo': 54.0, 'ehi': 58.0, 'estep': 0.002, 'epass': 10.0, 'tstep': 0.5, 'iter': 1, 'cis': True}
######### X-TREME samples ##############
# front end 4x6 mm2
# Ephot = 62 eV; if 'ephot' is not specified in the region, it will not be set!!
REG1 = {'name': '62eV_VBcoarse', 'elo': 49.0, 'ehi': 58.0, 'estep': 0.002, 'epass': 10., 'tstep': 0.5, 'iter': 1, 'slit' : 100, 'cis': True}
REG2 = {'name': '62eV_VBzoom', 'elo': 54.0, 'ehi': 58.0, 'estep': 0.002, 'epass': 10., 'tstep': 0.5, 'iter': 1, 'slit' : 100, 'cis': True}
REGIONS = [REG2, REG1]
#REGIONS = [REG1, REG2]
"""
DO NOT DO 80 eV ANY MORE # front end 3x4 mm2
# Ephot = 80 eV; if 'ephot' is not specified in the region, it will not be set!!
REG1 = {'name': 'VB_80eV_coarse', 'elo': 67.0, 'ehi': 76.0, 'estep': 0.002, 'epass': 10., 'tstep': 0.5, 'iter': 1, 'slit' : 50, 'cis': True}
REG2 = {'name': 'VB_80eV_zoom', 'elo': 72.0, 'ehi': 76.0, 'estep': 0.002, 'epass': 10., 'tstep': 0.5, 'iter': 2, 'slit' : 50, 'cis': True}
REGIONS = [REG1, REG2]
"""
"""
# front end 3x4 mm2
# Ephot = 510 eV; if 'ephot' is not specified in the region, it will not be set!!
REG1 = {'name': '510eV_Dy4d', 'elo': 340.0, 'ehi': 360.0, 'estep': 0.05, 'epass': 20., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
REG2 = {'name': '510eV_Ag3d', 'elo': 127.0, 'ehi': 141.0, 'estep': 0.05, 'epass': 20., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
REGIONS = [REG1, REG2]
"""
"""
# front end 3x4 mm2
# Ephot = 490 eV; if 'ephot' is not specified in the region, it will not be set!!
REG1 = {'name': '490eV_Dy4d', 'elo': 320.0, 'ehi': 340.0, 'estep': 0.05, 'epass': 20., 'tstep': 0.5, 'iter': 3, 'slit' : 100, 'cis': True}
#REG2 = {'name': '490eV_Ag3d', 'elo': 107.0, 'ehi': 121.0, 'estep': 0.05, 'epass': 20., 'tstep': 0.5, 'iter': 1, 'slit' : 100, 'cis': True}
REGIONS = [REG1]
"""
"""
# front end 3x4 mm2
# Ephot = 810 eV; if 'ephot' is not specified in the region, it will not be set!!
REG1 = {'name': '810eV_Tb4d', 'elo': 644.0, 'ehi': 662.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.5, 'iter': 5, 'slit' : 100, 'cis': True}
REG2 = {'name': '810eV_Ag3d', 'elo': 427.0, 'ehi': 441.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
REGIONS = [REG1]
"""
"""
# front end 3x4 mm2
# Ephot = 810 eV; if 'ephot' is not specified in the region, it will not be set!!
REG1 = {'name': '810eV_survey', 'elo': 60.0, 'ehi': 810.0, 'estep': 0.5, 'epass': 50., 'tstep': 0.25, 'iter': 1, 'slit' : 30, 'cis': True}
REG2 = {'name': '810eV_Ag3d', 'elo': 427.0, 'ehi': 441.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.2, 'iter': 1, 'slit' : 30, 'cis': True}
REG3 = {'name': '810eV_O1s', 'elo': 270.0, 'ehi': 280.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
#REG4 = {'name': '810eV_N1s', 'elo': 400.0, 'ehi': 416.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
REG4 = {'name': '810eV_N1s', 'elo': 400.0, 'ehi': 416.0, 'estep': 0.05, 'epass': 50., 'tstep': 1, 'iter': 2, 'slit' : 30, 'cis': True}
REG5 = {'name': '810eV_C1s', 'elo': 512.0, 'ehi': 528.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.5, 'iter': 2, 'slit' : 30, 'cis': True}
###REGVB_NaClcoarse = {'name': '810eV_VBcoarse', 'elo': 793.0, 'ehi': 807.0, 'estep': 0.02, 'epass': 50., 'tstep': 0.5, 'iter': 1, 'slit' : 100, 'cis': True}
###REGVB_NaClfine = {'name': '810eV_VBfine', 'elo': 802.0, 'ehi': 807.0, 'estep': 0.01, 'epass': 50., 'tstep': 0.5, 'iter': 2, 'slit' : 100, 'cis': True}
REG7 = {'name': '810eV_VBzoom', 'elo': 804.0, 'ehi': 806.0, 'estep': 0.005, 'epass': 50., 'tstep': 0.5, 'iter': 1, 'slit' : 50, 'cis': True}
#REGchlorine2s = {'name': '810eV_chlorine2s', 'elo': 528.0, 'ehi': 549.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
#REGchlorine2p = {'name': '810eV_chlorine2p', 'elo': 600.0, 'ehi': 609.0, 'estep': 0.05, 'epass': 50., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
#with NaCl
#REGIONS = [REG1, REG2, REG3, REG4b, REG5, REGchlorine2s, REGchlorine2p]
#REGIONS = [REG4b, REG5, REGVB_NaClcoarse, REGVB_NaClfine]
#with MgO
REGIONS = [REG1, REG2, REG3, REG4, REG5, REG7]
##REGIONS = [REGVB_NaClfine]
"""
"""
# Ephot = 1600 eV; if 'ephot' is not specified in the region, it will not be set!!
# front end 3x4 mm2
REGsurvey = {'name': '1600eV_survey', 'elo': 100.0, 'ehi': 1600.0, 'estep': 0.5, 'epass': 100., 'tstep': 0.25, 'iter': 1, 'slit' : 50, 'cis': True}
REGMg = {'name': '1600eV_Mg1s' , 'elo': 286.0, 'ehi': 300.0, 'estep': 0.02, 'epass': 100., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
REGAg = {'name': '1600eV_Ag3d1' , 'elo': 1219.0, 'ehi': 1231.0, 'estep': 0.02, 'epass': 100., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
REGNa = {'name': '1600eV_Na1s' , 'elo': 517.0, 'ehi': 531.0, 'estep': 0.02, 'epass': 100., 'tstep': 0.5, 'iter': 1, 'slit' : 30, 'cis': True}
#REGIONS = [REGsurvey, REGMg, REGAg]
#REGIONS = [REGsurvey, REGNa, REGAg] # for NaCl/Ag
REGIONS = [REGsurvey, REGAg]
"""
"""
# list of region dictionaries to execute at each scan position
#REGIONS = [REG1, REG2]
# close beam shutter and turn off analyser at the end of the scan
CLOSE_SHUTTER_AT_END = False
"""
# --- DO NOT EDIT BELOW THIS LINE! ---
set_exec_pars(keep=False)
def check_region(region):
"""
check region dictionary items and apply defaults where necessary
"""
region['fixed'] = 'efix' in region
if region['fixed']:
region['elo'] = region['efix']
region['ehi'] = region['efix']
if 'iter' not in region:
region['iter'] = 1
print("region {0}: setting default iter = {1}".format(region['name'], region['iter']))
if 'cis' not in region:
region['cis'] = False
print("region {0}: setting default cis = {1}".format(region['name'], region['cis']))
if 'slit' not in region:
region['slit'] = ExitSlit.read()
print("region {0}: setting default slit = {1}".format(region['name'], region['slit']))
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
self.channel_begin_dataset_name = path + "ScientaChannelBegin"
self.channel_end_dataset_name = path + "ScientaChannelEnd"
self.channel_center_dataset_name = path + "ScientaChannelCenter"
self.pass_energy_dataset_name = path + "ScientaPassEnergy"
self.step_energy_dataset_name = path + "ScientaStepEnergy"
self.step_time_dataset_name = path + "ScientaStepTime"
self.iterations_dataset_name = path + "ScientaIterations"
self.slit_dataset_name = path + "ExitSlit"
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
create_dataset(self.channel_center_dataset_name, 'd')
create_dataset(self.pass_energy_dataset_name, 'd')
create_dataset(self.step_energy_dataset_name, 'd')
create_dataset(self.step_time_dataset_name, 'd')
create_dataset(self.iterations_dataset_name, 'd')
create_dataset(self.slit_dataset_name, 'd')
def setup(self):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}".format(self.scan_index)
#ephot = Eph.read()
#try:
# if self.region['cis']:
# edelta = ephot - self.ephot_start
# else:
# edelta = 0.0
#except AttributeError:
# self.ephot_start = ephot
edelta = 0.0
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
try:
Eph.write(self.region['ephot'])
except KeyError:
pass
if self.region['fixed']:
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed)
Scienta.centerEnergy.write(elo)
else:
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(int(self.region['epass']))
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
ExitSlit.write(self.region['slit'])
Scienta.update()
if self.region['fixed']:
append_dataset(self.channel_center_dataset_name, elo)
else:
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
append_dataset(self.step_energy_dataset_name, self.region['estep'])
append_dataset(self.pass_energy_dataset_name, self.region['epass'])
append_dataset(self.step_time_dataset_name, self.region['tstep'])
append_dataset(self.iterations_dataset_name, self.region['iter'])
append_dataset(self.slit_dataset_name, self.region['slit'])
def read(self):
global current_region_index
current_region_index = self.region_index
self.setup()
print("Acquiring region {0}.".format(self.region['name']))
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
return sp
def getSize(self):
if self.region['fixed']:
nx = 992
else:
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def read(self):
return Scienta.getDataMatrix().read()
def getWidth(self):
if self.region['fixed']:
nx = 992
else:
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
return nx
def getHeight(self):
ny = Scienta.slices.read()
return ny
def setup_live_plots(regions):
global live_plots
global current_region_index
names = [region['name'] for region in regions]
live_plots = plot(None, names, title="Live Spectra")
current_region_index = 0
def update_live_plots():
global live_plots
global current_region_index
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
x = Scienta.spectrumX
try:
series = live_plots[current_region_index].getSeries(0)
series.setData(x, y)
except IndexError:
pass
time.sleep(1.0)
finally:
print "Stopping live spectra"
def do_scan(motors, positions, regions, latency):
global SENSORS
SENSORS = []
for (index, region) in enumerate(regions):
check_region(region)
reader = SpectrumReader()
reader.region_index = index
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()
#ascan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, zigzag = True, before_read=wait_beam, after_read = after_readout)
#lscan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, before_read=wait_beam, after_read = after_readout)
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name'])
set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions])
try:
################## THIS IS TO OPEN THE VALVES /SHUTTER
if caget('X03DA-OP-VG7:OPEN') == 'Not_Open':
caput('X03DA-OP-VG7:WT_SET',0) #open ES vacuum valve
time.sleep(0.2)
caput('X03DA-OP-VG7:WT_SET',1) #open ES vacuum valve
"""
caput('X03DA-OP-ST1:WT_SET_CLOSE',0) #
caput('X03DA-OP-ST1:WT_SET_OPEN',1) # open ES Shutter
print "check that shutter is open..."
while True:
if caget('X03DA-OP-ST1:OPEN') == 'Open':
break
time.sleep(0.5)
print "OK."
time.sleep(3.0)
############################################# """
setup_live_plots(REGIONS)
task = fork(update_live_plots)
do_scan(MOTORS, POSITIONS, REGIONS, LATENCY)
finally:
caput('X03DA-OP-VG7:WT_SET',1) #close ES vacuum valve
time.sleep(0.2)
caput('X03DA-OP-VG7:WT_SET',0) #close ES vacuum valve
if CLOSE_SHUTTER_AT_END:
after_scan()