Updated Absorption Spectrum scan

This commit is contained in:
gac-x11ma
2025-12-17 09:49:26 +01:00
parent 8ecd1f36c6
commit 8278eb87d8
148 changed files with 4562 additions and 1070 deletions
+13
View File
@@ -0,0 +1,13 @@
#add_device(Positioner("AU_CX", "X11MA-OP2-AHcenter", "X11MA-OP2-AHt2.D"), True)
#add_device(Positioner("AU_CY", "X11MA-OP2-AVcenter", "X11MA-OP2-AVt2.D"), True)
#AU_CX.monitored=True
#AU_CY.monitored=True
#
#sensors = [Keithley_2_raw]
#
#ascan([AU_CX, AU_CY], sensors, [-0.5, -0.5], [0.5, 0.5], [0.1, 0.1], latency=0.5, zigzag=False)
close_FE_slits()
BML_FE_sizeX.move(0.5)
BML_FE_sizeY.move(0.5)
@@ -0,0 +1,100 @@
#Read beamline values
#Read bumps:
#X = 0 um
#X prime = 0 urad
#Y = 0 um
#Y prime = 0 urad
#
#Machine bumps:
#X = 10 um
#X prime = -10 urad
#Y = -28 um
#Y prime = 45 urad
#
#Total bumps:
#X = 10 um
#X prime = -10 urad
#Y = -28 um
#Y prime = 45 urad
#Read ID gap and mode:
ID_gap = caget("X11MA-UIND2:GAP-RBV")
ID_mode = caget("X11MA-UIND2:MODE")
# 0 Off
# 1 Linear H
# 2 Linear V+
# 3 Linear V-
# 4 Circular+
# 5 Circular-
# 6 +45 deg
# 7 -45 deg
#Read FE slit size and position:
FE_centerX = caget("X11MA-FE-SL1:CENTERX.RBV")
FE_centerY = caget("X11MA-FE-SL1:CENTERY.RBV")
FE_sizeX = caget("X11MA-FE-SL1:SIZEX.RBV")
FE_sizeY = caget("X11MA-FE-SL1:SIZEY.RBV")
#Read CMU parameters:
CMU_X = caget("X11MA-OP-CM:ox")
CMU_Y = caget("X11MA-OP-CM:oy")
CMU_Z = caget("X11MA-OP-CM:oz")
CMU_Rx = caget("X11MA-OP-CM:oRx")
CMU_Ry = caget("X11MA-OP-CM:oRy")
CMU_Rz = caget("X11MA-OP-CM:oRz")
CMU_baffle = caget("X11MA-OP2-CM:TRB.RBV")
#Read AU slit parameters:
AU_centerV = caget("X11MA-OP2-AVcenter")
AU_centerH = caget("X11MA-OP2-AHcenter")
AU_sizeV = caget("X11MA-OP2-AVsize")
AU_sizeH = caget("X11MA-OP2-AHsize")
#Read XBPM parameters:
BP1_Y_motor = caget("X11MA-OP2-BP1:TRY.RBV")
BP1_X_motor = caget("X11MA-OP2-BP1:TRX.RBV")
#Read Mono parameters:
Mono_Grating_Select = caget("X11MA-PGM:grating")
Mono_Grating_Change = caget("X11MA-PGM-GRCH:GRATING")
# 0 G1 300
# 1 G2 1200
# 2 G3 600
Mono_Diff_Order = caget("X11MA-PGM:difforder0")
# 0 1
# 1 2
# 2 3
Mono_Energy = caget("X11MA-PGM:rbkenergy")
Mono_cff = caget("X11MA-PGM:rbkcff")
Mono_theta = caget("X11MA-PGM:rbktheta")
Mono_theta_off1A = caget("X11MA-PGM:THETAOFF1.A")
Mono_theta_off1B = caget("X11MA-PGM:THETAOFF1.B")
Mono_theta_off1C = caget("X11MA-PGM:THETAOFF1.C")
Mono_theta_off2A = caget("X11MA-PGM:THETAOFF2.A")
Mono_theta_off2B = caget("X11MA-PGM:THETAOFF2.B")
Mono_theta_off2C = caget("X11MA-PGM:THETAOFF2.C")
Mono_beta = caget("X11MA-PGM:rbkbeta")
Mono_beta_off1A = caget("X11MA-PGM:BETAOFF1.A")
Mono_beta_off1B = caget("X11MA-PGM:BETAOFF1.B")
Mono_beta_off1C = caget("X11MA-PGM:BETAOFF1.C")
Mono_beta_off2A = caget("X11MA-PGM:BETAOFF2.A")
Mono_beta_off2B = caget("X11MA-PGM:BETAOFF2.B")
Mono_beta_off2C = caget("X11MA-PGM:BETAOFF2.C")
Mono_cff = caget("X11MA-PGM:rbkcff")
X11MA-PGM:grating
Energy = 827.000 eV
Cff = 1.7
Offsets see screenshot
FMU:
X = -3.6501 mm
Y = -3.2786 mm
Z = -0.2798 mm
Pitch = -0.9498 mrad
Roll = 0.1098 mrad
Yaw = 3.200 mrad
+77
View File
@@ -0,0 +1,77 @@
#add_device(Positioner("FE_CX", "X11MA-FE-SL1:CENTERX", "X11MA-FE-SL1:CENTERX.RBV"), True)
#add_device(Positioner("FE_CY", "X11MA-FE-SL1:CENTERY", "X11MA-FE-SL1:CENTERY.RBV"), True)
#FE_CX.monitored=True
#FE_CY.monitored=True
cy=FE_CY.read()
cx=FE_CX.read()
DX=0.5
DY=0.5
STEPS=0.05
xmin=cx-DX/2
xmax=cx+DX/2
ymin=cy-DY/2
ymax=cy+DY/2
#sensors = [CADC2, FE_CX, FE_CY, FE_CX_RBV, FE_CY_RBV]
detectors=(CADC2, FE_CX_RBV, FE_CY_RBV)
FE_CX.move(xmin)
FE_CX.move(xmax)
FE_CX.move(xmin)
FE_CX.move(xmax)
FE_CX.move(xmin)
FE_CX.move(xmax)
FE_CX.move(xmin)
FE_CX.move(xmax)
FE_CX.move(xmin)
FE_CX.move(xmax)
# moves to 30.0 blocking the code here until 30.0 is reached.
# FE_CX.moveAsync(xmax)
# moveAsync -> command starts the movement without blocking the code
# The code would finish, if no other command follows.
#res = tscan(detectors, 200, 0.1)
#sensors = [Keithley_2_raw, CADC2, FE_CX, FE_CX_RBV, FE_CY, FE_CY_RBV]
#detector = Keithley_2_raw
#ascan([FE_CX, FE_CY], sensors, [X_min, Y_min], [X_max, Y_max], [X_step, Y_step], latency=0.5, zigzag=True)
#ascan([FE_CX, FE_CY], sensors, [-1.0, 0.3], [0.0, 1.3], [0.1, 0.1], latency=0.5, zigzag=True)
#ascan([FE_CX, FE_CY], sensors, [xmin, ymin], [xmax, ymax], [STEPS, STEPS], latency=0.25, zigzag=True)
FE_CX.moveAsync(-0.849586500000001)
FE_CY.moveAsync(1.4759635000000015)
# Scan speed tests:
#*****************
#ascan([FE_CX, FE_CY], sensors, [-0.5, 0.45], [0.0, 1.05], [0.05, 0.05], latency=0.5, zigzag=False) Motor velocity = 0.5, 4 min 40 sec
#ascan([FE_CX, FE_CY], sensors, [-0.5, 0.45], [0.0, 1.05], [0.05, 0.05], latency=0.5, zigzag=False) Motor velocity = 1.0, 4 min 35 sec
#ascan([FE_CX, FE_CY], sensors, [-0.5, 0.45], [0.0, 1.05], [0.05, 0.05], latency=0.5, zigzag=True) Motor velocity = 1.0, 3 min 35 sec
#scan([FE_CX, FE_CY], sensors, [-0.5, 0.45], [0.0, 1.05], [0.05, 0.05], latency=0.5, zigzag=True) Motor velocity = 5.0, 3 min 32 sec
#ascan([FE_CX, FE_CY], sensors, [-0.5, 0.45], [0.0, 1.05], [0.05, 0.05], latency=0.25, zigzag=True) Motor velocity = 5.0, 2 min 53 sec
#-> for latency below 0.25, motor errors occur
# Test motor speed (on the motor panels):
#TRXR Velocity 0.5 9 secs # Default setting for all motors (TRXR, TRYB, TRXW, TRYT)
#TRXR Velocity 1.0 1 secs
#TRXR Velocity 5.0 1 secs
#caput X11MA-FE-SL1:TRXW.VELO 5.0
#result=lscan(exit_slit, detector, 20.0, -30.0, steps=1.0, relative=False, latency=2.5)
#result=tscan((exit_slit.readback,Keithley_2_raw), 100, 0.1)
#lscan(energy, sensors, 1100, 1900, 5.0, latency=0.5)
@@ -0,0 +1,42 @@
#add_device(Positioner("FE_TRXW", "X11MA-FE-SL1:TRXW", "X11MA-FE-SL1:TRXW.RBV"), True)
#FE_TRXW.monitored=True
detectors=(exit_slit.readback, CADC2)
exit_slit.move(20.0)
# moves to 20.0 blocking the code here until 20.0 is reached.
exit_slit.moveAsync(-20.0)
# moveAsync -> command starts the movement without blocking the code
# The code would finish, if no other command follows.
res = None
# need just to be known
#Monitr scan example
def after_read(record, scan): # see definition of tscan under Built-in Function in Help
global res
if abs(record[exit_slit.readback] - (-20.0)) < 1.0:
scan.abort() # No documentation available, call Alexandre
res = scan.result
#mscan(exit_slit.readback, detectors, points = -1, timeout = None, async = True, take_initial = True, after_read=after_read)
#Time scan example
try:
res = tscan(detectors, 10000, 0.01, after_read=after_read)
except ScanAbortedException:
pass # just to properly get out here / no operation
plot(res[CADC2], xdata=res[exit_slit.readback])
FE_TRXW.move(0.5)
FE_TRXW.move(0.0)
FE_TRXW.move(0.5)
FE_TRXW.move(0.0)
FE_TRXW.move(0.5)
FE_TRXW.move(0.0)
FE_TRXW.move(0.5)
FE_TRXW.move(0.0)
FE_TRXW.move(0.5)
FE_TRXW.move(0.0)
@@ -0,0 +1,15 @@
# mytools.py
from beamline_configuration import *
from collections import OrderedDict
import os
import json
from javax.swing import JFileChooser
from javax.swing.filechooser import FileNameExtensionFilter
from java.io import File
BEAMLINE_PARAMETERS_FILE = "/sls/X11MA/data/X11MA/pshell/home/script/beamline_alignment/bml_align_params.json"
DATA_FILE = "/sls/X11MA/data/X11MA/pshell/home/data/2025_11/20251113/Monocam_AU_131.json"
DATA_DIR = "/sls/X11MA/data/X11MA/scans/2511"
#DATA_FILE = "/sls/X11MA/data/X11MA/scans/2511/0081.json"
+45
View File
@@ -0,0 +1,45 @@
import os
#path, name_only = save_data_and_config(default_dir=DATA_DIR, default_name=None, save_dialog=True)
bml_save_current_settings()
output_file = os.path.join(os.path.dirname(path), "Monocam_AU_"+name_only + ".jpg")
#cmd = ["curl http://root:monocam-4@129.129.121.54/axis-cgi/jpg/image.cgi -o ", output_file]
cmd = "curl http://root:monocam-4@129.129.121.54/axis-cgi/jpg/image.cgi -o " + output_file
os.system(cmd)
#from javax.swing import JFileChooser
#from javax.swing.filechooser import FileNameExtensionFilter
#from java.io import File
#
#frame = JFrame()
#frame.setAlwaysOnTop(True) # Dialog erscheint im Vordergrund
#
#chooser = JFileChooser()
#
#default_dir = "/sls/X11MA/data/X11MA/scans/2511" # <-- deinen Pfad hier eintragen
#chooser.setCurrentDirectory(File(default_dir))
#
## Nur *.json anzeigen
#json_filter = FileNameExtensionFilter("JSON Dateien (*.json)", ["json"])
#chooser.setFileFilter(json_filter)
## Dialog anzeigen
#result = chooser.showSaveDialog(frame)
#
#if result == JFileChooser.APPROVE_OPTION:
# filename = chooser.getSelectedFile().getAbsolutePath()
# print("Speichere Datei unter:", filename)
#else:
# print("Speichern abgebrochen.")
# os.system("curl http://root:monocam-4@129.129.121.54/axis-cgi/jpg/image.cgi -o /sls/X11MA/data/X11MA/scratch/kleibert/Rz_0000_test.jpg")
#add_device(Positioner("FE_TRXW", "X11MA-FE-SL1:TRXW", "X11MA-FE-SL1:TRXW.RBV"), True)
#FE_TRXW.monitored=True
#http://129.129.121.54/axis-cgi/mjpg/video.cgi?id=0 true
#http://root:monocam-4@129.129.121.54/axis-cgi/mjpg/video.cgi?id=0 true
#os.system("curl http://root:monocam-4@129.129.121.54/axis-cgi/jpg/image.cgi -o /sls/X11MA/data/X11MA/scratch/kleibert/Rz_0000_test.jpg")
+18
View File
@@ -0,0 +1,18 @@
###################################################################################################
# Demonstrate the use of Continuous Scan Scan: a Linear Scan with continuous motor move and
# sampling on the fly.
###################################################################################################
m1.move(0.0)
#
##A single motor at current speed
#r1 = cscan(m1, (ai1,ai2), -2, 3 , steps=10, relative=True)
#
##A single motor in a given time
#r2 = cscan(m1, (ai1,ai2), -2.0, 3.0, steps=100 ,time = 4.0, relative=True)
#
##Multiple motors in a given time
#r3 = cscan((m1, m2), (ai1,ai2), (-2.0, -3), (3.0, 5.0), steps=100,time = 4.0, relative=True)
r4 = cscan([m1], [create_averager(ai1, 1, 0.05)], [-5.0], [5.0], [0.1], latency=0.0, time=5.0, relative=False, passes=1, zigzag=False, keep=False, name='Unknown')
+56
View File
@@ -0,0 +1,56 @@
data_1d = [10.0, 20.0, 30.0, 40.0, 50.0]
data_2d = [ data_1d, data_1d, data_1d, data_1d, data_1d]
data_x = [5.5, 2.0, 3.7, 4.2, 1.0]
data_y = [1.0, 1.2, 6.6, 3.0, 1.0]
#2d-plot with optional xdata and ydata
plot(data_2d, title = "2d", xdata = data_x, ydata = data_y)
#from org.jfree.chart import ChartFactory, ChartPanel
#from org.jfree.data.xy import XYSeries, XYSeriesCollection
#from javax.swing import JFrame
#
## Beispiel-Daten
#x_values = [1, 2, 3, 4, 5]
#y_values = [5, 7, 6, 8, 4]
#
## XY-Datenserie erstellen
#series = XYSeries("Messdaten")
#for x, y in zip(x_values, y_values):
# series.add(x, y)
#
#dataset = XYSeriesCollection()
#dataset.addSeries(series)
#
## Scatter-Plot erzeugen
#chart = ChartFactory.createScatterPlot(
# "Scatter Plot Beispiel",
# "X-Achse",
# "Y-Achse",
# dataset
#)
#
## --- GLEICHE SKALIERUNG FÜR X UND Y ---
#plot = chart.getXYPlot()
#x_axis = plot.getDomainAxis()
#y_axis = plot.getRangeAxis()
#
#x_min, x_max = min(x_values), max(x_values)
#y_min, y_max = min(y_values), max(y_values)
#
#range_x = x_max - x_min
#range_y = y_max - y_min
#max_range = max(range_x, range_y)
#
#x_mid = (x_min + x_max) / 2.0
#y_mid = (y_min + y_max) / 2.0
#
#x_axis.setRange(x_mid - max_range/2.0, x_mid + max_range/2.0)
#y_axis.setRange(y_mid - max_range/2.0, y_mid + max_range/2.0)
#
## Fenster anzeigen
#frame = JFrame("Plot")
#frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
#frame.setSize(800, 600)
#frame.add(ChartPanel(chart))
+49
View File
@@ -0,0 +1,49 @@
###################################################################################################
# Create a device listener to interrupt the scan
###################################################################################################
import java.lang.InterruptedException
#Create a listener to the sensor, verifying the readback values.
class ListenerAI (DeviceListener):
def onValueChanged(self, device, value, former):
if value > 1.00:
print "Value over limit-> aborting"
abort()
listenerAI = ListenerAI()
ai1.addListener(listenerAI)
#Create a listener to the sensor, verifying the readback values.
class ListenerPressure (DeviceListener):
def onValueChanged(self, device, value, former):
if value > -1.400:
print "Value over limit-> aborting"
abort()
listenerPressure = ListenerPressure()
BML_FE_CX_RBV.addListener(listenerPressure)
#Create a listener to the positioner checking the setpoint before each command is sent.
class ListenerAO (DeviceListener):
def onStateChanged(self, device, state, former):
pass
def onValueChanged(self, device, value, former):
print "Moved to: " + str(value)
def onValueChanging(self, device, value, former):
if value > 0.2:
#Vetoing the change will abort the scan
raise Exception("Forbidden move to " + str(value))
print "Moving to: " + str(value) + " ... " ,
listenerAO = ListenerAO()
ao1.addListener(listenerAO)
try:
cscan(m1, BML_FE_CX_RBV, [-5.0], [5.0], [0.1], latency=0.0, time=5.0, relative=False, passes=1, zigzag=False, keep=False, name='Unknown')
# cscan([m1], [create_averager(ai1, 1, 0.05)], [-5.0], [5.0], [0.1], latency=0.0, time=5.0, relative=False, passes=1, zigzag=False, keep=False, name='Unknown')
# lscan(ao1, (ai1), 0, 40, 200, 0.01)
#a= lscan((ao1,positioner),(ai2,wf1,averager,clock),(0,0),(40,20),20,0.1)
except java.lang.InterruptedException:
print "Aborted"
finally:
ai1.removeListener(listenerAI)
ao1.removeListener(listenerAO)