Update APscripts and KB_Class with latest PXII changes
This commit is contained in:
1 parent
13b2eb32d9
commit
48ed5ce275
2 files changed
+117
-18
No files matched your search
@@ -625,7 +625,7 @@ def save_data(hindex: int, device_name: str, signal_name: str, isave=1):
|
||||
#########################################
|
||||
### just retrieve the saved data from csv
|
||||
########################################
|
||||
def read_data_csv(filename: str):
|
||||
def read_data_csv(filename: str, iplot=1):
|
||||
"""
|
||||
Get data stored in a CSV file
|
||||
|
||||
@@ -638,8 +638,10 @@ def read_data_csv(filename: str):
|
||||
# read output to simple data file for later analysis:
|
||||
|
||||
with open(filename, "r") as f:
|
||||
combined_data = np.loadtxt(f, delimiter=",") # no header and fmt for load
|
||||
|
||||
try:
|
||||
combined_data = np.loadtxt(f, delimiter=",") # no header and fmt ?
|
||||
except ValueError: # First row may be a header
|
||||
combined_data = np.loadtxt(f, delimiter=",", skiprows=1)
|
||||
rows, cols = combined_data.shape
|
||||
|
||||
print("No of Rows =", rows)
|
||||
@@ -664,19 +666,48 @@ def read_data_csv(filename: str):
|
||||
data_x = combined_data[:, ind1]
|
||||
data_y = combined_data[:, ind2]
|
||||
|
||||
plt.ion()
|
||||
plt.figure()
|
||||
plt.plot(data_x, data_y, ".")
|
||||
if iplot:
|
||||
plt.ion()
|
||||
plt.figure()
|
||||
plt.plot(data_x, data_y, ".")
|
||||
|
||||
plt.title(f"Scan from {filename}")
|
||||
plt.xlabel(f"data column {ind1}")
|
||||
plt.ylabel(f"data column {ind2}")
|
||||
plt.title(f"Scan from {filename}")
|
||||
plt.xlabel(f"data column {ind1}")
|
||||
plt.ylabel(f"data column {ind2}")
|
||||
|
||||
plt.show()
|
||||
plt.show()
|
||||
|
||||
return combined_data
|
||||
|
||||
|
||||
####################################
|
||||
### read and plot several files
|
||||
####################################
|
||||
|
||||
def plot_several(filenames):
|
||||
#filenames = [
|
||||
# "scan8.csv",
|
||||
# "scan16.csv",
|
||||
# "scan24.csv",
|
||||
#]
|
||||
|
||||
fig, ax = plt.subplots() # outside the loop -> in one plot
|
||||
# if new fig or subplot within loop: several
|
||||
for filename in filenames:
|
||||
x, y = read_data_csv(filename, iplot=0)
|
||||
|
||||
ax.plot(x, y, marker=".", label=filename)
|
||||
|
||||
ax.set_xlabel("Parameter 1")
|
||||
ax.set_ylabel("Parameter 2")
|
||||
ax.legend()
|
||||
ax.grid(True)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
####################################
|
||||
### save and plot the long gapscans
|
||||
####################################
|
||||
@@ -1047,8 +1078,8 @@ def slitscan(device_location: str, direction: str, range=1, nsteps=50, centre=0)
|
||||
|
||||
# FE slits ================================
|
||||
if device_location in ["fe"]:
|
||||
default_h = 1.0 ## 1.4 or 0.4 or ???
|
||||
default_v = 1.0 ## 1.2
|
||||
default_h = 0.6 ## 1.4 or 0.4 or ???
|
||||
default_v = 0.6 ## 1.2
|
||||
det = dev.lu_bpmsum
|
||||
if direction in ["x", "h"]:
|
||||
mot = dev.fe_sl_xcen
|
||||
@@ -1208,7 +1239,7 @@ def slitscan(device_location: str, direction: str, range=1, nsteps=50, centre=0)
|
||||
|
||||
print(f"opening slit to {s_open}")
|
||||
umv(size, s_open)
|
||||
return
|
||||
return res_center
|
||||
|
||||
|
||||
#####################
|
||||
@@ -1283,12 +1314,30 @@ def kbfocus(sizex, sizey):
|
||||
return
|
||||
|
||||
|
||||
#########################
|
||||
### Status of the BEC
|
||||
#########################
|
||||
|
||||
|
||||
def bstatus():
|
||||
#
|
||||
dock_area = bec.gui.new()
|
||||
|
||||
dbrowser = dock_area.new("device_browser").new(bec.gui.available_widgets.DeviceBrowser)
|
||||
|
||||
dock_area.new("queue").new(bec.gui.available_widgets.BECQueue)
|
||||
# queue = dock_area.queue.BECQueue # give it a name
|
||||
# text_box = dock_area.new().new(widget=bec.gui.available_widgets.TextBox)
|
||||
# text_box.set_plain_text("Hello, World!")
|
||||
# text_box.set_html_text("<h1>Welcome to BEC Widgets</h1><p>This is an example of displaying <strong>HTML</strong> text.</p>")
|
||||
|
||||
|
||||
###########################
|
||||
### move in the X-ray Eye
|
||||
###########################
|
||||
|
||||
|
||||
def detxeye_in(setdetzpos=200, setdetypos=151.6):
|
||||
def detxeye_in(setdetzpos=200, setdetypos=151.6): # had been 213.6
|
||||
"""
|
||||
moves in the Xray eye and the Diode below detector
|
||||
"""
|
||||
@@ -1298,7 +1347,7 @@ def detxeye_in(setdetzpos=200, setdetypos=151.6):
|
||||
setxrpos = 0.0
|
||||
|
||||
# setdetzpos = 200 # 200 better?
|
||||
# Detector Y reference changed by 62 mm; previous position was 213.6 mm.
|
||||
# setdetypos = 213.6 --> 151.6
|
||||
|
||||
detzpos = dev.det_z.user_readback.get()
|
||||
detypos = dev.det_y.user_readback.get()
|
||||
@@ -1335,7 +1384,7 @@ def detxeye_out():
|
||||
moves det back and down
|
||||
"""
|
||||
setdetzpos = 500
|
||||
setdetypos = 0
|
||||
setdetypos = 0 ### 70
|
||||
umv(dev.det_z, setdetzpos)
|
||||
detzpos = dev.det_z.user_readback.get()
|
||||
if detzpos > 300:
|
||||
@@ -1753,12 +1802,13 @@ def fluxcal(start_en=13, stop_en=14, step=1):
|
||||
fitpoly(dat_en, dat_quot_flbsum, 3)
|
||||
|
||||
|
||||
# ############################# check flux measurements ##################
|
||||
def testflux():
|
||||
import time, datetime
|
||||
|
||||
energy = get_current_energy()
|
||||
count = 0
|
||||
stop = 1000
|
||||
stop = 1000
|
||||
while count < stop:
|
||||
|
||||
bpmsum_c = dev.bcu_bpmsum.read(cached=True)["bcu_bpmsum"]["value"]
|
||||
@@ -1767,7 +1817,7 @@ def testflux():
|
||||
bpmsum = dev.bcu_bpmsum.read()["bcu_bpmsum"]["value"]
|
||||
transm = dev.transm.read()["transm"]["value"]
|
||||
|
||||
print(f'******************************************************************************')
|
||||
print(f'******************************************************************************')
|
||||
print(f'bpmsum_cached {bpmsum_c}, transm_cached {transm_c}')
|
||||
bpm2flux(energy, bpmsum_c, transm_c)
|
||||
print(f' ')
|
||||
@@ -1779,3 +1829,4 @@ def testflux():
|
||||
time.sleep(1)
|
||||
count += 1
|
||||
return
|
||||
|
||||
@@ -1,6 +1,54 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
def readKB():
|
||||
"""
|
||||
reads the focussing params from the KBs
|
||||
"""
|
||||
vfm_pitch = dev.vfm_pitch.user_readback.get()
|
||||
vfm_bu = dev.vfm_bu.user_readback.get()
|
||||
vfm_bd = dev.vfm_bd.user_readback.get()
|
||||
|
||||
hfm_pitch = dev.hfm_pitch.user_readback.get()
|
||||
hfm_bu = dev.hfm_bu.user_readback.get()
|
||||
hfm_bd = dev.hfm_bd.user_readback.get()
|
||||
|
||||
print(
|
||||
f" KB values vertical: \n pitch = {vfm_pitch} , bend upstream = {vfm_bu} , bend downstream = {vfm_bd}"
|
||||
)
|
||||
|
||||
print(
|
||||
f" KB values horizontal: \n pitch = {hfm_pitch} , bend upstream = {hfm_bu} , bend downstream = {hfm_bd}"
|
||||
)
|
||||
|
||||
return vfm_pitch, vfm_bu, vfm_bd, hfm_pitch, hfm_bu, hfm_bd
|
||||
|
||||
|
||||
def read_focinput(dir="v"):
|
||||
"""
|
||||
reads the input from the User Panel
|
||||
"""
|
||||
import epics
|
||||
|
||||
# channels:
|
||||
# X10SA-ES-VFM:DEFOCUS.RBV
|
||||
# X10SA-ES-VFM:USER_ASYM_SET
|
||||
# X10SA-ES-VFM:PARAM_CURV --- calcrec
|
||||
|
||||
str = "VFM"
|
||||
if dir == "h":
|
||||
str = "HFM"
|
||||
|
||||
user_defoc = epics.caget(f"X10SA-ES-{str}:DEFOCUS.RBV")
|
||||
user_asym_set = epics.caget(f"X10SA-ES-{str}:USER_ASYM_SET")
|
||||
calc_rad = epics.caget(f"X10SA-ES-{str}:PARAM_CURV")
|
||||
|
||||
print(
|
||||
f"{str} User Set Values: Defoc Dist s = {user_defoc}, Additional asym_set = {user_asym_set}, Radius from input = {calc_rad} "
|
||||
)
|
||||
return user_defoc, user_asym_set, calc_rad
|
||||
|
||||
|
||||
class KBMirror:
|
||||
def __init__(self, mirror_type="PXII_HFM"):
|
||||
self.mirror_type = mirror_type
|
||||
|
||||
Reference in new issue
Block a user