This commit is contained in:
gac-x11ma
2023-07-18 11:00:54 +02:00
parent 8488d81c80
commit 1d75bc4535
77 changed files with 2464 additions and 253 deletions

View File

@@ -0,0 +1,39 @@
import sys
from mathutils import fit_polynomial
from mathutils import PolynomialFunction
#seting parameters
sensor = 'KEI11'
if sensor == 'KEI10':
detector= keithley_1a
detector_range='X11MA-KEI10:RANGE'
elif sensor == 'KEI11':
detector= keithley_2a
detector_range='X11MA-KEI11:RANGE'
else:
print "Select a proper detector: KEI10 or KEI11."
sys.exit()
caput(detector_range, 4) # 6 --> 200 nA
exit_slit.move(30.0)
speed = exit_slit.getSpeed()
min_speed=exit_slit.getMinSpeed()
exit_slit.setSpeed(min_speed)
#scan Energy Slit
time.sleep(1)
#run('Users/PEEM/Armin/Functions/SlitCalib.py',{"Slit":exit_slit, "Slit_offset":exit_slit_offset, "detector":detector, "start":30, "end":-20.0, "step_size":1.0, "final_pos":20.0})
#cscan([girder_x], ['ca://machine_cur'], [0.16], [0.18], [0.01], latency=1.0, time=10.0, relative=False, passes=1, zigzag=False, keep=False, name='Unknown')
result=lscan([exit_slit], [detector], [30.0], [-20.0], [1.0], latency=1.0)
time.sleep(1)
#resetting parameters
caput(detector_range, 0) # 0--> AUTO
exit_slit.setSpeed(speed)

View File

@@ -0,0 +1,67 @@
###################################################################################################
# Function fitting and peak search with mathutils.py
###################################################################################################
from mathutils import fit_polynomial
from mathutils import PolynomialFunction
# Input parameters (example)
#Slit = exit_slit
#Slit_offset = exit_slit_offset
#detector = keithley_1a
#start = 30.0
#end = -20.0
#step_size = 1.0
#final_pos = 20.0
#run('beamline_init/with_x-rays/functions/SlitCalib.py',{"Slit":exit_slit, "Slit_offset":exit_slit_offset, "detector":detector, "start":30, "end":-20.0, "step_size":1.0, "final_pos":20.0})
# Execute the scan
result=lscan(Slit, detector, start, end, float(step_size))
readable_ = result[detector]
positions_ = result[Slit]
print positions_
readable=[]
positions=[]
# execute the fit
fit_threshold=readable_[0]*0.05
#filter the positions with analog values above the threshold
for i in range(8,len(positions_),1):
if(readable_[i]<fit_threshold):
readable.append(readable_[i])
positions.append(positions_[i])
pars_polynomial = (a0, a1) = fit_polynomial(readable, positions,1)
fitted_polynomial_function = PolynomialFunction(pars_polynomial)
print pars_polynomial
resolution = step_size/100
fit_polinomial = []
# from the fit function calculate the values at the positions
for x in frange(end,start,resolution, True):
fit_polinomial.append(fitted_polynomial_function.value(x))
x = frange(end, start+resolution, resolution)
# crate plots
plots = plot([readable_, fit_polinomial] , ["data", "polinomial"], xdata = [positions_,x], title="Data")
p = plot(None,name="Data 1")[0]
p.addSeries(LinePlotSeries("Data2"))
p.getSeries(0).setData(positions_, readable_)
p.getSeries(1).setData(x, fit_polinomial)
#calculate the position where the line crosses zero
k=-pars_polynomial[0]/pars_polynomial[1]
print k
#change the offset
#offset=Slit_offset.read()
#Slit_offset.write(offset+k)
Slit.write(final_pos)

View File

@@ -0,0 +1,23 @@
# Commands to move slit and CA>
# microscope.send_receive("mmp 7 -9044.7", 60000)
# microscope.send_receive("mmp 2 -5998.6", 60000)
# microscope.send_receive("mmp 1 0.0", 60000)
# slitttt.read()
# slitttt.write(pos[0])
# read ROI intensity, see FocusScan.py
# scan_contrast
# if roi is None:
# sensor = image_contrast
# else:
# sensor = roi_contrast
# roi_contrast.set_roi(roi)
#
# see test_autofocus
#r=lscan (objective, image.contrast, RANGE[0], RANGE[1], STEP_SIZE, latency=(SETTLING_TIME + eiger.getExposure()))
#(norm, mn, std )= fit (r["image_contrast"], r["objective"])
#if (mn<RANGE[0] or mn>RANGE[1]):
# raise Exception("Invalid fit")
#objective.write(mn)

