This commit is contained in:
1 parent
4ea28b56cb
commit
fc2f0bb073
8 files changed
+269
-9
No files matched your search
@@ -0,0 +1,15 @@
|
||||
For histo threshold beam location:
|
||||
|
||||
# PV: Stats5:CentroidThreshold
|
||||
# Get histogram, find index of 97th %ile, use it as threshold
|
||||
# histo -> cumsum -> final value * 0.97 -> index where cumsum exceeds this -> this value should be the threshold
|
||||
|
||||
|
||||
For profile fitting beam centre location:
|
||||
- Make sure NDPluginXYProfile is enabled:
|
||||
- X06DA-ES-MS:XYP1:EnableCallbacks
|
||||
- X06DA-ES-MS:XYP1:X:Compute
|
||||
- X06DA-ES-MS:XYP1:Y:Compute
|
||||
- Then, gaussian peak from X06DA-ES-MS:XYP1:X:Mu_RBV X06DA-ES-MS:XYP1:Y:Mu_RBV
|
||||
- This relies on filtering the green channel from the image only for better s/n
|
||||
- This is in plugin ROI1/ROI11 - full image (0-10000 x+y, 1 only z), needs to be the input port for the XYP1
|
||||
@@ -0,0 +1,11 @@
|
||||
fluorimeter:
|
||||
readoutPriority: on_request
|
||||
description: fluorimeter
|
||||
deviceClass: pxiii_bec.devices.Fluorimeter
|
||||
deviceConfig:
|
||||
prefix: "X06DA-ES-XRF:"
|
||||
deviceTags:
|
||||
- xrf
|
||||
enabled: true
|
||||
readOnly: false
|
||||
softwareTrigger: false
|
||||
@@ -193,7 +193,7 @@ states:
|
||||
bl_bright: 'on'
|
||||
bs_pos: in
|
||||
bs_z: safe
|
||||
coll_y: intermediate
|
||||
coll_y: in
|
||||
cryo_pos: in
|
||||
det_cov: 'close'
|
||||
diag_y: out
|
||||
|
||||
Regular → Executable
+52
-6
@@ -55,8 +55,8 @@ aerotech:
|
||||
deviceConfig:
|
||||
prefix: http://mx-x06da-queue-01:5234
|
||||
deviceTags:
|
||||
- motors
|
||||
- aerotech
|
||||
- motors
|
||||
enabled: true
|
||||
onFailure: buffer
|
||||
readoutPriority: baseline
|
||||
@@ -66,12 +66,12 @@ aerotech:
|
||||
work: 0
|
||||
work: null
|
||||
x:
|
||||
in: 0
|
||||
in: -0.0
|
||||
out: -10
|
||||
safe: -50
|
||||
y:
|
||||
mount: 0
|
||||
work: 0
|
||||
work: -0.01
|
||||
z:
|
||||
mount: 0
|
||||
work: 0.022
|
||||
@@ -246,6 +246,43 @@ bcu_sl_yt:
|
||||
enabled: true
|
||||
onFailure: buffer
|
||||
readoutPriority: baseline
|
||||
beam_profile_centroid:
|
||||
description: Beam location and size based on AD sample camera analysis with centroid
|
||||
analysis
|
||||
deviceClass: pxiii_bec.devices.CentroidBeamProfile
|
||||
deviceConfig:
|
||||
prefix: 'X06DA-ES-MS:Stats5:'
|
||||
deviceTags:
|
||||
- beam
|
||||
enabled: true
|
||||
readoutPriority: baseline
|
||||
beam_profile_gaussian:
|
||||
description: Beam location and size based on AD sample camera analysis with gaussiant
|
||||
fitting
|
||||
deviceClass: pxiii_bec.devices.GaussianBeamProfile
|
||||
deviceConfig:
|
||||
prefix: 'X06DA-ES-MS:XYP1:'
|
||||
deviceTags:
|
||||
- beam
|
||||
enabled: true
|
||||
readoutPriority: baseline
|
||||
beam_steering:
|
||||
description: Beam location and size based on AD sample camera analysis
|
||||
deviceClass: pxiii_bec.devices.BeamSteerer
|
||||
deviceConfig:
|
||||
hfm_step_per_x_px: -0.00013
|
||||
prefix: ''
|
||||
px_tolerance: 3
|
||||
sample_loc_x_px: 1020
|
||||
sample_loc_y_px: 1010
|
||||
step_fraction: 0.7
|
||||
vfm_step_per_y_px: -0.00033
|
||||
deviceTags:
|
||||
- beam
|
||||
enabled: true
|
||||
readoutPriority: on_request
|
||||
userParameter:
|
||||
profile_provider: beam_profile_centroid
|
||||
bl_bright:
|
||||
description: Backlight Brightness
|
||||
deviceClass: ophyd.EpicsSignal
|
||||
@@ -401,7 +438,7 @@ coll_y:
|
||||
onFailure: buffer
|
||||
readoutPriority: baseline
|
||||
userParameter:
|
||||
in: 25.40
|
||||
in: 25.4
|
||||
intermediate: 15
|
||||
out: 4.901
|
||||
park: 0
|
||||
@@ -616,8 +653,8 @@ det_z:
|
||||
onFailure: buffer
|
||||
readoutPriority: baseline
|
||||
userParameter:
|
||||
vis: 150
|
||||
mse: 800
|
||||
vis: 150
|
||||
diag_y:
|
||||
description: Scintillator/diode Y
|
||||
deviceClass: ophyd_devices.EpicsMotor
|
||||
@@ -741,6 +778,15 @@ fl_bright:
|
||||
'on': 3.0
|
||||
type: continuous
|
||||
"\u201Ctol\u201D": 0.01
|
||||
fluorimeter:
|
||||
description: fluorimeter
|
||||
deviceClass: pxiii_bec.devices.Fluorimeter
|
||||
deviceConfig:
|
||||
prefix: 'X06DA-ES-XRF:'
|
||||
deviceTags:
|
||||
- xrf
|
||||
enabled: true
|
||||
readoutPriority: on_request
|
||||
hfm_bd:
|
||||
description: HFM Downstream Bender
|
||||
deviceClass: ophyd_devices.EpicsMotorEC
|
||||
@@ -1019,8 +1065,8 @@ smargon:
|
||||
deviceConfig:
|
||||
prefix: http://x06da-smargopolo.psi.ch:3000
|
||||
deviceTags:
|
||||
- smargon
|
||||
- motors
|
||||
- smargon
|
||||
enabled: true
|
||||
onFailure: buffer
|
||||
readoutPriority: baseline
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
from ophyd import DeviceStatus, EpicsSignal, Component as Cpt
|
||||
|
||||
from ophyd_devices import PSIDeviceBase
|
||||
|
||||
class Fluorimeter(PSIDeviceBase):
|
||||
|
||||
start = Cpt(EpicsSignal, suffix="mca1Start")
|
||||
stop_signal = Cpt(EpicsSignal, suffix="mca1Stop")
|
||||
erase_and_start = Cpt(EpicsSignal, suffix="mca1EraseStart")
|
||||
erase = Cpt(EpicsSignal, suffix="mca1Erase")
|
||||
preset_mode = Cpt(EpicsSignal, suffix="dxp1:PresetMode")
|
||||
status = Cpt(EpicsSignal, suffix="mca1.ACQG")
|
||||
real_time = Cpt(EpicsSignal, suffix="mca1.PRTM")
|
||||
live_time = Cpt(EpicsSignal, suffix="mca1.PLTM")
|
||||
elapsed_real_time = Cpt(EpicsSignal, suffix="mca1.ERTM")
|
||||
elapsed_live_time = Cpt(EpicsSignal, suffix="mca1.ELTM")
|
||||
elapsed_trigger_live_time = Cpt(EpicsSignal, suffix="dxp1:ElapsedTriggerLiveTime")
|
||||
instant_dead_time = Cpt(EpicsSignal, suffix="mca1.IDTIM")
|
||||
average_dead_time = Cpt(EpicsSignal, suffix="mca1.DTIM")
|
||||
poll_time_rbv = Cpt(EpicsSignal, suffix="PollTime_RBV")
|
||||
poll_time = Cpt(EpicsSignal, suffix="PollTime")
|
||||
mca = Cpt(EpicsSignal, suffix="mca1")
|
||||
data = Cpt(EpicsSignal, suffix="mca1.VAL")
|
||||
background = Cpt(EpicsSignal, suffix="mca1.BG")
|
||||
saveFile = Cpt(EpicsSignal, suffix="SaveSystemFile")
|
||||
saveFile_name = Cpt(EpicsSignal, suffix="SaveSystem")
|
||||
saveFile_rbv = Cpt(EpicsSignal, suffix="SaveSystem_RBV")
|
||||
calibration_offset = Cpt(EpicsSignal, suffix="mca1.CALO")
|
||||
calibration_slope = Cpt(EpicsSignal, suffix="mca1.CALS")
|
||||
|
||||
@@ -276,7 +276,7 @@ def save_current_position(
|
||||
old_value = axis_params[position]
|
||||
print(f"Old value is {old_value}")
|
||||
|
||||
current_value = get_current_value(device, axis=None)
|
||||
current_value = get_current_value(device, axis)
|
||||
|
||||
delta = abs(current_value - old_value)
|
||||
|
||||
@@ -359,4 +359,4 @@ def get_current_value(device, axis=None):
|
||||
|
||||
signal_name = next(iter(data))
|
||||
|
||||
return round(data[signal_name]["value"],3)
|
||||
return round(data[signal_name]["value"],3)
|
||||
@@ -0,0 +1,79 @@
|
||||
def knife_plothist(hindex: int, signal_name: str, isave=1):
|
||||
"""
|
||||
Get data for a completed scan from the BEC history,
|
||||
and plot all the results.
|
||||
|
||||
Args:
|
||||
history_index (int): scan to fetch, e.g. -1 for the most recent scan
|
||||
signal_name (str): the monitor
|
||||
|
||||
Example:
|
||||
data_x, data_y = knife_plothist(-1,"xidode")
|
||||
|
||||
scanned with
|
||||
scans.line_scan(dev.aerotech.y,-0.05,0.05, steps=101, settling_time=0.5, relative=True)
|
||||
"""
|
||||
|
||||
from lmfit.models import LinearModel, GaussianModel, VoigtModel, QuadraticModel, LorentzianModel
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
if hindex < 0:
|
||||
h = bec.history[hindex]
|
||||
print('by scan number')
|
||||
else:
|
||||
h = bec.history.get_by_scan_number(hindex)
|
||||
print('by scan number')
|
||||
|
||||
md = h.metadata["bec"]
|
||||
sno = md['dataset_number']
|
||||
print(f"number of scan = {sno}")
|
||||
scanvar = list(md["args"].keys())[0] # string, returns the variable of the last performed scan
|
||||
# data = h.devices[device_name][signal].read()["value"]
|
||||
# data_x = h.devices.dcm_pitch.dcm_pitch.read()["value"]
|
||||
# data_y = h.devices.lu_bpmsum.lu_bpmsum.read()["value"]
|
||||
# data_x = h.devices[device_name][device_name].read()["value"]
|
||||
|
||||
# that works ...
|
||||
#print(list(md['args'].keys()))
|
||||
val = list(md['args'].keys())
|
||||
#val[0] = 'aerotech.x'
|
||||
devicenam = val[0]
|
||||
print('device = ', devicenam)
|
||||
data_xd = md["positions"] # last scan knows which device ... however, double array
|
||||
data_x = data_xd.flatten()
|
||||
print("dx = ", data_x)
|
||||
#data_y = h.devices[signal_name][signal_name].read()["value"]
|
||||
data_y = h.devices["xidiode"]["xidiode"].read()["value"]
|
||||
print("dy = ", data_y)
|
||||
|
||||
rev = 0
|
||||
if val[0][9] == 'x':
|
||||
rev = 1
|
||||
smoothplotgrad(data_x, data_y, reverse = rev)
|
||||
# g, xm = justfit(data_x, data_y, model=model, ibg=ibg)
|
||||
|
||||
# plt.ion()
|
||||
# plt.figure()
|
||||
# plt.plot(data_x, data_y, "*")
|
||||
# plt.plot(data_x, g.best_fit)
|
||||
# plt.xlabel(scanvar)
|
||||
# plt.ylabel(signal_name)
|
||||
# plt.show()
|
||||
|
||||
# gcen = g.pars["center"].value
|
||||
|
||||
|
||||
if isave:
|
||||
ans = "n"
|
||||
ans = input("Store data in csv file? y/n ")
|
||||
if ans == "y":
|
||||
dirname = "/sls/x06da/config/commissioning/Data/"
|
||||
# writing output to simple data file for later analysis:
|
||||
combined = np.column_stack((data_x, data_y))
|
||||
filename = dirname + "Scan" + str(sno) + devicenam + ".txt"
|
||||
with open(filename, "w") as f:
|
||||
np.savetxt(f, combined, delimiter=",", fmt="%.9e")
|
||||
|
||||
|
||||
return data_x, data_y
|
||||
@@ -0,0 +1,79 @@
|
||||
def knife_plothist(hindex: int, signal_name: str, isave=1):
|
||||
"""
|
||||
Get data for a completed scan from the BEC history,
|
||||
and plot all the results.
|
||||
|
||||
Args:
|
||||
history_index (int): scan to fetch, e.g. -1 for the most recent scan
|
||||
signal_name (str): the monitor
|
||||
|
||||
Example:
|
||||
data_x, data_y = knife_plothist(-1,"xidode")
|
||||
|
||||
scanned with
|
||||
scans.line_scan(dev.aerotech.y,-0.05,0.05, steps=101, settling_time=0.5, relative=True)
|
||||
"""
|
||||
|
||||
from lmfit.models import LinearModel, GaussianModel, VoigtModel, QuadraticModel, LorentzianModel
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
if hindex < 0:
|
||||
h = bec.history[hindex]
|
||||
print('by scan number')
|
||||
else:
|
||||
h = bec.history.get_by_scan_number(hindex)
|
||||
print('by scan number')
|
||||
|
||||
md = h.metadata["bec"]
|
||||
sno = md['dataset_number']
|
||||
print(f"number of scan = {sno}")
|
||||
scanvar = list(md["args"].keys())[0] # string, returns the variable of the last performed scan
|
||||
# data = h.devices[device_name][signal].read()["value"]
|
||||
# data_x = h.devices.dcm_pitch.dcm_pitch.read()["value"]
|
||||
# data_y = h.devices.lu_bpmsum.lu_bpmsum.read()["value"]
|
||||
# data_x = h.devices[device_name][device_name].read()["value"]
|
||||
|
||||
# that works ...
|
||||
#print(list(md['args'].keys()))
|
||||
val = list(md['args'].keys())
|
||||
#val[0] = 'aerotech.x'
|
||||
devicenam = val[0]
|
||||
print('device = ', devicenam)
|
||||
data_xd = md["positions"] # last scan knows which device ... however, double array
|
||||
data_x = data_xd.flatten()
|
||||
print("dx = ", data_x)
|
||||
#data_y = h.devices[signal_name][signal_name].read()["value"]
|
||||
data_y = h.devices["xidiode"]["xidiode"].read()["value"]
|
||||
print("dy = ", data_y)
|
||||
|
||||
rev = 0
|
||||
if val[0][9] == 'x':
|
||||
rev = 1
|
||||
smoothplotgrad(data_x, data_y, reverse = rev)
|
||||
# g, xm = justfit(data_x, data_y, model=model, ibg=ibg)
|
||||
|
||||
# plt.ion()
|
||||
# plt.figure()
|
||||
# plt.plot(data_x, data_y, "*")
|
||||
# plt.plot(data_x, g.best_fit)
|
||||
# plt.xlabel(scanvar)
|
||||
# plt.ylabel(signal_name)
|
||||
# plt.show()
|
||||
|
||||
# gcen = g.pars["center"].value
|
||||
|
||||
|
||||
if isave:
|
||||
ans = "n"
|
||||
ans = input("Store data in csv file? y/n ")
|
||||
if ans == "y":
|
||||
dirname = "/sls/x10sa/config/commissioning/Data/"
|
||||
# writing output to simple data file for later analysis:
|
||||
combined = np.column_stack((data_x, data_y))
|
||||
filename = dirname + "Scan" + str(sno) + devicenam + ".txt"
|
||||
with open(filename, "w") as f:
|
||||
np.savetxt(f, combined, delimiter=",", fmt="%.9e")
|
||||
|
||||
|
||||
return data_x, data_y
|
||||
Reference in new issue
Block a user