diff --git a/configuration/camera_config/SARES20-CAMS142-M1.json b/configuration/camera_config/SARES20-CAMS142-M1.json index b016511..516301c 100644 --- a/configuration/camera_config/SARES20-CAMS142-M1.json +++ b/configuration/camera_config/SARES20-CAMS142-M1.json @@ -25,6 +25,6 @@ "Bernina" ], "alias": [ - "tt_spatial" + "samplecam_sideview (SARES20-CAMS142-M1)" ] } \ No newline at end of file diff --git a/configuration/camera_config/SARES20-CAMS142-M3.json b/configuration/camera_config/SARES20-CAMS142-M3.json index a8784f8..189768a 100644 --- a/configuration/camera_config/SARES20-CAMS142-M3.json +++ b/configuration/camera_config/SARES20-CAMS142-M3.json @@ -1,13 +1,13 @@ { "camera_calibration": { "reference_marker": [ - 1321, - 974, - 1355, - 1113 + 1084, + 962, + 1116, + 1027 ], - "reference_marker_width": 44.8, - "reference_marker_height": 183.1, + "reference_marker_width": 76.8, + "reference_marker_height": 144.1, "angle_horizontal": 0.0, "angle_vertical": 0.0 }, diff --git a/configuration/camera_config/SARFE10-PPRM064.json b/configuration/camera_config/SARFE10-PPRM064.json index 0fdc2ce..34b46b7 100644 --- a/configuration/camera_config/SARFE10-PPRM064.json +++ b/configuration/camera_config/SARFE10-PPRM064.json @@ -1,13 +1,13 @@ { "camera_calibration": { "reference_marker": [ - 394, - 135, - 519, - 304 + 227, + 55, + 485, + 394 ], - "reference_marker_width": 2000.0, - "reference_marker_height": 2000.0, + "reference_marker_width": 4000.0, + "reference_marker_height": 4000.0, "angle_horizontal": 21.0, "angle_vertical": 0.0 }, diff --git a/configuration/camera_config/SATES21-CAMS154-M1.json b/configuration/camera_config/SATES21-CAMS154-M1.json index 30cce5e..75bba8b 100644 --- a/configuration/camera_config/SATES21-CAMS154-M1.json +++ b/configuration/camera_config/SATES21-CAMS154-M1.json @@ -21,5 +21,10 @@ "connections": 2, "buffer_size": 100, "buffer_logs": false, - "protocol": "icp" + "protocol": "icp", + "group": [ + "Photonics", + "Maloja" + ], + "alias": [] } \ No newline at end of file diff --git a/configuration/camera_config/servers.json b/configuration/camera_config/servers.json index 1705bb7..849f8aa 100644 --- a/configuration/camera_config/servers.json +++ b/configuration/camera_config/servers.json @@ -29,7 +29,8 @@ "expanding": false, "instances": [ "SATES21-CAMS154-M1", - "SATES24-CAMS161-M1" + "SATES24-CAMS161-M1", + "SATES21-PATT-M1" ] }, "http://sf-daqsync-05.psi.ch:8880": { diff --git a/configuration/pipeline_config/SARES11-SPEC125-M1_psen_db.json b/configuration/pipeline_config/SARES11-SPEC125-M1_psen_db.json index 7c99e63..f767a2a 100644 --- a/configuration/pipeline_config/SARES11-SPEC125-M1_psen_db.json +++ b/configuration/pipeline_config/SARES11-SPEC125-M1_psen_db.json @@ -1,12 +1,12 @@ { - "image_background_enable": true, - "image_background": null, + "image_background_enable": "passive", + "image_background": "SARES11-SPEC125-M1_20210926_143300_102984", "image_threshold": null, "image_region_of_interest": null, "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "function": "psen_min_processing", + "function": "maloja_spectrometers.py", "camera_name": "SARES11-SPEC125-M1", "name": "SARES11-SPEC125-M1_psen_db", "mode": "PUSH", @@ -25,5 +25,6 @@ "processing_threads": 6, "thread_buffer_size": 30, "abort_on_error": false, - "no_client_timeout": 0 + "no_client_timeout": 0, + "reload": true } \ No newline at end of file diff --git a/configuration/pipeline_config/SARFE10-PBPS053_proc.json b/configuration/pipeline_config/SARFE10-PBPS053_proc.json index bfe9cd1..bb3a807 100644 --- a/configuration/pipeline_config/SARFE10-PBPS053_proc.json +++ b/configuration/pipeline_config/SARFE10-PBPS053_proc.json @@ -8,8 +8,8 @@ "SARFE10-CVME-PHO6212:Lnk9Ch14-DATA-SUM", "SARFE10-CVME-PHO6212:Lnk9Ch15-DATA-SUM" ], - "mode": "PUSH", - "function": "SARFE10-PBPS053_proc.py", + "mode": "PUB", + "function": "pbps.py", "reload": true, "no_client_timeout": 0, "port": "9004", @@ -17,13 +17,13 @@ "down": "SARFE10-CVME-PHO6212:Lnk9Ch13-DATA-SUM", "right": "SARFE10-CVME-PHO6212:Lnk9Ch14-DATA-SUM", "left": "SARFE10-CVME-PHO6212:Lnk9Ch15-DATA-SUM", - "up_calib": 0.147, - "down_calib": 0.1369, - "left_calib": 0.3929, - "right_calib": 0.2598, - "horiz_calib": -4.2696, - "vert_calib": -7.722, - "uJ_calib": 605.4608924473305, + "up_calib": 0.12141717065655942, + "down_calib": 0.11333970757135983, + "left_calib": 0.32278186898577477, + "right_calib": 0.2083195172927878, + "horiz_calib": -4.333267670316629, + "vert_calib": -7.819575351015781, + "uJ_calib": 464.59651093235357, "threshold": 0, "queue_length": 1000, "xpos_all_x_pvname": "SARFE10-PBPS053:XPOS-ALL-HIST-X", diff --git a/configuration/pipeline_config/SAROP11-CVME-PBPS2_proc.json b/configuration/pipeline_config/SAROP11-CVME-PBPS2_proc.json deleted file mode 100644 index b624ffa..0000000 --- a/configuration/pipeline_config/SAROP11-CVME-PBPS2_proc.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "pipeline_type": "processing", - "image_background_enable": false, - "image_background": null, - "image_threshold": null, - "image_region_of_interest": null, - "image_good_region": null, - "image_slices": null, - "bsread_address": "", - "bsread_channels": [ - "SAROP11-CVME-PBPS2:Lnk9Ch11-DATA-SUM", - "SAROP11-CVME-PBPS2:Lnk9Ch13-DATA-SUM", - "SAROP11-CVME-PBPS2:Lnk9Ch14-DATA-SUM", - "SAROP11-CVME-PBPS2:Lnk9Ch15-DATA-SUM" - ], - "bsread_image_buf": 1000, - "bsread_data_buf": 1000, - "mode": "PUB", - "camera_name": "SAROP11-PPRM110", - "function": "SAROP11-CVME-PBPS2_proc", - "name": "SAROP11-CVME-PBPS2_proc", - - - "up": "SAROP11-CVME-PBPS2:Lnk9Ch11-DATA-SUM", - "down": "SAROP11-CVME-PBPS2:Lnk9Ch13-DATA-SUM", - "right": "SAROP11-CVME-PBPS2:Lnk9Ch14-DATA-SUM", - "left": "SAROP11-CVME-PBPS2:Lnk9Ch15-DATA-SUM", - "up_calib": 0.147, - "down_calib": 0.1369, - "left_calib": 0.3929, - "right_calib": 0.2598, - "horiz_calib": -4.2696, - "vert_calib": -7.722, - "uJ_calib": 1, - "threshold": 0.3, - "queue_length": 512, - "intensity_pvname": "SLAAR11-GEN:LAS-XRAY", - "proc_pv": "SLAAR11-GEN:LAS-EVR", - "fft_x_pos_all_X_pvname": "SLAAR21-LSCP1-FNS:WFM1-X", - "fft_x_pos_all_Y_pvname": "SLAAR21-LSCP1-FNS:WFM1-Y", - "fft_x_pos_odd_X_pvname": "SLAAR21-LSCP1-FNS:WFM2-X", - "fft_x_pos_odd_Y_pvname": "SLAAR21-LSCP1-FNS:WFM2-Y", - "fft_x_pos_even_X_pvname": "SLAAR21-LSCP1-FNS:WFM3-X", - "fft_x_pos_even_Y_pvname": "SLAAR21-LSCP1-FNS:WFM3-Y", - "fft_y_pos_all_X_pvname": "SLAAR21-LSCP1-FNS:WFM4-X", - "fft_y_pos_all_Y_pvname": "SLAAR21-LSCP1-FNS:WFM4-Y", - "fft_y_pos_odd_X_pvname": "SLAAR21-LSCP1-FNS:WFM5-X", - "fft_y_pos_odd_Y_pvname": "SLAAR21-LSCP1-FNS:WFM5-Y", - "fft_y_pos_even_X_pvname": "", - "fft_y_pos_even_Y_pvname": "" - - -} diff --git a/configuration/pipeline_config/SATES21-CAMS154-M1_psen_db.json b/configuration/pipeline_config/SATES21-CAMS154-M1_psen_db.json index cbb7c05..64c41d4 100644 --- a/configuration/pipeline_config/SATES21-CAMS154-M1_psen_db.json +++ b/configuration/pipeline_config/SATES21-CAMS154-M1_psen_db.json @@ -1,28 +1,30 @@ { - "image_background_enable": false, - "image_background": null, + "image_background_enable": "passive", + "image_background": "SATES21-CAMS154-M1_20210930_111716_937207", "image_threshold": null, "image_region_of_interest": null, "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "function": "maloja_spectrometers.py", + "function": "spectrometer.py", "camera_name": "SATES21-CAMS154-M1", "name": "SATES21-CAMS154-M1_psen_db", "mode": "PUSH", "roi_background": [ - 250, - 1600, - 420, - 700 + 1000, + 1001, + 1000, + 1001 ], "roi_signal": [ - 250, - 1600, - 420, - 700 - ], + 103, + 997, + 370, + 1540 + ], "processing_threads": 4, "thread_buffer_size": 30, -"reload": true -} + "reload": true, + "project_axis": 0, + "threshold": 10 +} \ No newline at end of file diff --git a/configuration/pipeline_config/SATES24-CAMS161-M1_psen_db.json b/configuration/pipeline_config/SATES24-CAMS161-M1_psen_db.json index bf0fdfa..dc131b9 100644 --- a/configuration/pipeline_config/SATES24-CAMS161-M1_psen_db.json +++ b/configuration/pipeline_config/SATES24-CAMS161-M1_psen_db.json @@ -6,24 +6,25 @@ "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "function": "maloja_spectrometers.py", + "function": "spectrometer.py", "camera_name": "SATES24-CAMS161-M1", "name": "SATES24-CAMS161-M1_psen_db", "mode": "PUSH", "roi_background": [ - 250, - 1600, - 420, - 700 + 1000, + 1001, + 1000, + 1001 ], "roi_signal": [ - 250, - 1600, - 420, - 700 + 103, + 997, + 370, + 1540 ], "reload": true, "processing_threads": 4, "thread_buffer_size": 30, - "project_axis": 1 -} + "project_axis": 0, + "threshold": 1 +} \ No newline at end of file diff --git a/configuration/pipeline_config/permanent_instances.json b/configuration/pipeline_config/permanent_instances.json index 7f25f6b..1214e98 100644 --- a/configuration/pipeline_config/permanent_instances.json +++ b/configuration/pipeline_config/permanent_instances.json @@ -1,4 +1,6 @@ { + "#SAROP21-ATT01_proc": "SAROP21-ATT01_proc", + "#test_stream": "test_stream", "SARES11-SPEC125-M1_psen_db": "SARES11-SPEC125-M1_psen_db1", "SARES11-SPEC125-M1_psen_ib": "SARES11-SPEC125-M1_psen_ib1", "SARES11-SPEC125-M2_psen_db": "SARES11-SPEC125-M2_psen_db1", @@ -13,13 +15,18 @@ "SARES20-PROF142-M1_ib": "SARES20-PROF142-M1_ib1", "SARES20-PROF142-M1_proc": "SARES20-PROF142-M1_proc1", "SARES20-PROF146-M1_proc": "SARES20-PROF146-M_proc1", - "SARFE10-PBPS053_proc": "SARFE10-PBPS053_proc1", + "SARFE10-PBPS053_proc": "SARFE10-PBPS053_proc", "SARFE10-PSSS059_psss": "SARFE10-PSSS059_psss1", "SARFE10-PSSS059_store": "SARFE10-PSSS059_store1", - "SAROP21-ATT01_proc": "SAROP21-ATT01_proc", + "SAROP11-PBPS117_proc": "SAROP11-PBPS117_proc", + "SAROP11-PBPS122_proc": "SAROP11-PBPS122_proc", + "SAROP21-PBPS133_proc": "SAROP21-PBPS133_proc", + "SAROP21-PBPS138_proc": "SAROP21-PBPS138_proc", "SAROP21-PPRM138_proc": "SAROP21-PPRM138_proc", "SATES21-CAMS154-M1_psen_db": "SATES21-CAMS154-M1_psen_db1", "SATES21-CAMS154-M1_psen_ib": "SATES21-CAMS154-M1_psen_ib1", + "SATES21-PATT-M1_psen_db": "SATES21-PATT-M1_psen_db", + "SATES21-PATT-M1_psen_ib": "SATES21-PATT-M1_psen_ib", "SATES24-CAMS161-M1_psen_db": "SATES24-CAMS161-M1_psen_db1", "SATES24-CAMS161-M1_psen_ib": "SATES24-CAMS161-M1_psen_ib1", "jungfrau_proc": "jungfrau_proc", diff --git a/configuration/pipeline_config/servers.json b/configuration/pipeline_config/servers.json index 1c13446..fa1b044 100644 --- a/configuration/pipeline_config/servers.json +++ b/configuration/pipeline_config/servers.json @@ -41,13 +41,19 @@ "testdb_ib:9005", "simulation_2_sp", "SARFE10-PBPS053_proc:9004", - "SAROP21-ATT01_proc:9003" + "SAROP21-ATT01_proc:9003", + "test_stream:9006", + "SAROP21-PBPS138_proc:9009", + "SAROP11-PBPS117_proc:9007", + "SAROP11-PBPS122_proc:9010", + "SAROP21-PBPS133_proc:9008" ] }, "http://sf-daqsync-04.psi.ch:8881": { "cameras": [ "SATES21-CAMS154-M1", - "SATES24-CAMS161-M1" + "SATES24-CAMS161-M1", + "SATES21-PATT-M1" ], "expanding": false, "instances": [ @@ -58,7 +64,10 @@ "SATES24-CAMS161-M1_sp", "SATES24-CAMS161-M1_psen_ib:9010", "SATES24-CAMS161-M1_psen_db:9011", - "SATES21-CAMS154-GIGE7_sp" + "SATES21-CAMS154-GIGE7_sp", + "SATES21-PATT-M1_psen_db:9003", + "SATES21-PATT-M1_psen_ib:9002", + "SATES21-PATT-M1_sp" ] }, "http://sf-daqsync-05.psi.ch:8881": { diff --git a/configuration/user_scripts/SARFE10-PBPS053_proc.py b/configuration/user_scripts/SARFE10-PBPS053_proc.py deleted file mode 100644 index 865ef5d..0000000 --- a/configuration/user_scripts/SARFE10-PBPS053_proc.py +++ /dev/null @@ -1,168 +0,0 @@ -import time -from collections import defaultdict, deque -from functools import partial -from logging import getLogger -from threading import Thread - -import epics -import numpy as np -from cam_server.utils import create_thread_pvs - -_logger = getLogger(__name__) - -initialized = False - -dif_vals = { - "xpos_odd_m": np.nan, - "xpos_odd_w": np.nan, - "ypos_odd_m": np.nan, - "ypos_odd_w": np.nan, - "xpos_evn_m": np.nan, - "xpos_evn_w": np.nan, - "ypos_evn_m": np.nan, - "ypos_evn_w": np.nan, -} - -# this is to avoid exceptions in the 'process' function upon appending to buffers if not all of -# them were created in the 'initialize' function -buffers = defaultdict(partial(deque, maxlen=1)) - - -def initialize(params): - global device, initialized - - epics.ca.clear_cache() - - for label in ("xpos_all", "ypos_all", "xpos_odd", "ypos_odd", "xpos_evn", "ypos_evn"): - x_pvname = params[f"{label}_x_pvname"] - y_pvname = params[f"{label}_y_pvname"] - m_pvname = params[f"{label}_m_pvname"] - w_pvname = params[f"{label}_w_pvname"] - - if x_pvname and y_pvname and m_pvname and w_pvname: - buffer = deque(maxlen=params["queue_length"]) - buffers[label] = buffer - - thread = Thread(target=update_PVs, args=(label, buffer, x_pvname, y_pvname, m_pvname, w_pvname)) - thread.start() - - # diff PVs - xpos_dif_m_pvname = params["xpos_dif_m_pvname"] - xpos_dif_w_pvname = params["xpos_dif_w_pvname"] - ypos_dif_m_pvname = params["ypos_dif_m_pvname"] - ypos_dif_w_pvname = params["ypos_dif_w_pvname"] - - thread = Thread(target=update_dif_PVs, args=(xpos_dif_m_pvname, xpos_dif_w_pvname, ypos_dif_m_pvname, ypos_dif_w_pvname)) - thread.start() - - device, _ = params["up"].split(":", 1) - - initialized = True - - -def update_PVs(label, buffer, x_pvname, y_pvname, m_pvname, w_pvname): - x_pv, y_pv, m_pv, w_pv = create_thread_pvs([x_pvname, y_pvname, m_pvname, w_pvname]) - - x_pv.wait_for_connection() - y_pv.wait_for_connection() - m_pv.wait_for_connection() - w_pv.wait_for_connection() - if not (x_pv.connected and y_pv.connected and m_pv.connected and w_pv.connected): - raise (f"Cannot connect to {label} PVs.") - - x_pv.put(np.arange(buffer.maxlen)) - y_pv.put(np.zeros(buffer.maxlen)) - m_pv.put(0) - w_pv.put(0) - - while True: - time.sleep(3) - if len(buffer) != buffer.maxlen: - continue - - _buffer = np.array(buffer) - _buffer = _buffer[~np.isnan(_buffer)] - - # histogram - y_hist, x_hist = np.histogram(_buffer, bins=50) - x_hist = (x_hist[1:] + x_hist[:-1]) / 2 - - x_pv.put(x_hist) - y_pv.put(y_hist) - - # stats - mean_val = np.mean(_buffer) - std_val = np.std(_buffer) - - m_pv.put(mean_val) - w_pv.put(std_val) - - dif_vals[f"{label}_m"] = mean_val - dif_vals[f"{label}_w"] = std_val - - -def update_dif_PVs(xpos_dif_m_pvname, xpos_dif_w_pvname, ypos_dif_m_pvname, ypos_dif_w_pvname): - xpos_dif_m_pv, xpos_dif_w_pv, ypos_dif_m_pv, ypos_dif_w_pv = create_thread_pvs( - [xpos_dif_m_pvname, xpos_dif_w_pvname, ypos_dif_m_pvname, ypos_dif_w_pvname] - ) - - xpos_dif_m_pv.wait_for_connection() - xpos_dif_w_pv.wait_for_connection() - ypos_dif_m_pv.wait_for_connection() - ypos_dif_w_pvname.wait_for_connection() - if not (xpos_dif_m_pv.connected and xpos_dif_w_pv.connected and ypos_dif_m_pv.connected and ypos_dif_w_pvname.connected): - raise (f"Cannot connect to dif PVs.") - - while True: - time.sleep(3) - xpos_dif_m_pv.put(dif_vals["xpos_odd_m"] - dif_vals["xpos_evn_m"]) - xpos_dif_w_pv.put(dif_vals["xpos_odd_w"] - dif_vals["xpos_evn_w"]) - ypos_dif_m_pv.put(dif_vals["ypos_odd_m"] - dif_vals["ypos_evn_m"]) - ypos_dif_w_pv.put(dif_vals["ypos_odd_w"] - dif_vals["ypos_evn_w"]) - - -def process(data, pulse_id, timestamp, params): - # Initialize on first run - if not initialized: - initialize(params) - - # Read stream inputs - up = data[params["up"]] * params["up_calib"] - down = data[params["down"]] * params["down_calib"] - right = data[params["right"]] * params["right_calib"] - left = data[params["left"]] * params["left_calib"] - - # Calculations - try: - intensity = down + up + left + right - intensity_uJ = intensity * params["uJ_calib"] - except: - intensity = np.nan - intensity_uJ = np.nan - - if intensity > params["threshold"]: - xpos = ((right - left) / (right + left)) * params["horiz_calib"] - ypos = ((up - down) / (up + down)) * params["vert_calib"] - else: - xpos = np.nan - ypos = np.nan - - # Update buffers - buffers["xpos_all"].append(xpos) - buffers["ypos_all"].append(ypos) - if pulse_id % 2: - buffers["xpos_odd"].append(xpos) - buffers["ypos_odd"].append(ypos) - else: - buffers["xpos_evn"].append(xpos) - buffers["ypos_evn"].append(ypos) - - # Set bs outputs - output = {} - output[f"{device}:INTENSITY"] = intensity - output[f"{device}:INTENSITY_UJ"] = intensity_uJ - output[f"{device}:XPOS"] = xpos - output[f"{device}:YPOS"] = ypos - - return output - diff --git a/configuration/user_scripts/SAROP11-CVME-PBPS2_proc.py b/configuration/user_scripts/SAROP11-CVME-PBPS2_proc.py deleted file mode 100644 index 3c1f99d..0000000 --- a/configuration/user_scripts/SAROP11-CVME-PBPS2_proc.py +++ /dev/null @@ -1,127 +0,0 @@ -import time -from collections import defaultdict, deque -from functools import partial -from logging import getLogger -from threading import RLock, Thread -from cam_server.pipeline.data_processing import functions, processor - -import epics -import numpy as np -from cam_server.utils import create_thread_pvs -from scipy.fftpack import fft - -_logger = getLogger(__name__) - -intensity_pv = None -initialized = False - -# this is to avoid exceptions in the 'process' function upon appending to buffers if not all of -# them were created in the 'initialize' function -buffers = defaultdict(partial(deque, maxlen=1)) - - -def initialize(params): - global intensity_pv, device, initialized - - epics.ca.clear_cache() - [intensity_pv] = create_thread_pvs([params["intensity_pvname"]]) - intensity_pv.wait_for_connection() - # If raising this exception then the pipeline won't start - if not intensity_pv.connected: - raise ("Cannot connect to " + params["intensity_pvname"]) - - for label in ("x_pos_all", "y_pos_all", "x_pos_odd", "y_pos_odd", "x_pos_even", "y_pos_even"): - out_x_pvname = params[f"fft_{label}_X_pvname"] - out_y_pvname = params[f"fft_{label}_Y_pvname"] - - if out_x_pvname and out_y_pvname: - buffer = deque(maxlen=params["queue_length"]) - buffers[label] = buffer - - thread = Thread(target=calculate_fft, args=(buffer, out_x_pvname, out_y_pvname)) - thread.start() - - device, _ = params["up"].split(":", 1) - - initialized = True - - -# Processing the buffer every second and setting result to EPICS channel -def calculate_fft(buffer, out_x_pvname, out_y_pvname): - _logger.info("Start buffer processing thread") - try: - out_x_pv, out_y_pv = create_thread_pvs([out_x_pvname, out_y_pvname]) - - out_x_pv.wait_for_connection() - out_y_pv.wait_for_connection() - if not (out_x_pv.connected and out_y_pv.connected): - raise ("Cannot connect to fft PVs.") - - out_x_pv.put(np.arange(buffer.maxlen)) - out_y_pv.put(np.zeros(buffer.maxlen)) - - while True: - _buffer = buffer.copy() - if len(_buffer) == _buffer.maxlen: - out_y_pv.put(np.abs(fft(np.array(_buffer)))) - - time.sleep(1.0) - - except Exception as e: - _logger.error("Error on buffer processing thread %s" % (str(e))) - finally: - _logger.info("Exit buffer processing thread") - - - -def process_image(image, pulse_id, timestamp, x_axis, y_axis, params, data): - ret = processor.process_image(image, pulse_id, timestamp, x_axis, y_axis, params, data) - intensity = float(ret ["intensity"] ) - - # Initialize on first run - if not initialized: - initialize(params) - - # Read stream inputs - up = data[params["up"]] * params["up_calib"] - down = data[params["down"]] * params["down_calib"] - right = data[params["right"]] * params["right_calib"] - left = data[params["left"]] * params["left_calib"] - - # Calculations - try: - intensity = down + up + left + right - intensity_uJ = intensity * params["uJ_calib"] - except: - intensity = float("nan") - intensity_uJ = float("nan") - - if intensity > params["threshold"]: - x_pos = ((right - left) / (right + left)) * params["horiz_calib"] - y_pos = ((up - down) / (up + down)) * params["vert_calib"] - else: - x_pos = float("nan") - y_pos = float("nan") - - # Update buffers - buffers["x_pos_all"].append(x_pos) - buffers["y_pos_all"].append(y_pos) - if pulse_id % 2: - buffers["x_pos_odd"].append(x_pos) - buffers["y_pos_odd"].append(y_pos) - else: - buffers["x_pos_even"].append(x_pos) - buffers["y_pos_even"].append(y_pos) - - # Update intensity EPICS channel - intensity_pv.put(intensity) - - # Set bs outputs - output = {} - output[f"{device}:intensity"] = intensity - output[f"{device}:intensity_uJ"] = intensity_uJ - output[f"{device}:x_pos"] = x_pos - output[f"{device}:y_pos"] = y_pos - - return output - diff --git a/configuration/user_scripts/maloja_spectrometers.py b/configuration/user_scripts/maloja_spectrometers.py index 5aaca58..6336235 100644 --- a/configuration/user_scripts/maloja_spectrometers.py +++ b/configuration/user_scripts/maloja_spectrometers.py @@ -13,7 +13,8 @@ def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, image_ processing_parameters = { "roi_signal": roi_signal, "roi_background": roi_background, - "project_axis": project_axis + "project_axis": project_axis, +# "input_params": len(parameters.get("background_data", [123])) } processing_parameters = json.dumps(processing_parameters) @@ -27,6 +28,8 @@ def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, image_ projection_background = get_roi_projection(image, roi_background, project_axis) res[camera_name + ".projection_background"] = projection_background +# res["TEST-SPEC"] = 123 #list(parameters) + return res