View File

@@ -0,0 +1,20 @@
#for i in [-1.9, -2.0, -2.1]:
## girder_x.move(i, -1)
## rmu_ry.move(-4.477, -1)
# print "Do something"
# time.sleep(1.0)
#
#for x in range(0, 15):
# y = -3.5 + float(x)*0.5
# z = -5.2211 + y*0.4865
# #print("Girder x %f" % (y))
# print("RMU Ry %f" % (z))
# #str(1.23)
for x in range(30, 70):
y = -3.5 + float(x)*0.05
z = -5.222 + y*0.4638
print("Girder x %f" % (y))
#girder_x.move(y, -1)
print("RMU Ry %f" % (z))
#rmu_ry.move(z, -1)
time.sleep(3.0)

17
script/Users/PEEM/Armin/TestUserScript_Armin.py Executable file → Normal file
View File

@@ -14,17 +14,18 @@ two_pol(switching="Tune_Detune", sequence="A", measurements=MEASUREMENTS, exposu
time.sleep(2.0)
#TwoEnergies with lin hor polarization ID2 only (normal)
set_beamline_setup(id ="ID2", en=710, pol2="Lin_Hor")
#set_beamline_setup(id ="ID2", en=710, pol2="Lin_Hor") -> causes problems?
two_energies(705, 710, measurements=MEASUREMENTS, exposure=EXPOSURE, average=AVERAGE)
time.sleep(2.0)
#abs_spec(ranges=[[500.0, 1000.0, 100.0],], switch_pol=False, scans=1, exposure=EXPOSURE, average=AVERAGE) #Use manulally defined ranges and rois defined in GUI
abs_spec(ranges="Fe_L3_fine", roi="test", switch_pol=False, scans=1, exposure=EXPOSURE, average=AVERAGE)
#eiger.stop()
#eiger_threshold.write(7500)
#eiger.start()
#tscan(['ca://X11MA-PC-ET7000:SW-K'], points=10, interval=1.0, title='temperature', keep=False, name='tewsst', layout='table', provider='txt', auto_range=True, domain_axis='Time')
#Direct functions to change energy, pol, offset:
#change_energy(700)
@@ -36,4 +37,10 @@ abs_spec(ranges="Fe_L3_fine", roi="test", switch_pol=False, scans=1, exposure=EX
#switch_pol()
#Restoring beamline state defined in last set_beamline_setut:
#restore_beamline_setup()
#restore_beamline_setup()
#
#for i in [-1.9, -2.0, -2.1]:
# girder_x.move(i, -1)
# rmu_ry.move(-4.477, -1)
# print "Do something"
# caput("X11MA-HG:X_SET", 1.9)

View File

@@ -0,0 +1,26 @@
##Constants
AVERAGE = 1
EXPOSURE = 1.0
MEASUREMENTS = 5
DRIFT_CORRECTION = True
eiger.stop()
eiger_threshold.write(4000.0)
time.sleep(2.0)
#eiger.start()
##TakeImage at 710 eV at the given polarization
#change_energy(712)
take_image(scans=1, switch_pol=False, measurements=MEASUREMENTS, exposure=EXPOSURE, average=AVERAGE)
time.sleep(2.0)
#
eiger.stop()
eiger_threshold.write(4100.0)
time.sleep(2.0)
#eiger.start()
##TakeImage at 710 eV at the given polarization
#change_energy(712)
take_image(scans=1, switch_pol=False, measurements=MEASUREMENTS, exposure=EXPOSURE, average=AVERAGE)
time.sleep(2.0)

View File

@@ -0,0 +1,2 @@
#cscan([girder_x], ['ca://machine_cur'], [0.16], [0.18], [0.01], latency=1.0, time=10.0, relative=False, passes=1, zigzag=False, keep=False, name='Unknown')
cscan(girder_x, machine_cur, 0.16, 0.18, 0.01)