diff --git a/pxii_bec/macros/CHANGELOG.md b/pxii_bec/macros/CHANGELOG.md new file mode 100644 index 0000000..9ffdefa --- /dev/null +++ b/pxii_bec/macros/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +## Test deployment + +### Safe for production +- Updated undulator harmonic calibration (pxii_parameters). +- Updated monochromator pitch calibration(pxii_parameters). . +- Improved beamstop and collimator alignment scans (daily_setup). +- Added a new beamline state: DET_DIODE (pxii-beamline_states.yaml, beamline_planner.py ) + +### Requires testing but should be safe +- Removed obsolete mock devices. (build_devices, devices_manager, position_device) +- Simplified positioned device definitions (as above) +- Changed BEC GUI window selection and plotting. (mx_methods and mx_basics now mxcomm_*) +- Added a daily beamline setup workflow. (daily_setup) + +### Likely to break Aare +- Added `beamline_context`. (scripts/beamline_context) +- BEC startup scripts handling of beamline initialisation (bec_ipython/startup post and pres startup files) +- Changed initialisation of `env`, `d`, and `planner`. (scripts/init_beamline.py) +- Changed macro imports to use `bl.planner`, `bl.d`, and `bl.env` (added to macro files that use these). \ No newline at end of file diff --git a/pxii_bec/macros/calibrate_bpm.py b/pxii_bec/macros/calibrate_bpm.py index 59caed3..c0ca7c3 100644 --- a/pxii_bec/macros/calibrate_bpm.py +++ b/pxii_bec/macros/calibrate_bpm.py @@ -9,32 +9,32 @@ import pandas as pd import matplotlib.pyplot as plt -def compute_norm(n_readings=5): - """Average normalized BPM X/Y from repeated sets of four channels.""" +# def compute_norm(n_readings=5): +# """Average normalized BPM X/Y from repeated sets of four channels.""" - xn_values = [] - yn_values = [] +# xn_values = [] +# yn_values = [] - for _ in range(n_readings): - bpm1 = dev.bcu_bpm1.read()["bcu_bpm1"]["value"] - bpm2 = dev.bcu_bpm2.read()["bcu_bpm2"]["value"] - bpm3 = dev.bcu_bpm3.read()["bcu_bpm3"]["value"] - bpm4 = dev.bcu_bpm4.read()["bcu_bpm4"]["value"] +# for _ in range(n_readings): +# bpm1 = dev.bcu_bpm1.read()["bcu_bpm1"]["value"] +# bpm2 = dev.bcu_bpm2.read()["bcu_bpm2"]["value"] +# bpm3 = dev.bcu_bpm3.read()["bcu_bpm3"]["value"] +# bpm4 = dev.bcu_bpm4.read()["bcu_bpm4"]["value"] - total = bpm1 + bpm2 + bpm3 + bpm4 +# total = bpm1 + bpm2 + bpm3 + bpm4 - if total == 0: - continue +# if total == 0: +# continue - xn = ((bpm1 + bpm2) - (bpm3 + bpm4)) / total - yn = ((bpm1 + bpm3) - (bpm2 + bpm4)) / total +# xn = ((bpm1 + bpm2) - (bpm3 + bpm4)) / total +# yn = ((bpm1 + bpm3) - (bpm2 + bpm4)) / total - xn_values.append(xn) - yn_values.append(yn) +# xn_values.append(xn) +# yn_values.append(yn) - time.sleep(0.1) +# time.sleep(0.1) - return float(np.mean(xn_values)), float(np.mean(yn_values)) +# return float(np.mean(xn_values)), float(np.mean(yn_values)) def run_calibration(env): @@ -203,78 +203,7 @@ def read_bpm_calibration_data( # return result -def beam_offset_um( - bpm_signal, - bpm_motor_position, - calibration, -): - """ - Calculate beam position relative to the sample-camera crosshair. - Returns position in microns. - """ - - if calibration.crosshair_signal is None: - raise ValueError( - "Camera crosshair reference has not been calibrated." - ) - - if calibration.crosshair_bpm_position is None: - raise ValueError( - "Crosshair BPM motor position is not defined." - ) - - if abs(bpm_signal) > calibration.signal_limit: - raise ValueError( - f"BPM signal {bpm_signal:.3f} is outside the " - f"calibration range ±{calibration.signal_limit:.3f}" - ) - - # Has the BPM itself moved since the crosshair was calibrated? - motor_shift = ( - bpm_motor_position - - calibration.crosshair_bpm_position - ) - - # Convert current BPM signal to equivalent BPM position - current_local = np.polyval( - calibration.coeffs, - bpm_signal, - ) - - # Convert the BPM signal measured at the camera crosshair - # to equivalent BPM position - crosshair_local = np.polyval( - calibration.coeffs, - calibration.crosshair_signal, - ) - - signal_shift = current_local - crosshair_local - - # BPM motion and apparent beam motion have opposite signs - beam_shift_mm = motor_shift - signal_shift - - return float(beam_shift_mm * 1000) - - -def get_bcu_beampos(): - bpm_xn, bpm_yn = compute_norm() - bpm_x = dev.bcu_bpm_x.position - bpm_y = dev.bcu_bpm_y.position - - beam_x = beam_offset_um( - bpm_xn, - bpm_x, - BPM_X_Calibration, - ) - - beam_y = beam_offset_um( - bpm_yn, - bpm_y, - BPM_Y_Calibration, - ) - - return beam_x, beam_y def polynomial_calibration( env, diff --git a/pxii_bec/macros/calibrate_bpm.py.bak b/pxii_bec/macros/calibrate_bpm.py.bak deleted file mode 100644 index 7ad0ad5..0000000 --- a/pxii_bec/macros/calibrate_bpm.py.bak +++ /dev/null @@ -1,670 +0,0 @@ -""" -BPM calibration using inverse PCHIP spline. - -Calibration concept: - BPM signal -> beam position relative to BPM - -Final beam position: - beam_absolute = bpm_motor_position + local_beam_position - beam_relative_to_camera_crosshair = beam_absolute - camera_crosshair_position -""" - -import time -import os -from datetime import datetime, timedelta -from pathlib import Path -import numpy as np -import pandas as pd -import matplotlib.pyplot as plt -from pyparsing import results -from scipy.optimize import curve_fit -import scipy.special as special -from scipy.interpolate import PchipInterpolator, CubicSpline - - -def read_currents(): - """Read the individual bpm channels""" - vals_bpm1 = [] - vals_bpm2 = [] - vals_bpm3 = [] - vals_bpm4 = [] - - for _ in range(5): - vals_bpm1.append(dev.bcu_bpm1.read()["bcu_bpm1"]["value"]) - time.sleep(0.1) - for _ in range(5): - vals_bpm2.append(dev.bcu_bpm2.read()["bcu_bpm2"]["value"]) - time.sleep(0.1) - for _ in range(5): - vals_bpm3.append(dev.bcu_bpm3.read()["bcu_bpm3"]["value"]) - time.sleep(0.1) - for _ in range(5): - vals_bpm4.append(dev.bcu_bpm4.read()["bcu_bpm4"]["value"]) - time.sleep(0.1) - bpm1 = np.mean(vals_bpm1) - bpm2 = np.mean(vals_bpm2) - bpm3 = np.mean(vals_bpm3) - bpm4 = np.mean(vals_bpm4) - - return {"bpm1": bpm1, "bpm2": bpm2, "bpm3": bpm3, "bpm4": bpm4} - - -def compute_norm(): - """Compute normalised x and y positions""" - readings = read_currents() - total = readings["bpm1"] + readings["bpm2"] + readings["bpm3"] + readings["bpm4"] - # print(f"Sum is {total:.2f}") - xn = ( - (readings["bpm1"] + readings["bpm2"]) - (readings["bpm3"] + readings["bpm4"]) - ) / total - yn = ( - (readings["bpm1"] + readings["bpm3"]) - (readings["bpm2"] + readings["bpm4"]) - ) / total - # return xn, yn, readings["bpm1"], readings["bpm2"], readings["bpm3"], readings["bpm4"] - return float(xn), float(yn) - - -# def compute_pos(): -# """Compute the beam x and y positions""" -# cal = { -# "bcu_bpm": { -# "x_slope": 7.778, -# "x_off": -1.019, -# "y_slope": -8.625, -# "y_off": -1.935, -# } -# } -# xn, yn, bpm1, bpm2, bpm3, bpm4 = compute_norm() -# # print(f"Normalised positions are {xn}, {yn}") -# x_pos = (xn - cal["bcu_bpm"]["x_off"]) / cal["bcu_bpm"]["x_slope"] -# y_pos = (yn - cal["bcu_bpm"]["y_off"]) / cal["bcu_bpm"]["y_slope"] -# return x_pos, y_pos - - -def run_calibration(): - """Scan bpm in x and y and record normalised x and y positions""" - # centred_x = 0.749 - # centred_y = -0.660 - now = datetime.now() - fnow = now.strftime("%d%m%H%M") - centred_x = 0.46 - centred_y = -1.51 - print(f"moving bpm to {centred_x}, {centred_y}") - umv(dev.bcu_bpm_y, centred_y) - umv(dev.bcu_bpm_x, centred_x) - - # # Calibrate in X - umv(dev.ss_sl_xsize,0.02) - umv(dev.ss_sl_xsize, 3.0) - filename = f"luts/bpm_calib/{fnow}_bcu_bpm_x.csv" - xn_data = [] - x_positions = np.linspace(centred_x - 0.6, centred_x + 0.6, 101) - with open(filename, "w", encoding="utf-8") as f: - f.write(f"Xpos,Xnorm,BPM1,BPM2,BPM3,BPM4\n") - for x in x_positions: - umv(dev.bcu_bpm_x, x) - print(f"Moving BPM to {x} mm") - time.sleep(0.2) - xn, yn, bpm1, bpm2, bpm3, bpm4 = compute_norm() - xn_data.append(xn) - with open(filename, "a", encoding="utf-8") as f: - f.write(f"{x},{xn},{bpm1},{bpm2},{bpm3},{bpm4}\n") - - # Calibrate in Y - umv(dev.bcu_bpm_x, centred_x) - umv(dev.ss_sl_xsize, 3.0) - umv(dev.ss_sl_ysize, 0.03) - filename = f"luts/bpm_calib/{fnow}_bcu_bpm_y.csv" - y_positions = np.linspace(centred_y - 0.1, centred_y + 0.1, 251) - yn_data = [] - with open(filename, "w", encoding="utf-8") as f: - f.write(f"Ypos,Ynorm,BPM1,BPM2,BPM3,BPM4\n") - for y in y_positions: - umv(dev.bcu_bpm_y, y) - print(f"Moving BPM to {y} mm") - time.sleep(0.2) - xn, yn, bpm1, bpm2, bpm3, bpm4 = compute_norm() - yn_data.append(yn) - with open(filename, "a", encoding="utf-8") as f: - f.write(f"{y},{yn},{bpm1},{bpm2},{bpm3},{bpm4}\n") - - umv(dev.bcu_bpm_x, centred_x) - umv(dev.bcu_bpm_y, centred_y) - umv(dev.ss_sl_ysize, 3.0) - - - -def fit_bpm_data(x_y, rundate="02072130_", bpm_name="bcu_bpm"): - CALIB_DIR = "luts/bpm_calib/" - filename = os.path.join(CALIB_DIR, f"{rundate}{bpm_name}_{x_y}.csv") - data = np.loadtxt(filename, delimiter=",", skiprows=1) - - xdata = data[:, 0] # scan / motor position - ydata = data[:, 1] # normalised BPM signal - - return xdata, ydata - -def linear_calibration( - x_y, - bpm_motor_position, - crosshair_bpm_signal, - rundate = "05071923_", - bpm_name = "bcu_bpm", - sanity_limit = 0.2, - plot = True -): - calib_dir = "luts/bpm_calib" - xdata, ydata = fit_bpm_data(x_y, rundate = rundate, bpm_name = bpm_name) - # Remove non-linear region - if x_y == 'x': - mask_limit = 0.59 - else: - mask_limit = 0.9 - mask = np.abs(ydata) < mask_limit - xdata = xdata[mask] - ydata = ydata[mask] - - m, c = np.polyfit(xdata, ydata, 1) - - # --- Plot --- - plt.figure(figsize=(7, 5)) - plt.scatter(xdata, ydata, color="red", label=f"BPM {x_y} data") - - x_fit = np.linspace(min(xdata), max(xdata), 100) - plt.plot(x_fit, m * x_fit + c, "r--", label=f"Fit: Linear") - - plt.xlabel("label") - plt.ylabel("label") - plt.title("title") - plt.legend() - plt.grid(True) - plt.tight_layout() - plt.show() - -def make_inverse_spline_calibration( - x_y, - bpm_motor_position, - crosshair_bpm_signal, - rundate="05071923_", - bpm_name="bcu_bpm", - sanity_limit=0.2, - plot=True, -): - """ - Create and save inverse BPM calibration. - - Parameters - ---------- - x_y : str - "x" or "y" - bpm_motor_position : float - Current physical BPM motor position during calibration. - crosshair_bpm_signal : float - Normalised BPM reading when the beam is on the sample-camera crosshair. - mask_limit : float - Ignore saturated BPM readings outside +/- mask_limit. - sanity_limit : float - Warn later if BPM motor has moved by more than this. - """ - CALIB_DIR = "luts/bpm_calib/" - xdata, ydata = fit_bpm_data(x_y, rundate=rundate, bpm_name=bpm_name) - - # Remove saturated BPM response - if x_y == 'x': - mask_limit = 0.98 - else: - mask_limit = 0.91 - mask = np.abs(ydata) < mask_limit - xdata = xdata[mask] - ydata = ydata[mask] - - # For inverse calibration: BPM signal -> beam position - order = np.argsort(ydata) - bpm_signal = ydata[order] - local_position = xdata[order] - - # Remove duplicate BPM signal values - bpm_signal, unique_idx = np.unique(bpm_signal, return_index=True) - local_position = local_position[unique_idx] - - spline = PchipInterpolator(bpm_signal, local_position) - - # Local beam position when beam is visually on camera crosshair - crosshair_local_position = float(spline(crosshair_bpm_signal)) - - # Absolute beamline coordinate of camera crosshair - crosshair_absolute_position = bpm_motor_position + crosshair_local_position - - save_file = os.path.join(CALIB_DIR, f"{bpm_name}_{x_y}_inverse_spline.npz") - - np.savez( - save_file, - bpm_signal=bpm_signal, - local_position=local_position, - bpm_motor_position=bpm_motor_position, - crosshair_bpm_signal=crosshair_bpm_signal, - crosshair_local_position=crosshair_local_position, - crosshair_absolute_position=crosshair_absolute_position, - mask_limit=mask_limit, - sanity_limit=sanity_limit, - ) - - print(f"Saved {x_y} BPM calibration to:") - print(save_file) - print() - print(f"Calibration BPM motor position: {bpm_motor_position:.6f}") - print(f"Crosshair BPM signal: {crosshair_bpm_signal:.6f}") - print(f"Crosshair local position: {crosshair_local_position:.6f}") - print(f"Crosshair absolute position: {crosshair_absolute_position:.6f}") - - if plot: - signal_fit = np.linspace(np.min(bpm_signal), np.max(bpm_signal), 1000) - pos_fit = spline(signal_fit) - - plt.figure() - plt.scatter(ydata, xdata, label="calibration data") - plt.plot(signal_fit, pos_fit, label="inverse PCHIP spline", color='red') - plt.axvline(crosshair_bpm_signal, linestyle="--", label="camera crosshair") - plt.xlabel(f"{bpm_name}_{x_y} normalised signal") - plt.ylabel(f"{x_y} local beam position") - plt.title(f"{bpm_name}_{x_y} inverse calibration") - plt.grid(True) - plt.legend() - plt.show() - - return save_file - -class BPMCalibration: - def __init__(self, filename): - data = np.load(filename) - - self.bpm_signal = data["bpm_signal"] - self.local_position = data["local_position"] - - self.bpm_motor_position_calib = float(data["bpm_motor_position"]) - self.crosshair_absolute_position = float(data["crosshair_absolute_position"]) - self.sanity_limit = float(data["sanity_limit"]) - - self.spline = PchipInterpolator( - self.bpm_signal, - self.local_position, - ) - - def beam_position(self, bpm_signal, bpm_motor_position, warn=True): - """ - Return beam position relative to the sample-camera crosshair. - """ - - motor_shift = bpm_motor_position - self.bpm_motor_position_calib - - if warn and abs(motor_shift) > self.sanity_limit: - print( - "Warning: BPM motor has moved since calibration: " - f"delta = {motor_shift:.3f} mm" - ) - - local_beam_position = float(self.spline(bpm_signal)) - absolute_beam_position = bpm_motor_position + local_beam_position - - relative_to_crosshair = ( - absolute_beam_position - self.crosshair_absolute_position - ) - - return relative_to_crosshair - -def get_beampos(): - x_cal = BPMCalibration("luts/bpm_calib/bcu_bpm_x_inverse_spline.npz") - y_cal = BPMCalibration("luts/bpm_calib/bcu_bpm_y_inverse_spline.npz") - - bpm_x_signal, bpm_y_signal = compute_norm() - - beam_x = x_cal.beam_position( - bpm_signal=bpm_x_signal, - bpm_motor_position=dev.bcu_bpm_x.position, - ) - - beam_y = y_cal.beam_position( - bpm_signal=bpm_y_signal, - bpm_motor_position=dev.bcu_bpm_y.position, - ) - - beam_x_mic = 1000 * beam_x - beam_y_mic = 1000 * beam_y - - print(f"Beam relative to camera crosshair:") - print(f"X = {beam_x_mic:.4f} um") - print(f"Y = {beam_y_mic:.4f} um") - - return beam_x_mic, beam_y_mic - -#!/usr/bin/env python -"""Calculate photon flux from a Si diode current.""" - -import math -from dataclasses import dataclass - -import numpy as np - - -@dataclass -class PXIIDiodeConfig: - """Diode/beamline-specific constants.""" - - si_thickness_um: float = 12.0 - al_thickness_um: float = 20.0 - diode_offset_mm: float = 15.0 - - si_density: float = 2.33 # g/cm^3 - al_density: float = 2.699 # g/cm^3 - air_density: float = 1.205e-3 # g/cm^3 - - eps_si: float = 3.62 # eV per electron-hole pair - - -def flux( - current_a: float, - energy_kev: float | None = None, - det_z: float | None = None, - config = PXIIDiodeConfig, -) -> float: - """ - Calculate photon flux from Si diode current. - - Parameters - ---------- - current_a: - Diode current in A. - energy_kev: - Beam energy in keV. Will use the current energy if - not specified. - det_z: - Detector distance (dev.det_z) (mm). Will use the current - detector distance if not specified. - config: - DiodeConfig containing Si/Al thicknesses and material constants. - - Returns - ------- - float - Flux in photons/s. - """ - if energy_kev is None: - energy_kev = get_current_energy() / 1000 - - if det_z is None: - det_z = dev.det_z.position - - air_path_mm = det_z + config.diode_offset_mm - - si_thickness_cm = config.si_thickness_um / 10_000.0 - al_thickness_cm = config.al_thickness_um / 10_000.0 - - log_energy = math.log10(energy_kev) - - # Photoelectric mass attenuation coefficient fits - si_poly = np.poly1d([0.0789, -0.477, -2.238, 4.158]) - al_poly = np.poly1d([0.0638, -0.413, -2.349, 4.106]) - air_poly = np.poly1d([0.928, -2.348, -1.026, 3.153]) - - a_si = 10 ** si_poly(log_energy) - a_al = 10 ** al_poly(log_energy) - a_air = 10 ** air_poly(log_energy) - - # Fraction of beam absorbed in active Si layer - si_absorbed_fraction = -np.expm1( - -a_si * config.si_density * si_thickness_cm - ) - - if si_absorbed_fraction <= 0: - raise ValueError("Calculated Si absorption fraction is zero or negative.") - - # Flux before Al/air correction - flux = ( - 1000.0 - * current_a - * config.eps_si - / 1.602 - / energy_kev - / si_absorbed_fraction - * 1.0e13 - ) - - # Transmission through Al and air - al_transmission = np.exp( - -a_al * config.al_density * al_thickness_cm - ) - - air_transmission = np.exp( - -a_air * config.air_density * air_path_mm / 10.0 - ) - - flux /= al_transmission - flux /= air_transmission - - - print(f"Flux = {flux: .3g} ph/s") - - return float(flux) - -def calibrate_bpm_flux(ave = 5): - # d['det_z'].move('mse') - # d['det_y'].move('xi') - # d['det_z'].move(200) - - dir = "luts/bpm_calib/" - filename = dir + "bpm_flux_20260708b.csv" - with open(filename, 'w', encoding="utf-8") as f: - f.write("Energy,Transmission,BPMSum,Flux\n") - print("Energy,Transmission,BPMSum,Flux\n") - energies = [12400,7000,8000,9000,10000,11000,13000,14000,15000,16000,18000,20000,25000] - transmissions = [1, 0.9, 0.8, 0.7, 0.6, 0.5,0.4,0.3,0.2,0.1] - - for energy in energies: - print(f"Moving to energy {energy}") - bl_energy(energy) - - for set_trans in transmissions: - print(f"Setting transmission to {set_trans}") - dev.transm.put(set_trans) - time.sleep(5) - - flux_values = [] - bpm_values = [] - - print(f"Measuring flux and bpmsum") - for _ in range(ave): - diode_current = dev.xidiode.read()['xidiode']['value'] - fl = flux(diode_current) - bpmsum = dev.bcu_bpmsum.read()['bcu_bpmsum']['value'] - flux_values.append(fl) - bpm_values. append(bpmsum) - - actual_trans = dev.transm.read()['transm']['value'] - flux_ave = np.mean(flux_values) - bpmsum_ave = np.mean(bpm_values) - print(f"{energy:.5g},{actual_trans:.3g},{bpmsum_ave:.4g},{flux_ave:.4f}\n") - - with open(filename, 'a') as f: - f.write(f"{energy:.5g},{actual_trans:.3g},{bpmsum_ave:.4g},{flux_ave:.4f}\n") - bl_energy(12400) - umv(dev.det_y, 70) - umv(dev.id_gap, 20) - -def analyse_bpm_flux_calibration( - filename="luts/bpm_calib/bpm_flux_20260708b.csv", - force_zero_intercept=False, -): - data = pd.read_csv(filename) - - results = [] - with open("luts/bpm_calib/bpm_flux_fits.csv", "w") as f: - f.write("Energy,Slope,Intercept\n") - for energy, group in data.groupby("Energy"): - x = group["BPMSum"].to_numpy(dtype=float) - print(f"x is {x}") - y = group["Flux"].to_numpy(dtype=float) - - if force_zero_intercept: - # y = m*x - slope = np.sum(x * y) / np.sum(x * x) - intercept = 0.0 - else: - # y = m*x + c - slope, intercept = np.polyfit(x, y, deg=1) - - y_fit = slope * x + intercept - - # --- Plot --- - plt.figure(figsize=(7, 5)) - plt.scatter(x, y, color="red") - - x_fit = np.linspace(min(x), max(x), 100) - plt.plot(x_fit, slope * x_fit + intercept, - "r--", label=f"Fit: Slope = {slope:.5g}, Intercept = {intercept:.5g}") - - plt.xlabel("BPMSUm") - plt.ylabel("Flux") - plt.title(f"{energy} eV") - plt.legend() - plt.grid(True) - plt.tight_layout() - plt.savefig(f"luts/bpm_calib/{energy}_bpm_flux") - # plt.show() - - residuals = y - y_fit - ss_res = np.sum(residuals**2) - ss_tot = np.sum((y - np.mean(y))**2) - - r2 = 1 - ss_res / ss_tot if ss_tot > 0 else np.nan - - results.append( - { - "Energy": energy, - "Slope": f"{slope:.5g}", - "Intercept": f"{intercept:.5g}", - "R2": f"{r2:.3g}", - # "N": len(group), - } - ) - - results = pd.DataFrame(results) - - results.to_csv("luts/bpm_calib/bpm_flux_fits.csv", index=False) - dict = results.to_dict() - print(dict) - return results - -def linear_bpm_flux_calib(): - filename = 'luts/bpm_calib/fits-25.csv' - df = pd.read_csv(filename) - energies = df["Energy"].to_numpy() - intercepts = df["Intercept"].to_numpy() - slopes = df["Slope"].to_numpy() - # --- Plot --- - plt.figure(figsize=(7, 5)) - plt.scatter(energies, slopes, color="red") - - x_fit = np.linspace(min(energies), max(energies), 100) - coeffs = np.polyfit(energies, slopes,1) - y_fit = np.poly1d(coeffs) - plt.plot(x_fit, y_fit(x_fit)), - plt.xlabel("Energy eV") - plt.ylabel("Slope") - plt.title(f"Energies vs slopes, coeffs = {coeffs}") - # plt.legend() - plt.grid(True) - plt.tight_layout() - plt.savefig(f"luts/bpm_calib/slopes_vs_energy") - plt.show() - return coeffs - - -# def get_flux_calibration(energy): -# # filename = "luts/bpm_calib/bpm_flux_fits.csv" -# filename = 'luts/bpm_calib/fits-25.csv' -# default_slope = 4.42e8 -# default_intercept = -1.66e11 - -# try: -# df = pd.read_csv(filename) -# energies = df["Energy"].to_numpy() -# intercepts = df["Intercept"].to_numpy() -# slopes = df["Slope"].to_numpy() -# slope_interp = CubicSpline(energies, slopes) -# intercept_interp = CubicSpline(energies, intercepts) -# slope = slope_interp(energy) -# intercept = intercept_interp(energy) -# print(f"Using data from calibration file") -# # --- Plot --- -# plt.figure(figsize=(7, 5)) -# plt.scatter(energies, slopes, color="red") - -# x_fit = np.linspace(min(energies), max(energies), 100) -# coeffs = np.polyfit(energies, slopes,1) -# print("linear co-efficients: ", coeffs) -# y_fit = np.poly1d(coeffs) -# plt.plot(x_fit, y_fit(x_fit)), -# # "r--", label=f"Fit: Slope = {slope:.5g}, Intercept = {intercept:.5g}") - -# plt.xlabel("Energy") -# plt.ylabel("Slope") -# plt.title(f"{energy} eV") -# # plt.legend() -# plt.grid(True) -# plt.tight_layout() -# plt.show() -# except FileNotFoundError: -# print("Cannot access calibration file, using default parameters") -# slope = default_slope -# intercept = default_intercept - -# return coeffs - - -def bpm2flux(energy=None, bpmsum=None, transm=None): - """ - Calculate the flux from BCU BPM reading. - Option to provide energy, bpmsum reading and transmission. - If these are not given, the current values are used. - - Returns the flux at the sample (after attenuators) and a calculated - value of the full flux if attenuation was 0. - - """ - calibration_min_energy = 6500 - calibration_max_energy = 21000 - - if energy is None: - energy = get_current_energy() - - if bpmsum is None: - bpmsum = dev.bcu_bpmsum.read()["bcu_bpmsum"]["value"] - - if transm is None: - transm = dev.transm.read()['transm']['value'] - - if not calibration_min_energy <= energy <= calibration_max_energy: - raise ValueError( - f"Energy {energy:.0f} eV is outside the calibrated range " - f"{calibration_min_energy:.0f}–" - f"{calibration_max_energy:.0f} eV" - ) - - coeffs = [ - 1.06436277e5, - -6.38943746e8, - ] - - calibration_factor = np.polyval(coeffs, energy) - flux = calibration_factor * bpmsum - full_flux = flux/transm - if transm == 1: - print(f"Transmission = {transm*100:.5g} %, Flux = {flux: .3g} ph/s,\n") - else: - print(f"Transmission = {transm*100: .5g} %, Flux = {flux: .3g} ph/s,\n" - f"Flux with 100 % transmission would be {full_flux: .3g} ph/s") - - return float(flux), float(full_flux) - - - diff --git a/pxii_bec/macros/daily.py b/pxii_bec/macros/daily.py new file mode 100644 index 0000000..6ec7721 --- /dev/null +++ b/pxii_bec/macros/daily.py @@ -0,0 +1,479 @@ +""" Files needed for the daily setup routine for local contacts """ + +import time +import beamline_context as bl + + +def daily_setup(energy=12400): + """ The daily setup workflow """ + + plot1, plot2, plot3, plot4, log, progress = select_daily_setup_gui() + + messages = [] + + progress_state = { + "Set energy": "todo", + "Align beamstop": "todo", + "Measure beam position": "todo", + "Align collimator": "todo", + "Measure flux": "todo", + "Save new positions to BEC": "todo", + "Align rotation axis": "todo", + } + + update_log(log, messages, "Starting daily beamline setup") + + clear_daily_plots + # # Step 1: set beamline energy + set_progress(progress, progress_state, "Set energy", "running") + daily_energy(energy,plot_widget=plot1) + set_progress(progress, progress_state, "Set energy", "done") + update_log(log, messages, f"Beamline energy is {get_current_energy():.5g} eV") + + # Step 2: align beamstop + clear_daily_plots() + set_progress(progress, progress_state, "Align beamstop", "running") + bs_result = daily_beamstop() + set_progress(progress, progress_state, "Align beamstop", "done") + update_log(log, messages, f"Beamstop centred: " + f"X centre: {bs_result['x_position']:.4g}, " + f"Y centre: {bs_result['y_position']:.4g}" + ) + save_current_position(dev.bs_x, 'in') + save_current_position(dev.bs_y, 'in') + set_progress(progress, progress_state, "Align beamstop", "done") + + # Step 3: measure beam position + set_progress(progress, progress_state, "Measure beam position", "running") + pos_result = daily_beampos() + update_log(log, messages, "Beam centres: ") + for zoom in CameraZoom: + update_log(log, messages, f"{zoom.label} zoom: ({pos_result[zoom.label]['x']:.4g}, {pos_result[zoom.label]['y']:.4g})") + set_progress(progress, progress_state, "Measure beam position", "done") + + # Step 4: Align collimator + set_progress(progress, progress_state, "Align collimator", "running") + coll_result = daily_coll() + update_log(log, messages, f"Collimator centred: " + f"X centre: {coll_result['x_position']:.4g}, " + f"Y centre: {coll_result['y_position']:.4g}" + ) + save_current_position(dev.coll_x, 'in') + save_current_position(dev.coll_y, 'in') + set_progress(progress, progress_state, "Align collimator", "done") + + # Step 5: measure flux + set_progress(progress, progress_state, "Measure flux", "running") + flux1,flux2 = bpm2flux() + update_log(log, messages, f"Flux at 100% transmission is {flux2:.3g} ph/s") + set_progress(progress, progress_state, "Measure flux", "done") + + # Step 6: save new positions and reload + set_progress(progress, progress_state, "Save new positions to BEC", "running") + save_and_reload() + update_log(log, messages, f"Positions for collimator and beamstop have been saved") + set_progress(progress, progress_state, "Save new positions to BEC", "done") + +def select_daily_setup_gui_old(): + """Return widgets belonging to the Daily Setup GUI.""" + + window_name = "DailySetup" + open_windows = bec.gui.windows + + if open_windows.get(window_name) is None: + gui = bec.gui.new(window_name) + + plot1 = gui.new( + widget = "Waveform", + object_name = "Plot1" + ) + + plot2 = gui.new( + widget = "Waveform", + object_name = "Plot2" + ) + + results = gui.new( + widget = "TextBox", + object_name = "Results", + where = "bottom", + ) + + log = gui.new( + widget = "TextBox", + object_name = "Info", + where = "bottom", + ) + + progress = gui.new( + widget = "TextBox", + object_name = "Progress", + where = "left", + ) + + else: + gui = open_windows[window_name] + plot1 = gui.Plot1 + plot2 = gui.Plot2 + log = gui.Info + results = gui.Results + progress = gui.Progress + + return plot1, plot2, results, log, progress + + +def select_daily_setup_gui(): + """Return widgets belonging to the Daily Setup GUI.""" + + window_name = "DailySetup" + open_windows = bec.gui.windows + + if open_windows.get(window_name) is None: + gui = bec.gui.new(window_name) + + # Row 1 + plot1 = gui.new( + widget="Waveform", + object_name="Beamstop_X", + ) + + plot2 = gui.new( + widget="Waveform", + object_name="Beamstop_Y", + relative_to="Beamstop_X", + where="right", + ) + + # Row 2 - start a new full-width row + plot3 = gui.new( + widget="Waveform", + object_name="Collimator_X", + where="bottom", + ) + + plot4 = gui.new( + widget="Waveform", + object_name="Collimator_Y", + relative_to="Collimator_X", + where="right", + ) + + # Row 3 - start another full-width row + log = gui.new( + widget="TextBox", + object_name="Info", + where="bottom", + ) + + progress = gui.new( + widget="TextBox", + object_name="Progress", + relative_to="Info", + where="right", + ) + gui.set_layout_ratios( + horizontal=[1, 1], + vertical=[2, 2, 1], + ) + else: + gui = open_windows[window_name] + plot1 = gui.Beamstop_X + plot2 = gui.Beamstop_Y + plot3 = gui.Collimator_X + plot4 = gui.Collimator_Y + log = gui.Info + progress = gui.Progress + + return plot1, plot2, plot3, plot4, log, progress + +def clear_daily_plots(): + plot1, plot2, plot3, plot4, log, progress = select_daily_setup_gui() + plot1.clear_all() + plot2.clear_all() + plot3.clear_all() + plot4.clear_all() + + + +def update_log(log_box, messages, message): + """Add new message to the daily setup log """ + messages.append(message) + log_box.set_plain_text("\n".join(messages)) + +def update_progress(progress_box, progress_state): + """ Sets up the status icons for the progress tracker""" + status = { + "todo": "\u25CB", + "running": "\u25B6", + "done": "\u2713", + "warning": "\u26A0", + "failed": "\u2717", + } + + + text = "\n".join( + f"{status[state]} {label}" + for label, state in progress_state.items() + ) + progress_box.set_plain_text(text) + +def set_progress(progress_box, progress_state, step, status): + """Change the status of one step and update the display.""" + progress_state[step] = status + update_progress(progress_box, progress_state) + +def plot_daily_setup_scan( + motor_name, + signal_name, + plot="x", + title=None, +): + """Plot live scan data in one of the Daily Setup waveform widgets.""" + + plot1, plot2, plot3, plot4, log, progress = select_daily_setup_gui() + + if plot.lower() == "beamstop_x": + wf = plot1 + elif plot.lower() == "beamstop_y": + wf = plot2 + elif plot.lower() == "collimator_x": + wf = plot3 + elif plot.lower() == "collimator_y": + wf = plot4 + else: + raise ValueError("plot must be 'x' or 'y'") + + wf.clear_all() + + if title is None: + title = f"{motor_name} scan" + + wf.title = title + wf.x_label = motor_name + wf.y_label = signal_name + + wf.plot( + device_x=motor_name, + device_y=signal_name, + ) + +def daily_energy(energy, plot_widget=None): + """ Set the beamline to the required energy """ + current_energy = get_current_energy() + if abs(energy - current_energy) > 1: + bl_energy(energy, window_name="DailySetup", plot_widget=plot_widget) + else: + gap_actual = dev.id_gap.position + gap_req = new_calc_gap(energy) + if abs(gap_actual-gap_req) > 0.05: + umv(dev.id_gap, gap_req) + mono_pitch_scan(window_name="DailySetup", plot_widget=plot_widget) + +def set_zoom(zoom): + """Set sample camera zoom level.""" + + if isinstance(zoom, str): + zoom = CameraZoom.from_label(zoom) + umv(dev.scam_zoom, zoom.position) + else: + umv(dev.scam_zoom, zoom) + +def daily_beampos(): + """Measure beam positions at different zoom levels""" + results = {} + # Ensure shutter and detector cover are closed before changing states + dev.bcu_shutter.put(0) + bl.d['det_cov'].move('close') + try: + # set transmission to 10% + dev.transm.put(0.1) + + # move to beam visualisation + bl.planner.move_to(BeamlineState.BEAM_VISUALISATION) + + # open shutter + dev.bcu_shutter.put(1) + + for zoom in CameraZoom: + print(F"Moving to {zoom.label}") + umv(dev.scam_zoom, zoom.position) + + # set autoexposure + auto_exposure(cam="samcam", max_iter=25) + time.sleep(0.2) + + # take readings + x = dev.samcam_x.read()['samcam_x']['value'] + y = dev.samcam_y.read()['samcam_y']['value'] + + # append results + results[zoom.label] = {'x': x, 'y': y} + + print(f" {zoom.label}: x = {x:.4g}, y = {y:.4g}") + return results + finally: + dev.bcu_shutter.put(0) + +def daily_coll(): + """Centre the collimator in X and Y using the I1 diode.""" + plot1, plot2, plot3, plot4, log, progress = select_daily_setup_gui() + + result = { + "success": False, + "start_intensity": None, + "y_start_intensity": None, + "y_end_intensity": None, + "x_start_intensity": None, + "x_end_intensity": None, + "y_position": None, + "x_position": None, + } + + dev.bcu_shutter.put(0) + + try: + if not bl.planner.is_state(BeamlineState.FLUX_MEASUREMENT): + bl.planner.move_to(BeamlineState.FLUX_MEASUREMENT) + + dev.bcu_shutter.put(1) + + time.sleep(0.2) + + result["start_intensity"] = read_i1() + print(f"Starting intensity is {result['start_intensity']:.4g}") + + bl.d["coll_y"].move("in") + + # Centre Y + result["y_start_intensity"] = read_i1() + print( + "Intensity with collimator in before Y scan: " + f"{result['y_start_intensity']:.4g}" + ) + + y_result = find_feature( + dev.coll_y, + dev.i1, + -0.3, + 0.3, + 30, + feature="peak", + relative=True, + confirm=False, + plot_widget=plot4, + ) + + result["y_position"] = y_result["centre"] + result["y_end_intensity"] = read_i1() + + print( + "Intensity with collimator in after Y scan: " + f"{result['y_end_intensity']:.4g}" + ) + + # Centre X + result["x_start_intensity"] = read_i1() + + print( + "Intensity with collimator in before X scan: " + f"{result['x_start_intensity']:.4g}" + ) + + x_result = find_feature( + dev.coll_x, + dev.i1, + -0.3, + 0.3, + 30, + feature="peak", + relative=True, + confirm=False, + plot_widget=plot3, + ) + + result["x_position"] = x_result["centre"] + result["x_end_intensity"] = read_i1() + + print( + "Intensity with collimator in after X scan: " + f"{result['x_end_intensity']:.4g}" + ) + + result["success"] = True + + return result + + finally: + dev.bcu_shutter.put(0) + +def daily_beamstop(): + """Centre the beamstop against i2""" + + plot1, plot2, plot3, plot4, log, progress = select_daily_setup_gui() + + result = { + # "success": False, + # "x_position": None, + "y_position": None, + "intensity after alignment": None + } + + dev.bcu_shutter.put(0) + + try: + if not bl.planner.is_state(BeamlineState.BEAMSTOP_ALIGNMENT): + bl.planner.move_to(BeamlineState.BEAMSTOP_ALIGNMENT) + set_zoom('2x') + auto_exposure('samcam', max_iter=20) + + bl.d['bl_pos'].move('out') + bl.d['det_cov'].move('close') + dev.bcu_shutter.put(1) + + time.sleep(0.2) + + # Centre Y + y_result = find_feature( + dev.bs_y, + dev.i2, + -1, + 1, + 30, + settle=0.3, + feature="dip", + relative=True, + confirm=False, + plot_widget=plot2, + ) + # Wait for bs_y to setlle + time.sleep(2) + # Centre X + x_result = find_feature( + dev.bs_x, + dev.i2, + -0.1, + 1.5, + 30, + feature="edge_offset", + offset = Beamstop.x_offset, + relative=True, + confirm=False, + plot_widget=plot1, + ) + + result["x_position"] = x_result["centre"] + result["y_position"] = y_result["centre"] + result["intensity after alignment"] = read_i2() + + print( + "Intensity after Y scan: " + f"{result['intensity after alignment']:.4g}" + ) + + return result + + finally: + dev.bcu_shutter.put(0) + + + diff --git a/pxii_bec/macros/init_beamline.py.bak b/pxii_bec/macros/init_beamline.py.bak new file mode 100755 index 0000000..2c9ae8a --- /dev/null +++ b/pxii_bec/macros/init_beamline.py.bak @@ -0,0 +1,123 @@ +"""Initialise sample environment devices and beamline states.""" + +import os +from dataclasses import dataclass +from pathlib import Path + +# path = Path(__file__) / "../../.." + +@dataclass +class Environment: + """Define configuration files for a beamline and BEC deployment.""" + + beamline: str + deployment: str + + beamline_configs = { + "x10sa": { + "config_root": "/sls/x10sa/config/bec", + "package": "pxii_bec", + "devices": "pxii-devices.yaml", + "states": "pxii-beamline-states.yaml", + }, + "x06da": { + "config_root": "/sls/x06da/config/bec", + "package": "pxiii_bec", + "devices": "pxiii-devices.yaml", + "states": "pxiii-beamline-states.yaml", + }, + } + + valid_deployments = ("test", "production") + + def __post_init__(self): + + if self.beamline not in self.beamline_configs: + raise ValueError( + f"Unknown beamline '{self.beamline}'. " + f"Choose from {list(self.beamline_configs)}" + ) + + if self.deployment not in self.valid_deployments: + raise ValueError( + f"Unknown deployment '{self.deployment}'. " + f"Choose from {self.valid_deployments}" + ) + + cfg = self.beamline_configs[self.beamline] + + self.bec_dir = ( + Path(cfg["config_root"]) + / self.deployment + / cfg["package"] + / cfg["package"] + ) + + self.device_config_dir = self.bec_dir / "device_configs" + self.lut_dir = self.bec_dir / "macros" / "luts" + + self.devices_file = self.device_config_dir / cfg["devices"] + self.states_file = self.device_config_dir / cfg["states"] + + + if not self.devices_file.exists(): + raise FileNotFoundError( + f"Device configuration not found: {self.devices_file}" + ) + + if not self.states_file.exists(): + raise FileNotFoundError( + f"State configuration not found: {self.states_file}" + ) + + +def init_beamline_environment(deployment): + """ + Initialise beamline positioned devices and state planner. + + Parameters + ---------- + deployment : str + BEC deployment to use: "test" or "production". + """ + + beamline = os.environ["BEAMLINE"] + + env = Environment( + beamline=beamline, + deployment=deployment, + ) + + print("=" * 60) + print(f"Beamline : {beamline}") + print(f"BEC deployment : {deployment.upper()}") + print(f"Devices file : {env.devices_file}") + print(f"States file : {env.states_file}") + print("=" * 60) + + # Initialise positioned devices + device_manager = DeviceManager() + devices = device_manager.initialize_devices(env.devices_file) + + # Initialise beamline states + state_manager = DefineStatesManager() + states, allow_modifiers = state_manager.initialize_states( + env.states_file + ) + + # Set up dependencies + deps = planner_deps() + + # Set up planner + planner = StateChangePlanner( + devices, + states, + allow_modifiers, + deps, + ) + + print("Beamline state planner and devices initialised") + + return env, devices, planner + + diff --git a/pxii_bec/macros/katscripts.py b/pxii_bec/macros/katscripts.py index faa3cb3..64a1045 100755 --- a/pxii_bec/macros/katscripts.py +++ b/pxii_bec/macros/katscripts.py @@ -31,6 +31,89 @@ def bragg_scan(): ) gap += 0.5 +def scan_bpm(bpmname): + """ + Runs a grid scan of a BPM in x and y, and plots each channel + as a heatmap. + + Parameters: + bpmname: the name of the bpm to be scanned e.g. "fe" + + """ + + # Open a dock area and set up the heatmaps + dock_area = bec.gui.new("XBPM_Scan") + wf5 = dock_area.new("Sum").new(bec.gui.available_widgets.Heatmap) + wf1 = dock_area.new("Ch1", relative_to="Sum", position="bottom").new( + bec.gui.available_widgets.Heatmap + ) + wf3 = dock_area.new("Ch3", relative_to="Ch1", position="right").new( + bec.gui.available_widgets.Heatmap + ) + wf4 = dock_area.new("Ch4", relative_to="Ch3", position="bottom").new( + bec.gui.available_widgets.Heatmap + ) + wf2 = dock_area.new("Ch2", relative_to="Ch1", position="bottom").new( + bec.gui.available_widgets.Heatmap + ) + wfscan = dock_area.new("ScanControl").new(bec.gui.available_widgets.ScanControl) + + cfg = getattr(BPMScans, bpmname) + + wf1.x_label = cfg["x_name"] + wf1.y_label = cfg["y_name"] + wf1.plot(x_name=cfg["x_name"], y_name=cfg["y_name"], z_name=cfg["z1_name"], color_map="plasma") + + wf2.x_label = cfg["x_name"] + wf2.y_label = cfg["y_name"] + wf2.plot(x_name=cfg["x_name"], y_name=cfg["y_name"], z_name=cfg["z2_name"], color_map="plasma") + + wf3.x_label = cfg["x_name"] + wf3.y_label = cfg["y_name"] + wf3.plot(x_name=cfg["x_name"], y_name=cfg["y_name"], z_name=cfg["z3_name"], color_map="plasma") + + wf4.x_label = cfg["x_name"] + wf4.y_label = cfg["y_name"] + wf4.plot(x_name=cfg["x_name"], y_name=cfg["y_name"], z_name=cfg["z4_name"], color_map="plasma") + + wf5.x_label = cfg["x_name"] + wf5.y_label = cfg["y_name"] + wf5.plot(x_name=cfg["x_name"], y_name=cfg["y_name"], z_name=cfg["z5_name"], color_map="plasma") + # Run the scan + x_mot = cfg["x_device"] + y_mot = cfg["y_device"] + # scans.grid_scan(x_mot, -0.5, 0.5, 20, y_mot, -0.5, 0.5, 20, + # exp_time=0.5, relative=False, snaked=True) + + +def optimise_kb(mirror): + """ + Runs a grid scan of a the upstream and downstream benders, + and plots a heatmap of the sample camera x or y sigma. + + Parameters: + mirror: either "hfm" or :vfm" + + """ + + # Open a dock area and set up the heatmaps + dock_area = bec.gui.new(mirror) + wf1 = dock_area.new("Heatmap").new(bec.gui.available_widgets.Heatmap) + + wfscan = dock_area.new("ScanControl").new(bec.gui.available_widgets.ScanControl) + + cfg = getattr(MirrorConfig, mirror) + + wf1.x_label = cfg["bu_name"] + wf1.y_label = cfg["bd_name"] + wf1.plot(x_name=cfg["bu_name"], y_name=cfg["bd_name"], z_name=cfg["z_name"], color_map="plasma") + + # Run the scan + x_mot = cfg["x_device"] + y_mot = cfg["y_device"] + # scans.grid_scan(x_mot, -0.02, 0.02, 11, y_mot, -0.02, 0.02, 11, + # exp_time=0.5, relative=True, snaked=True) + def move_xeye(direction): """Move the xeye in or out""" @@ -1005,23 +1088,30 @@ def mirror_pitch(mirror = 'vfm'): bl_energy(12400) results = np.array(results) -def read_samcam_scint(zoom=800): - # set transmission tp 10% - dev.transm.put(0.1) - # set camera zoom - umv(dev.scam_zoom, zoom) - # move to beam visualisation, ensure shutter is closed first +def read_scintXY(zoom=800): + """ Get the X and Y beam positions from the sample camera at + a sepcified zoom. Default zoom is 800""" + # Ensure shutter and detector cover are closed before changing states dev.bcu_shutter.put(0) - bl.planner.move_to(BeamlineState.BEAM_VISUALISATION) - # open shutter - dev.bcu_shutter.put(1) - # set autoexposure - auto_exposure(cam="samcam", max_iter=25) - time.sleep(0.2) - x = dev.samcam_x.read()['samcam_x']['value'] - y = dev.samcam_y.read()['samcam_y']['value'] - dev.bcu_shutter.put(0) - return x, y + bl.d['det_cov'].move('close') + try: + # set transmission to 10% + dev.transm.put(0.1) + # set camera zoom + umv(dev.scam_zoom, zoom) + # move to beam visualisation + + bl.planner.move_to(BeamlineState.BEAM_VISUALISATION) + # open shutter + dev.bcu_shutter.put(1) + # set autoexposure + auto_exposure(cam="samcam", max_iter=25) + time.sleep(0.2) + x = dev.samcam_x.read()['samcam_x']['value'] + y = dev.samcam_y.read()['samcam_y']['value'] + return x, y + finally: + dev.bcu_shutter.put(0) def find_best_roll(low = 6000, high = 20000): # low_scanpoints = np.linspace(2.0, 7.0, 11) @@ -1400,14 +1490,14 @@ def get_mirror_data(history_index: int): # } -def record_beampos_until(stop_time_str, planner, env, interval_minutes=10): +def record_beampos_until(stop_time_str, interval_minutes=10): """ Runs `record_beam()` every `interval_minutes` minutes until the next occurrence of the given stop time (HH:MM). """ # Prepare the file - filename = env.lut_dir / "beampos" / f"beampos_{filenow()}.csv" + filename = bl.env.lut_dir / "beampos" / f"beampos_{filenow()}.csv" scam_zoom = dev.scam_zoom.read()['scam_zoom']['value'] umv(dev.scam_zoom, 800) beam_size = "25 x 25" @@ -1432,7 +1522,7 @@ def record_beampos_until(stop_time_str, planner, env, interval_minutes=10): # Change to beam visualisation state, ensure shutter is closed first dev.bcu_shutter.put(0) - planner.move_to(BeamlineState.BEAM_VISUALISATION) + bl.planner.move_to(BeamlineState.BEAM_VISUALISATION) # Start recording beam position print(f"Starting now ({now:%Y-%m-%d %H:%M}), running until {end_time:%Y-%m-%d %H:%M}") @@ -1447,7 +1537,7 @@ def record_beampos_until(stop_time_str, planner, env, interval_minutes=10): time.sleep(interval_minutes * 60) print(f"Finished — reached {end_time:%H:%M}.") - planner.move_to(BeamlineState.MANUAL_SAMPLE_EXCHANGE) + bl.planner.move_to(BeamlineState.MANUAL_SAMPLE_EXCHANGE) @@ -1461,26 +1551,28 @@ def record_beam(filename): umv(dev.bcu_bpm_x, BPM_X_Calibration.centred_position) umv(dev.bcu_bpm_y, BPM_Y_Calibration.centred_position) - # Open shutter and record positions - dev.bcu_shutter.put(1) - auto_exposure(cam="samcam") - time.sleep(2) - now = datetime.now() + try: + # Open shutter and record positions + dev.bcu_shutter.put(1) + auto_exposure(cam="samcam") + time.sleep(2) + now = datetime.now() - # Append data to the file - with open(filename, "a", encoding="utf-8") as f: - fnow = now.strftime("%H:%M:%S") - xpos_cam = dev.samcam_x.read()["samcam_x"]["value"] - ypos_cam = dev.samcam_y.read()["samcam_y"]["value"] - xpos_bpm, ypos_bpm = get_bcu_beampos() - print(f"Time is {fnow}, ScinX position is {xpos_cam:.5g}, ScinY position is {ypos_cam:.5g}") - print(f"BPM X is: {xpos_bpm}, BPM Y is {ypos_bpm}") - f.write( - # f"{fnow}, {xpos: .5g}, {ypos: .4g}, {xpos_cam: .5g}, {ypos_cam: .4g}\n" - f"{fnow},{xpos_cam: .5g},{ypos_cam: .4g},{xpos_bpm: .5g},{ypos_bpm: .5g}\n" - ) - # Close shutter - dev.bcu_shutter.put(0) + # Append data to the file + with open(filename, "a", encoding="utf-8") as f: + fnow = now.strftime("%H:%M:%S") + xpos_cam = dev.samcam_x.read()["samcam_x"]["value"] + ypos_cam = dev.samcam_y.read()["samcam_y"]["value"] + xpos_bpm, ypos_bpm = get_bcu_beampos() + print(f"Time is {fnow}, ScinX position is {xpos_cam:.5g}, ScinY position is {ypos_cam:.5g}") + print(f"BPM X is: {xpos_bpm}, BPM Y is {ypos_bpm}") + f.write( + # f"{fnow}, {xpos: .5g}, {ypos: .4g}, {xpos_cam: .5g}, {ypos_cam: .4g}\n" + f"{fnow},{xpos_cam: .5g},{ypos_cam: .4g},{xpos_bpm: .5g},{ypos_bpm: .5g}\n" + ) + finally: + # Close shutter + dev.bcu_shutter.put(0) def analyse_beampos(file): @@ -1578,120 +1670,6 @@ def scan_scin_focus(planner, type = 'fine'): go_to_peak(dev.diag_z, dev.scam, min, max, steps, relative=True, gomax=True, confirm=False) dev.bcu_shutter.put(0) -def daily_setup(energy=12400): - - wf, results, log, progress = select_daily_setup_gui() - - messages = [] - - progress_state = { - "Set energy": "todo", - "Measure flux": "todo", - "Measure beam position": "todo", - "Align collimator": "todo", - "Check beamstop": "todo", - "Align rotation axis": "todo", - } - - update_log(log, messages, "Starting daily beamline setup") - - - # Step 1: set beamline - set_progress(progress, progress_state, "Set energy", "running") - current_energy = get_current_energy() - if abs(energy - current_energy) > 1: - bl_energy(energy, window_name="DailySetup") - else: - gap_actual = dev.id_gap.position - gap_req = new_calc_gap(energy) - if abs(gap_actual-gap_req) > 0.05: - umv(dev.id_gap, gap_req) - mono_pitch_scan(window_name="DailySetup") - - set_progress(progress, progress_state, "Set energy", "done") - update_log(log, messages, f"Beamline energy is {energy} eV") - - # Step 2: measure flux - set_progress(progress, progress_state, "Measure flux", "running") - flux1,flux2 = bpm2flux() - update_log(log, messages, f"Flux at 100% transmission is {flux2:.3g} ph/s") - set_progress(progress, progress_state, "Measure flux", "done") - - # Step 3: measure beam position - - # Step 4: Align collimator - set_progress(progress, progress_state, "Align collimator", "running") - result = cen_coll(d, planner, window_name="DailySetup") - update_log(log, messages, f"Success: result['success'], X centre: results['x_position'], Y centre: result['y_position']") - set_progress(progress, progress_state, "Align collimator", "done") - - -def update_log(log_box, messages, message): - messages.append(message) - log_box.set_plain_text("\n".join(messages)) - -def update_progress(progress_box, progress_state): - status = { - "todo": "\u25CB", - "running": "\u25B6", - "done": "\u2713", - "warning": "\u26A0", - "failed": "\u2717", - } - - - text = "\n".join( - f"{status[state]} {label}" - for label, state in progress_state.items() - ) - progress_box.set_plain_text(text) - -def set_progress(progress_box, progress_state, step, status): - """Change the status of one step and update the display.""" - progress_state[step] = status - update_progress(progress_box, progress_state) - - -def select_daily_setup_gui(): - """Return widgets belonging to the Daily Setup GUI.""" - - window_name = "DailySetup" - open_windows = bec.gui.windows - - if open_windows.get(window_name) is None: - gui = bec.gui.new(window_name) - - plot = gui.new( - widget = "Waveform", - object_name = "Plot" - ) - - results = gui.new( - widget = "TextBox", - object_name = "Results", - where = "bottom", - ) - - log = gui.new( - widget = "TextBox", - object_name = "Info", - where = "bottom", - ) - - progress = gui.new( - widget = "TextBox", - object_name = "Progress", - where = "left", - ) - - else: - gui = open_windows[window_name] - plot = gui.Plot - log = gui.Info - results = gui.Results - progress = gui.Progress - - return plot, results, log, progress def bpm_errors(ch1, ch2, ch3, ch4): total = ch1 + ch2 + ch3 + ch4 @@ -1769,96 +1747,8 @@ def centre_bcu_bpm_y(): def read_i1(): return dev.i1.read()['i1']['value'] +def read_i2(): + return dev.i2.read()['i2']['value'] -def cen_coll(window_name="Fitting"): - """Centre the collimator in X and Y using the I1 diode.""" - - result = { - "success": False, - "start_intensity": None, - "y_start_intensity": None, - "y_end_intensity": None, - "x_start_intensity": None, - "x_end_intensity": None, - "y_position": None, - "x_position": None, - } - - dev.bcu_shutter.put(0) - - try: - if not bl.planner.is_state(BeamlineState.FLUX_MEASUREMENT): - bl.planner.move_to(BeamlineState.FLUX_MEASUREMENT) - - dev.bcu_shutter.put(1) - - time.sleep(0.2) - - result["start_intensity"] = read_i1() - print(f"Starting intensity is {result['start_intensity']:.4g}") - - bl.d["coll_y"].move("in") - - # Centre Y - result["y_start_intensity"] = read_i1() - print( - "Intensity with collimator in before Y scan: " - f"{result['y_start_intensity']:.4g}" - ) - - y_result = find_feature( - dev.coll_y, - dev.i1, - -0.3, - 0.3, - 30, - feature="peak", - relative=True, - confirm=False, - window_name=window_name, - ) - - result["y_position"] = y_result["centre"] - result["y_end_intensity"] = read_i1() - - print( - "Intensity with collimator in after Y scan: " - f"{result['y_end_intensity']:.4g}" - ) - - # Centre X - result["x_start_intensity"] = read_i1() - - print( - "Intensity with collimator in before X scan: " - f"{result['x_start_intensity']:.4g}" - ) - - x_result = find_feature( - dev.coll_x, - dev.i1, - -0.3, - 0.3, - 30, - feature="peak", - relative=True, - confirm=False, - window_name=window_name, - ) - - result["x_position"] = x_result["centre"] - result["x_end_intensity"] = read_i1() - - print( - "Intensity with collimator in after X scan: " - f"{result['x_end_intensity']:.4g}" - ) - - result["success"] = True - return result - - finally: - dev.bcu_shutter.put(0) - - - +def quick_test(): + bl.planner.closest_states() diff --git a/pxii_bec/macros/luts/20260817-1852_ge_edge.csv b/pxii_bec/macros/luts/20260817-1852_ge_edge.csv new file mode 100644 index 0000000..9dec68f --- /dev/null +++ b/pxii_bec/macros/luts/20260817-1852_ge_edge.csv @@ -0,0 +1,301 @@ +Energy,Bragg,bcu_bpmsum +11125.71,178.69,3.80 +11125.51,178.70,2.51 +11125.30,178.70,2.04 +11125.09,178.70,1.95 +11124.89,178.71,1.68 +11124.68,178.71,1.47 +11124.48,178.71,1.40 +11124.27,178.72,1.28 +11124.06,178.72,1.24 +11123.86,178.72,1.11 +11123.65,178.73,1.00 +11123.45,178.73,0.91 +11123.24,178.73,0.89 +11123.03,178.74,0.88 +11122.83,178.74,0.84 +11122.62,178.74,0.74 +11122.42,178.75,0.72 +11122.21,178.75,0.69 +11122.01,178.75,0.65 +11121.80,178.76,0.61 +11121.59,178.76,0.54 +11121.39,178.76,0.51 +11121.18,178.77,0.47 +11120.98,178.77,0.55 +11120.77,178.77,0.54 +11120.56,178.78,0.48 +11120.36,178.78,0.48 +11120.15,178.78,0.54 +11119.95,178.79,0.56 +11119.74,178.79,0.47 +11119.54,178.79,0.42 +11119.33,178.80,0.47 +11119.12,178.80,0.60 +11118.92,178.80,0.55 +11118.71,178.81,0.36 +11118.51,178.81,0.46 +11118.30,178.81,0.36 +11118.10,178.82,0.41 +11117.89,178.82,0.40 +11117.68,178.82,0.36 +11117.48,178.83,0.18 +11117.27,178.83,0.12 +11117.07,178.83,0.10 +11116.86,178.84,0.10 +11116.66,178.84,0.19 +11116.45,178.84,0.17 +11116.24,178.85,0.06 +11116.04,178.85,0.11 +11115.83,178.85,0.08 +11115.63,178.86,0.14 +11115.42,178.86,0.03 +11115.22,178.87,0.04 +11115.01,178.87,0.07 +11114.80,178.87,-0.07 +11114.60,178.88,-0.02 +11114.39,178.88,-0.03 +11114.19,178.88,-0.12 +11113.98,178.89,-0.08 +11113.78,178.89,-0.22 +11113.57,178.89,-0.13 +11113.37,178.90,-0.08 +11113.16,178.90,-0.08 +11112.95,178.90,-0.14 +11112.75,178.91,-0.24 +11112.54,178.91,-0.29 +11112.34,178.91,-0.20 +11112.13,178.92,-0.19 +11111.93,178.92,-0.20 +11111.72,178.92,-0.10 +11111.52,178.93,-0.09 +11111.31,178.93,-0.06 +11111.10,178.93,-0.14 +11110.90,178.94,-0.15 +11110.69,178.94,-0.11 +11110.49,178.94,-0.15 +11110.28,178.95,-0.06 +11110.08,178.95,-0.03 +11109.87,178.95,-0.10 +11109.67,178.96,-0.15 +11109.46,178.96,-0.16 +11109.26,178.96,-0.10 +11109.05,178.97,-0.07 +11108.85,178.97,-0.10 +11108.64,178.97,-0.06 +11108.43,178.98,0.00 +11108.23,178.98,-0.05 +11108.02,178.98,-0.13 +11107.82,178.99,-0.01 +11107.61,178.99,0.01 +11107.41,178.99,0.04 +11107.20,179.00,0.16 +11107.00,179.00,0.26 +11106.79,179.00,0.50 +11106.59,179.01,0.74 +11106.38,179.01,1.39 +11106.18,179.01,1.93 +11105.97,179.02,2.73 +11105.77,179.02,3.92 +11105.56,179.02,5.29 +11105.36,179.03,7.08 +11105.15,179.03,9.11 +11104.94,179.03,11.59 +11104.74,179.04,14.55 +11104.53,179.04,17.79 +11104.33,179.04,21.27 +11104.12,179.05,25.14 +11103.92,179.05,29.00 +11103.71,179.05,33.25 +11103.51,179.06,37.55 +11103.30,179.06,41.89 +11103.10,179.06,46.30 +11102.89,179.07,50.35 +11102.69,179.07,54.80 +11102.48,179.07,58.91 +11102.28,179.08,63.03 +11102.07,179.08,66.92 +11101.87,179.08,70.94 +11101.66,179.09,74.49 +11101.46,179.09,78.21 +11101.25,179.09,81.73 +11101.05,179.10,85.38 +11100.84,179.10,88.54 +11100.64,179.10,91.74 +11100.43,179.11,94.87 +11100.23,179.11,97.94 +11100.02,179.11,100.68 +11099.82,179.12,103.64 +11099.61,179.12,106.52 +11099.41,179.12,108.90 +11099.20,179.13,111.79 +11099.00,179.13,114.13 +11098.79,179.13,117.06 +11098.59,179.14,119.46 +11098.38,179.14,121.88 +11098.18,179.14,124.41 +11097.97,179.15,126.56 +11097.77,179.15,128.96 +11097.56,179.15,131.08 +11097.36,179.16,133.29 +11097.15,179.16,135.51 +11096.95,179.16,137.56 +11096.74,179.17,139.77 +11096.54,179.17,141.70 +11096.33,179.17,143.82 +11096.13,179.18,145.76 +11095.92,179.18,147.86 +11095.72,179.18,149.70 +11095.51,179.19,151.59 +11095.31,179.19,153.75 +11095.10,179.19,155.45 +11094.90,179.20,157.51 +11094.69,179.20,159.26 +11094.49,179.20,161.27 +11094.28,179.21,162.94 +11094.08,179.21,164.67 +11093.87,179.21,166.33 +11093.67,179.22,168.12 +11093.46,179.22,170.04 +11093.26,179.22,171.60 +11093.05,179.23,173.29 +11092.85,179.23,175.07 +11092.64,179.23,176.67 +11092.44,179.24,178.05 +11092.24,179.24,179.67 +11092.03,179.24,181.16 +11091.83,179.25,182.68 +11091.62,179.25,184.08 +11091.42,179.25,185.57 +11091.21,179.26,186.95 +11091.01,179.26,188.35 +11090.80,179.26,189.91 +11090.60,179.27,191.38 +11090.39,179.27,192.93 +11090.19,179.27,194.48 +11089.98,179.28,196.13 +11089.78,179.28,197.60 +11089.57,179.28,198.94 +11089.37,179.29,200.55 +11089.16,179.29,201.96 +11088.96,179.29,203.19 +11088.76,179.30,204.62 +11088.55,179.30,205.86 +11088.35,179.30,207.37 +11088.14,179.31,208.60 +11087.94,179.31,209.93 +11087.73,179.31,211.17 +11087.53,179.32,212.55 +11087.32,179.32,213.99 +11087.12,179.32,215.14 +11086.91,179.33,216.32 +11086.71,179.33,217.03 +11086.51,179.33,218.14 +11086.30,179.34,219.25 +11086.10,179.34,220.11 +11085.89,179.34,221.21 +11085.69,179.35,222.30 +11085.48,179.35,223.30 +11085.28,179.35,224.57 +11085.07,179.36,225.47 +11084.87,179.36,226.83 +11084.66,179.36,227.84 +11084.46,179.37,228.90 +11084.26,179.37,230.66 +11084.05,179.37,231.67 +11083.85,179.38,232.77 +11083.64,179.38,234.07 +11083.44,179.38,235.42 +11083.23,179.39,236.55 +11083.03,179.39,237.55 +11082.82,179.39,238.47 +11082.62,179.40,239.46 +11082.42,179.40,240.46 +11082.21,179.40,241.38 +11082.01,179.41,242.37 +11081.80,179.41,243.27 +11081.60,179.41,244.32 +11081.39,179.42,245.23 +11081.19,179.42,246.23 +11080.99,179.42,247.28 +11080.78,179.43,248.09 +11080.58,179.43,249.04 +11080.37,179.43,249.78 +11080.17,179.44,250.74 +11079.96,179.44,251.72 +11079.76,179.44,252.27 +11079.56,179.45,252.90 +11079.35,179.45,253.61 +11079.15,179.45,254.53 +11078.94,179.46,255.28 +11078.74,179.46,256.04 +11078.53,179.46,256.71 +11078.33,179.47,257.44 +11078.13,179.47,258.01 +11077.92,179.47,258.72 +11077.72,179.48,259.48 +11077.51,179.48,260.02 +11077.31,179.48,260.72 +11077.10,179.49,261.14 +11076.90,179.49,262.13 +11076.70,179.49,262.68 +11076.49,179.50,263.44 +11076.29,179.50,264.13 +11076.08,179.50,265.21 +11075.88,179.51,265.80 +11075.68,179.51,266.46 +11075.47,179.51,267.13 +11075.27,179.52,267.60 +11075.06,179.52,268.21 +11074.86,179.52,268.91 +11074.65,179.53,269.65 +11074.45,179.53,270.27 +11074.25,179.53,271.26 +11074.04,179.54,271.58 +11073.84,179.54,272.03 +11073.63,179.54,272.31 +11073.43,179.55,272.62 +11073.23,179.55,273.22 +11073.02,179.55,273.68 +11072.82,179.56,274.21 +11072.61,179.56,274.41 +11072.41,179.56,274.89 +11072.21,179.57,275.20 +11072.00,179.57,275.56 +11071.80,179.57,275.59 +11071.59,179.58,275.99 +11071.39,179.58,276.56 +11071.19,179.58,277.07 +11070.98,179.59,277.64 +11070.78,179.59,277.91 +11070.57,179.59,278.20 +11070.37,179.60,278.55 +11070.17,179.60,278.91 +11069.96,179.60,279.27 +11069.76,179.61,279.93 +11069.55,179.61,280.12 +11069.35,179.61,279.91 +11069.15,179.62,280.21 +11068.94,179.62,280.44 +11068.74,179.62,280.63 +11068.54,179.63,280.58 +11068.33,179.63,280.76 +11068.13,179.63,280.56 +11067.92,179.64,281.27 +11067.72,179.64,281.48 +11067.52,179.64,281.63 +11067.31,179.65,281.85 +11067.11,179.65,282.20 +11066.90,179.65,282.63 +11066.70,179.66,282.89 +11066.50,179.66,282.47 +11066.29,179.66,282.56 +11066.09,179.67,282.70 +11065.89,179.67,282.74 +11065.68,179.67,283.00 +11065.48,179.68,282.97 +11065.27,179.68,282.99 +11065.07,179.68,282.93 +11064.87,179.69,282.77 +11064.66,179.69,282.73 +11064.46,179.69,282.84 diff --git a/pxii_bec/macros/luts/20260817-2200_lut.csv b/pxii_bec/macros/luts/20260817-2200_lut.csv new file mode 100644 index 0000000..c57f078 --- /dev/null +++ b/pxii_bec/macros/luts/20260817-2200_lut.csv @@ -0,0 +1 @@ +energy,harmonic,gap,pitch,roll,perp,samcam_x,samcam_y,zoom=800.0 diff --git a/pxii_bec/macros/luts/20260817-2205_lut.csv b/pxii_bec/macros/luts/20260817-2205_lut.csv new file mode 100644 index 0000000..3dba517 --- /dev/null +++ b/pxii_bec/macros/luts/20260817-2205_lut.csv @@ -0,0 +1,5 @@ +energy,harmonic,gap,pitch,roll,perp,samcam_x,samcam_y,zoom=800.0 +6000,H3,5.9369,-5.5148,4.56,0.17812,998.9,983.3 +6300,H3,6.2148,-5.5098,4.559,0.15915,988.1,1016 +6600,H3,6.5016,-5.5071,4.557,0.14417,1001,987.4 +6900,H3,6.7991,-5.5043,4.56,0.13109,1006,990.5 diff --git a/pxii_bec/macros/luts/20260817-2216_lut.csv b/pxii_bec/macros/luts/20260817-2216_lut.csv new file mode 100644 index 0000000..1d79d25 --- /dev/null +++ b/pxii_bec/macros/luts/20260817-2216_lut.csv @@ -0,0 +1,81 @@ +energy,harmonic,gap,pitch,roll,perp,samcam_x,samcam_y,zoom=800.0 +6000,H3,5.9377,-5.5148,4.558,0.17794,991.8,978.6 +6300,H3,6.2142,-5.5094,4.559,0.15927,996.9,983 +6600,H3,6.5013,-5.5068,4.557,0.14419,989.8,987.9 +6900,H3,6.799,-5.5042,4.558,0.13106,999,986.9 +7200,H5,4.5,-5.5016,4.559,0.11953,924.9,974.8 +7500,H5,4.6436,-5.4999,4.558,0.1098,955.3,959.3 +7800,H5,4.7915,-5.4985,4.559,0.10101,955,969.8 +8100,H5,4.9409,-5.4974,4.559,0.093355,977.2,974.7 +8400,H5,5.0915,-5.4963,4.557,0.08646,996.7,982.8 +8700,H5,5.244,-5.495,4.559,0.08041,1007,985 +9000,H5,5.3976,-5.494,4.557,0.07478,1006,986.2 +9300,H5,5.5544,-5.493,4.561,0.070005,1011,987.4 +9600,H5,5.713,-5.492,4.559,0.065495,1010,987.5 +9900,H5,5.874,-5.4909,4.559,0.061445,1010,987.6 +10200,H7,4.5343,-5.4901,4.56,0.057765,1004,983.7 +10500,H7,4.638,-5.4894,4.559,0.05447,1002,983.1 +10800,H7,4.7432,-5.4887,4.557,0.05137,1001,984.3 +11100,H7,4.8486,-5.4879,4.558,0.0486,1002,985.5 +11400,H7,5.0359,-5.4888,4.56,0.046005,966.4,983.6 +11700,H7,5.0627,-5.487,4.56,0.04357,1002,983.4 +12000,H7,5.1707,-5.4867,4.56,0.041215,1001,986.3 +12300,H7,5.2797,-5.4861,4.559,0.03932,1001,985.7 +12600,H7,5.3896,-5.4855,4.559,0.03744,1002,986.9 +12900,H7,5.5008,-5.4852,4.56,0.035705,1004,985.9 +13200,H9,4.5875,-5.4853,4.559,0.034105,1003,986.4 +13500,H9,4.63,-5.4846,4.559,0.03241,997.1,986.2 +13800,H9,4.7138,-5.4844,4.559,0.03102,996.7,985.8 +14100,H9,4.7976,-5.484,4.558,0.029765,997,985.1 +14400,H9,4.8814,-5.4834,4.559,0.028375,999.8,986.5 +14700,H9,4.9652,-5.4828,4.56,0.02831,1000,985.2 +15000,H9,5.049,-5.4827,4.559,0.02612,999.2,986.5 +15300,H9,5.1328,-5.482,4.558,0.02612,1002,985.7 +15600,H9,5.2141,-5.4819,4.558,0.02409,999.3,986.5 +15900,H9,5.3004,-5.4817,4.558,0.024085,998.8,987 +16200,H11,4.6009,-5.4819,4.558,0.022355,1051,982.1 +16500,H11,4.6773,-5.4817,4.558,0.02232,1051,982.1 +16800,H11,4.7462,-5.4814,4.559,0.02077,1052,982.8 +17100,H11,4.8156,-5.4812,4.559,0.020735,1043,984.6 +17400,H11,4.8875,-5.481,4.558,0.019405,1042,984.1 +17700,H11,4.9552,-5.4807,4.56,0.01937,1040,984.2 +18000,H11,5.0265,-5.4806,4.559,0.018115,1043,984.5 +18300,H11,5.0986,-5.4803,4.56,0.018095,1043,985.2 +18600,H11,5.1726,-5.4802,4.561,0.01808,1024,984.2 +18900,H11,5.2568,-5.4799,4.558,0.0164,1049,983.4 +19200,H13,4.6038,-5.4793,4.559,0.01636,1049,984.4 +19500,H13,4.6621,-5.4792,4.559,0.016345,1049,986.2 +19800,H13,4.7191,-5.479,4.558,0.014945,1050,986.6 +20100,H13,4.777,-5.4788,4.559,0.01496,1050,985.4 +20400,H13,4.8342,-5.4785,4.558,0.01495,1049,985.2 +20700,H13,4.8921,-5.4783,4.558,0.013675,1051,985.2 +21000,H13,4.9498,-5.4782,4.56,0.013665,1049,983.4 +21300,H13,5.008,-5.4781,4.558,0.013655,1049,979.4 +21600,H13,5.0666,-5.4778,4.559,0.012545,1048,974.2 +21900,H13,5.1256,-5.4775,4.559,0.01253,1047,967.6 +22200,H15,4.6048,-5.4767,4.559,0.01253,1046,962.7 +22500,H15,4.653,-5.4771,4.559,0.012505,1041,957.6 +22800,H15,4.7023,-5.4771,4.559,0.011245,1028,953.7 +23100,H15,4.752,-5.477,4.559,0.0112,1029,965 +23400,H15,4.8012,-5.4768,4.559,0.01119,1013,961.7 +23700,H15,4.8509,-5.4769,4.559,0.011185,990.1,961.3 +24000,H15,4.9006,-5.4767,4.559,0.011175,979.1,961.7 +24300,H15,4.9507,-5.4764,4.558,0.009915,967.3,962 +24600,H15,5.001,-5.4763,4.559,0.009905,959.9,963.3 +24900,H15,5.0513,-5.4762,4.559,0.00991,952.6,966.6 +25200,H17,4.6147,-5.476,4.558,0.009915,942,954.7 +25500,H17,4.648,-5.476,4.56,0.00989,950.1,972.1 +25800,H17,4.6913,-5.4759,4.558,0.008815,946.7,972.4 +26100,H17,4.7346,-5.4758,4.558,0.008825,941.9,970.2 +26400,H17,4.7779,-5.4757,4.559,0.008805,944.9,968.8 +26700,H17,4.8219,-5.4756,4.56,0.0088,941.9,965 +27000,H17,4.8663,-5.4758,4.558,0.00881,938.2,965.3 +27300,H17,4.9105,-5.4757,4.559,0.0088,934.4,962.7 +27600,H19,4.6564,-5.4753,4.558,0.00765,935.8,960.3 +27900,H19,4.5773,-5.4754,4.559,0.00765,916.5,956.2 +28200,H19,4.6282,-5.4755,4.559,0.007645,894.2,948.2 +28500,H19,4.6633,-5.4752,4.558,0.007635,899,951 +28800,H19,4.7015,-5.4753,4.559,0.007635,892.8,947.6 +29100,H19,4.7404,-5.4752,4.56,0.00764,922,951 +29400,H19,4.7791,-5.4752,4.559,0.00764,922,951 +29700,H19,4.8067,-5.4751,4.558,0.0076,922,951 diff --git a/pxii_bec/macros/luts/beampos/beampos_20260819-2205.csv b/pxii_bec/macros/luts/beampos/beampos_20260819-2205.csv new file mode 100644 index 0000000..c0344b5 --- /dev/null +++ b/pxii_bec/macros/luts/beampos/beampos_20260819-2205.csv @@ -0,0 +1,2 @@ +Beam size: 25 x 25, Energy: 12400 eV, Zoom: 800.0 +Time,Scin_x,Scin_y,BPM_x,BPM_y diff --git a/pxii_bec/macros/luts/beampos/beampos_20260819-2210.csv b/pxii_bec/macros/luts/beampos/beampos_20260819-2210.csv new file mode 100644 index 0000000..d56228e --- /dev/null +++ b/pxii_bec/macros/luts/beampos/beampos_20260819-2210.csv @@ -0,0 +1,4 @@ +Beam size: 25 x 25, Energy: 12400 eV, Zoom: 800.0 +Time,Scin_x,Scin_y,BPM_x,BPM_y +22:10:24, 999.79, 974.3, 1.2074, 29.93 +22:20:28, 997.6, 975.4, 5.8946, 29.932 diff --git a/pxii_bec/macros/luts/beampos/beampos_20260819-2226.csv b/pxii_bec/macros/luts/beampos/beampos_20260819-2226.csv new file mode 100644 index 0000000..06b032e --- /dev/null +++ b/pxii_bec/macros/luts/beampos/beampos_20260819-2226.csv @@ -0,0 +1,41 @@ +Beam size: 25 x 25, Energy: 12400 eV, Zoom: 800.0 +Time,Scin_x,Scin_y,BPM_x,BPM_y +22:26:31, 999.9, 974.2, 0.92435, 0.039731 +22:36:35, 998.96, 975.6, 0.94917, 0.056158 +22:46:41, 999.21, 973.9, 5.8831, 0.16222 +22:56:44, 998, 975.7, 2.0407, 0.04065 +23:06:49, 999.82, 974.5, 0.23308, 0.11144 +23:16:53, 999, 975.2, 0.047717, 0.0065082 +23:26:56, 998.86, 975.4, 5.4399, 0.1429 +23:37:00, 997.98, 973.9, 1.33, 0.1089 +23:47:04, 997.99, 974.7, 5.5525, 0.25047 +23:57:08, 997.45, 974.9, 1.6066, 0.053616 +00:07:12, 996.59, 973.7, 5.7047, 0.10329 +00:17:15, 996.75, 973.7, 6.0996, 0.16812 +00:27:19, 997.13, 974.4, 5.7864, 0.123 +00:37:23, 997.58, 973.7, 0.6539, 0.24882 +00:47:28, 995.77, 974.3, 6.0715, 0.11591 +00:57:32, 996.78, 973.4, 7.0393, 0.34914 +01:07:35, 998.6, 973.7, 0.59761, 0.22803 +01:17:39, 996.6, 974.3, 1.4257, 0.15672 +01:27:45, 995.45, 973, 5.245, 0.30833 +01:37:49, 997.66, 973.5, 5.1992, 0.13886 +01:47:52, 996.01, 973.7, 5.027, 0.15912 +01:57:56, 995.73, 972.8, 6.6106, 0.2942 +02:08:00, 998.22, 973.7, 1.3031, 0.26335 +02:18:03, 997.65, 973.6, 1.169, 0.19847 +02:28:07, 997.58, 974.2, 6.4368, 0.23441 +02:38:12, 998.24, 973.7, 5.5986, 0.19723 +02:48:16, 997.79, 972.3,-0.034362, 0.27994 +02:58:22, 995.65, 972.5, 6.4239, 0.27336 +03:08:28, 994.94, 972.4, 5.0984, 0.37458 +03:18:34, 970.57, 965.8, 6.919, 0.3945 +03:28:40, 993.27, 970.3, 5.2906, 0.36815 +03:38:45, 996.38, 972.7, 5.5236, 0.19219 +03:48:49, 997.89, 970.9, 0.23334, 0.40342 +03:58:52, 996.42, 971.8, 5.4008, 0.36335 +04:08:56, 996.15, 971.9, 0.80869, 0.34427 +04:19:02, 996.92, 971.3, 5.1908, 0.30017 +04:29:08, 972.82, 964.8, 5.5878, 0.46857 +04:39:14, 985.87, 967.9, 0.78278, 0.32211 +04:49:19, 995.53, 970.9, 0.69024, 0.30616 diff --git a/pxii_bec/macros/luts/beampos/beampos_20260821-2226.csv b/pxii_bec/macros/luts/beampos/beampos_20260821-2226.csv new file mode 100644 index 0000000..b7eb5be --- /dev/null +++ b/pxii_bec/macros/luts/beampos/beampos_20260821-2226.csv @@ -0,0 +1,65 @@ +Beam size: 25 x 25, Energy: 12400 eV, Zoom: 1.0 +Time,Scin_x,Scin_y,BPM_x,BPM_y +22:26:16, 965.48, 911, 7.1254, 5.6352 +22:36:21, 961.44, 910.5, 10.822, 5.6976 +22:46:27, 963.11, 912.6, 8.518, 5.5868 +22:56:31, 963.49, 913.7, 7.8575, 5.666 +23:06:35, 963.83, 913.5, 10.336, 5.4877 +23:16:38, 962.55, 913, 9.5282, 5.6278 +23:26:42, 961.96, 913.1, 8.6951, 5.6422 +23:36:46, 962.17, 912, 7.4954, 5.6943 +23:46:50, 963.99, 912.4, 7.2082, 5.649 +23:56:54, 961.64, 912.3, 10.787, 5.6363 +00:06:58, 962.75, 912.1, 7.8735, 5.7375 +00:17:01, 963.64, 911.5, 7.8687, 5.7019 +00:27:06, 960.81, 911.2, 10.12, 5.7291 +00:37:10, 963.24, 912, 8.2391, 5.6991 +00:47:14, 963.06, 911.8, 7.4562, 5.7199 +00:57:19, 961.67, 913.1, 11.234, 5.6243 +01:07:23, 961.07, 912.2, 10.477, 5.7043 +01:17:27, 962.98, 911.7, 8.0118, 5.652 +01:27:32, 963.23, 910.7, 10.137, 5.7623 +01:37:36, 963.31, 912.6, 10.836, 5.6122 +01:47:40, 962.41, 912.4, 10.561, 5.6472 +01:57:44, 961.74, 912.2, 11.176, 5.6783 +02:07:47, 963.62, 910.9, 7.5405, 5.788 +02:17:53, 961.55, 912, 10.223, 5.6184 +02:27:57, 960.79, 913.2, 11.754, 5.6076 +02:38:00, 962.1, 911.3, 11.129, 5.6434 +02:48:04, 962.34, 911.6, 8.1098, 5.6701 +02:58:09, 962.94, 912.1, 8.7236, 5.6526 +03:08:15, 965.39, 911.9, 10.581, 5.6999 +03:18:21, 939.66, 907.7, 8.3212, 5.5753 +03:28:27, 948.57, 907.8, 12.156, 5.6227 +03:38:32, 962.1, 910.8, 10.447, 5.6124 +03:48:37, 962.65, 910.8, 10.397, 5.7454 +03:58:41, 961.69, 910.7, 11.916, 5.6104 +04:08:45, 960.05, 911.1, 12.066, 5.6648 +04:18:48, 960.67, 910, 11.864, 5.6369 +04:28:52, 960.7, 909.9, 10.655, 5.6757 +04:38:56, 962.57, 912, 9.5644, 5.5882 +04:48:59, 961.34, 911.8, 12.327, 5.5655 +04:59:03, 961.26, 910.5, 9.6895, 5.6876 +05:09:07, 963.61, 910.6, 8.5848, 5.7027 +05:19:11, 962.39, 911.2, 9.57, 5.6125 +05:29:15, 961.96, 911.3, 8.8365, 5.6812 +05:39:19, 963.26, 911.5, 8.679, 5.6749 +05:49:23, 962.63, 910.9, 9.071, 5.7136 +05:59:27, 963.04, 909.8, 10.303, 5.7564 +06:09:30, 961.35, 909.9, 10.022, 5.7022 +06:19:35, 961.42, 910.7, 9.7227, 5.6848 +06:29:38, 961.6, 910.6, 8.9894, 5.6707 +06:39:44, 961.34, 909.5, 12.381, 5.7527 +06:49:47, 959.83, 908.6, 11.657, 5.7214 +06:59:51, 960.96, 910, 12.833, 5.6707 +07:09:55, 961.7, 908.2, 11.392, 5.7856 +07:19:59, 961.08, 908.9, 11.67, 5.7393 +07:30:03, 962.13, 910.1, 9.065, 5.6821 +07:40:07, 960.6, 910.2, 9.4, 5.6778 +07:50:10, 960.6, 908.6, 12.606, 5.693 +08:00:16, 963.96, 908.5, 9.2651, 5.8144 +08:10:20, 961.11, 909, 12.769, 5.7328 +08:20:23, 960.82, 909.3, 12.279, 5.7436 +08:30:27, 960.29, 907.6, 9.6736, 5.7722 +08:40:32, 959.87, 908.7, 9.1505, 5.7219 +08:50:36, 960.56, 908.1, 10.702, 5.7976 diff --git a/pxii_bec/macros/luts/beampos/beampos_20260822-2155.csv b/pxii_bec/macros/luts/beampos/beampos_20260822-2155.csv new file mode 100644 index 0000000..2de355d --- /dev/null +++ b/pxii_bec/macros/luts/beampos/beampos_20260822-2155.csv @@ -0,0 +1,20 @@ +Beam size: 25 x 25, Energy: 12400 eV, Zoom: 1.0 +Time,Scin_x,Scin_y,BPM_x,BPM_y +21:55:57, 1008.1, 960, 3.7702,-2.5832 +22:06:01, 1011, 958.3, 3.0557,-2.5152 +22:16:04, 1011.9, 960.7, 2.8244,-2.674 +22:26:08, 1012, 959.6, 0.77502,-2.6056 +22:36:14, 1012.5, 962.2, 3.4013,-2.6519 +22:46:18, 1012.8, 961.7, 1.4864,-2.7374 +22:56:22, 1013.1, 960.9, 1.8226,-2.5766 +23:06:25, 1014, 962.2, 1.7887,-2.755 +23:16:29, 1012.6, 961.2, 2.7817,-2.5939 +23:26:33, 1013.4, 960, 4.6455,-2.5467 +23:36:37, 1013, 962.3, 3.6926,-2.6477 +23:46:41, 1012.1, 960.7, 5.2687,-2.5876 +23:56:45, 1012.7, 960.6, 4.9731,-2.5824 +00:06:48, 1011.8, 960.2, 3.4213,-2.6197 +00:16:54, 1010.7, 960.7, 4.5734,-2.6167 +00:26:57, 1012.2, 961.6, 6.3409,-2.6988 +00:37:01, 1010.6, 961.4, 6.3514,-2.7626 +00:47:05, 1011.6, 959.8, 6.0105,-2.5472 diff --git a/pxii_bec/macros/luts/bpm_calib/20260817_bcu_bpm_x.csv b/pxii_bec/macros/luts/bpm_calib/20260817_bcu_bpm_x.csv new file mode 100644 index 0000000..461e90e --- /dev/null +++ b/pxii_bec/macros/luts/bpm_calib/20260817_bcu_bpm_x.csv @@ -0,0 +1,102 @@ +Xpos,Xnorm,BPM1,BPM2,BPM3,BPM4 +-0.1694,-0.9915957714775472 +-0.15739999999999998,-0.9929781019415261 +-0.1454,-0.993453696387353 +-0.1334,-0.9934074035427931 +-0.1214,-0.9930503585948808 +-0.1094,-0.9928574618633765 +-0.09739999999999999,-0.9928269315257744 +-0.08539999999999999,-0.9925911672910518 +-0.07339999999999999,-0.9924264290464678 +-0.061399999999999996,-0.9919468956387827 +-0.0494,-0.9915697930211868 +-0.03739999999999999,-0.9910241353945078 +-0.025399999999999978,-0.9907140839768224 +-0.013399999999999995,-0.9899323962484751 +-0.0013999999999999846,-0.9886291298368717 +0.010599999999999998,-0.9872999045298451 +0.02260000000000001,-0.9858700166714639 +0.03460000000000002,-0.9841569882728415 +0.0466,-0.9823940586364639 +0.05860000000000001,-0.9798121414337622 +0.0706,-0.9765958369329042 +0.0826,-0.9726739003218974 +0.09460000000000002,-0.967952755740734 +0.10660000000000003,-0.9626958548954613 +0.11860000000000004,-0.9560652341193799 +0.1306,-0.9490479480133168 +0.1426,-0.9410302055233439 +0.15460000000000002,-0.9310310906144889 +0.16660000000000003,-0.9199356235527283 +0.17860000000000004,-0.906697434402576 +0.1906,-0.8914775548505844 +0.2026,-0.8742455345138012 +0.2146,-0.854256054042623 +0.22660000000000002,-0.8331033756572455 +0.23860000000000003,-0.809795930375354 +0.2506,-0.7835992661961892 +0.2626,-0.7532793759481816 +0.2746,-0.7219909359013827 +0.2866,-0.689433718963919 +0.29860000000000003,-0.6524488521783858 +0.3106,-0.6118706862336628 +0.3226,-0.5699728042686675 +0.3346,-0.5181555517516677 +0.3466,-0.4680841593973484 +0.35860000000000003,-0.4125481862156571 +0.37060000000000004,-0.35293374622911944 +0.38260000000000005,-0.29143266254148253 +0.39460000000000006,-0.23185945181301612 +0.4066000000000001,-0.16398983614198098 +0.41859999999999997,-0.09634528046789055 +0.4306,-0.026534247043113655 +0.4426,0.03774067637152329 +0.4546,0.10580779454654377 +0.4666,0.17709753649089519 +0.4786,0.24656058345764964 +0.49060000000000004,0.31154079954230135 +0.5026,0.3729203511772465 +0.5146000000000001,0.44173506095611575 +0.5266000000000001,0.5052924335232817 +0.5386,0.5657368446083462 +0.5506,0.6228044384530939 +0.5626,0.6754752396210227 +0.5746,0.721327700557592 +0.5866,0.7622282563983194 +0.5986,0.7999283952877195 +0.6106,0.8343173815994085 +0.6226,0.8648657809994393 +0.6346,0.8857081509392144 +0.6466000000000001,0.9084714040004795 +0.6586000000000001,0.9247919272253045 +0.6706,0.9382209101400852 +0.6826,0.9500786610271668 +0.6946,0.9606260186086204 +0.7066,0.9675799619168703 +0.7186,0.9724769374187608 +0.7306,0.9766170275343372 +0.7426,0.9796010209809398 +0.7546,0.9815232467323963 +0.7666000000000001,0.983541856516753 +0.7786000000000001,0.9844531038102419 +0.7906,0.9853542119018801 +0.8026,0.9859927670459557 +0.8146,0.9863718466619773 +0.8266,0.9868273337389251 +0.8386,0.9871309586865652 +0.8506,0.9874623854853187 +0.8626,0.9880422739940511 +0.8746,0.9884524805482449 +0.8866,0.9890906323752511 +0.8986000000000001,0.9891335280195586 +0.9106000000000001,0.9894341676689815 +0.9226000000000001,0.9895132085852458 +0.9346000000000001,0.9897227846910519 +0.9466000000000001,0.9901537508297996 +0.9586000000000001,0.9904546500614948 +0.9706000000000001,0.9907659041028072 +0.9826000000000001,0.9912134593871215 +0.9945999999999999,0.9913483068123514 +1.0066,0.9914982657426877 +1.0186,0.9916664319346152 +1.0306,0.9917755843778947 diff --git a/pxii_bec/macros/luts/bpm_calib/20260817_bcu_bpm_y.csv b/pxii_bec/macros/luts/bpm_calib/20260817_bcu_bpm_y.csv new file mode 100644 index 0000000..89a3f3d --- /dev/null +++ b/pxii_bec/macros/luts/bpm_calib/20260817_bcu_bpm_y.csv @@ -0,0 +1,252 @@ +Ypos,Ynorm +-1.6280000000000001,0.8681004591884547 +-1.6272000000000002,0.9037799664752383 +-1.6264,0.9170976612760804 +-1.6256000000000002,0.9239205249392006 +-1.6248,0.9298397040690505 +-1.624,0.9368845306851705 +-1.6232000000000002,0.9386639392350385 +-1.6224,0.9324213023636486 +-1.6216000000000002,0.9352613066372509 +-1.6208,0.9360237450531141 +-1.62,0.9311384848186477 +-1.6192000000000002,0.9300012941633233 +-1.6184,0.9403553565075445 +-1.6176000000000001,0.9407389534639755 +-1.6168,0.9398744319226626 +-1.616,0.9427934307032192 +-1.6152000000000002,0.9461474334807704 +-1.6144,0.940474615730575 +-1.6136000000000001,0.9396716587115334 +-1.6128,0.9398623520760926 +-1.612,0.9379037762504165 +-1.6112000000000002,0.9368657685183719 +-1.6104,0.938466745284266 +-1.6096000000000001,0.9341171754255483 +-1.6088,0.9360972502388788 +-1.608,0.9418979299473301 +-1.6072000000000002,0.9365577722316529 +-1.6064,0.9399541070941446 +-1.6056000000000001,0.9435980690455966 +-1.6048,0.9416477572133739 +-1.604,0.9376072191061087 +-1.6032000000000002,0.9358056471723916 +-1.6024,0.9347856384746507 +-1.6016000000000001,0.9330551115211724 +-1.6008,0.9364347830757743 +-1.6,0.9335571731714524 +-1.5992000000000002,0.9345978959829956 +-1.5984,0.9318955000080615 +-1.5976000000000001,0.9324917584626518 +-1.5968,0.9303740339370503 +-1.596,0.9285588859741076 +-1.5952000000000002,0.9268018557876178 +-1.5944,0.9305835441409768 +-1.5936000000000001,0.9266734046706132 +-1.5928,0.927186077643909 +-1.592,0.9289767841788478 +-1.5912000000000002,0.9308569643837977 +-1.5904,0.9266497093414068 +-1.5896000000000001,0.9278255676958086 +-1.5888,0.9236000687610125 +-1.588,0.9231959261288554 +-1.5872000000000002,0.9202485869652567 +-1.5864,0.9188207349448093 +-1.5856000000000001,0.9218482047520951 +-1.5848,0.9182814952242782 +-1.584,0.9181625418818085 +-1.5832000000000002,0.9103899379168612 +-1.5824,0.913843539609817 +-1.5816000000000001,0.9145319439422802 +-1.5808,0.9125402554736637 +-1.58,0.910098535458735 +-1.5792000000000002,0.9063402209282875 +-1.5784,0.9041354297852561 +-1.5776000000000001,0.905450995281228 +-1.5768,0.9049449058242416 +-1.576,0.9006977526504835 +-1.5752000000000002,0.8961534294073031 +-1.5744,0.8940730852299242 +-1.5736,0.8934208521106829 +-1.5728,0.8886421527006727 +-1.572,0.8910022225498708 +-1.5712000000000002,0.8840333295186402 +-1.5704,0.8779131284082584 +-1.5696,0.8804094092296643 +-1.5688,0.8775077129005402 +-1.568,0.8733154812444213 +-1.5672000000000001,0.8743338069496389 +-1.5664,0.8637045379479876 +-1.5656,0.8621333304394067 +-1.5648,0.8601000526878975 +-1.564,0.8538165247111158 +-1.5632000000000001,0.8490111891751235 +-1.5624,0.8492681678886551 +-1.5616,0.8471945446901906 +-1.5608,0.8404923331410723 +-1.56,0.8360143155188285 +-1.5592000000000001,0.8329139956680597 +-1.5584,0.8290369024092494 +-1.5576,0.8232368403830631 +-1.5568,0.8168759455783798 +-1.556,0.8070485111126899 +-1.5552000000000001,0.798349424708247 +-1.5544,0.7905811952697741 +-1.5536,0.7848638337060913 +-1.5528,0.7750945958525671 +-1.552,0.7694856031513194 +-1.5512000000000001,0.757437272048161 +-1.5504,0.7537577999889558 +-1.5496,0.7441015529807927 +-1.5488,0.7332715242021378 +-1.548,0.7213379494950614 +-1.5472000000000001,0.710726528806812 +-1.5464,0.6952450646132353 +-1.5456,0.680099833610649 +-1.5448,0.6630139271120008 +-1.544,0.6436997109600813 +-1.5432000000000001,0.6231309633819127 +-1.5424,0.6003620576945642 +-1.5416,0.5746689965723503 +-1.5408,0.5472451767451516 +-1.54,0.5230489649411925 +-1.5392000000000001,0.4943471918307804 +-1.5384,0.45283407999816677 +-1.5376,0.41244517892328225 +-1.5368,0.36999157882510086 +-1.536,0.31686701400005823 +-1.5352000000000001,0.24352168199737192 +-1.5344,0.18723254998246233 +-1.5336,0.12357235266913709 +-1.5328,0.06639492967038144 +-1.532,0.009429327398322442 +-1.5312000000000001,-0.04196115962360383 +-1.5304,-0.08906880179198018 +-1.5296,-0.13693595711750262 +-1.5288,-0.18140813557708324 +-1.528,-0.22831427298381107 +-1.5272000000000001,-0.2786561147842765 +-1.5264,-0.3327433837150307 +-1.5256,-0.38514455047360346 +-1.5248,-0.4304326078611559 +-1.524,-0.4700175349545476 +-1.5232,-0.5065489928811561 +-1.5224,-0.5375256096377843 +-1.5216,-0.5634359189124948 +-1.5208,-0.5891531551889723 +-1.52,-0.6098628226255491 +-1.5192,-0.6250963913320443 +-1.5184,-0.6464822733785676 +-1.5176,-0.6652374376336423 +-1.5168,-0.6786197864642295 +-1.516,-0.6927128087146937 +-1.5152,-0.709664214194833 +-1.5144,-0.7229725256537569 +-1.5136,-0.7323330585325638 +-1.5128,-0.7422272966801335 +-1.512,-0.7501698257916073 +-1.5112,-0.7598885854963757 +-1.5104,-0.7656560350629523 +-1.5096,-0.7675716795367853 +-1.5088,-0.7764593637250924 +-1.508,-0.7805215168020629 +-1.5072,-0.7870286872926607 +-1.5064,-0.7896552662367698 +-1.5056,-0.7972391255964432 +-1.5048,-0.8019081053846279 +-1.504,-0.8072426235547802 +-1.5032,-0.8107649155549287 +-1.5024,-0.8168917967438283 +-1.5016,-0.8207073173378476 +-1.5008,-0.823826432550412 +-1.5,-0.8281958172531523 +-1.4992,-0.8322493783998001 +-1.4984,-0.8345199991290526 +-1.4976,-0.836301023322616 +-1.4968,-0.8425575274764195 +-1.496,-0.8444531658817372 +-1.4952,-0.8494850747893488 +-1.4944,-0.8525928706257379 +-1.4936,-0.855615583005294 +-1.4928,-0.8581996797742137 +-1.492,-0.8598201629570317 +-1.4912,-0.8597982576303124 +-1.4904,-0.8605907683662828 +-1.4896,-0.8674378767509432 +-1.4888,-0.865922754206133 +-1.488,-0.8705415686742026 +-1.4872,-0.8713786281471041 +-1.4864,-0.874072108850904 +-1.4856,-0.8734185427885551 +-1.4848,-0.8728079875289255 +-1.484,-0.8775353668483399 +-1.4832,-0.8787467919229094 +-1.4824,-0.879818630694012 +-1.4816,-0.8820053609510048 +-1.4808,-0.8837272829527744 +-1.48,-0.885681546806312 +-1.4792,-0.8855138562881295 +-1.4784,-0.8875338318516854 +-1.4776,-0.8898914256287014 +-1.4768,-0.8935648336582335 +-1.476,-0.89576174724388 +-1.4752,-0.8977713798251226 +-1.4744,-0.8975600650649316 +-1.4736,-0.8983763193735104 +-1.4727999999999999,-0.8978576180971389 +-1.472,-0.9023349797934441 +-1.4712,-0.9033060409705691 +-1.4704,-0.906816452100462 +-1.4696,-0.9078195384013841 +-1.4687999999999999,-0.9071423994532135 +-1.468,-0.9103136620943173 +-1.4672,-0.9112613789683068 +-1.4664,-0.9103992349988045 +-1.4656,-0.9106927526839452 +-1.4647999999999999,-0.9124299647229716 +-1.464,-0.9120057436115616 +-1.4632,-0.9120464595876179 +-1.4624,-0.9139892779985598 +-1.4616,-0.9143835616438356 +-1.4607999999999999,-0.9131539365077678 +-1.46,-0.9146678844325973 +-1.4592,-0.9152195303566204 +-1.4584,-0.914797753585072 +-1.4576,-0.9136145464552011 +-1.4567999999999999,-0.9148108199564327 +-1.456,-0.9135163646912994 +-1.4552,-0.9180587733203267 +-1.4544,-0.9191408180508983 +-1.4536,-0.9188600096519467 +-1.4527999999999999,-0.9242039295392954 +-1.452,-0.9232432832585119 +-1.4512,-0.9239634864235596 +-1.4504,-0.924728851472478 +-1.4496,-0.9234015548151675 +-1.4487999999999999,-0.9280332595294605 +-1.448,-0.9313778213203701 +-1.4472,-0.9325964502072485 +-1.4464,-0.9289979039190362 +-1.4456,-0.9275985549331683 +-1.4447999999999999,-0.9276556824970527 +-1.444,-0.9311536402711454 +-1.4432,-0.9324861966026472 +-1.4424,-0.9312191669395646 +-1.4416,-0.931070110701107 +-1.4407999999999999,-0.9290763715989662 +-1.44,-0.9287304653574268 +-1.4392,-0.9305348751254026 +-1.4384,-0.9325761825629519 +-1.4376,-0.934254164168254 +-1.4367999999999999,-0.9369476519373848 +-1.436,-0.9352223701731026 +-1.4352,-0.9363745306383318 +-1.4344,-0.9373186489042787 +-1.4336,-0.9417214856525021 +-1.4327999999999999,-0.9407045395258706 +-1.432,-0.934370060782213 +-1.4312,-0.9399608764944487 +-1.4304,-0.9363051231218142 +-1.4296,-0.9368103939237489 +-1.4287999999999998,-0.9353112015602476 +-1.428,-0.937162248414961 diff --git a/pxii_bec/macros/luts/bpm_calib/bcu_bpm_x_20260819.csv b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_x_20260819.csv new file mode 100644 index 0000000..ef70cbf --- /dev/null +++ b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_x_20260819.csv @@ -0,0 +1,102 @@ +Xpos,Xnorm,BPM1,BPM2,BPM3,BPM4 +0.043999999999999984,-0.9930920325991766 +0.051999999999999984,-0.992398552377238 +0.059999999999999984,-0.9912290082934647 +0.06799999999999998,-0.9898548002652906 +0.07599999999999998,-0.988258247726045 +0.08399999999999999,-0.9864456940284907 +0.09199999999999998,-0.9843713010162473 +0.09999999999999998,-0.982041464338355 +0.10799999999999998,-0.9794180233112277 +0.11599999999999999,-0.976403765424746 +0.12399999999999999,-0.9730293780562783 +0.13199999999999998,-0.9693218088813109 +0.13999999999999999,-0.9651806711221049 +0.148,-0.9604931545932465 +0.15599999999999997,-0.9552888944635467 +0.16399999999999998,-0.9495151069019616 +0.172,-0.9429389631834753 +0.18,-0.9359471708339121 +0.188,-0.928069445351632 +0.19599999999999998,-0.9192907536712843 +0.204,-0.9097013406239501 +0.212,-0.8977932653168965 +0.21999999999999997,-0.8843615056381698 +0.22799999999999998,-0.8717625454649311 +0.236,-0.8580758306169468 +0.244,-0.8444062366936302 +0.252,-0.8311793230687603 +0.26,-0.8137549710966338 +0.268,-0.7948716930320016 +0.276,-0.7747421915896526 +0.284,-0.7527940483383867 +0.292,-0.7290913154011965 +0.3,-0.7043723854657895 +0.308,-0.6788822873591872 +0.316,-0.6506862293772206 +0.324,-0.620896074822454 +0.332,-0.5896882950850517 +0.33999999999999997,-0.5565283730400894 +0.348,-0.52200634272276 +0.356,-0.48514207948487004 +0.364,-0.44736605380601185 +0.372,-0.40755000457781015 +0.38,-0.365719507972644 +0.388,-0.32251681628529494 +0.39599999999999996,-0.2788816607644797 +0.40399999999999997,-0.23357905644943477 +0.412,-0.1860291832352086 +0.42,-0.13801549805408733 +0.428,-0.08886899344524517 +0.436,-0.03884399412505509 +0.444,0.011796581082090177 +0.452,0.06180898637130301 +0.46,0.1122931099354593 +0.46799999999999997,0.16303079194872608 +0.476,0.21268950491929894 +0.484,0.2631949767621771 +0.492,0.3099523279037373 +0.5,0.3566065332954498 +0.508,0.40431584989862607 +0.516,0.4509110115721649 +0.524,0.49555971540432825 +0.532,0.5391391815311883 +0.54,0.5806277241146071 +0.548,0.6197650366462408 +0.556,0.6568941049141013 +0.5640000000000001,0.6924126368204242 +0.5720000000000001,0.7257285343904373 +0.5800000000000001,0.7560463694337622 +0.5880000000000001,0.7840728406333934 +0.5960000000000001,0.8099691107722687 +0.6040000000000001,0.8337783106358629 +0.6120000000000001,0.855512703309783 +0.6200000000000001,0.874888805495138 +0.6279999999999999,0.8919883988916286 +0.6359999999999999,0.9073163446738687 +0.6439999999999999,0.9206261730559465 +0.6519999999999999,0.9321913345165439 +0.6599999999999999,0.9419960332172992 +0.6679999999999999,0.9503135546055907 +0.6759999999999999,0.9574532633570404 +0.6839999999999999,0.9636790756137413 +0.692,0.9687543787941808 +0.7,0.9729842108753124 +0.708,0.9764561875233922 +0.716,0.97925433100593 +0.724,0.9815874066246634 +0.732,0.9834106759797006 +0.74,0.984982231641093 +0.748,0.9862706218518922 +0.756,0.9870897867350016 +0.764,0.9880179241937713 +0.772,0.988541708197743 +0.78,0.9888385866635783 +0.788,0.9890264810605447 +0.796,0.9891780941949522 +0.804,0.9893617127352035 +0.812,0.9895350147182721 +0.8200000000000001,0.9896779336504316 +0.8280000000000001,0.9898778904067861 +0.8360000000000001,0.9900104500032657 +0.8440000000000001,0.9901319303839525 diff --git a/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819-1211.csv b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819-1211.csv new file mode 100644 index 0000000..43eea25 --- /dev/null +++ b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819-1211.csv @@ -0,0 +1,102 @@ +Ypos,Ynorm,BPM1,BPM2,BPM3,BPM4 +-1.9404,0.9858355061916735 +-1.9324,0.988721727704902 +-1.9243999999999999,0.9897494415742896 +-1.9163999999999999,0.9906152258309527 +-1.9083999999999999,0.9910179221951669 +-1.9003999999999999,0.9912845672439848 +-1.8923999999999999,0.9914496078010088 +-1.8843999999999999,0.9913818403915252 +-1.8763999999999998,0.9908882291668752 +-1.8683999999999998,0.9907021491851147 +-1.8603999999999998,0.990677793459001 +-1.8523999999999998,0.9902775580933795 +-1.8443999999999998,0.9903238507024923 +-1.8363999999999998,0.9907411126935672 +-1.8284,0.9903330945266041 +-1.8204,0.9910442909594434 +-1.8124,0.9901793010158517 +-1.8044,0.9896518695175558 +-1.7964,0.989240631192747 +-1.7884,0.9885859055675117 +-1.7804,0.9880092376394767 +-1.7724,0.9876620387808445 +-1.7644,0.9870595764230071 +-1.7564,0.9869368196347307 +-1.7484,0.986016268050193 +-1.7404,0.9849371388353995 +-1.7324,0.9844461140603098 +-1.7244,0.9840443802608302 +-1.7164,0.9835281878298354 +-1.7084,0.9823015007770639 +-1.7004,0.9820755001949044 +-1.6924,0.9808575547286199 +-1.6844,0.9802945586384311 +-1.6764,0.9797578774855448 +-1.6683999999999999,0.9790841828412161 +-1.6603999999999999,0.9782984621877957 +-1.6524,0.977698134232837 +-1.6444,0.9766652426537984 +-1.6364,0.9754753636276702 +-1.6284,0.9748831312095178 +-1.6204,0.9737075497497216 +-1.6124,0.9717690613128376 +-1.6044,0.9701861833059973 +-1.5964,0.9688501765052219 +-1.5884,0.9668421274138107 +-1.5804,0.963142001059919 +-1.5724,0.9590758629037303 +-1.5644,0.9553804465280201 +-1.5564,0.9473904615136285 +-1.5484,0.9296165657881623 +-1.5404,0.6786819910657522 +-1.5324,-0.881756876923624 +-1.5244,-0.9144279162269665 +-1.5164,-0.928047883651303 +-1.5084,-0.9333986228313652 +-1.5004,-0.9377788035711047 +-1.4924,-0.9418138552281087 +-1.4844,-0.9450498208168038 +-1.4764,-0.9470027027257459 +-1.4684,-0.9491950466583311 +-1.4604,-0.9510151014496262 +-1.4524,-0.9539869288675332 +-1.4444,-0.9538690356634983 +-1.4364,-0.9555993883335078 +-1.4284,-0.9565783751600697 +-1.4203999999999999,-0.9575492799558362 +-1.4123999999999999,-0.9587734011944016 +-1.4043999999999999,-0.9596166149527372 +-1.3963999999999999,-0.9611804892890236 +-1.3883999999999999,-0.9613400140545624 +-1.3803999999999998,-0.9626703122419603 +-1.3724,-0.9637312497266723 +-1.3644,-0.9634902004694816 +-1.3564,-0.9637581398703028 +-1.3484,-0.9641391724478318 +-1.3404,-0.964558698651015 +-1.3324,-0.9648796659771637 +-1.3244,-0.9657526239087623 +-1.3164,-0.9660113784888928 +-1.3084,-0.9664092006733673 +-1.3004,-0.966703256124519 +-1.2924,-0.9677205304266455 +-1.2844,-0.9672815173570604 +-1.2764,-0.9679911222196487 +-1.2684000000000002,-0.9686113251936885 +-1.2604000000000002,-0.9692052061473195 +-1.2524000000000002,-0.9697765873647397 +-1.2444000000000002,-0.9695110917737283 +-1.2364000000000002,-0.9698785014754528 +-1.2284000000000002,-0.9704234711099068 +-1.2204000000000002,-0.9704895702802304 +-1.2124000000000001,-0.9710968921939348 +-1.2044000000000001,-0.9710931343203232 +-1.1964000000000001,-0.9713645922501568 +-1.1884000000000001,-0.971639602755263 +-1.1804000000000001,-0.9719144066734735 +-1.1724,-0.9723135798897568 +-1.1644,-0.972609024683036 +-1.1564,-0.9734340298940433 +-1.1484,-0.9733165345246064 +-1.1404,-0.974240546879075 diff --git a/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819-1231.csv b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819-1231.csv new file mode 100644 index 0000000..4ff63cc --- /dev/null +++ b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819-1231.csv @@ -0,0 +1,102 @@ +Ypos,Ynorm,BPM1,BPM2,BPM3,BPM4 +-1.5904,0.8711201804317473 +-1.5894,0.8827639432826752 +-1.5884,0.8894796037368595 +-1.5874000000000001,0.890650231793468 +-1.5864,0.8870775612884955 +-1.5854,0.8928482871948326 +-1.5844,0.887069571032609 +-1.5834000000000001,0.8901254090805308 +-1.5824,0.8970607077877151 +-1.5814,0.8841375791845584 +-1.5804,0.88639535032581 +-1.5794000000000001,0.8791557467919989 +-1.5784,0.8836375725080873 +-1.5774,0.8762438658669573 +-1.5764,0.8784697136163682 +-1.5754000000000001,0.8764411178849519 +-1.5744,0.8677247543673968 +-1.5734,0.8613146191614611 +-1.5724,0.8512472541713226 +-1.5714000000000001,0.8559898826334207 +-1.5704,0.8506794099669593 +-1.5694,0.8503579737528759 +-1.5684,0.8503626996571153 +-1.5674000000000001,0.8401330944458666 +-1.5664,0.8363862220875184 +-1.5654,0.8244459539780927 +-1.5644,0.8214331277907717 +-1.5634000000000001,0.8156912113000617 +-1.5624,0.8159940222105795 +-1.5614,0.8070887469152257 +-1.5604,0.7974267162363584 +-1.5594000000000001,0.7843968866649436 +-1.5584,0.7807546766435062 +-1.5574,0.7683809980888389 +-1.5564,0.7668408171766788 +-1.5554000000000001,0.7391353022480763 +-1.5544,0.7209438764505415 +-1.5534,0.6982916740048369 +-1.5524,0.6832786284996927 +-1.5514000000000001,0.6649650101442098 +-1.5504,0.655114274178162 +-1.5493999999999999,0.6244236881307383 +-1.5484,0.60042333852912 +-1.5474,0.5667855955678671 +-1.5464,0.5310766826079814 +-1.5453999999999999,0.4932603390990375 +-1.5444,0.4509456908444057 +-1.5434,0.4037281314883651 +-1.5424,0.3532911131941745 +-1.5413999999999999,0.29953203842596415 +-1.5404,0.24568011139263626 +-1.5394,0.18580602425156859 +-1.5384,0.10211094291259973 +-1.5373999999999999,0.010952425990731039 +-1.5364,-0.07023779818932525 +-1.5354,-0.17501688808826837 +-1.5344,-0.24931646508179242 +-1.5333999999999999,-0.30948662308284147 +-1.5324,-0.36534435236355434 +-1.5314,-0.40925895422683434 +-1.5304,-0.45513002018578225 +-1.5293999999999999,-0.48933722278591096 +-1.5284,-0.5221424269933578 +-1.5274,-0.5554298037678008 +-1.5264,-0.5827856950555875 +-1.5253999999999999,-0.6186494777720638 +-1.5244,-0.641731623131858 +-1.5234,-0.6652238436804352 +-1.5224,-0.6809043459923027 +-1.5213999999999999,-0.6940582866670448 +-1.5204,-0.7080295148335981 +-1.5194,-0.7196985129354248 +-1.5184,-0.7359330561294617 +-1.5173999999999999,-0.7462796560863664 +-1.5164,-0.7541898960328908 +-1.5154,-0.768095687918667 +-1.5144,-0.7784849646239109 +-1.5133999999999999,-0.7845710103749624 +-1.5124,-0.7936238656227317 +-1.5114,-0.8026318060229529 +-1.5104,-0.8093454386594748 +-1.5093999999999999,-0.8062359939610046 +-1.5084,-0.8111370565797564 +-1.5074,-0.8143974033668647 +-1.5064,-0.8224223183561951 +-1.5053999999999998,-0.8259257985173463 +-1.5044,-0.8305601335587851 +-1.5034,-0.8327543996821205 +-1.5024,-0.834271470268658 +-1.5013999999999998,-0.8382277439037328 +-1.5004,-0.843001467554289 +-1.4994,-0.8470393480198649 +-1.4984,-0.8536390624270043 +-1.4973999999999998,-0.8539178764630875 +-1.4964,-0.8563042628744244 +-1.4954,-0.8596810005561475 +-1.4944,-0.865656325796767 +-1.4933999999999998,-0.8659221183273871 +-1.4924,-0.8691497783742362 +-1.4914,-0.8733654566145334 +-1.4904,-0.876312620169452 diff --git a/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819.csv b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819.csv new file mode 100644 index 0000000..c0f8159 --- /dev/null +++ b/pxii_bec/macros/luts/bpm_calib/bcu_bpm_y_20260819.csv @@ -0,0 +1,102 @@ +Ypos,Ynorm,BPM1,BPM2,BPM3,BPM4 +-1.5904,0.8559728616428397 +-1.5894,0.8674854073470474 +-1.5884,0.8684557576772519 +-1.5874000000000001,0.8723867191782555 +-1.5864,0.8725448516282629 +-1.5854,0.8733552490408302 +-1.5844,0.8715241597271858 +-1.5834000000000001,0.8665383078119829 +-1.5824,0.864005441848851 +-1.5814,0.8620324173409509 +-1.5804,0.8589258144369022 +-1.5794000000000001,0.853892794831488 +-1.5784,0.8474798430560946 +-1.5774,0.8453802694105512 +-1.5764,0.841728107618678 +-1.5754000000000001,0.8350474271220597 +-1.5744,0.8319791239385238 +-1.5734,0.8290674499108361 +-1.5724,0.8157616971207088 +-1.5714000000000001,0.8122258451439136 +-1.5704,0.8030023384179154 +-1.5694,0.7956524360310395 +-1.5684,0.7918003565062389 +-1.5674000000000001,0.781346639507648 +-1.5664,0.7736689237660315 +-1.5654,0.7645721408757331 +-1.5644,0.7506667253443646 +-1.5634000000000001,0.7350145863129213 +-1.5624,0.7248113626276075 +-1.5614,0.7114374360963227 +-1.5604,0.6955314782531941 +-1.5594000000000001,0.6755750612001852 +-1.5584,0.649394480841771 +-1.5574,0.6326612597251297 +-1.5564,0.604775852431526 +-1.5554000000000001,0.5685581865982454 +-1.5544,0.5320100387862194 +-1.5534,0.48264468097747343 +-1.5524,0.44115415207672415 +-1.5514000000000001,0.4059107690612201 +-1.5504,0.36381070042318586 +-1.5493999999999999,0.3182264013667154 +-1.5484,0.2712098066246879 +-1.5474,0.21325558831563968 +-1.5464,0.1429937964673012 +-1.5453999999999999,0.06471300649418762 +-1.5444,-0.020257020466444568 +-1.5434,-0.08932994255568039 +-1.5424,-0.15154237512530025 +-1.5413999999999999,-0.2073323712779303 +-1.5404,-0.26360494104330673 +-1.5394,-0.3154860844240928 +-1.5384,-0.3780577187356848 +-1.5373999999999999,-0.4285648770241825 +-1.5364,-0.4751603405381964 +-1.5354,-0.5368104977162115 +-1.5344,-0.5744941864136172 +-1.5333999999999999,-0.6024362786650701 +-1.5324,-0.6264475358953175 +-1.5314,-0.6449590265706482 +-1.5304,-0.6634386424594358 +-1.5293999999999999,-0.6810194950181359 +-1.5284,-0.6931515972012285 +-1.5274,-0.7056068431387127 +-1.5264,-0.7193108054426638 +-1.5253999999999999,-0.729308606785317 +-1.5244,-0.7386505667688769 +-1.5234,-0.7530642439073069 +-1.5224,-0.7610206401124405 +-1.5213999999999999,-0.7699438421678487 +-1.5204,-0.7788468230217831 +-1.5194,-0.7909132509642413 +-1.5184,-0.795002505659334 +-1.5173999999999999,-0.8003436559306488 +-1.5164,-0.8057307700587716 +-1.5154,-0.8154531831000514 +-1.5144,-0.8191065766484761 +-1.5133999999999999,-0.8241741205045497 +-1.5124,-0.8297193602621029 +-1.5114,-0.8303095581741022 +-1.5104,-0.8379867998203118 +-1.5093999999999999,-0.8415964860705206 +-1.5084,-0.8438101319343176 +-1.5074,-0.849742544147631 +-1.5064,-0.8548472372697725 +-1.5053999999999998,-0.8571391657120218 +-1.5044,-0.8582220388800084 +-1.5034,-0.8598448605795516 +-1.5024,-0.8622835394050983 +-1.5013999999999998,-0.8630663163408266 +-1.5004,-0.8709049932731775 +-1.4994,-0.8721681735363884 +-1.4984,-0.8737471319888902 +-1.4973999999999998,-0.8773187969338366 +-1.4964,-0.8816537692374575 +-1.4954,-0.8865515500704974 +-1.4944,-0.8862015973680222 +-1.4933999999999998,-0.8887582761422372 +-1.4924,-0.8867669179413578 +-1.4914,-0.8899351166565489 +-1.4904,-0.8906605139574553 diff --git a/pxii_bec/macros/luts/dcm_calibration_20260818-1757.csv b/pxii_bec/macros/luts/dcm_calibration_20260818-1757.csv new file mode 100644 index 0000000..56c1c76 --- /dev/null +++ b/pxii_bec/macros/luts/dcm_calibration_20260818-1757.csv @@ -0,0 +1,74 @@ +energy,harmonic,gap,pitch,samcam_x,samcam_y,zoom=800.0 +6000,H3,5.9117,-5.5183,1057,998 +6300,H3,6.189,-5.5131,1057,998 +6600,H3,6.4759,-5.5102,1057,998 +6900,H3,6.7735,-5.5078,991.5,1041 +7200,H5,4.4999,-5.5054,988.1,1023 +7500,H5,4.6266,-5.504,983.4,1037 +7800,H5,4.7818,-5.5016,995.9,1037 +8100,H5,4.9298,-5.5004,994.1,1035 +8400,H5,5.0799,-5.4991,995.6,1032 +8700,H5,5.2278,-5.498,995.8,1033 +9000,H5,5.3807,-5.4971,997.6,1031 +9300,H5,5.5362,-5.4961,995.2,1031 +9600,H5,5.6939,-5.4948,996.3,1026 +9900,H5,5.8546,-5.4939,996.1,1027 +10200,H7,4.529,-5.493,994.1,1024 +10500,H7,4.6267,-5.4927,983.6,1018 +10800,H7,4.7377,-5.4915,991.7,1021 +11100,H7,4.8415,-5.4908,989.1,1022 +11400,H7,4.9501,-5.49,993,1021 +11700,H7,5.054,-5.4895,991.3,1020 +12000,H7,5.1647,-5.489,993.7,1019 +12300,H7,5.2734,-5.4885,992.2,1018 +12600,H7,5.3798,-5.4882,989.5,1019 +12900,H7,5.4933,-5.4876,988.7,1020 +13200,H9,4.5498,-5.4871,992.2,1017 +13500,H9,4.63,-5.4869,984.7,1009 +13800,H9,4.7115,-5.4864,991,1017 +14100,H9,4.7953,-5.486,993.2,1017 +14400,H9,4.8743,-5.4858,992.5,1016 +14700,H9,4.958,-5.4853,995.9,1016 +15000,H9,5.0439,-5.4852,997,1016 +15300,H9,5.1278,-5.4848,995.2,1015 +15600,H9,5.2116,-5.4844,994.2,1014 +15900,H9,5.2932,-5.4838,992,1016 +16200,H11,4.565,-5.4836,991.8,1011 +16500,H11,4.6238,-5.4836,988.1,1012 +16800,H11,4.6955,-5.483,992.5,1013 +17100,H11,4.7648,-5.4826,988.1,1016 +17400,H11,4.8292,-5.4823,991,1015 +17700,H11,4.8984,-5.4822,989.5,1015 +18000,H11,4.9676,-5.4818,991.4,1014 +18300,H11,5.032,-5.4818,991.9,1015 +18600,H11,5.1012,-5.4816,991.6,1016 +18900,H11,5.1726,-5.4811,990.1,1012 +19200,H13,4.5708,-5.481,991,1013 +19500,H13,4.6317,-5.4808,984,1003 +19800,H13,4.6872,-5.4804,985,1011 +20100,H13,4.7401,-5.4803,987.8,1012 +20400,H13,4.7979,-5.4803,985.6,1011 +20700,H13,4.8579,-5.4801,985.9,1011 +21000,H13,4.9157,-5.48,986.3,1008 +21300,H13,4.9686,-5.48,988.8,1008 +21600,H13,5.0264,-5.4797,988.6,1005 +21900,H13,5.0842,-5.4795,990.8,1002 +22200,H15,4.5811,-5.4794,990.5,994.2 +22500,H15,4.6291,-5.4792,989.6,993.4 +22800,H15,4.6768,-5.479,992.5,996.5 +23100,H15,4.7269,-5.4791,1022,994.2 +23400,H15,4.777,-5.4791,992.5,995.2 +23700,H15,4.827,-5.479,992.1,991 +24000,H15,4.8771,-5.4789,990.3,998.7 +24300,H15,4.9271,-5.4787,990.4,999.2 +24600,H15,4.9724,-5.4786,991.1,1000 +24900,H15,5.0224,-5.4785,990.5,1004 +25200,H17,4.5859,-5.4787,986.4,1002 +25500,H17,4.6361,-5.4785,988.9,996.6 +25800,H17,4.6734,-5.4791,984.1,999.2 +26100,H17,4.7152,-5.4787,986.4,997.1 +26400,H17,4.7645,-5.4787,986.1,989 +26700,H17,4.7993,-5.4785,986.4,989.6 +27000,H17,4.8487,-5.4783,986.4,989.6 +27300,H17,4.8931,-5.4783,986.4,989.6 +27600,H19,4.5186,-5.4784,986.4,989.6 diff --git a/pxii_bec/macros/luts/dcm_calibration_20260818-2020.csv b/pxii_bec/macros/luts/dcm_calibration_20260818-2020.csv new file mode 100644 index 0000000..9ee71cf --- /dev/null +++ b/pxii_bec/macros/luts/dcm_calibration_20260818-2020.csv @@ -0,0 +1,8 @@ +energy,harmonic,gap,pitch,samcam_x,samcam_y,zoom=800.0 +27900,H19,4.5546,-5.4786,980.2,1013 +28200,H19,4.6013,-5.4783,1520,1252 +28500,H19,4.6395,-5.4782,1520,1252 +28800,H19,4.6679,-5.4784,1520,1252 +29100,H19,4.7109,-5.4784,1520,1252 +29400,H19,4.7421,-5.4783,1520,1252 +29700,H19,4.7875,-5.4782,1520,1252 diff --git a/pxii_bec/macros/luts/roll_20000.csv b/pxii_bec/macros/luts/roll_20000.csv index aed035c..9170c8f 100644 --- a/pxii_bec/macros/luts/roll_20000.csv +++ b/pxii_bec/macros/luts/roll_20000.csv @@ -1,10 +1,10 @@ Roll, Y pos -1,313.4 -2,351.5 -3,388.1 -4,425 -5,460 -6,494.7 -7,526.9 -8,558.8 -9,590.4 +1,675.5 +2,758.3 +3,844.1 +4,924.9 +5,1006 +6,1086 +7,1163 +8,1235 +9,1306 diff --git a/pxii_bec/macros/luts/roll_6000.csv b/pxii_bec/macros/luts/roll_6000.csv index 35bd5d2..1576a01 100644 --- a/pxii_bec/macros/luts/roll_6000.csv +++ b/pxii_bec/macros/luts/roll_6000.csv @@ -1,12 +1,10 @@ Roll, Y pos -2,125.4 -2.5,194.1 -3,260.1 -3.5,325.8 -4,387.4 -4.5,446.9 -5,504.4 -5.5,558.2 -6,609.9 -6.5,658.1 -7,705.2 +2.5,359.2 +3,512.3 +3.5,657.5 +4,794.8 +4.5,931.8 +5,931.9 +5.5,1207 +6,1327 +6.5,1438 diff --git a/pxii_bec/macros/test_state_transitions.py b/pxii_bec/macros/test_state_transitions.py new file mode 100755 index 0000000..6179cc8 --- /dev/null +++ b/pxii_bec/macros/test_state_transitions.py @@ -0,0 +1,49 @@ +"""Test state changes""" + +import random +import time +import beamline_context as bl + +def state_test(number_tries=20): + tested_states = [] + states_to_test = [BeamlineState.BEAMSTOP_ALIGNMENT, + # BeamlineState.DATA_COLLECTION, + BeamlineState.MAINTENANCE, + BeamlineState.ROBOT_SAMPLE_EXCHANGE, + BeamlineState.SAMPLE_ALIGNMENT, + # BeamlineState.DC_XRF, + # BeamlineState.FLUX_MEASUREMENT, + # BeamlineState.XTAL_SNAPSHOT, + BeamlineState.MANUAL_SAMPLE_EXCHANGE, + BeamlineState.BEAM_VISUALISATION] + # BeamlineState.DET_DIODE] + previous = None + for i in range(number_tries): + choices = [s for s in states_to_test if s != previous] + current = random.choice(choices) + print(f"Testing {current}") + bl.planner.move_to(current) + time.sleep(2) + tested_states.append(current.name) + previous = current + bl.planner.move_to(BeamlineState.MANUAL_SAMPLE_EXCHANGE) + + print("\n".join(tested_states)) + +def beamstop_test(): + # time.sleep(10) + # bl.d['bs_pos'].move('out') + # time.sleep(5) + # bl.d['bs_pos'].move('in') + # for i in range(6): + # bl.planner.move_to(BeamlineState.ROBOT_SAMPLE_EXCHANGE) + # bl.planner.move_to(BeamlineState.BEAMSTOP_ALIGNMENT) + # time.sleep(1) + # bl.planner.move_to(BeamlineState.MANUAL_SAMPLE_EXCHANGE) + # bl.planner.move_to(BeamlineState.BEAM_VISUALISATION) + time.sleep(10) + bl.d['bl_pos'].move('out') + time.sleep(10) + bl.d['bl_pos'].move('in') + +