Implemented logic to move goniometer to correct position. Disabled XAS with XRD scans

This commit is contained in:
x10da
2026-04-01 10:54:50 +02:00
parent 34c523c03f
commit c420675cc2
+172 -142
View File
@@ -57,6 +57,36 @@ class XASSimpleScan(AsyncFlyScanBase):
self.scan_duration = scan_duration
self.primary_readout_cycle = 1
def stage(self):
"""call the stage procedure"""
# Compute position for mo1_gonio pre move
# Since energy is not linear to angle, we have to calculate the angles first.
pos_start = yield from self.stubs.send_rpc_and_wait(
"mo1_bragg",
"convert_angle_energy",
mode = "EnergyToAngle",
inp = self.start,
)
pos_end = yield from self.stubs.send_rpc_and_wait(
"mo1_bragg",
"convert_angle_energy",
mode = "EnergyToAngle",
inp = self.stop,
)
# Goniometer position is in the middle of the start and stop angle of the scan
pos = (pos_start + pos_end) / 2
# Premove with mo1_gonio
yield from self.stubs.send_rpc_and_wait(
"mo1_gonio",
"move",
position = pos,
wait = True,
timeout = 30, # 30 seconds timeout
)
# Continue with staging the devices
yield from self.stubs.stage()
def update_readout_priority(self):
"""Ensure that NIDAQ is not monitored for any quick EXAFS."""
super().update_readout_priority()
@@ -101,75 +131,75 @@ class XASSimpleScan(AsyncFlyScanBase):
self.num_pos = self.point_id
class XASSimpleScanWithXRD(XASSimpleScan):
"""Class for the XAS simple scan with XRD"""
# class XASSimpleScanWithXRD(XASSimpleScan):
# """Class for the XAS simple scan with XRD"""
scan_name = "xas_simple_scan_with_xrd"
gui_config = {
"Movement Parameters": ["start", "stop"],
"Scan Parameters": ["scan_time", "scan_duration"],
"Low Energy Range": ["xrd_enable_low", "num_trigger_low", "exp_time_low", "cycle_low"],
"High Energy Range": ["xrd_enable_high", "num_trigger_high", "exp_time_high", "cycle_high"],
}
# scan_name = "xas_simple_scan_with_xrd"
# gui_config = {
# "Movement Parameters": ["start", "stop"],
# "Scan Parameters": ["scan_time", "scan_duration"],
# "Low Energy Range": ["xrd_enable_low", "num_trigger_low", "exp_time_low", "cycle_low"],
# "High Energy Range": ["xrd_enable_high", "num_trigger_high", "exp_time_high", "cycle_high"],
# }
def __init__(
self,
start: float,
stop: float,
scan_time: float,
scan_duration: float,
xrd_enable_low: bool,
num_trigger_low: int,
exp_time_low: float,
cycle_low: int,
xrd_enable_high: bool,
num_trigger_high: int,
exp_time_high: float,
cycle_high: float,
motor: DeviceBase = "mo1_bragg",
**kwargs,
):
"""The xas_simple_scan_with_xrd is an oscillation motion on the mono motor
with XRD triggering at low and high energy ranges.
If scan duration is set to 0, the scan will run infinitely.
# def __init__(
# self,
# start: float,
# stop: float,
# scan_time: float,
# scan_duration: float,
# xrd_enable_low: bool,
# num_trigger_low: int,
# exp_time_low: float,
# cycle_low: int,
# xrd_enable_high: bool,
# num_trigger_high: int,
# exp_time_high: float,
# cycle_high: float,
# motor: DeviceBase = "mo1_bragg",
# **kwargs,
# ):
# """The xas_simple_scan_with_xrd is an oscillation motion on the mono motor
# with XRD triggering at low and high energy ranges.
# If scan duration is set to 0, the scan will run infinitely.
Args:
start (float): Start energy for the scan.
stop (float): Stop energy for the scan.
scan_time (float): Time for one oscillation .
scan_duration (float): Total duration of the scan.
xrd_enable_low (bool): Enable XRD triggering for the low energy range.
num_trigger_low (int): Number of triggers for the low energy range.
exp_time_low (float): Exposure time for the low energy range.
cycle_low (int): Specify how often the triggers should be considered,
every nth cycle for low
xrd_enable_high (bool): Enable XRD triggering for the high energy range.
num_trigger_high (int): Number of triggers for the high energy range.
exp_time_high (float): Exposure time for the high energy range.
cycle_high (int): Specify how often the triggers should be considered,
every nth cycle for high
motor (DeviceBase, optional): Motor device to be used for the scan.
Defaults to "mo1_bragg".
# Args:
# start (float): Start energy for the scan.
# stop (float): Stop energy for the scan.
# scan_time (float): Time for one oscillation .
# scan_duration (float): Total duration of the scan.
# xrd_enable_low (bool): Enable XRD triggering for the low energy range.
# num_trigger_low (int): Number of triggers for the low energy range.
# exp_time_low (float): Exposure time for the low energy range.
# cycle_low (int): Specify how often the triggers should be considered,
# every nth cycle for low
# xrd_enable_high (bool): Enable XRD triggering for the high energy range.
# num_trigger_high (int): Number of triggers for the high energy range.
# exp_time_high (float): Exposure time for the high energy range.
# cycle_high (int): Specify how often the triggers should be considered,
# every nth cycle for high
# motor (DeviceBase, optional): Motor device to be used for the scan.
# Defaults to "mo1_bragg".
Examples:
>>> scans.xas_simple_scan_with_xrd(start=8000, stop=9000, scan_time=1, scan_duration=10, xrd_enable_low=True, num_trigger_low=5, cycle_low=2, exp_time_low=100, xrd_enable_high=False, num_trigger_high=3, cycle_high=1, exp_time_high=1000)
"""
super().__init__(
start=start,
stop=stop,
scan_time=scan_time,
scan_duration=scan_duration,
motor=motor,
**kwargs,
)
self.xrd_enable_low = xrd_enable_low
self.num_trigger_low = num_trigger_low
self.exp_time_low = exp_time_low
self.cycle_low = cycle_low
self.xrd_enable_high = xrd_enable_high
self.num_trigger_high = num_trigger_high
self.exp_time_high = exp_time_high
self.cycle_high = cycle_high
# Examples:
# >>> scans.xas_simple_scan_with_xrd(start=8000, stop=9000, scan_time=1, scan_duration=10, xrd_enable_low=True, num_trigger_low=5, cycle_low=2, exp_time_low=100, xrd_enable_high=False, num_trigger_high=3, cycle_high=1, exp_time_high=1000)
# """
# super().__init__(
# start=start,
# stop=stop,
# scan_time=scan_time,
# scan_duration=scan_duration,
# motor=motor,
# **kwargs,
# )
# self.xrd_enable_low = xrd_enable_low
# self.num_trigger_low = num_trigger_low
# self.exp_time_low = exp_time_low
# self.cycle_low = cycle_low
# self.xrd_enable_high = xrd_enable_high
# self.num_trigger_high = num_trigger_high
# self.exp_time_high = exp_time_high
# self.cycle_high = cycle_high
class XASAdvancedScan(XASSimpleScan):
@@ -225,84 +255,84 @@ class XASAdvancedScan(XASSimpleScan):
self.e_kink = e_kink
class XASAdvancedScanWithXRD(XASAdvancedScan):
"""Class for the XAS advanced scan with XRD"""
# class XASAdvancedScanWithXRD(XASAdvancedScan):
# """Class for the XAS advanced scan with XRD"""
scan_name = "xas_advanced_scan_with_xrd"
gui_config = {
"Movement Parameters": ["start", "stop"],
"Scan Parameters": ["scan_time", "scan_duration"],
"Spline Parameters": ["p_kink", "e_kink"],
"Low Energy Range": ["xrd_enable_low", "num_trigger_low", "exp_time_low", "cycle_low"],
"High Energy Range": ["xrd_enable_high", "num_trigger_high", "exp_time_high", "cycle_high"],
}
# scan_name = "xas_advanced_scan_with_xrd"
# gui_config = {
# "Movement Parameters": ["start", "stop"],
# "Scan Parameters": ["scan_time", "scan_duration"],
# "Spline Parameters": ["p_kink", "e_kink"],
# "Low Energy Range": ["xrd_enable_low", "num_trigger_low", "exp_time_low", "cycle_low"],
# "High Energy Range": ["xrd_enable_high", "num_trigger_high", "exp_time_high", "cycle_high"],
# }
def __init__(
self,
start: float,
stop: float,
scan_time: float,
scan_duration: float,
p_kink: float,
e_kink: float,
xrd_enable_low: bool,
num_trigger_low: int,
exp_time_low: float,
cycle_low: int,
xrd_enable_high: bool,
num_trigger_high: int,
exp_time_high: float,
cycle_high: float,
motor: DeviceBase = "mo1_bragg",
**kwargs,
):
"""The xas_advanced_scan is an oscillation motion on the mono motor
with XRD triggering at low and high energy ranges.
Start and Stop define the energy range for the scan, scan_time is the time for
one scan cycle and scan_duration is the duration of the scan. If scan duration
is set to 0, the scan will run infinitely. p_kink and e_kink add a kink to the
motion profile to slow down in the exafs region of the scan.
# def __init__(
# self,
# start: float,
# stop: float,
# scan_time: float,
# scan_duration: float,
# p_kink: float,
# e_kink: float,
# xrd_enable_low: bool,
# num_trigger_low: int,
# exp_time_low: float,
# cycle_low: int,
# xrd_enable_high: bool,
# num_trigger_high: int,
# exp_time_high: float,
# cycle_high: float,
# motor: DeviceBase = "mo1_bragg",
# **kwargs,
# ):
# """The xas_advanced_scan is an oscillation motion on the mono motor
# with XRD triggering at low and high energy ranges.
# Start and Stop define the energy range for the scan, scan_time is the time for
# one scan cycle and scan_duration is the duration of the scan. If scan duration
# is set to 0, the scan will run infinitely. p_kink and e_kink add a kink to the
# motion profile to slow down in the exafs region of the scan.
Args:
start (float): Start angle for the scan.
stop (float): Stop angle for the scan.
scan_time (float): Time for one oscillation .
scan_duration (float): Total duration of the scan.
p_kink (float): Position of kink.
e_kink (float): Energy of the kink.
xrd_enable_low (bool): Enable XRD triggering for the low energy range.
num_trigger_low (int): Number of triggers for the low energy range.
exp_time_low (float): Exposure time for the low energy range.
cycle_low (int): Specify how often the triggers should be considered,
every nth cycle for low
xrd_enable_high (bool): Enable XRD triggering for the high energy range.
num_trigger_high (int): Number of triggers for the high energy range.
exp_time_high (float): Exposure time for the high energy range.
cycle_high (int): Specify how often the triggers should be considered,
every nth cycle for high
motor (DeviceBase, optional): Motor device to be used for the scan.
Defaults to "mo1_bragg".
# Args:
# start (float): Start angle for the scan.
# stop (float): Stop angle for the scan.
# scan_time (float): Time for one oscillation .
# scan_duration (float): Total duration of the scan.
# p_kink (float): Position of kink.
# e_kink (float): Energy of the kink.
# xrd_enable_low (bool): Enable XRD triggering for the low energy range.
# num_trigger_low (int): Number of triggers for the low energy range.
# exp_time_low (float): Exposure time for the low energy range.
# cycle_low (int): Specify how often the triggers should be considered,
# every nth cycle for low
# xrd_enable_high (bool): Enable XRD triggering for the high energy range.
# num_trigger_high (int): Number of triggers for the high energy range.
# exp_time_high (float): Exposure time for the high energy range.
# cycle_high (int): Specify how often the triggers should be considered,
# every nth cycle for high
# motor (DeviceBase, optional): Motor device to be used for the scan.
# Defaults to "mo1_bragg".
Examples:
>>> scans.xas_advanced_scan_with_xrd(start=10000, stop=12000, scan_time=0.5, scan_duration=10, p_kink=50, e_kink=10500, xrd_enable_low=True, num_trigger_low=5, cycle_low=2, exp_time_low=100, xrd_enable_high=False, num_trigger_high=3, cycle_high=1, exp_time_high=1000)
"""
super().__init__(
start=start,
stop=stop,
scan_time=scan_time,
scan_duration=scan_duration,
p_kink=p_kink,
e_kink=e_kink,
motor=motor,
**kwargs,
)
self.p_kink = p_kink
self.e_kink = e_kink
self.xrd_enable_low = xrd_enable_low
self.num_trigger_low = num_trigger_low
self.exp_time_low = exp_time_low
self.cycle_low = cycle_low
self.xrd_enable_high = xrd_enable_high
self.num_trigger_high = num_trigger_high
self.exp_time_high = exp_time_high
self.cycle_high = cycle_high
# Examples:
# >>> scans.xas_advanced_scan_with_xrd(start=10000, stop=12000, scan_time=0.5, scan_duration=10, p_kink=50, e_kink=10500, xrd_enable_low=True, num_trigger_low=5, cycle_low=2, exp_time_low=100, xrd_enable_high=False, num_trigger_high=3, cycle_high=1, exp_time_high=1000)
# """
# super().__init__(
# start=start,
# stop=stop,
# scan_time=scan_time,
# scan_duration=scan_duration,
# p_kink=p_kink,
# e_kink=e_kink,
# motor=motor,
# **kwargs,
# )
# self.p_kink = p_kink
# self.e_kink = e_kink
# self.xrd_enable_low = xrd_enable_low
# self.num_trigger_low = num_trigger_low
# self.exp_time_low = exp_time_low
# self.cycle_low = cycle_low
# self.xrd_enable_high = xrd_enable_high
# self.num_trigger_high = num_trigger_high
# self.exp_time_high = exp_time_high
# self.cycle_high = cycle_high