updated utiliry files
This commit is contained in:
1 parent
6880f46467
commit
41a4e281af
3 files changed
+56
-41
No files matched your search
@@ -166,8 +166,10 @@ def check_peak_fit(x_data, result, min_fwhm_steps=3):
|
||||
centre = result["centre"]
|
||||
fwhm = result["fwhm"]
|
||||
|
||||
step_size = np.mean(np.diff(x_data))
|
||||
fwhm_steps = result["fwhm"] / abs(step_size)
|
||||
# step_size = np.mean(np.diff(x_data))
|
||||
# fwhm_steps = result["fwhm"] / abs(step_size)
|
||||
|
||||
fwhm_steps = fwhm / step
|
||||
|
||||
problems = []
|
||||
|
||||
|
||||
@@ -76,22 +76,31 @@ def get_value(dev_name, details=False):
|
||||
Returns: value or full details
|
||||
|
||||
"""
|
||||
# if dev_name == dev.scam:
|
||||
# root = "scam"
|
||||
# live_root = "scam"
|
||||
# name = "scam_contrast"
|
||||
# value = dev_name.read(cached=True)[name]["value"]
|
||||
# else:
|
||||
# try:
|
||||
# name = live_root = root = dev_name.name
|
||||
# value = dev_name.read(cached=True)[name]["value"]
|
||||
# except:
|
||||
# print("non-standard device")
|
||||
# root = dev_name.dotted_name
|
||||
# name = dev_name.full_name
|
||||
# live_root = dev_name.parent.name
|
||||
# value = dev_name.read(cached=True)[name]["value"]
|
||||
|
||||
if dev_name == dev.scam:
|
||||
root = "scam"
|
||||
live_root = "scam"
|
||||
name = "scam_contrast"
|
||||
try:
|
||||
name = live_root = root = dev_name.name
|
||||
value = dev_name.read(cached=True)[name]["value"]
|
||||
except:
|
||||
print("non-standard device")
|
||||
root = dev_name.dotted_name
|
||||
name = dev_name.full_name
|
||||
live_root = dev_name.parent.name
|
||||
value = dev_name.read(cached=True)[name]["value"]
|
||||
else:
|
||||
try:
|
||||
name = live_root = root = dev_name.name
|
||||
value = dev_name.read(cached=True)[name]["value"]
|
||||
except:
|
||||
print("non-standard device")
|
||||
root = dev_name.dotted_name
|
||||
name = dev_name.full_name
|
||||
live_root = dev_name.parent.name
|
||||
value = dev_name.read(cached=True)[name]["value"]
|
||||
|
||||
if details:
|
||||
return {"value": value, "root": root, "name": name, "live_root": live_root}
|
||||
|
||||
@@ -4,44 +4,48 @@ import epics
|
||||
import time
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from pxiii_bec.scripts import beamline_context as bl
|
||||
from pxiii_bec.macros.beamline_planner import BeamlineState
|
||||
|
||||
# =============================================================================
|
||||
# Camera utilities
|
||||
# =============================================================================
|
||||
def predict_scint_transmission(target_flux=None):
|
||||
"""Predict transmission required for a scintillator measurement."""
|
||||
# def predict_scint_transmission(target_flux=None):
|
||||
# """
|
||||
# Predict transmission required for a scintillator measurement.
|
||||
# Not required on PXIII
|
||||
# """
|
||||
|
||||
if target_flux is None:
|
||||
target_flux = BeamMove.scint_target_flux
|
||||
# if target_flux is None:
|
||||
# target_flux = BeamMove.scint_target_flux
|
||||
|
||||
_, full_flux = bpm2flux()
|
||||
# _, full_flux = bpm2flux()
|
||||
|
||||
if not np.isfinite(full_flux) or full_flux <= 0:
|
||||
raise ValueError(
|
||||
f"Cannot predict scintillator transmission: "
|
||||
f"invalid full flux ({full_flux:.3g} ph/s)"
|
||||
)
|
||||
# if not np.isfinite(full_flux) or full_flux <= 0:
|
||||
# raise ValueError(
|
||||
# f"Cannot predict scintillator transmission: "
|
||||
# f"invalid full flux ({full_flux:.3g} ph/s)"
|
||||
# )
|
||||
|
||||
transmission = target_flux / full_flux
|
||||
# transmission = target_flux / full_flux
|
||||
|
||||
# Prevent an unreasonable attenuator setting
|
||||
transmission = np.clip(transmission, 0.001, 1.0)
|
||||
# # Prevent an unreasonable attenuator setting
|
||||
# transmission = np.clip(transmission, 0.001, 1.0)
|
||||
|
||||
return float(transmission)
|
||||
# return float(transmission)
|
||||
|
||||
|
||||
def prepare_scint_measurement(autoexp=True, zoom=1000):
|
||||
"""Prepare for taking a reading of the beam from the scintillator"""
|
||||
|
||||
# set transmission
|
||||
transmission = predict_scint_transmission()
|
||||
print(
|
||||
f"Predicted scintillator transmission: "
|
||||
f"{transmission:.2%}"
|
||||
)
|
||||
dev.transm.put(transmission)
|
||||
time.sleep(3)
|
||||
# # set transmission
|
||||
# transmission = predict_scint_transmission()
|
||||
# print(
|
||||
# f"Predicted scintillator transmission: "
|
||||
# f"{transmission:.2%}"
|
||||
# )
|
||||
# dev.transm.put(transmission)
|
||||
# time.sleep(3)
|
||||
|
||||
|
||||
# set camera zoom
|
||||
@@ -49,8 +53,8 @@ def prepare_scint_measurement(autoexp=True, zoom=1000):
|
||||
umv(dev.scam_zoom, zoom)
|
||||
|
||||
# move to beam visualisation
|
||||
if not planner.is_state(BeamlineState.BEAM_VISUALISATION):
|
||||
planner.move_to(BeamlineState.BEAM_VISUALISATION)
|
||||
if not bl.planner.is_state(BeamlineState.BEAM_VISUALISATION):
|
||||
bl.planner.move_to(BeamlineState.BEAM_VISUALISATION)
|
||||
|
||||
# open shutter
|
||||
dev.bcu_shutter.put(1)
|
||||
|
||||
Reference in new issue
Block a user