From 103adcab0316735f72e2757630a2cc85fab9d02e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 1 Jun 2023 14:42:44 +0200 Subject: [PATCH] Add late averaging for Furka --- .../camera_config/SARCL02-DSCR280.json | 45 ++--- .../camera_config/SARES11-XPR125-C4P3.json | 22 +++ .../camera_config/SARES20-CAMS142-C1.json | 18 +- .../camera_config/SARES20-CAMS142-C2.json | 12 +- .../camera_config/SARES20-CAMS142-C3.json | 2 +- .../camera_config/SARES20-CAMS142-M3.json | 12 +- .../camera_config/SARES20-CAMS142-M5.json | 3 +- .../camera_config/SATES30-CAMS182-GIGE1.json | 12 +- .../camera_config/SATES30-CAMS182-GIGE2.json | 8 +- .../camera_config/SATES30-RIXS-CAM01.json | 5 +- .../camera_config/SLAAR11-LCAM-C431.json | 24 +++ .../camera_config/SLAAR21-LCAM-CT1C1.json | 16 ++ .../camera_config/SLAAR21-LCAM-CT1C2.json | 16 ++ .../camera_config/permanent_instances.json | 2 + configuration/camera_config/servers.json | 9 +- .../SARES11-SPEC125-M1_psen_db.json | 12 +- ...en_sp.json => SARES11-XPR125-C4P3_sp.json} | 4 +- .../pipeline_config/SAROP11-PBPS110_proc.json | 12 +- .../pipeline_config/SAROP11-PBPS122_proc.json | 12 +- .../pipeline_config/SAROP31-PBPS113_proc.json | 38 ++--- .../pipeline_config/SAROP31-PBPS149_proc.json | 38 ++--- .../pipeline_config/SATBD02-DSCR050_sp.json | 22 +-- .../SATES21-CAMS-PATT1_spec_db.json | 20 +-- .../SATES21-CAMS154-M1_spec_db.json | 31 +++- .../SATES24-CAMS161-M1_spec_db.json | 20 +-- .../SATES30-RIXS-CAM01_proc.json | 17 ++ .../SATES30-RIXS-CAM01_sp.json | 5 +- .../SATES31-CAMS187-RIXS1_sp.json | 3 +- .../pipeline_config/SATMA02_calib.json | 21 +++ .../SLAAR02-LPMO01-C321_proc.json | 3 +- .../pipeline_config/SLAAR11-LCAM-C431_sp.json | 12 ++ .../SLAAR21-LCAM-CT1C1_proc.json | 14 ++ ...ame_sp.json => SLAAR21-LCAM-CT1C1_sp.json} | 4 +- .../SLAAR21-LCAM-CT1C2_proc.json | 14 ++ ...ame_sp.json => SLAAR21-LCAM-CT1C2_sp.json} | 4 +- .../{name:_sp.json => _sp.json} | 4 +- configuration/pipeline_config/example_sp.json | 10 -- .../pipeline_config/permanent_instances.json | 11 +- configuration/pipeline_config/servers.json | 11 +- .../sf-daqsync-01:8889_sp.json | 11 -- .../pipeline_config/simulation_sp.json | 19 ++- configuration/pipeline_config/test_furka.json | 5 +- .../user_scripts/SARES11-SPEC125-M1_2tt.py | 154 ++++++++++++++++++ .../user_scripts/SARES11-SPEC125-M1_tt.py | 8 +- .../SARES11-SPEC125-M1_tt_events.py | 142 ++++++++++++++++ .../user_scripts/SAROP21-ATT01_Test_proc.py | 23 +-- configuration/user_scripts/late_averaging.py | 27 +++ configuration/user_scripts/single_photon.c | 66 ++++---- 48 files changed, 775 insertions(+), 228 deletions(-) create mode 100644 configuration/camera_config/SARES11-XPR125-C4P3.json create mode 100644 configuration/camera_config/SLAAR11-LCAM-C431.json create mode 100644 configuration/camera_config/SLAAR21-LCAM-CT1C1.json create mode 100644 configuration/camera_config/SLAAR21-LCAM-CT1C2.json rename configuration/pipeline_config/{myscreen_sp.json => SARES11-XPR125-C4P3_sp.json} (74%) create mode 100644 configuration/pipeline_config/SATES30-RIXS-CAM01_proc.json create mode 100644 configuration/pipeline_config/SATMA02_calib.json create mode 100644 configuration/pipeline_config/SLAAR11-LCAM-C431_sp.json create mode 100644 configuration/pipeline_config/SLAAR21-LCAM-CT1C1_proc.json rename configuration/pipeline_config/{camera_name_sp.json => SLAAR21-LCAM-CT1C1_sp.json} (74%) create mode 100644 configuration/pipeline_config/SLAAR21-LCAM-CT1C2_proc.json rename configuration/pipeline_config/{new_camera_name_sp.json => SLAAR21-LCAM-CT1C2_sp.json} (74%) rename configuration/pipeline_config/{name:_sp.json => _sp.json} (82%) delete mode 100644 configuration/pipeline_config/example_sp.json delete mode 100644 configuration/pipeline_config/sf-daqsync-01:8889_sp.json create mode 100644 configuration/user_scripts/SARES11-SPEC125-M1_2tt.py create mode 100644 configuration/user_scripts/SARES11-SPEC125-M1_tt_events.py create mode 100644 configuration/user_scripts/late_averaging.py diff --git a/configuration/camera_config/SARCL02-DSCR280.json b/configuration/camera_config/SARCL02-DSCR280.json index 311f0af..2542b1a 100644 --- a/configuration/camera_config/SARCL02-DSCR280.json +++ b/configuration/camera_config/SARCL02-DSCR280.json @@ -1,21 +1,26 @@ { - "name": "SARCL02-DSCR280", - "camera_calibration": { - "angle_horizontal": 0.0, - "angle_vertical": 8.0, - "reference_marker_height": 6000.0, - "reference_marker": [ - 107, - 211, - 1938, - 900 - ], - "reference_marker_width": 16000.0 - }, - "source": "SARCL02-DSCR280", - "mirror_y": false, - "rotate": 1, - "mirror_x": false, - "group": ["Electrons"], - "alias": [] -} + "camera_calibration": { + "reference_marker": [ + 13, + 534, + 1849, + 1229 + ], + "reference_marker_width": 16000.0, + "reference_marker_height": 6000.0, + "angle_horizontal": 0.0, + "angle_vertical": 8.0 + }, + "mirror_x": false, + "mirror_y": false, + "rotate": 1, + "roi": null, + "image_background": null, + "source_type": "epics", + "name": "SARCL02-DSCR280", + "source": "SARCL02-DSCR280", + "group": [ + "Electrons" + ], + "alias": [] +} \ No newline at end of file diff --git a/configuration/camera_config/SARES11-XPR125-C4P3.json b/configuration/camera_config/SARES11-XPR125-C4P3.json new file mode 100644 index 0000000..5bc3a85 --- /dev/null +++ b/configuration/camera_config/SARES11-XPR125-C4P3.json @@ -0,0 +1,22 @@ +{ + "camera_calibration": { + "reference_marker": [ + 0, + 0, + 100, + 100 + ], + "reference_marker_width": 100.0, + "reference_marker_height": 100.0, + "angle_horizontal": 0.0, + "angle_vertical": 0.0 + }, + "mirror_x": false, + "mirror_y": false, + "rotate": 0, + "roi": null, + "image_background": null, + "source_type": "epics", + "name": "SARES11-XPR125-C4P3", + "source": "SARES11-XPR125-C4P3" +} \ No newline at end of file diff --git a/configuration/camera_config/SARES20-CAMS142-C1.json b/configuration/camera_config/SARES20-CAMS142-C1.json index c39afa5..b4e1a4c 100644 --- a/configuration/camera_config/SARES20-CAMS142-C1.json +++ b/configuration/camera_config/SARES20-CAMS142-C1.json @@ -1,19 +1,19 @@ { "camera_calibration": { "reference_marker": [ - 1159, - 940, - 1706, - 981 + 1412, + 1469, + 1513, + 1569 ], - "reference_marker_width": 200.0, - "reference_marker_height": 15.2, + "reference_marker_width": 23.5, + "reference_marker_height": 21.2, "angle_horizontal": 0.0, "angle_vertical": 0.0 }, - "mirror_x": false, + "mirror_x": true, "mirror_y": false, - "rotate": 0, + "rotate": 1, "roi": null, "image_background": null, "source_type": "bsread", @@ -21,7 +21,7 @@ "name": "SARES20-CAMS142-C1", "source": "SARES20-CAMS142-C1", "alias": [ - "SAMPLECAM" + "SAMPLECAM_FRONT (SARES20-CAMS142-C1)" ], "group": [ "Photonics", diff --git a/configuration/camera_config/SARES20-CAMS142-C2.json b/configuration/camera_config/SARES20-CAMS142-C2.json index e65fe4c..46fcea6 100644 --- a/configuration/camera_config/SARES20-CAMS142-C2.json +++ b/configuration/camera_config/SARES20-CAMS142-C2.json @@ -1,13 +1,13 @@ { "camera_calibration": { "reference_marker": [ - 567, - 460, - 570, - 464 + 1076, + 851, + 1133, + 893 ], "reference_marker_width": 73.0, - "reference_marker_height": 96.0, + "reference_marker_height": 54.0, "angle_horizontal": 0.0, "angle_vertical": 0.0 }, @@ -25,6 +25,6 @@ "Bernina" ], "alias": [ - "SAMPLECAM_SIDEVIEW_45DEG_THC (SARES20-CAMS142-C2)" + "SAMPLECAM_BACK_RACKS (SARES20-CAMS142-C2)" ] } \ No newline at end of file diff --git a/configuration/camera_config/SARES20-CAMS142-C3.json b/configuration/camera_config/SARES20-CAMS142-C3.json index 9c678a4..358c138 100644 --- a/configuration/camera_config/SARES20-CAMS142-C3.json +++ b/configuration/camera_config/SARES20-CAMS142-C3.json @@ -21,7 +21,7 @@ "name": "SARES20-CAMS142-C3", "source": "SARES20-CAMS142-C3", "alias": [ - "SAMPLECAM_SIDEVIEW (SARES20-CAMS142-C3)" + "SAMPLECAM_BACK_DOOR (SARES20-CAMS142-C3)" ], "group": [ "Photonics", diff --git a/configuration/camera_config/SARES20-CAMS142-M3.json b/configuration/camera_config/SARES20-CAMS142-M3.json index b4cdbe4..116c0d4 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": [ - 1209, - 892, - 1328, - 1050 + 943, + 1072, + 1027, + 1192 ], - "reference_marker_width": 231.0, - "reference_marker_height": 307.0, + "reference_marker_width": 163.0, + "reference_marker_height": 233.0, "angle_horizontal": 0.0, "angle_vertical": 0.0 }, diff --git a/configuration/camera_config/SARES20-CAMS142-M5.json b/configuration/camera_config/SARES20-CAMS142-M5.json index 7a07aa3..e3212ce 100644 --- a/configuration/camera_config/SARES20-CAMS142-M5.json +++ b/configuration/camera_config/SARES20-CAMS142-M5.json @@ -41,5 +41,6 @@ 2190, 800, 150 - ] + ], + "debug": true } \ No newline at end of file diff --git a/configuration/camera_config/SATES30-CAMS182-GIGE1.json b/configuration/camera_config/SATES30-CAMS182-GIGE1.json index 592fbf6..42dbb8c 100644 --- a/configuration/camera_config/SATES30-CAMS182-GIGE1.json +++ b/configuration/camera_config/SATES30-CAMS182-GIGE1.json @@ -1,13 +1,13 @@ { "camera_calibration": { "reference_marker": [ - 81, - 48, - 231, - 200 + 204, + 108, + 349, + 934 ], "reference_marker_width": 5000.0, - "reference_marker_height": 5000.0, + "reference_marker_height": 2000.0, "angle_horizontal": 0.0, "angle_vertical": 0.0 }, @@ -16,8 +16,8 @@ "rotate": 0, "roi": null, "image_background": null, - "forwarder_port": 9003, "source_type": "bsread", + "forwarder_port": 9003, "source": "SATES30-CAMS182-GIGE1", "name": "SATES30-CAMS182-GIGE1", "prefix": "SATES30-CAMS182-GIGE1", diff --git a/configuration/camera_config/SATES30-CAMS182-GIGE2.json b/configuration/camera_config/SATES30-CAMS182-GIGE2.json index f3964dd..7439671 100644 --- a/configuration/camera_config/SATES30-CAMS182-GIGE2.json +++ b/configuration/camera_config/SATES30-CAMS182-GIGE2.json @@ -1,10 +1,10 @@ { "camera_calibration": { "reference_marker": [ - 396, - 30, - 1579, - 1218 + 265, + 72, + 1253, + 1066 ], "reference_marker_width": 5000.0, "reference_marker_height": 5000.0, diff --git a/configuration/camera_config/SATES30-RIXS-CAM01.json b/configuration/camera_config/SATES30-RIXS-CAM01.json index 42430ce..75f7279 100644 --- a/configuration/camera_config/SATES30-RIXS-CAM01.json +++ b/configuration/camera_config/SATES30-RIXS-CAM01.json @@ -13,5 +13,8 @@ "Photonics", "Furka" ], - "alias": [] + "debug": true, + "alias": [], + "forwarder_port": 9007, + "check_timestamp": true } \ No newline at end of file diff --git a/configuration/camera_config/SLAAR11-LCAM-C431.json b/configuration/camera_config/SLAAR11-LCAM-C431.json new file mode 100644 index 0000000..d05428b --- /dev/null +++ b/configuration/camera_config/SLAAR11-LCAM-C431.json @@ -0,0 +1,24 @@ +{ + "camera_calibration": { + "reference_marker": [ + 0, + 0, + 100, + 100 + ], + "reference_marker_width": 100.0, + "reference_marker_height": 100.0, + "angle_horizontal": 0.0, + "angle_vertical": 0.0 + }, + "mirror_x": false, + "mirror_y": false, + "rotate": 0, + "source_type": "epics", + "source": "SLAAR11-LCAM-C431", + "name": "SLAAR11-LCAM-C431", + "group": [ + "Laser" + ], + "alias": [] +} \ No newline at end of file diff --git a/configuration/camera_config/SLAAR21-LCAM-CT1C1.json b/configuration/camera_config/SLAAR21-LCAM-CT1C1.json new file mode 100644 index 0000000..88e87ea --- /dev/null +++ b/configuration/camera_config/SLAAR21-LCAM-CT1C1.json @@ -0,0 +1,16 @@ +{ + "camera_calibration": null, + "mirror_x": false, + "mirror_y": false, + "rotate": 0, + "source_type": "bsread", + "name": "SLAAR21-LCAM-CT1C1", + "protocol": "tcp", + "source": "SLAAR21-LCAM-CT1C1", + "_debug": true, + "group": [ + "Laser", + "Bernina" + ], + "_forwarder_port": 9030 +} \ No newline at end of file diff --git a/configuration/camera_config/SLAAR21-LCAM-CT1C2.json b/configuration/camera_config/SLAAR21-LCAM-CT1C2.json new file mode 100644 index 0000000..b36c66b --- /dev/null +++ b/configuration/camera_config/SLAAR21-LCAM-CT1C2.json @@ -0,0 +1,16 @@ +{ + "camera_calibration": null, + "mirror_x": false, + "mirror_y": false, + "rotate": 0, + "source_type": "bsread", + "name": "SLAAR21-LCAM-CT1C2", + "protocol": "tcp", + "source": "SLAAR21-LCAM-CT1C2", + "_debug": true, + "group": [ + "Laser", + "Bernina" + ], + "_forwarder_port": 9032 +} \ No newline at end of file diff --git a/configuration/camera_config/permanent_instances.json b/configuration/camera_config/permanent_instances.json index f024ae0..83b0856 100644 --- a/configuration/camera_config/permanent_instances.json +++ b/configuration/camera_config/permanent_instances.json @@ -7,6 +7,7 @@ "SARES11-SPEC125-M1": "SARES11-SPEC125-M1", "SARES11-SPEC125-M2": "SARES11-SPEC125-M2", "SARES20-CAMS142-M1": "SARES20-CAMS142-M1", + "SARES20-CAMS142-M2": "SARES20-CAMS142-M2", "SARES20-CAMS142-M5": "SARES20-CAMS142-M5", "SARES30-CAMS156-XE": "SARES30-CAMS156-XE", "SARFE10-PPRM064": "SARFE10-PPRM064", @@ -19,6 +20,7 @@ "SATES24-CAMS161-M1": "SATES24-CAMS161-M1", "SATES30-CAMS182-GIGE1": "SATES30-CAMS182-GIGE1", "SATES30-CAMS182-GIGE2": "SATES30-CAMS182-GIGE2", + "SATES30-RIXS-CAM01": "SATES30-RIXS-CAM01", "SATES31-CAMS187-RIXS1": "SATES31-CAMS187-RIXS1", "SATOP21-PMOS127-2D": "SATOP21-PMOS127-2D", "SATOP31-PMOS132-2D": "SATOP31-PMOS132-2D", diff --git a/configuration/camera_config/servers.json b/configuration/camera_config/servers.json index 3679f8a..534b1c9 100644 --- a/configuration/camera_config/servers.json +++ b/configuration/camera_config/servers.json @@ -78,6 +78,7 @@ "expanding": false, "instances": [ "SARES20-CAMS142-M1", + "SARES20-CAMS142-M2", "SARES20-CAMS142-M4", "SARES20-CAMS142-M5", "SARES20-PROF141-M1", @@ -85,7 +86,10 @@ "SARES20-PROF146-M1", "SLAAR02-LPMO01-C321", "SLAAR02-LPMO02-C322", - "SAROP21-PPRM133" + "SAROP21-PPRM133", + "SLAAR21-LCAM-CS842", + "SLAAR21-LCAM-CT1C1", + "SLAAR21-LCAM-CT1C2" ] }, "http://sf-daqsync-15.psi.ch:8880": { @@ -94,7 +98,8 @@ "instances": [ "SATES31-CAMS187-RIXS1", "SATES30-CAMS182-GIGE1", - "SATES30-CAMS182-GIGE2" + "SATES30-CAMS182-GIGE2", + "SATES30-RIXS-CAM01" ] }, "http://sf-daqsync-16.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 6fddead..eed5041 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": "passive", - "image_background": "SARES11-SPEC125-M1_20230507_163124_994260", + "image_background": "SARES11-SPEC125-M1_20230528_190225_021209", "image_threshold": null, "image_region_of_interest": null, "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "function": "SARES11-SPEC125-M1_tt.py", + "function": "SARES11-SPEC125-M1_2tt.py", "camera_name": "SARES11-SPEC125-M1", "name": "SARES11-SPEC125-M1_psen_db", "mode": "PUSH", @@ -14,7 +14,13 @@ 0, 2048, 50, - 300 + 200 + ], + "roi_signal2": [ + 0, + 2048, + 250, + 400 ], "no_client_timeout": 0, "port": "9013", diff --git a/configuration/pipeline_config/myscreen_sp.json b/configuration/pipeline_config/SARES11-XPR125-C4P3_sp.json similarity index 74% rename from configuration/pipeline_config/myscreen_sp.json rename to configuration/pipeline_config/SARES11-XPR125-C4P3_sp.json index 2a3585b..a284cbb 100644 --- a/configuration/pipeline_config/myscreen_sp.json +++ b/configuration/pipeline_config/SARES11-XPR125-C4P3_sp.json @@ -6,6 +6,6 @@ "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "camera_name": "myscreen", - "name": "myscreen_sp" + "camera_name": "SARES11-XPR125-C4P3", + "name": "SARES11-XPR125-C4P3_sp" } \ No newline at end of file diff --git a/configuration/pipeline_config/SAROP11-PBPS110_proc.json b/configuration/pipeline_config/SAROP11-PBPS110_proc.json index d273746..17611f5 100644 --- a/configuration/pipeline_config/SAROP11-PBPS110_proc.json +++ b/configuration/pipeline_config/SAROP11-PBPS110_proc.json @@ -19,12 +19,12 @@ "down": "SAROP11-CVME-PBPS2:Lnk9Ch11-DATA-SUM", "right": "SAROP11-CVME-PBPS2:Lnk9Ch14-DATA-SUM", "left": "SAROP11-CVME-PBPS2:Lnk9Ch15-DATA-SUM", - "up_calib": 5.487581379365339, - "down_calib": 6.5694290116170215, - "left_calib": 4.714773884372932, - "right_calib": 4.9736472409598855, - "horiz_calib": -4.131288944529578, - "vert_calib": 4.049881575553348, + "up_calib": 0.5765547724194534, + "down_calib": 0.629603239864361, + "left_calib": 0.6530107029826532, + "right_calib": 0.6941451598287135, + "horiz_calib": -5.1719577228641995, + "vert_calib": 6.389710225223535, "uJ_calib": 605.4608924473305, "threshold": 0, "queue_length": 5000, diff --git a/configuration/pipeline_config/SAROP11-PBPS122_proc.json b/configuration/pipeline_config/SAROP11-PBPS122_proc.json index 145b588..eb0dc63 100644 --- a/configuration/pipeline_config/SAROP11-PBPS122_proc.json +++ b/configuration/pipeline_config/SAROP11-PBPS122_proc.json @@ -18,12 +18,12 @@ "down": "SAROP11-CVME-PBPS1:Lnk9Ch5-DATA-SUM", "right": "SAROP11-CVME-PBPS1:Lnk9Ch3-DATA-SUM", "left": "SAROP11-CVME-PBPS1:Lnk9Ch7-DATA-SUM", - "up_calib": 0.4329961889591279, - "down_calib": 0.2756326807724613, - "left_calib": 0.1406206505323777, - "right_calib": 0.15756942651115974, - "horiz_calib": -4.876669457859753, - "vert_calib": 4.488795635241031, + "up_calib": 1.3170784909053646, + "down_calib": 0.7802132837143382, + "left_calib": 0.7509033641005436, + "right_calib": 0.821373380836796, + "horiz_calib": -4.1710745052592735, + "vert_calib": 4.844916769802791, "uJ_calib": 605.9512700123181, "threshold": 0, "queue_length": 1000, diff --git a/configuration/pipeline_config/SAROP31-PBPS113_proc.json b/configuration/pipeline_config/SAROP31-PBPS113_proc.json index 033436a..467ea40 100644 --- a/configuration/pipeline_config/SAROP31-PBPS113_proc.json +++ b/configuration/pipeline_config/SAROP31-PBPS113_proc.json @@ -16,12 +16,12 @@ "down": "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD2", "right": "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD3", "left": "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD0", - "up_calib": 6.840257443212456e-06, - "down_calib": 6.1653460988550605e-06, - "left_calib": 1.6201787692292536e-05, - "right_calib": 1.584162631910054e-05, - "horiz_calib": -3.733833274072839, - "vert_calib": -5.937107209807579, + "up_calib": 1.6116935198445244e-05, + "down_calib": 1.7494281469273323e-05, + "left_calib": 4.3270966600698636e-05, + "right_calib": 3.879033729594731e-05, + "horiz_calib": -4.034562196356022, + "vert_calib": -6.839696258843613, "uJ_calib": 941.943984588351, "threshold": 0, "queue_length": 5000, @@ -60,14 +60,14 @@ 0.3 ], "calib_x_norm": [ - 0.07671441650364863, - -0.0010584166106423775, - -0.08397835040865761 + 0.07449821626464098, + 0.0005958932347863629, + -0.07421680429989863 ], "calib_x_norm_std": [ - 0.24206983712709104, - 0.2517192221440592, - 0.2520562331441098 + 0.04855156593259901, + 0.051051286192765735, + 0.05876136938532417 ], "calib_y_range": [ -0.3, @@ -75,14 +75,14 @@ 0.3 ], "calib_y_norm": [ - 0.0484748027920197, - -0.00020584146521665983, - -0.05258451427890211 + 0.04395861917928205, + 0.00014199002803831937, + -0.04376457455526574 ], "calib_y_norm_std": [ - 0.27576174925738167, - 0.2568940077045247, - 0.25090631714920764 + 0.053443256985745716, + 0.04917184029140196, + 0.056349840562236894 ], - "calib_datetime": "2023-03-13 01:48:04" + "calib_datetime": "2023-05-30 08:51:22" } \ No newline at end of file diff --git a/configuration/pipeline_config/SAROP31-PBPS149_proc.json b/configuration/pipeline_config/SAROP31-PBPS149_proc.json index 1516c84..f24b038 100644 --- a/configuration/pipeline_config/SAROP31-PBPS149_proc.json +++ b/configuration/pipeline_config/SAROP31-PBPS149_proc.json @@ -17,12 +17,12 @@ "down": "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD2", "right": "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD3", "left": "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD0", - "up_calib": 1.508662346943942e-06, - "down_calib": 1.612838087958512e-06, - "left_calib": 8.288800811575718e-07, - "right_calib": 8.588190343731463e-07, - "horiz_calib": -4.612748469769838, - "vert_calib": -4.2123940480695445, + "up_calib": 2.2755419526287142e-06, + "down_calib": 2.4702806952286848e-06, + "left_calib": 1.2467389547855256e-06, + "right_calib": 1.2850241689915753e-06, + "horiz_calib": -4.6898874532309005, + "vert_calib": -4.191461530174274, "uJ_calib": 605.9512700123181, "threshold": 0.0, "queue_length": 5000, @@ -61,14 +61,14 @@ 0.3 ], "calib_x_norm": [ - 0.06510022968417475, - -0.00020972107922603213, - -0.06497406418469041 + 0.06411399525764434, + 0.0001758428549206672, + -0.06382084454040991 ], "calib_x_norm_std": [ - 0.027264758010278046, - 0.030226724851444217, - 0.027674513899714915 + 0.027336294963008215, + 0.027818148361284857, + 0.02853702836194553 ], "calib_y_range": [ -0.3, @@ -76,14 +76,14 @@ 0.3 ], "calib_y_norm": [ - 0.06945988844641009, - -0.0007141178504136682, - -0.07297692851637332 + 0.0693417671672449, + -4.741442975529518e-05, + -0.0738063914596704 ], "calib_y_norm_std": [ - 0.02898536535723783, - 0.02802813913376357, - 0.027555030271288982 + 0.028123280441208747, + 0.029229162548315823, + 0.031015460819767877 ], - "calib_datetime": "2023-04-29 12:57:42" + "calib_datetime": "2023-05-30 09:54:10" } \ No newline at end of file diff --git a/configuration/pipeline_config/SATBD02-DSCR050_sp.json b/configuration/pipeline_config/SATBD02-DSCR050_sp.json index a1aea46..04360b1 100644 --- a/configuration/pipeline_config/SATBD02-DSCR050_sp.json +++ b/configuration/pipeline_config/SATBD02-DSCR050_sp.json @@ -3,15 +3,12 @@ "image_background": "SATBD02-DSCR050_20221013_123827_350915", "image_threshold": null, "image_region_of_interest": [ - 175, - 1602, - 389, - 1464 + 28, + 1092, + 6, + 1007 ], - "image_good_region": { - "threshold": 0.1, - "gfscale": 10.0 - }, + "image_good_region": null, "image_slices": null, "pipeline_type": "processing", "camera_name": "SATBD02-DSCR050", @@ -20,7 +17,10 @@ "no_client_timeout": 0, "port": "9020", "Marker": [ - 1280, - 1080 - ] + 364, + 676 + ], + "reload": true, + "function": "beam_full_width", + "fw_threshold": 0.1 } \ No newline at end of file diff --git a/configuration/pipeline_config/SATES21-CAMS-PATT1_spec_db.json b/configuration/pipeline_config/SATES21-CAMS-PATT1_spec_db.json index ef88abd..833a322 100644 --- a/configuration/pipeline_config/SATES21-CAMS-PATT1_spec_db.json +++ b/configuration/pipeline_config/SATES21-CAMS-PATT1_spec_db.json @@ -1,6 +1,6 @@ { "image_background_enable": "passive", - "image_background": "SATES21-CAMS-PATT1_20230504_151024_448849", + "image_background": "SATES21-CAMS-PATT1_20230531_133321_260634", "image_threshold": null, "image_region_of_interest": null, "image_good_region": null, @@ -17,17 +17,17 @@ "project_axis": 0, "no_client_timeout": 0, "port": "9003", - "threshold": 1, + "threshold": 5, "roi_background": [ - 22, - 1036, - 3, - 2519 + 103, + 1153, + 72, + 1147 ], "roi_signal": [ - 22, - 1036, - 3, - 2519 + 103, + 1153, + 72, + 1147 ] } \ No newline at end of file diff --git a/configuration/pipeline_config/SATES21-CAMS154-M1_spec_db.json b/configuration/pipeline_config/SATES21-CAMS154-M1_spec_db.json index 865a0b4..c85c24a 100644 --- a/configuration/pipeline_config/SATES21-CAMS154-M1_spec_db.json +++ b/configuration/pipeline_config/SATES21-CAMS154-M1_spec_db.json @@ -1,6 +1,6 @@ { "image_background_enable": "passive", - "image_background": "SATES21-CAMS154-M1_20230502_141426_180792", + "image_background": "SATES21-CAMS154-M1_20230530_152447_004964", "image_threshold": null, "image_region_of_interest": null, "image_good_region": null, @@ -14,10 +14,29 @@ "thread_buffer_size": 30, "project_axis": 0, "roi_signal": [ - 20, - 200, - 500, - 1650 + 7, + 895, + 0, + 2523 ], - "threshold": 5 + "threshold": 5, + "roi_background": [ + "(", + "7", + ",", + " ", + "8", + "9", + "5", + ",", + " ", + "0", + ",", + " ", + "2", + "5", + "2", + "3", + ")" + ] } \ No newline at end of file diff --git a/configuration/pipeline_config/SATES24-CAMS161-M1_spec_db.json b/configuration/pipeline_config/SATES24-CAMS161-M1_spec_db.json index 017b5c2..b7f2828 100644 --- a/configuration/pipeline_config/SATES24-CAMS161-M1_spec_db.json +++ b/configuration/pipeline_config/SATES24-CAMS161-M1_spec_db.json @@ -1,6 +1,6 @@ { "image_background_enable": "passive", - "image_background": "SATES24-CAMS161-M1_20230504_140735_343566", + "image_background": "SATES24-CAMS161-M1_20230531_144316_923916", "image_threshold": null, "image_region_of_interest": null, "image_good_region": null, @@ -11,19 +11,19 @@ "name": "SATES24-CAMS161-M1_spec_db", "mode": "PUSH", "roi_signal": [ - 0, - 694, - 0, - 2317 + 11, + 782, + 15, + 2540 ], "processing_threads": 4, "thread_buffer_size": 30, "project_axis": 0, - "threshold": 0, + "threshold": 5, "roi_background": [ - 0, - 694, - 0, - 2317 + 11, + 782, + 15, + 2540 ] } \ No newline at end of file diff --git a/configuration/pipeline_config/SATES30-RIXS-CAM01_proc.json b/configuration/pipeline_config/SATES30-RIXS-CAM01_proc.json new file mode 100644 index 0000000..3078387 --- /dev/null +++ b/configuration/pipeline_config/SATES30-RIXS-CAM01_proc.json @@ -0,0 +1,17 @@ +{ + "image_background_enable": true, + "image_background": "SATES30-RIXS-CAM01_20230601_093318_381947", + "image_threshold": null, + "image_region_of_interest": null, + "image_good_region": null, + "image_slices": null, + "pipeline_type": "processing", + "camera_name": "SATES30-RIXS-CAM01", + "name": "SATES30-RIXS-CAM01_proc", + "function": "single_photon.c", + "mode": "PUSH", + "block": false, + "threshold": 10.0, + "_max_frame_rate": 5.1, + "reload": true +} \ No newline at end of file diff --git a/configuration/pipeline_config/SATES30-RIXS-CAM01_sp.json b/configuration/pipeline_config/SATES30-RIXS-CAM01_sp.json index a6d1852..654d6c7 100644 --- a/configuration/pipeline_config/SATES30-RIXS-CAM01_sp.json +++ b/configuration/pipeline_config/SATES30-RIXS-CAM01_sp.json @@ -7,5 +7,8 @@ "image_slices": null, "pipeline_type": "processing", "camera_name": "SATES30-RIXS-CAM01", - "name": "SATES30-RIXS-CAM01_sp" + "name": "SATES30-RIXS-CAM01_sp", + "max_frame_rate": 10.1, + "late_averaging": 10, + "function": "late_averaging.py" } \ No newline at end of file diff --git a/configuration/pipeline_config/SATES31-CAMS187-RIXS1_sp.json b/configuration/pipeline_config/SATES31-CAMS187-RIXS1_sp.json index b0f0556..a1ba643 100644 --- a/configuration/pipeline_config/SATES31-CAMS187-RIXS1_sp.json +++ b/configuration/pipeline_config/SATES31-CAMS187-RIXS1_sp.json @@ -8,5 +8,6 @@ "pipeline_type": "processing", "camera_name": "SATES31-CAMS187-RIXS1", "name": "SATES31-CAMS187-RIXS1_sp", - "max_frame_rate": 5.1 + "max_frame_rate": 5.1, + "reload": true } \ No newline at end of file diff --git a/configuration/pipeline_config/SATMA02_calib.json b/configuration/pipeline_config/SATMA02_calib.json new file mode 100644 index 0000000..8343dde --- /dev/null +++ b/configuration/pipeline_config/SATMA02_calib.json @@ -0,0 +1,21 @@ +{ + "pipeline_type": "stream", + "abort_on_timeout": false, + "_stream_timeout": 20, + "name": "SATMA02_calib", + "input_pipeline": "S10BD01-DSCR030_sp1", + "_input_pipeline": "SATBD02-DSCR050_sp1", + "bsread_address2": "", + "bsread_channels2": [ + "SATMA02-RLLE-DSP:PHASE-VS", + "SATBD02-DBPM040:X2" + ], + "include": [ + "x_center_of_mass", + "SATMA02-RLLE-DSP:PHASE-VS", + "SATBD02-DBPM040:X2" + ], + "mode": "PUSH", + "block": false, + "function": "propagate_stream" +} \ No newline at end of file diff --git a/configuration/pipeline_config/SLAAR02-LPMO01-C321_proc.json b/configuration/pipeline_config/SLAAR02-LPMO01-C321_proc.json index 41dbfd0..efb100e 100644 --- a/configuration/pipeline_config/SLAAR02-LPMO01-C321_proc.json +++ b/configuration/pipeline_config/SLAAR02-LPMO01-C321_proc.json @@ -11,5 +11,6 @@ "function": "pprm_simple.py", "mode": "PUSH", "debug": true, - "no_client_timeout": 0 + "no_client_timeout": 0, + "reload": true } \ No newline at end of file diff --git a/configuration/pipeline_config/SLAAR11-LCAM-C431_sp.json b/configuration/pipeline_config/SLAAR11-LCAM-C431_sp.json new file mode 100644 index 0000000..cf1b079 --- /dev/null +++ b/configuration/pipeline_config/SLAAR11-LCAM-C431_sp.json @@ -0,0 +1,12 @@ +{ + "image_background_enable": false, + "image_background": null, + "image_threshold": null, + "image_region_of_interest": null, + "image_good_region": null, + "image_slices": null, + "pipeline_type": "processing", + "camera_name": "SLAAR11-LCAM-C431", + "name": "SLAAR11-LCAM-C431_sp", + "max_frame_rate": 10.1 +} \ No newline at end of file diff --git a/configuration/pipeline_config/SLAAR21-LCAM-CT1C1_proc.json b/configuration/pipeline_config/SLAAR21-LCAM-CT1C1_proc.json new file mode 100644 index 0000000..328c971 --- /dev/null +++ b/configuration/pipeline_config/SLAAR21-LCAM-CT1C1_proc.json @@ -0,0 +1,14 @@ +{ + "image_background_enable": false, + "image_background": null, + "image_threshold": null, + "image_region_of_interest": null, + "image_good_region": null, + "image_slices": null, + "pipeline_type": "processing", + "camera_name": "SLAAR21-LCAM-CT1C1", + "name": "SLAAR21-LCAM-CT1C1_proc", + "function": "pprm_simple.py", + "mode": "PUSH", + "no_client_timeout": 0 +} \ No newline at end of file diff --git a/configuration/pipeline_config/camera_name_sp.json b/configuration/pipeline_config/SLAAR21-LCAM-CT1C1_sp.json similarity index 74% rename from configuration/pipeline_config/camera_name_sp.json rename to configuration/pipeline_config/SLAAR21-LCAM-CT1C1_sp.json index 8fdc3e1..3608c4d 100644 --- a/configuration/pipeline_config/camera_name_sp.json +++ b/configuration/pipeline_config/SLAAR21-LCAM-CT1C1_sp.json @@ -6,6 +6,6 @@ "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "camera_name": "camera_name", - "name": "camera_name_sp" + "camera_name": "SLAAR21-LCAM-CT1C1", + "name": "SLAAR21-LCAM-CT1C1_sp" } \ No newline at end of file diff --git a/configuration/pipeline_config/SLAAR21-LCAM-CT1C2_proc.json b/configuration/pipeline_config/SLAAR21-LCAM-CT1C2_proc.json new file mode 100644 index 0000000..1ef73af --- /dev/null +++ b/configuration/pipeline_config/SLAAR21-LCAM-CT1C2_proc.json @@ -0,0 +1,14 @@ +{ + "image_background_enable": false, + "image_background": null, + "image_threshold": null, + "image_region_of_interest": null, + "image_good_region": null, + "image_slices": null, + "pipeline_type": "processing", + "camera_name": "SLAAR21-LCAM-CT1C2", + "name": "SLAAR21-LCAM-CT1C2_proc", + "function": "pprm_simple.py", + "mode": "PUSH", + "no_client_timeout": 0 +} \ No newline at end of file diff --git a/configuration/pipeline_config/new_camera_name_sp.json b/configuration/pipeline_config/SLAAR21-LCAM-CT1C2_sp.json similarity index 74% rename from configuration/pipeline_config/new_camera_name_sp.json rename to configuration/pipeline_config/SLAAR21-LCAM-CT1C2_sp.json index d5255a0..342b680 100644 --- a/configuration/pipeline_config/new_camera_name_sp.json +++ b/configuration/pipeline_config/SLAAR21-LCAM-CT1C2_sp.json @@ -6,6 +6,6 @@ "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "camera_name": "new_camera_name", - "name": "new_camera_name_sp" + "camera_name": "SLAAR21-LCAM-CT1C2", + "name": "SLAAR21-LCAM-CT1C2_sp" } \ No newline at end of file diff --git a/configuration/pipeline_config/name:_sp.json b/configuration/pipeline_config/_sp.json similarity index 82% rename from configuration/pipeline_config/name:_sp.json rename to configuration/pipeline_config/_sp.json index 37bbb0e..a1824f5 100644 --- a/configuration/pipeline_config/name:_sp.json +++ b/configuration/pipeline_config/_sp.json @@ -6,6 +6,6 @@ "image_good_region": null, "image_slices": null, "pipeline_type": "processing", - "camera_name": "name:", - "name": "name:_sp" + "camera_name": "", + "name": "_sp" } \ No newline at end of file diff --git a/configuration/pipeline_config/example_sp.json b/configuration/pipeline_config/example_sp.json deleted file mode 100644 index 4115fc1..0000000 --- a/configuration/pipeline_config/example_sp.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "image_background_enable": false, - "image_background": null, - "image_threshold": null, - "image_region_of_interest": null, - "image_good_region": null, - "image_slices": null, - "camera_name": "example", - "name": "example_sp" -} \ No newline at end of file diff --git a/configuration/pipeline_config/permanent_instances.json b/configuration/pipeline_config/permanent_instances.json index 97f7e38..6dc4b42 100644 --- a/configuration/pipeline_config/permanent_instances.json +++ b/configuration/pipeline_config/permanent_instances.json @@ -8,13 +8,15 @@ "#SAROP11-ATT01_proc": "SAROP11-ATT01_proc", "#SAROP21-PPRM102_proc": "SAROP21-PPRM102_proc", "#SAROP31-PPRM113_proc": "SAROP31-PPRM113_proc", + "#SATES30-RIXS-CAM01_sp1": "SATES30-RIXS-CAM01_sp", + "#SATES31-CAMS187-RIXS1_sp1": "SATES31-CAMS187-RIXS1_sp", + "#SATMA02_calib": "SATMA02_calib", "#SINBC02-DSRM310_profiles": "SINBC02-DSRM310_profiles", "#jungfrau_proc": "jungfrau_proc", "#test_merge": "test_merge", "#test_proc_with_bs": "test_proc_with_bs", "#test_str": "test_str", "#test_stream": "test_stream", - "#test_tadej": "test_tadej", "#testdb_ib": "testdb_ib", "S10BD01-DSCR030_profiles": "S10BD01-DSCR030_profiles", "SARCL01-DSCR170_profiles": "SARCL01-DSCR170_profiles", @@ -48,6 +50,7 @@ "SATES24-CAMS161-M1_spec_db": "SATES24-CAMS161-M1_spec_db", "SATES30-CAMS182-GIGE1_profiles": "SATES30-CAMS182-GIGE1_profiles", "SATES30-CAMS182-GIGE2_profiles": "SATES30-CAMS182-GIGE2_profiles", + "SATES30-RIXS-CAM01_proc": "SATES30-RIXS-CAM01_proc", "SATES31-CAMS187-RIXS1_proc": "SATES31-CAMS187-RIXS1_proc", "SATOP21-PMOS127-2D_pmos": "SATOP21-PMOS127-2D_pmos", "SATOP31-PMOS132-2D_pmos": "SATOP31-PMOS132-2D_pmos", @@ -60,5 +63,9 @@ "SLAAR21-LCAM-CS842_proc": "SLAAR21-LCAM-CS842_proc", "SLAAR21-LCAM-CS843_proc": "SLAAR21-LCAM-CS843_proc", "SLAAR21-LCAM-CS844_proc": "SLAAR21-LCAM-CS844_proc", - "test_furka": "test_furka" + "SLAAR21-LCAM-CT1C1_proc": "SLAAR21-LCAM-CT1C1_proc", + "SLAAR21-LCAM-CT1C2_proc": "SLAAR21-LCAM-CT1C2_proc", + "simulation_sp1": "simulation_sp", + "test_furka": "test_furka", + "test_tadej": "test_tadej" } \ No newline at end of file diff --git a/configuration/pipeline_config/servers.json b/configuration/pipeline_config/servers.json index d24a643..19a09c9 100644 --- a/configuration/pipeline_config/servers.json +++ b/configuration/pipeline_config/servers.json @@ -63,6 +63,7 @@ "simulation_2_sp", "simulation2_sp", "test_alain_100Hz:9010", + "SATMA02_calib", "test_str:9000", "simulation_proc", "test_merge:9001", @@ -170,7 +171,8 @@ "#SARES12-CAMS128-M1_psen_ib:9002", "#SARES12-CAMS128-M1_psen_db:9003", "SARES12-XPR128-C4F1_ib:9004", - "SARES11-XMI125-C4P1_ib:9005" + "SARES11-XMI125-C4P1_ib:9005", + "SARES11-XMI125-C4P1_db:9011" ] }, "http://sf-daqsync-14.psi.ch:8881": { @@ -192,7 +194,9 @@ "SLAAR21-LCAM-CS843", "SLAAR21-LCAM-CS844", "SLAAR02-LPMO02-C321", - "SLAAR02-LPMO02-C322" + "SLAAR02-LPMO02-C322", + "SLAAR21-LCAM-CT1C1", + "SLAAR21-LCAM-CT1C2" ], "enabled": true, "expanding": false, @@ -228,6 +232,8 @@ "SLAAR02-LPMO02-C322_proc:9026", "SLAAR21-LCAM-C561_proc:9027", "SLAAR21-LCAM-C562_proc:9028", + "SLAAR21-LCAM-CT1C1_proc:9033", + "SLAAR21-LCAM-CT1C2_proc:9035", "#arrival_time_proc:9008", "test_arrival" ] @@ -246,6 +252,7 @@ "SATES31-CAMS187-RIXS1_proc:9000", "SATES31-CAMS187-RIXS1_ib:9001", "SATES30-RIXS-CAM01_sp", + "SATES30-RIXS-CAM01_proc:9006", "SATES30-CAMS182-GIGE1_sp", "SATES30-CAMS182-GIGE2_sp", "SATES30-CAMS182-GIGE1_profiles:9002", diff --git a/configuration/pipeline_config/sf-daqsync-01:8889_sp.json b/configuration/pipeline_config/sf-daqsync-01:8889_sp.json deleted file mode 100644 index e51203f..0000000 --- a/configuration/pipeline_config/sf-daqsync-01:8889_sp.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "camera_calibration": null, - "image_background_enable": false, - "image_background": null, - "image_threshold": null, - "image_region_of_interest": null, - "image_good_region": null, - "image_slices": null, - "camera_name": "sf-daqsync-01:8889", - "name": "sf-daqsync-01:8889_sp" -} \ No newline at end of file diff --git a/configuration/pipeline_config/simulation_sp.json b/configuration/pipeline_config/simulation_sp.json index 2aed331..3de278d 100644 --- a/configuration/pipeline_config/simulation_sp.json +++ b/configuration/pipeline_config/simulation_sp.json @@ -1,11 +1,22 @@ { "image_background_enable": false, "image_background": null, - "image_threshold": null, - "image_region_of_interest": null, - "image_good_region": null, + "image_threshold": 7000.0, + "image_region_of_interest": [ + 462, + 344, + 390, + 159 + ], + "image_good_region": { + "threshold": 0.1, + "gfscale": 3.0 + }, "image_slices": null, "pipeline_type": "processing", "camera_name": "simulation", - "name": "simulation_sp" + "name": "simulation_sp", + "reload": true, + "function": "beam_full_width", + "fw_threshold": 0.3 } \ No newline at end of file diff --git a/configuration/pipeline_config/test_furka.json b/configuration/pipeline_config/test_furka.json index 6540d82..1be9454 100644 --- a/configuration/pipeline_config/test_furka.json +++ b/configuration/pipeline_config/test_furka.json @@ -11,5 +11,8 @@ "_function": "furka.py", "function": "single_photon.c", "mode": "PUB", - "reload": true + "reload": true, + "include": [ + "simulation:EVENT_NUM" + ] } \ No newline at end of file diff --git a/configuration/user_scripts/SARES11-SPEC125-M1_2tt.py b/configuration/user_scripts/SARES11-SPEC125-M1_2tt.py new file mode 100644 index 0000000..755ac2d --- /dev/null +++ b/configuration/user_scripts/SARES11-SPEC125-M1_2tt.py @@ -0,0 +1,154 @@ +import sys +import json + +from logging import getLogger +from scipy.interpolate import interp1d +from scipy import signal +from scipy.ndimage import gaussian_filter1d +from scipy.ndimage import convolve1d +import numpy as np + +_logger = getLogger(__name__) + +# Alvra spectral encoder constants/waveforms +px2fs = 2.1 # calibration from ... +#lambdas = 528.34 + 0.0261*np.arange(0,2048) # calibration from 2021-10-06 +lambdas = np.linspace(504.17385, 608.07410, num=2048) # calibration from 2023-04-25 +#lambdas = np.linspace(510.57796, 628.63459, num=2048) # calibration from 2022-05-18 +nus = 299792458 / (lambdas * 10**-9) # frequency space, uneven +nus_new = np.linspace(nus[0], nus[-1], num=2048, endpoint=True) # frequency space, even +filters = { + "YAG": np.concatenate((np.ones(20),signal.tukey(40)[20:40], np.zeros(2008), np.zeros(2048))), # back timetool YAG + "SiN5": np.concatenate((signal.tukey(40)[25:40], np.zeros(2033), np.zeros(2048))), # back timetool SiN + "SiN2": np.concatenate((np.ones(5), signal.tukey(12)[9:11], signal.tukey(12)[0:4], np.ones(5), signal.tukey(40)[25:40], np.zeros(2017), np.zeros(2048))) # back timetool SiN +} + +# Functions for image analysis and spectral encoding processing +def get_roi_projection(image, roi, axis): + x_start, x_stop, y_start, y_stop = roi + cropped = image[y_start:y_stop, x_start:x_stop] + project = cropped.sum(axis=axis) + return project.astype("int64") + + +def interpolate(xold, xnew, vals): + """ + Interpolate vals from xold to xnew + """ + interp = interp1d(xold, vals, kind='cubic') + return interp(xnew) + + +def fourier_filter(vals, filt): + """ + Fourier transform, filter, inverse fourier transform, take the real part + """ + vals = np.hstack((vals, np.zeros_like(vals))) # pad + transformed = np.fft.fft(vals) + filtered = transformed * filt + inverse = np.fft.ifft(filtered) + invreal = 2 * np.real(inverse) + return invreal + + +def edge(filter_name, backgrounds, signals, peakback): + """ + returns: + edge positions determined from argmax of peak traces, converted to fs + edge amplitudes determined from the amax of the peak traces + the actual peak traces, which are the derivative of signal traces (below) + the raw signal traces, without any processing or smoothing except for the Fourier filter applied to remove the etalon + """ + ffilter = filters[filter_name] + + # background normalization + sig_norm = (signals / backgrounds) - 1 + # interpolate to get evenly sampled in frequency space + sig_interp = interpolate(nus, nus_new, sig_norm) + # Fourier filter + #sig_filtered = fourier_filter(sig_interp, ffilter) + sig_filtered = sig_interp + # interpolate to get unevenly sampled in frequency space (back to original wavelength space) + sig_uninterp = interpolate(nus_new, nus, sig_filtered[..., 0:2048]) + 1 + # peak via the derivative + sig_deriv = 20000 * gaussian_filter1d(sig_uninterp, 50, order=1) + sig_deriv -= peakback + peak_pos = 1024 - (np.argmax(sig_deriv[500:1500], axis=-1) + 500) + peak_pos *= px2fs + peak_amp = np.amax(sig_deriv[500:1500], axis=-1) + + return peak_pos, peak_amp, sig_deriv, sig_uninterp + + +def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None): + try: + """ + takes an image, processes the signal, sends out the raw data and processed results + """ + image = image.astype(int) + camera_name = parameters["camera_name"] + background = parameters.get("background_data") + background = background.astype(int) + background_name = parameters.get("image_background") + background_mode = parameters.get("image_background_enable") + roi_signal = parameters.get("roi_signal") + roi_signal2 = parameters.get("roi_signal2") + project_axis = parameters.get("project_axis", 0) +# events = bsdata["SAR-CVME-TIFALL4:EvtSet"] +# laser_off = int(events[21]) +# laser_on = int(events[18]) +# fel_on = int(events[13]) + + # maintain the structure of processing_parameters + background_shape = None + + # maintain the structure of res + projection_signal = projection_background = None + + try: + + if roi_signal is not None: + projection_background = get_roi_projection(background, roi_signal, project_axis) + projection_background2 = get_roi_projection(background, roi_signal2, project_axis) + projection_signal = get_roi_projection(image, roi_signal, project_axis) + projection_signal2 = get_roi_projection(image, roi_signal2, project_axis) + peak_pos, peak_amp, sig_deriv, sig_uninterp = edge("YAG", projection_background, projection_signal, 0) + peak_pos2, peak_amp2, sig_deriv2, sig_uninterp2 = edge("YAG", projection_background2, projection_signal2, 0) + + except Exception as e: + lineno = sys.exc_info()[2].tb_lineno + tn = type(e).__name__ + status = f"Error in line number {lineno}: {tn}: {e}" + raise e + else: + status = "OK" + + processing_parameters = { + "status": status, + "background_name": background_name, + "roi_signal": roi_signal, + } + + processing_parameters = json.dumps(processing_parameters) + + res = { + camera_name + ".processing_parameters": processing_parameters, + camera_name + ".projection_signal": projection_signal, + camera_name + ".projection_background": projection_background, + camera_name + ".edge_position": peak_pos, + camera_name + ".edge_amplitude": peak_amp, + camera_name + ".edge_derivative": sig_deriv, + camera_name + ".edge_raw": sig_uninterp, + camera_name + ".projection_signal2": projection_signal2, + camera_name + ".projection_background2": projection_background2, + camera_name + ".edge_position2": peak_pos2, + camera_name + ".edge_amplitude2": peak_amp2, + camera_name + ".edge_derivative2": sig_deriv2, + camera_name + ".edge_raw2": sig_uninterp2 + + } + return res + + except: + _logger.exception("Error in processing function") + raise \ No newline at end of file diff --git a/configuration/user_scripts/SARES11-SPEC125-M1_tt.py b/configuration/user_scripts/SARES11-SPEC125-M1_tt.py index fd38995..f635a38 100644 --- a/configuration/user_scripts/SARES11-SPEC125-M1_tt.py +++ b/configuration/user_scripts/SARES11-SPEC125-M1_tt.py @@ -11,7 +11,7 @@ import numpy as np _logger = getLogger(__name__) # Alvra spectral encoder constants/waveforms -px2fs = 1.91 # calibration from ... +px2fs = 2.1 # calibration from ... #lambdas = 528.34 + 0.0261*np.arange(0,2048) # calibration from 2021-10-06 lambdas = np.linspace(504.17385, 608.07410, num=2048) # calibration from 2023-04-25 #lambdas = np.linspace(510.57796, 628.63459, num=2048) # calibration from 2022-05-18 @@ -19,7 +19,8 @@ nus = 299792458 / (lambdas * 10**-9) # frequency space, uneven nus_new = np.linspace(nus[0], nus[-1], num=2048, endpoint=True) # frequency space, even filters = { "YAG": np.concatenate((np.ones(20),signal.tukey(40)[20:40], np.zeros(2008), np.zeros(2048))), # back timetool YAG - "SiN": np.concatenate((signal.tukey(40)[25:40], np.zeros(2033), np.zeros(2048))) # back timetool SiN + "SiN5": np.concatenate((signal.tukey(40)[25:40], np.zeros(2033), np.zeros(2048))), # back timetool SiN + "SiN2": np.concatenate((np.ones(5), signal.tukey(12)[9:11], signal.tukey(12)[0:4], np.ones(5), signal.tukey(40)[25:40], np.zeros(2017), np.zeros(2048))) # back timetool SiN } # Functions for image analysis and spectral encoding processing @@ -65,7 +66,8 @@ def edge(filter_name, backgrounds, signals, peakback): # interpolate to get evenly sampled in frequency space sig_interp = interpolate(nus, nus_new, sig_norm) # Fourier filter - sig_filtered = fourier_filter(sig_interp, ffilter) + #sig_filtered = fourier_filter(sig_interp, ffilter) + sig_filtered = sig_interp # interpolate to get unevenly sampled in frequency space (back to original wavelength space) sig_uninterp = interpolate(nus_new, nus, sig_filtered[..., 0:2048]) + 1 # peak via the derivative diff --git a/configuration/user_scripts/SARES11-SPEC125-M1_tt_events.py b/configuration/user_scripts/SARES11-SPEC125-M1_tt_events.py new file mode 100644 index 0000000..6145582 --- /dev/null +++ b/configuration/user_scripts/SARES11-SPEC125-M1_tt_events.py @@ -0,0 +1,142 @@ +import sys +import json + +from logging import getLogger +from scipy.interpolate import interp1d +from scipy import signal +from scipy.ndimage import gaussian_filter1d +from scipy.ndimage import convolve1d +import numpy as np + +_logger = getLogger(__name__) + +# Alvra spectral encoder constants/waveforms +px2fs = 2.1 # calibration from ... +#lambdas = 528.34 + 0.0261*np.arange(0,2048) # calibration from 2021-10-06 +lambdas = np.linspace(504.17385, 608.07410, num=2048) # calibration from 2023-04-25 +#lambdas = np.linspace(510.57796, 628.63459, num=2048) # calibration from 2022-05-18 +nus = 299792458 / (lambdas * 10**-9) # frequency space, uneven +nus_new = np.linspace(nus[0], nus[-1], num=2048, endpoint=True) # frequency space, even +filters = { + "YAG": np.concatenate((np.ones(20),signal.tukey(40)[20:40], np.zeros(2008), np.zeros(2048))), # back timetool YAG + "SiN": np.concatenate((signal.tukey(40)[25:40], np.zeros(2033), np.zeros(2048))) # back timetool SiN +} + +# Functions for image analysis and spectral encoding processing +def get_roi_projection(image, roi, axis): + x_start, x_stop, y_start, y_stop = roi + cropped = image[y_start:y_stop, x_start:x_stop] + project = cropped.sum(axis=axis) + return project.astype("int64") + + +def interpolate(xold, xnew, vals): + """ + Interpolate vals from xold to xnew + """ + interp = interp1d(xold, vals, kind='cubic') + return interp(xnew) + + +def fourier_filter(vals, filt): + """ + Fourier transform, filter, inverse fourier transform, take the real part + """ + vals = np.hstack((vals, np.zeros_like(vals))) # pad + transformed = np.fft.fft(vals) + filtered = transformed * filt + inverse = np.fft.ifft(filtered) + invreal = 2 * np.real(inverse) + return invreal + + +def edge(filter_name, backgrounds, signals, peakback): + """ + returns: + edge positions determined from argmax of peak traces, converted to fs + edge amplitudes determined from the amax of the peak traces + the actual peak traces, which are the derivative of signal traces (below) + the raw signal traces, without any processing or smoothing except for the Fourier filter applied to remove the etalon + """ + ffilter = filters[filter_name] + + # background normalization + sig_norm = (signals / backgrounds) - 1 + # interpolate to get evenly sampled in frequency space + sig_interp = interpolate(nus, nus_new, sig_norm) + # Fourier filter + sig_filtered = fourier_filter(sig_interp, ffilter) + # interpolate to get unevenly sampled in frequency space (back to original wavelength space) + sig_uninterp = interpolate(nus_new, nus, sig_filtered[..., 0:2048]) + 1 + # peak via the derivative + sig_deriv = 20000 * gaussian_filter1d(sig_uninterp, 50, order=1) + sig_deriv -= peakback + peak_pos = 1024 - (np.argmax(sig_deriv[500:1500], axis=-1) + 500) + peak_pos *= px2fs + peak_amp = np.amax(sig_deriv[500:1500], axis=-1) + + return peak_pos, peak_amp, sig_deriv, sig_uninterp + + +def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None): + try: + """ + takes an image, processes the signal, sends out the raw data and processed results + """ + image = image.astype(int) + camera_name = parameters["camera_name"] + background = parameters.get("background_data") + background = background.astype(int) + background_name = parameters.get("image_background") + background_mode = parameters.get("image_background_enable") + roi_signal = parameters.get("roi_signal") + project_axis = parameters.get("project_axis", 0) +# events = bsdata["SAR-CVME-TIFALL4:EvtSet"] +# laser_off = int(events[21]) +# laser_on = int(events[18]) +# fel_on = int(events[13]) + + # maintain the structure of processing_parameters + background_shape = None + + # maintain the structure of res + projection_signal = projection_background = None + + try: + + if roi_signal is not None: + projection_background = get_roi_projection(background, roi_signal, project_axis) + projection_signal = get_roi_projection(image, roi_signal, project_axis) + peak_pos, peak_amp, sig_deriv, sig_uninterp = edge("SiN", projection_background, projection_signal, 0) + + except Exception as e: + lineno = sys.exc_info()[2].tb_lineno + tn = type(e).__name__ + status = f"Error in line number {lineno}: {tn}: {e}" + raise e + else: + status = "OK" + + processing_parameters = { + "status": status, + "background_name": background_name, + "roi_signal": roi_signal, + } + + processing_parameters = json.dumps(processing_parameters) + + res = { + camera_name + ".processing_parameters": processing_parameters, + camera_name + ".projection_signal": projection_signal, + camera_name + ".projection_background": projection_background, + camera_name + ".edge_position": peak_pos, + camera_name + ".edge_amplitude": peak_amp, + camera_name + ".edge_derivative": sig_deriv, + camera_name + ".edge_raw": sig_uninterp + } + return res + + except: + _logger.exception("Error in processing function") + raise + \ No newline at end of file diff --git a/configuration/user_scripts/SAROP21-ATT01_Test_proc.py b/configuration/user_scripts/SAROP21-ATT01_Test_proc.py index 59f5590..83a93bd 100644 --- a/configuration/user_scripts/SAROP21-ATT01_Test_proc.py +++ b/configuration/user_scripts/SAROP21-ATT01_Test_proc.py @@ -127,6 +127,18 @@ def process(data, pulse_id, timestamp, params): except: edge_results["arrival_time_odd"] = calib + try: + #_logger.warning("Shape: " + str(edge_results["signal"].shape)) + edge_results["signal"] = edge_results["signal"].reshape((edge_results["signal"].shape[1],)) + except: + #_logger.warning("Shape err" + str(edge_results["signal"])) + pass + try: + #_logger.warning("Shape: " + str(edge_results["signal"].shape)) + edge_results["xcorr"] = edge_results["xcorr"].reshape((edge_results["xcorr"].shape[1],)) + except: + #_logger.warning("Shape err" + str(edge_results["signal"])) + pass # push pulse ID for debuging edge_results["pulse_id"] = pulse_id @@ -139,16 +151,7 @@ def process(data, pulse_id, timestamp, params): # output[f"{device}:arrival_time_even"] = None # Set bs outputs #log = "" - for key, value in edge_results.items(): - if isinstance(value,np.floating): - value=float(value) - if isinstance(value,np.integer): - value=int(value) - if type(value) == list: - value = np.array(value) - #if isinstance(value,np.ndarray): - # log = log + " | " + str(key) + " - " + str(value.dtype) + " - " + str(value.shape) - #log = log + " | " + str(key) + " - " + str(type(value)) + for key, value in edge_results.items(): output[f"{device}:{key}"] = value #_logger.info(log) diff --git a/configuration/user_scripts/late_averaging.py b/configuration/user_scripts/late_averaging.py new file mode 100644 index 0000000..1996f85 --- /dev/null +++ b/configuration/user_scripts/late_averaging.py @@ -0,0 +1,27 @@ +import numpy +from cam_server.pipeline.data_processing import functions, processor +from logging import getLogger + +_logger = getLogger(__name__) +image_buffer = [] + +def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None): + global image_buffer + averaging = parameters.get("late_averaging") + if averaging: + while len(image_buffer) >= averaging: + image_buffer.pop(0) + image_buffer.append(image) + try: + frames = numpy.array(image_buffer) + image = numpy.average(frames, 0) + #_logger.info("Averaged: %d" % len(image_buffer)) + except: + # Different shapes + image_buffer = [] + return None + else: + image_buffer = [] + + ret = processor.process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata) + return ret diff --git a/configuration/user_scripts/single_photon.c b/configuration/user_scripts/single_photon.c index 29c3a3f..0bfce4d 100644 --- a/configuration/user_scripts/single_photon.c +++ b/configuration/user_scripts/single_photon.c @@ -9,18 +9,21 @@ const char *CHANNEL_NAMES[] = {"EVENT_NUM", "EVENT_I", "EVENT_J", "EVENT_CHARGE", "EVENT_ETA_X", "EVENT_ETA_Y", "EVENT_I_INTERP", "EVENT_J_INTERP"}; -const int MAX_NUM_EVENTS= 1000; // max number of events per frame -const int EVENT_CHANNELS = 7; +// max number of events per frame +#define MAX_NUM_EVENTS 100 +#define EVENT_CHANNELS 7 + +double evt_p[EVENT_CHANNELS][MAX_NUM_EVENTS]; -struct events_double func_ph_1d_double( double *frame, int i_dim, int j_dim, double *th_m); -//struct decl. -struct events_double { - double **evnt_ijc; - int evnt_num; -}; +int func_ph_1d_double( double *frame, int i_dim, int j_dim, double *th_m); +void setArrayToValue(double array[], int size, double value) { + for (int i = 0; i < size; i++) { + array[i] = value; + } +} //def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None): PyObject *process(PyObject *self, PyObject *args) @@ -54,19 +57,28 @@ PyObject *process(PyObject *self, PyObject *args) int i,j,l; int i_dim=size_y; - int j_dim=size_x; + int j_dim=size_x; + PyObject* threshold_obj = PyDict_GetItemString(pars, "threshold"); + double threshold_val = 60000.0; + if (threshold_obj!=NULL){ + if (PyFloat_Check(threshold_obj)) { + threshold_val = PyFloat_AsDouble(threshold_obj); + } else if (PyLong_Check(threshold_obj)) { + threshold_val = PyLong_AsDouble(threshold_obj); + } + } double *threshold = malloc(i_dim*j_dim*sizeof(double)); for(i=0; i=MAX_NUM_EVENTS){ break; } @@ -206,9 +219,6 @@ PyObject *process(PyObject *self, PyObject *args) } } } - struct events_double events_i_d; - events_i_d.evnt_ijc = evt_p; - events_i_d.evnt_num = evt_i; - return events_i_d; + return evt_i; }