diff --git a/pxii_bec/daily_setup_files/Ge_edge_derivative.png b/pxii_bec/daily_setup_files/Ge_edge_derivative.png new file mode 100644 index 0000000..c464d33 Binary files /dev/null and b/pxii_bec/daily_setup_files/Ge_edge_derivative.png differ diff --git a/pxii_bec/daily_setup_files/Ge_edge_signal.png b/pxii_bec/daily_setup_files/Ge_edge_signal.png new file mode 100644 index 0000000..bb60d50 Binary files /dev/null and b/pxii_bec/daily_setup_files/Ge_edge_signal.png differ diff --git a/pxii_bec/daily_setup_files/daily_beam.png b/pxii_bec/daily_setup_files/daily_beam.png new file mode 100644 index 0000000..5dc6f7a Binary files /dev/null and b/pxii_bec/daily_setup_files/daily_beam.png differ diff --git a/pxii_bec/daily_setup_files/daily_beam_12400eV.png b/pxii_bec/daily_setup_files/daily_beam_12400eV.png new file mode 100644 index 0000000..c65417c Binary files /dev/null and b/pxii_bec/daily_setup_files/daily_beam_12400eV.png differ diff --git a/pxii_bec/daily_setup_files/daily_beam_13000eV.png b/pxii_bec/daily_setup_files/daily_beam_13000eV.png new file mode 100644 index 0000000..028edd4 Binary files /dev/null and b/pxii_bec/daily_setup_files/daily_beam_13000eV.png differ diff --git a/pxii_bec/daily_setup_files/daily_beamline_health.csv b/pxii_bec/daily_setup_files/daily_beamline_health.csv new file mode 100644 index 0000000..48cb3d5 --- /dev/null +++ b/pxii_bec/daily_setup_files/daily_beamline_health.csv @@ -0,0 +1,3 @@ +timestamp,energy_eV,pitch_offset,flux_ph_s,beam_start_x_px,beam_start_y_px,vfm_mot_start_mm,hfm_mot_start_mm,vfm_mot_final_mm,hfm_mot_final_mm,beam_final_x_um,beam_final_y_um,beam_final_x_bpm_um,beam_final_y_bpm_um,vfm_y_mm,vfm_mot_mm,vfm_pitch_mrad,hfm_x_mm,hfm_mot_mm,hfm_pitch_mrad +2026-10-28T20:39:08,12400,-0.001,8.56e+12,995,938,-0.84008,1.90791,-0.84092,1.90791,-0.5,-0.5,-13.68,5.24,-1.55210,-0.84092,2.99273,1.40495,1.90791,3.01181 +2026-11-01T15:45:54,12400,-0.004,8.65e+12,997,964,-0.84439,1.90556,-0.84440,1.90556,-0.3,0.7,-18.02,6.07,-1.55296,-0.84439,2.98573,1.40357,1.90554,3.00788 diff --git a/pxii_bec/daily_setup_files/daily_beamline_health_archive_20261028_203908.csv b/pxii_bec/daily_setup_files/daily_beamline_health_archive_20261028_203908.csv new file mode 100644 index 0000000..97802c9 --- /dev/null +++ b/pxii_bec/daily_setup_files/daily_beamline_health_archive_20261028_203908.csv @@ -0,0 +1,48 @@ +timestamp,energy_eV,pitch_offset,flux_ph_s,beam_start_x_px,beam_start_y_px,vfm_mot_start_mm,hfm_mot_start_mm,vfm_mot_final_mm,hfm_mot_final_mm,beam_final_x_um,beam_final_y_um,vfm_y_mm,vfm_mot_mm,vfm_pitch_mrad,hfm_x_mm,hfm_mot_mm,hfm_pitch_mrad +2026-09-24T19:44:41,12400,-0,8.94e+12,,,,,,,,,-1.55391,-0.84548,2.98923,1.41258,1.91366,3.00429 +2026-09-24T19:46:16,12400,-0,9.04e+12,990,964,-0.84547,1.91368,-0.84547,1.91367,0.8,0.7,-1.55390,-0.84547,2.98920,1.41259,1.91367,3.00434 +2026-09-24T19:49:29,12400,-0,9.03e+12,989,963,-0.84547,1.91369,-0.84547,1.91367,0.9,0.8,-1.55391,-0.84547,2.98919,1.41259,1.91367,3.00428 +2026-09-24T19:55:21,12400,-0.043,9.00e+12,988,963,-0.84548,1.91368,-0.84547,1.91369,0.9,0.7,-1.55390,-0.84547,2.98916,1.41262,1.91369,3.00430 +2026-09-25T09:22:48,12400,-0.044,8.92e+12,985,968,-0.84545,1.91365,-0.84545,1.91313,-0.2,-0.2,-1.55388,-0.84545,2.98922,1.41232,1.91313,3.00317 +2026-09-25T18:00:09,12400,-0.044,8.87e+12,,,,,,,,,-1.55392,-0.84549,2.98917,1.41232,1.91311,3.00317 +2026-09-25T18:34:58,12400,-0.044,9.00e+12,995,966,-0.84547,1.91311,-0.84548,1.91313,-0.1,0.5,-1.55392,-0.84548,2.98918,1.41234,1.91313,3.00317 +2026-09-25T18:37:18,,,7.46e+10,,,,,,,,,-1.55392,-0.84548,2.98922,1.41231,1.91312,3.00324 +2026-09-25T18:41:25,12400,-0.044,9.04e+12,996,966,-0.84548,1.91312,-0.84549,1.91312,-0.5,0.5,-1.55392,-0.84549,2.98916,1.41232,1.91312,3.00319 +2026-09-25T18:43:08,12400,-0.044,9.03e+12,996,966,-0.84548,1.91314,-0.84548,1.91312,-0.3,0.4,-1.55392,-0.84548,2.98922,1.41230,1.91312,3.00322 +2026-09-25T18:50:59,8000,-0.044,1.11e+11,,,,,,,,,-1.55393,-0.84549,2.98919,1.41232,1.91311,3.00317 +2026-09-25T18:57:10,9000,-0.042,5.24e+12,989,969,-0.84548,1.91313,-0.84547,1.91313,0.4,-0.0,-1.55392,-0.84547,2.98918,1.41234,1.91313,3.00320 +2026-09-27T09:28:10,12400,-0.046,7.58e+12,1031,992,-0.84553,1.91317,-0.84491,1.91518,-0.1,-0.2,-1.55378,-0.84491,2.99041,1.41337,1.91518,3.00725 +2026-09-27T11:37:30,12400,-0.046,8.39e+12,967,948,-0.84493,1.91519,-0.84550,1.91390,0.1,-0.4,-1.55393,-0.84550,2.98926,1.41273,1.91390,3.00472 +2026-09-27T11:40:57,12400,-0.046,7.45e+12,997,974,-0.84551,1.91389,-0.84551,1.91392,-0.4,-0.8,-1.55393,-0.84551,2.98919,1.41274,1.91392,3.00471 +2026-09-27T11:44:01,12400,-0.046,7.47e+12,997,973,-0.84550,1.91389,-0.84551,1.91388,-0.6,-0.7,-1.55393,-0.84551,2.98917,1.41271,1.91388,3.00467 +2026-09-27T14:14:31,12400,-0.045,8.48e+12,1007,983,-0.84553,1.91388,-0.84515,1.91466,0.3,0.3,-1.55387,-0.84515,2.98994,1.41311,1.91466,3.00618 +2026-09-27T14:17:44,8000,-0.044,1.48e+13,979,974,-0.84515,1.91467,-0.84516,1.91388,-0.5,-0.5,-1.55387,-0.84516,2.98990,1.41272,1.91388,3.00465 +2026-09-27T14:25:24,,,4.07e+12,1003,983,-0.84516,1.91389,-0.84479,1.91449,0.3,0.1,-1.55378,-0.84479,2.99070,1.41301,1.91449,3.00589 +2026-09-27T14:26:46,,,1.46e+13,982,957,-0.84478,1.91442,-0.84512,1.91389,-0.4,-0.2,-1.55386,-0.84512,2.99006,1.41272,1.91389,3.00467 +2026-09-27T14:33:15,20000,-0.041,1.16e+12,991,962,-0.84512,1.91388,-0.84511,1.91387,0.3,1.1,-1.55387,-0.84511,2.99002,1.41273,1.91389,3.00466 +2026-09-27T14:34:21,20000,-0.041,1.17e+12,992,963,-0.84513,1.91389,-0.84510,1.91390,0.4,0.8,-1.55386,-0.84510,2.99006,1.41272,1.91390,3.00467 +2026-09-27T14:37:06,,,-6.15e+08,,,,,,,,,-1.55385,-0.84510,2.99004,1.41272,1.91389,3.00466 +2026-09-27T14:40:52,6000,-0.045,7.94e+12,993,976,-0.84512,1.91389,-0.84511,1.91387,-0.1,-1.0,-1.55386,-0.84511,2.99004,1.41271,1.91387,3.00462 +2026-09-27T14:49:28,12400,-0.042,8.07e+12,1001,969,-0.84511,1.91389,-0.84510,1.91437,0.3,-0.1,-1.55386,-0.84510,2.99002,1.41297,1.91437,3.00562 +2026-10-08T20:09:41,12400,-0.124,3.29e+12,,,,,,,,,,,-1.55140,-0.84004,2.99086,1.40837,1.90528,2.98761 +2026-10-08T21:06:10,12400,-0.124,7.40e+12,1114,976,-0.84003,1.90525,-0.83984,1.91103,-0.5,-0.0,28.93,-2.45,-1.55132,-0.83983,2.99124,1.41125,1.91103,2.99912 +2026-10-08T21:19:29,12400,-0.124,8.22e+12,1001,976,-0.83984,1.91103,-0.83984,1.91128,-0.6,-0.9,29.01,-2.59,-1.55132,-0.83985,2.99119,1.41139,1.91131,2.99972 +2026-10-08T21:22:48,12400,-0.124,8.21e+12,1000,978,-0.83984,1.91130,-0.83958,1.91130,-0.7,0.1,28.61,-2.35,-1.55126,-0.83960,2.99173,1.41139,1.91130,2.99966 +2026-10-08T21:25:37,12400,-0.124,8.26e+12,1001,966,-0.83961,1.91130,-0.83960,1.91166,-0.1,0.2,28.57,-2.22,-1.55126,-0.83960,2.99174,1.41155,1.91162,3.00031 +2026-10-08T21:29:25,12400,-0.124,8.28e+12,996,968,-0.83961,1.91164,-0.83961,1.91162,-0.5,0.0,28.38,-2.28,-1.55126,-0.83960,2.99174,1.41155,1.91163,3.00030 +2026-10-08T21:33:06,12400,-0.124,8.22e+12,,,,,,,,,,,-1.55120,-0.83936,2.99221,1.40896,1.90646,2.99000 +2026-10-08T21:44:01,12400,-0.124,8.34e+12,1107,962,-0.83936,1.90645,-0.83936,1.91190,-0.6,0.7,27.17,-2.04,-1.55120,-0.83937,2.99223,1.41170,1.91189,3.00082 +2026-10-10T11:07:24,12400,-0.123,8.96e+12,941,890,-0.83860,1.91188,-0.84066,1.90895,-1.1,0.3,26.15,-2.32,-1.55165,-0.84066,2.98975,1.41020,1.90891,2.99484 +2026-10-10T11:08:19,12400,-0.123,8.99e+12,1002,965,-0.84068,1.90889,-0.84068,1.90956,0.7,0.7,27.52,-2.17,-1.55165,-0.84067,2.98973,1.41049,1.90950,2.99604 +2026-10-10T14:59:51,12400,-0.006,8.90e+12,1019,884,-0.84070,1.90952,-0.84296,1.91079,-0.1,-0.4,16.17,0.98,-1.55224,-0.84294,2.98518,1.41113,1.91078,2.99861 +2026-10-10T15:13:26,12400,-0.006,8.93e+12,1004,972,-0.84296,1.91080,-0.84296,1.91112,-0.4,-0.6,14.81,0.75,-1.55223,-0.84294,2.98520,1.41129,1.91109,2.99922 +2026-10-10T15:16:28,12400,-0.005,8.39e+12,962,975,-0.84296,1.91111,-0.84295,1.90925,-0.6,-0.7,29.46,0.67,-1.55225,-0.84297,2.98517,1.41033,1.90920,2.99546 +2026-10-10T17:35:14,12400,-0.005,8.88e+12,1007,978,-0.84296,1.90920,-0.84271,1.91003,0.5,0.1,24.24,0.87,-1.55219,-0.84270,2.98573,1.41073,1.90997,2.99701 +2026-10-10T18:06:55,12400,-0.003,8.80e+12,994,968,-0.84270,1.90995,-0.84271,1.90995,0.1,0.2,1.74,-0.11,-1.55219,-0.84271,2.98573,1.41072,1.90996,2.99692 +2026-10-10T22:27:30,12400,-0.002,8.42e+12,1001,971,-0.84269,1.90996,-0.84269,1.91037,-0.1,-0.3,4.02,0.02,-1.55216,-0.84269,2.98569,1.41091,1.91032,2.99764 +2026-10-10T22:39:06,12400,-0.001,8.79e+12,993,967,-0.84268,1.91032,-0.84268,1.91032,0.1,0.2,3.07,0.15,-1.55216,-0.84268,2.98569,1.41090,1.91029,2.99761 +2026-10-11T11:01:27,12400,-0.001,8.95e+12,977,939,-0.84267,1.91028,-0.84348,1.90966,0.8,-0.1,3.61,0.06,-1.55233,-0.84350,2.98410,1.41058,1.90967,2.99636 +2026-10-11T11:16:48,12400,-0.001,8.92e+12,983,969,-0.84348,1.90965,-0.84349,1.90885,-0.7,0.0,4.79,-0.17,-1.55234,-0.84347,2.98410,1.41018,1.90888,2.99476 +2026-10-11T11:49:23,13000,-0.001,6.49e+12,998,970,-0.84348,1.90886,-0.84347,1.90884,-0.4,-0.1,4.41,-0.39,-1.55234,-0.84348,2.98412,1.41016,1.90884,2.99474 +2026-10-11T11:52:05,12400,-0.003,8.86e+12,993,971,-0.84348,1.90883,-0.84349,1.90884,-0.2,-0.4,6.72,-0.33,-1.55234,-0.84347,2.98411,1.41015,1.90883,2.99475 +2026-10-11T15:53:27,12400,-0.002,8.82e+12,1003,976,-0.84327,1.90922,-0.84307,1.90994,0.5,0.1,5.93,0.30,-1.55225,-0.84306,2.98494,1.41070,1.90993,2.99690 diff --git a/pxii_bec/daily_setup_files/daily_report.pdf b/pxii_bec/daily_setup_files/daily_report.pdf new file mode 100644 index 0000000..43cdcad Binary files /dev/null and b/pxii_bec/daily_setup_files/daily_report.pdf differ diff --git a/pxii_bec/daily_setup_files/weekly_beamline_health.csv b/pxii_bec/daily_setup_files/weekly_beamline_health.csv new file mode 100644 index 0000000..b57af0a --- /dev/null +++ b/pxii_bec/daily_setup_files/weekly_beamline_health.csv @@ -0,0 +1,2 @@ +timestamp,energy_eV,id_gap_mm,pitch_offset_mrad,fe_x,fe_y,bsf_x,bsf_y,ss_x,ss_y,lu_Xnorm,lu_Ynorm,ss_Xnorm,ss_Ynorm,bcu_Xnorm,bcu_Ynorm,bcu_beamX,bcu_beamY,energy_offset_eV +2026-10-28T20:38:34,12400,5.310,-0.0031,0.150,0.793,0.103,0.052,0.214,-0.771,-0.0059,-0.3476,-0.0245,0.3841,0.0800,0.2747,-16.7,6.3,1.58 diff --git a/pxii_bec/daily_setup_files/weekly_beamline_health_archive_20261028_203834.csv b/pxii_bec/daily_setup_files/weekly_beamline_health_archive_20261028_203834.csv new file mode 100644 index 0000000..b04aca0 --- /dev/null +++ b/pxii_bec/daily_setup_files/weekly_beamline_health_archive_20261028_203834.csv @@ -0,0 +1,15 @@ +timestamp,energy_eV,id_gap_mm,pitch_offset_mrad,fe_x,fe_y,bsf_x,bsf_y,ss_x,ss_y +2026-09-24T21:42:20,12400.033814014585,5.307,-0.042640079687492616,0.1402884999999987,0.8723975000000008,0.0979238876343338,0.15329813690165395,0.21542000000000003,-0.6441100000000001 +2026-10-08T18:55:27,,,,,,,,,,,,,,,,, +2026-10-08T19:02:21,12400,5.307,-0.1248,,,0.079,0.156,0.161,-0.597,,,,,,,, +2026-10-08T19:57:27,12400,5.307,-0.1239,0.130,0.878,0.092,0.157,0.178,-0.585,,,,,,,, +2026-10-08T20:08:32,12400,5.307,-0.1235,0.130,0.878,0.092,0.157,0.176,-0.584,,,,,,,, +2026-10-08T21:05:34,12400,5.307,-0.1239,0.130,0.878,0.092,0.157,0.173,-0.582,,,,,,,, +2026-10-08T21:18:55,12400,5.307,-0.1237,0.130,0.878,0.092,0.157,0.174,-0.584,,,,,,,, +2026-10-10T18:06:20,12400,5.310,-0.0052,0.130,0.878,0.092,0.157,0.184,-0.635,0.0896,0.0125,-0.0092,0.0103,-0.0142,0.0055,-1.1,0.1, +2026-10-10T18:13:15,12400,5.310,-0.0034,,,,,,,0.0977,0.0140,-0.0167,0.0053,-0.0342,-0.0040,2.2,-0.2, +2026-10-10T22:38:26,12400,5.310,-0.0019,0.130,0.878,0.092,0.157,0.180,-0.634,0.1084,0.0101,-0.0101,0.0104,-0.0568,0.0006,6.0,-0.0,0.25 +2026-10-11T11:00:45,12400,5.310,0.0001,0.130,0.872,0.092,0.156,0.189,-0.636,0.0870,0.0046,-0.0097,0.0171,-0.0363,0.0299,2.5,0.8,0.25 +2026-10-11T11:16:09,12400,5.310,-0.0013,0.130,0.873,0.092,0.156,0.183,-0.636,0.0977,0.0014,-0.0129,0.0206,-0.0584,-0.0041,6.2,-0.2,0.25 +2026-10-11T11:39:15,12400,5.310,-0.0018,0.130,0.873,0.092,0.156,0.180,-0.634,0.1001,0.0081,-0.0147,0.0101,-0.0489,-0.0180,4.6,-0.5,0.25 +2026-10-11T11:48:39,12400,5.310,-0.0019,0.130,0.873,0.092,0.156,0.181,-0.635,0.0999,0.0076,-0.0174,0.0154,-0.0477,-0.0081,4.4,-0.3,0.25 diff --git a/pxii_bec/macros/luts/dcm_calibration_20260906.csv b/pxii_bec/macros/luts/dcm_calibration_20260906.csv new file mode 100644 index 0000000..d497b7e --- /dev/null +++ b/pxii_bec/macros/luts/dcm_calibration_20260906.csv @@ -0,0 +1,50 @@ +energy,harmonic,gap,pitch,samcam_x,samcam_y,zoom=800.0 +5500,H3,5.4676,-5.5269,971.5,986.9 +6000,H3,5.9134,-5.5182,968.7,991.5 +6500,H3,6.3792,-5.5141,969.1,991.4 +7000,H3,6.875,-5.5093,969.1,991.4 +7500,H5,4.6338,-5.5055,961,970.4 +8000,H5,4.8789,-5.5032,983.2,976 +8500,H5,5.1305,-5.5012,995.3,981.5 +9000,H5,5.3823,-5.4993,998.2,981.8 +9500,H5,5.6419,-5.4974,998.6,980 +10000,H5,5.911,-5.4956,1000,981.7 +10500,H7,4.6331,-5.4942,999.7,977.1 +11000,H7,4.8079,-5.4938,993.6,977.8 +11500,H7,4.9819,-5.4919,998.1,976.8 +12000,H7,5.1654,-5.4906,1001,976.1 +12500,H7,5.344,-5.4895,998.9,975.5 +13000,H7,5.5308,-5.4892,996.3,975.4 +13500,H9,4.6331,-5.4884,997.6,973.3 +14000,H9,4.7673,-5.4877,997.1,972.8 +14500,H9,4.9053,-5.4871,997.7,972.8 +15000,H9,5.0433,-5.4866,998.7,972.4 +15500,H9,5.1814,-5.4859,998.5,973.1 +16000,H11,4.5186,-5.4856,997.3,971.3 +16500,H11,4.6282,-5.4848,994.4,973.6 +17000,H11,4.7405,-5.4841,997.8,972.7 +17500,H11,4.8533,-5.4837,995,971.8 +18000,H11,4.9661,-5.4833,995.7,969.8 +18500,H11,5.0789,-5.483,994.5,970.9 +19000,H13,4.5338,-5.4826,993.5,970.2 +19500,H13,4.6324,-5.4822,993,968.7 +20000,H13,4.7236,-5.482,994.6,969 +20500,H13,4.8182,-5.4811,993.3,970.4 +21000,H13,4.9129,-5.4811,992,967.8 +21500,H13,5.0075,-5.4807,992.4,965.1 +22000,H15,4.5498,-5.4807,988.9,955.4 +22500,H15,4.6282,-5.4805,993.3,952.8 +23000,H15,4.7111,-5.4802,990.9,956.2 +23500,H15,4.7932,-5.4791,998.5,956.5 +24000,H15,4.8752,-5.4791,996.6,957.1 +24500,H15,4.9572,-5.4791,996,958.4 +25000,H17,4.5602,-5.479,988.5,956.1 +25500,H17,4.6331,-5.479,985.3,956.7 +26000,H17,4.7031,-5.4791,986,959.4 +26500,H17,4.7753,-5.4782,989.9,956.4 +27000,H17,4.8474,-5.4785,988.1,953.3 +27500,H19,4.5051,-5.4795,972.6,951.6 +28000,H19,4.5659,-5.4791,974.4,959.9 +28500,H19,4.6331,-5.4788,966.3,968.4 +29000,H19,4.6966,-5.4785,967.7,965.8 +29500,H19,4.7596,-5.4784,963.9,967.7 diff --git a/pxii_bec/macros/luts/dcm_calibration_4thOct.csv b/pxii_bec/macros/luts/dcm_calibration_4thOct.csv new file mode 100644 index 0000000..18b28e9 --- /dev/null +++ b/pxii_bec/macros/luts/dcm_calibration_4thOct.csv @@ -0,0 +1,28 @@ +energy,pitch,lu_Xnorm,lu_Ynorm,ss_Xnorm,ss_Ynorm,bcu_x,bcu_y,samcam_x,samcam_y,zoom=1000.0 +6000,-5.5651,0.031085,0.036155,0.0052168,0.0041921,10.75,-1.11,-8.771,-4.583 +7000,-5.5546,0.026899,0.026529,-0.0073424,0.053473,6.16,-1.84,-0.7224,-2.887 +8000,-5.5484,0.066689,0.032268,0.005212,0.0042436,7.95,-2.62,0.9412,-3.068 +9000,-5.5441,0.041593,0.029141,-0.010786,0.042077,12.07,-0.95,-0.5363,-2.653 +10000,-5.5411,0.042201,0.013278,0.025073,0.053635,13.84,-0.60,1.682,-1.665 +11000,-5.5382,0.065656,0.022891,0.027213,0.041838,21.11,-0.06,1.831,-3.373 +12000,-5.5358,0.045707,0.02277,0.021949,0.053366,12.55,0.30,-0.132,-0.07301 +13000,-5.5344,0.046219,0.014825,0.079975,0.088181,17.28,0.47,0.2965,0.02576 +14000,-5.5325,0.071565,0.024777,0.096642,0.083641,20.87,0.44,-0.04888,0.1838 +15000,-5.5313,0.063579,0.021258,0.15225,0.12223,18.18,0.67,0.06056,0.4581 +16000,-5.5304,0.11033,0.023619,0.2533,0.17271,22.24,0.90,1.668,0.6958 +17000,-5.529,0.094652,0.026446,0.32328,0.23969,23.89,0.86,0.6903,0.5908 +18000,-5.5278,0.088299,0.029077,0.57684,0.074821,21.01,0.89,0.9228,0.9236 +18500,-5.5278,0.079312,0.031407,0.57597,0.41821,21.95,0.86,0.4968,0.9468 +19000,-5.5277,0.10892,0.034869,0.672,-0.043649,22.96,0.79,1.274,0.7789 +19500,-5.5273,0.1123,0.037979,0.65287,0.41444,29.04,0.98,1.399,0.7602 +20000,-5.527,0.10889,0.042196,0.76301,0.55486,280.03,-0.09,1.669,0.9976 +20500,-5.5268,0.11885,0.048114,0.94538,0.64762,25.79,1.31,1.943,0.8993 +21000,-5.5264,0.11568,0.055515,1.157,0.84596,22.99,2.12,2.15,1.261 +21500,-5.5257,0.10583,0.061478,1.4832,1.0726,22.62,4.43,1.107,2.616 +22000,-5.5253,0.14069,0.053697,1.1677,0.83326,25.98,7.66,1.164,7.532 +22500,-5.5251,0.14969,0.059799,1.1592,-0.24509,26.08,6.51,1.278,8.663 +23000,-5.5247,0.14373,0.075002,1.5391,0.66679,26.93,7.41,1.376,5.2 +23500,-5.5243,0.14984,0.091189,2.0988,1.5083,27.65,6.24,0.9794,6.096 +24000,-5.5242,0.14755,0.10074,2.6501,1.955,29.90,6.02,0.9268,5.937 +24500,-5.5239,0.15082,0.11364,3.4195,2.5418,32.97,4.64,1.019,4.126 +25000,-5.5237,0.18897,0.10096,2.2261,1.6208,39.12,3.63,2.495,3.873 diff --git a/pxii_bec/macros/luts/dcm_calibration_failures_20260906.csv b/pxii_bec/macros/luts/dcm_calibration_failures_20260906.csv new file mode 100644 index 0000000..7086c7f --- /dev/null +++ b/pxii_bec/macros/luts/dcm_calibration_failures_20260906.csv @@ -0,0 +1,6 @@ +energy,scan,reason +27500,gap,An alarm has occurred. Severity: MAJOR. +ValueError. + An error occurred during 'set' on device 'id_gap'. + +ValueError: 4.4999 outside of user-specified limits diff --git a/pxii_bec/macros/luts/dcm_exit_scan_20260926_181234.csv b/pxii_bec/macros/luts/dcm_exit_scan_20260926_181234.csv new file mode 100644 index 0000000..13e203e --- /dev/null +++ b/pxii_bec/macros/luts/dcm_exit_scan_20260926_181234.csv @@ -0,0 +1 @@ +energy_eV,perp_mm,pitch_mrad,xnorm,ynorm, lu_bpmsum ss_bpmsum diff --git a/pxii_bec/macros/luts/dcm_exit_scan_20260926_181308.csv b/pxii_bec/macros/luts/dcm_exit_scan_20260926_181308.csv new file mode 100644 index 0000000..13e203e --- /dev/null +++ b/pxii_bec/macros/luts/dcm_exit_scan_20260926_181308.csv @@ -0,0 +1 @@ +energy_eV,perp_mm,pitch_mrad,xnorm,ynorm, lu_bpmsum ss_bpmsum diff --git a/pxii_bec/macros/luts/dcm_exit_scan_20260926_181513.csv b/pxii_bec/macros/luts/dcm_exit_scan_20260926_181513.csv new file mode 100644 index 0000000..13e203e --- /dev/null +++ b/pxii_bec/macros/luts/dcm_exit_scan_20260926_181513.csv @@ -0,0 +1 @@ +energy_eV,perp_mm,pitch_mrad,xnorm,ynorm, lu_bpmsum ss_bpmsum diff --git a/pxii_bec/macros/luts/dcm_exit_scan_20260926_182236.csv b/pxii_bec/macros/luts/dcm_exit_scan_20260926_182236.csv new file mode 100644 index 0000000..7052b6a --- /dev/null +++ b/pxii_bec/macros/luts/dcm_exit_scan_20260926_182236.csv @@ -0,0 +1,15 @@ +energy_eV,perp_mm,pitch_mrad,xnorm,ynorm, lu_bpmsum ss_bpmsum +6000,0.17804500,-5.56510000,0.00521437,0.00419858,18546.24343,130514.24424 +8000,0.09572500,-5.54755500,-0.00225690,0.00918682,9612.95290,129623.67127 +10000,0.06008000,-5.53949300,-0.02426170,0.01969609,2084.64965,28565.13518 +12000,0.04132500,-5.53418600,-0.01799166,0.01162217,2059.34329,27819.81720 +13000,0.03510000,-5.53270700,0.03050872,0.04007080,949.56476,12683.89401 +14000,0.03023500,-5.53090900,0.03626750,0.03772359,1012.74372,13396.74962 +15000,0.02619000,-5.52960400,0.09607227,0.07708974,616.34191,8091.35177 +16000,0.02304000,-5.52835700,0.18510543,0.12410138,430.47984,5545.57757 +18000,0.01803500,-5.52676200,0.48661103,0.21400983,206.13640,2828.90937 +20000,0.01463000,-5.52525400,0.75358426,0.54795139,127.00779,1573.76959 +22000,0.01204500,-5.52421000,1.24799354,0.91159801,79.27741,967.34562 +24000,0.01013500,-5.52334000,3.17771287,2.39121669,37.50232,389.56068 +27000,0.00794000,-5.52273100,8.23593902,6.11316409,20.46831,158.89555 +30000,0.00638000,-5.52212200,4.78199624,2.01229170,11.43039,336.39939 diff --git a/pxii_bec/macros/luts/dcm_exit_scan_20260926_191417.csv b/pxii_bec/macros/luts/dcm_exit_scan_20260926_191417.csv new file mode 100644 index 0000000..11d6e52 --- /dev/null +++ b/pxii_bec/macros/luts/dcm_exit_scan_20260926_191417.csv @@ -0,0 +1,7 @@ +energy_eV,perp_mm,pitch_mrad,xnorm_lu,ynorm_lu, xnorm_ss, ynorm_ss, lu_bpmsum ss_bpmsum +6000,0.17806000,-5.56530300,0.01296605,-0.00291025,-37.92899905,-28.13960455,18490.47712,11.51306 +8000,0.09571500,-5.54743900,0.03002982,-0.00716467,-27.93686376,-20.93736216,9570.71890,-39.90783 +10000,0.06012000,-5.53923200,-0.00552074,-0.02081064,-17.98290053,-13.48165964,2088.09847,-66.55146 +12000,0.04133000,-5.53415700,0.00803005,-0.01288914,-17.76660664,-13.31911194,2041.66463,-67.26575 +13000,0.03514500,-5.53247500,-0.00156358,-0.02135799,-16.69315624,-12.50683717,950.79006,-73.28571 +14000,0.03021500,-5.53102500,0.02126158,-0.01633925,-16.72877093,-12.52602982,1006.73113,-72.64209 diff --git a/pxii_bec/macros/luts/dcm_exit_scan_20260926_192425.csv b/pxii_bec/macros/luts/dcm_exit_scan_20260926_192425.csv new file mode 100644 index 0000000..500e5b7 --- /dev/null +++ b/pxii_bec/macros/luts/dcm_exit_scan_20260926_192425.csv @@ -0,0 +1,15 @@ +energy_eV,perp_mm,pitch_mrad,xnorm_lu,ynorm_lu, xnorm_ss, ynorm_ss, lu_bpmsum ss_bpmsum +6000,0.17806500,-5.56510000,0.00922953,-0.00224840,0.00521027,0.00419006,18191.10746,130510.48387 +8000,0.09573000,-5.54738100,0.02848413,-0.00868348,-0.00342115,0.00763945,9605.32321,129804.80492 +10000,0.06011500,-5.53931900,-0.00214782,-0.01757398,-0.01877671,0.01781310,2074.10696,28497.29954 +12000,0.04120500,-5.53421500,0.01009199,-0.01169106,-0.01621283,0.01227703,2039.62346,27607.92166 +13000,0.03517000,-5.53244600,-0.00006709,-0.01900989,0.02157420,0.04027503,954.52988,12760.55607 +14000,0.03021500,-5.53079300,0.02255849,-0.01555700,0.03971769,0.03848089,1012.50677,13401.01997 +15000,0.02624000,-5.52960400,0.01656820,-0.01561637,0.10018775,0.07797078,611.34639,8022.30415 +16000,0.02303500,-5.52847300,0.03837033,-0.01752713,0.18684740,0.12382397,432.63907,5599.75576 +18000,0.01804000,-5.52670400,0.02852739,-0.00842583,0.48117730,0.21631104,206.86437,2830.33794 +20000,0.01462500,-5.52542800,0.02772654,-0.00128462,0.75500833,0.55177904,125.75706,1563.77419 +22000,0.01204000,-5.52403600,0.02409124,0.01266679,1.24969612,0.91368184,79.45357,977.20430 +24000,0.01010500,-5.52336900,0.03221193,0.04940811,3.17721905,2.37818429,37.30737,395.73118 +27000,0.00794000,-5.52267300,0.10109644,0.12093432,8.17011447,6.06082970,20.64468,163.96160 +30000,0.00638000,-5.52226700,0.20304003,0.27814825,5.45522490,2.52367977,10.77651,270.02919 diff --git a/pxii_bec/macros/luts/energy_beam_position_20261010-1635.csv b/pxii_bec/macros/luts/energy_beam_position_20261010-1635.csv new file mode 100644 index 0000000..7eb3380 --- /dev/null +++ b/pxii_bec/macros/luts/energy_beam_position_20261010-1635.csv @@ -0,0 +1,4 @@ +energy,harmonic,gap,dcm_pitch,dcm_perp,dcm_roll,lu_bpmsum,lu_Xnorm,lu_Ynorm,xi_cam_x,xi_cam_y,bcu_bpmsum,bcu_x,bcu_y,samcam_x,samcam_y,flux +6000,H3,5.9180,-5.64238,0.17767,3.88092,18141.6,0.095,0.021,152.7,209.4,11544.3,2.71,0.22,-10.46,-5.59,1.087e+13 +8000,H5,4.8794,-5.62539,0.09557,3.88123,10078.9,0.114,0.017,147.2,206.3,19104.1,19.97,-0.49,-1.86,-4.60,1.811e+13 +10000,H5,5.9092,-5.61921,0.06028,3.88092,3482.5,0.090,0.018,149.2,207.5,5110.8,21.89,-0.44,-2.28,-3.40,1.292e+13 diff --git a/pxii_bec/macros/luts/energy_beam_position_20261010-1721.csv b/pxii_bec/macros/luts/energy_beam_position_20261010-1721.csv new file mode 100644 index 0000000..5d65201 --- /dev/null +++ b/pxii_bec/macros/luts/energy_beam_position_20261010-1721.csv @@ -0,0 +1,7 @@ +energy,harmonic,gap,dcm_pitch,dcm_perp,dcm_roll,lu_bpmsum,lu_Xnorm,lu_Ynorm,xi_cam_x,xi_cam_y,bcu_bpmsum,bcu_Xnorm,bcu_Ynorm,bcu_x,bcu_y,samcam_x,samcam_y,flux +12400,H7,5.3102,-5.61425,0.03857,3.88184,1677.9,0.101,0.015,148.5,209.8,1181.5,-0.141,0.010,23.03,0.37,-1.88,-2.15,7.894e+12 +15000,H9,5.0387,-5.61066,0.02622,3.88153,602.8,0.122,0.015,150.1,208.2,853.0,-0.193,0.012,31.71,0.43,-0.56,-1.70,3.889e+12 +18000,H11,4.9660,-5.60645,0.01810,3.88092,242.8,0.115,0.019,150.2,208.6,655.5,-0.164,0.017,26.84,0.58,-1.76,-1.61,2.118e+12 +20000,H13,4.7119,-5.60532,0.01461,3.88062,73.0,0.150,0.032,151.3,208.0,428.8,-0.220,0.044,36.30,1.30,-0.15,-0.53,6.673e+11 +22000,H15,4.5315,-5.60474,0.01210,3.88000,25.7,0.148,0.093,151.6,208.2,90.3,-0.232,0.353,38.24,7.38,0.92,2.72,1.570e+11 +25000,H17,4.5556,-5.60324,0.00923,3.88031,41.0,0.128,0.056,151.0,208.3,26.8,-0.224,0.137,37.15,3.83,-0.76,1.38,5.419e+10 diff --git a/pxii_bec/macros/luts/energy_beam_position_20261010-1741.csv b/pxii_bec/macros/luts/energy_beam_position_20261010-1741.csv new file mode 100644 index 0000000..cdec368 --- /dev/null +++ b/pxii_bec/macros/luts/energy_beam_position_20261010-1741.csv @@ -0,0 +1,10 @@ +energy,harmonic,gap,dcm_pitch,dcm_perp,dcm_roll,lu_bpmsum,lu_Xnorm,lu_Ynorm,xi_cam_x,xi_cam_y,bcu_bpmsum,bcu_Xnorm,bcu_Ynorm,bcu_x,bcu_y,samcam_x,samcam_y,flux +6000,H3,5.9180,-5.64227,0.17800,3.88123,17993.2,0.091,0.019,142.1,207.0,8560.7,0.052,-0.019,-11.96,-0.51,-6.74,-4.48,1.086e+13 +8000,H5,4.8794,-5.62527,0.09560,3.88123,10097.4,0.112,0.015,147.8,205.7,18890.3,-0.009,-0.036,-1.97,-1.02,-1.11,-3.80,1.790e+13 +10000,H5,5.9092,-5.61942,0.06021,3.88092,3493.2,0.089,0.013,149.3,207.4,5132.5,-0.013,-0.031,-1.38,-0.88,-0.53,-1.83,1.297e+13 +12400,H7,5.3102,-5.61440,0.03863,3.88123,1679.3,0.097,0.011,149.6,208.7,1236.5,-0.039,-0.001,2.98,-0.09,1.09,-0.35,8.921e+12 +15000,H9,5.0387,-5.61101,0.02601,3.88031,601.0,0.122,0.010,150.5,208.9,854.3,-0.060,0.007,6.46,0.12,1.28,-0.05,3.890e+12 +18000,H11,4.9660,-5.60753,0.01805,3.87970,225.9,0.130,0.017,151.3,208.9,614.0,-0.099,0.016,12.97,0.37,2.90,0.02,1.855e+12 +20000,H13,4.7119,-5.60544,0.01468,3.88000,74.0,0.145,0.028,151.3,207.8,435.7,-0.079,0.034,9.62,0.85,1.21,0.86,6.783e+11 +22000,H15,4.5315,-5.60480,0.01197,3.87970,26.6,0.159,0.089,151.6,208.3,93.3,-0.102,0.342,13.68,7.12,1.74,4.31,1.622e+11 +25000,H17,4.5556,-5.60469,0.00932,3.88062,38.4,0.135,0.058,151.4,208.3,25.3,-0.147,0.120,21.60,3.06,2.90,2.59,5.157e+10 diff --git a/pxii_bec/macros/luts/predicted_trans.csv b/pxii_bec/macros/luts/predicted_trans.csv new file mode 100644 index 0000000..a0d5e14 --- /dev/null +++ b/pxii_bec/macros/luts/predicted_trans.csv @@ -0,0 +1,8 @@ +Energy,PredictedT,ExposureTime,max,auto_expT,max2 +8000,0.249,0.0050,255,0.0005,203 +10000,0.105,0.0050,190,0.0052,199 +12400,0.092,0.0050,159,0.0070,203 +16000,0.270,0.0050,201,0.0050,201 +18000,0.485,0.0050,255,0.0026,203 +20000,1.000,0.0050,255,0.0016,203 +24000,1.000,0.0050,86,0.0271,196 diff --git a/pxii_bec/macros/moregaps_new.py b/pxii_bec/macros/moregaps_new.py new file mode 100644 index 0000000..b39f5a0 --- /dev/null +++ b/pxii_bec/macros/moregaps_new.py @@ -0,0 +1,264 @@ + +import pandas as pd +import matplotlib.pyplot as plt +import numpy as np +import time +import sys +import math +import glob + +from datetime import datetime + +def harm(energy): + import numpy as np + data = { + 6: np.array([3, 4]), + 7: np.array([3, 4]), + 8: np.array([3, 4, 5]), + 9: np.array([4, 5, 6]), + 10: np.array([4, 5, 6]), + 11: np.array([4, 5, 6, 7]), + 12: np.array([5, 6, 7, 8]), #np.array([5, 6]), #####, 7, 8]), + 13: np.array([5, 6, 7, 8, 9]), + 14: np.array([5, 6, 7, 8, 9]), + 15: np.array([6, 7, 8, 9, 10]), + 16: np.array([6, 7, 8, 9, 10, 11]), + 17: np.array([6, 7, 8, 9, 10, 11]), + 18: np.array([7, 8, 9, 10, 11, 12]), + 19: np.array([7, 8, 9, 10, 11, 12, 13]), + 20: np.array([8, 9, 10, 11, 12, 13]), + 21: np.array([8, 9, 10, 11, 12, 13, 14]), + 22: np.array([8, 9, 10, 11, 12, 13, 14, 15]), + 23: np.array([9, 10, 11, 12, 13, 14, 15, 16]), + 24: np.array([9, 10, 11, 12, 13, 14, 15, 16]), + 25: np.array([9, 10, 11, 12, 13, 14, 15, 16, 17]), + 26: np.array([10, 11, 12, 13, 14, 15, 16, 17, 18]), + 27: np.array([10, 11, 12, 13, 14, 15, 16, 17, 18]), + 28: np.array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19]), + 29: np.array([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]), + 30: np.array([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]), + } + res = data[energy] + return res # data = harm(9) --> returns the harmonics of that energy + + +def newgaps(e1, e2): + import numpy as np + """ + scan the gaps around the max only, read in the array of peaks at the harms + """ + + dirname = "/sls/x10sa/config/commissioning/Data/GapsFE_0p3/" + + results = [] + + for e in range(e1, e2+1): + + bl_energy(e*1000,move_gap = False,plot = False) + print(f' ============energy now {e} ============= ') + scan_pos = {} + he = harm(e) + res = [] + for h in he: + print(f'harmonics are {h}') + gpos = setu19(e, h, simul=1) + res.append((h, gpos)) ### keep track of both + + print(f'harmonic {h}: move to {gpos} and scan') + gm,xm = calculate_max_position(e, gpos) + # print(f'note the max of the peak pos there') + gm = round(gm,3) + xm = round(xm,3) + results.append((e, h, gm, xm)) + + df = pd.DataFrame( + results, + columns=["energy", "harmonic","fitmax_position", "max_position"] + ) + scan_pos[e] = res + print(f'scan pos for {e} are {scan_pos[e]}') + + ## save data structure in file: + + dname = f"gscan_results_{datetime.now():%d-%m-%y}.txt" + filename = dirname + dname + write_results_pd2csv(filename, df) + + + return df + + +### ============================= + +def calculate_max_position(en, gpos): + #time.sleep(0.1) + scans.umv(dev.id_gap, gpos, relative=False) + time.sleep(0.1) + #print(f'move to {gpos}') + #print(f'scan around this pos') + #gm=5. + gm, xm = gscan(deltag=0.1, silent=1, isave=1, iplot=0) + + return gm, xm + +### ======================= + + +def write_results_pd2csv(filename, resultsdf): + import pandas as pd + """Write (energy, harmonic, fitmax_position, max_position) results DataFrame to CSV.""" + resultsdf.to_csv(filename, index=False) ## .to_csv is a pandas method + +def read_results_csv2pd(filename): + """Read results from CSV and return list of tuples.""" + df = pd.read_csv(filename) + print(f'df = {df}') + return df + + + +def write_results(filename, results): + """Write (energy, harmonic, fitmax_position, max_position) results to CSV.""" + import csv + with open(filename, "w", newline="") as f: + writer = csv.writer(f) + + # header + writer.writerow(["energy", "harmonic", "fitmax_position" "max_position"]) + + # data + writer.writerows(results) + + +def read_results(filename): + """Read results from CSV and return list of tuples.""" + import csv + results = [] + + with open(filename, "r", newline="") as f: + reader = csv.DictReader(f) + + for row in reader: + results.append( + ( + float(row["energy"]), + int(row["harmonic"]), + float(row["fitmax_position"]), + float(row["max_position"]) + ) + ) + + return results + + +#write_results("gscan_results.csv", results) +#results = read_results("gscan_results.csv") +# print(results) + + +### =============== + +#Regroup according to harmonic +#A defaultdict is ideal: +#from collections import defaultdict + +def regroup(): + by_harmonic = defaultdict(list) + + for energy, harmonic, position in results: + by_harmonic[harmonic].append((energy, position)) + + + + +### =============== + +#plot each harmonic vs energy: + +def plotharmon(): + import matplotlib.pyplot as plt + + for harmonic, values in by_harmonic.items(): + + values.sort() # sort by energy + + energy = [v[0] for v in values] + position = [v[1] for v in values] + + plt.plot(energy, position, 'o-', label=f'Harmonic {harmonic}') + + plt.xlabel('Energy') + plt.ylabel('Maximum position') + plt.legend() + plt.show() + +### ========== + +#with pandas: + +def pandstruct(): + + import pandas as pd + + df = pd.DataFrame( + results, + columns=['energy', 'harmonic', 'fit gposition', 'max gposition'] + ) + + # selct a harmon + df[df.harmonic == 6] + + + #or sort: + df = df.sort_values(['harmonic', 'energy']) + + + # plotting: + for harmonic, group in df.groupby('harmonic'): + plt.plot( + group.energy, + group.position, + 'o-', + label=f'Harmonic {harmonic}' + ) + +# plotting for inspection + +def plot_gaps(energy): +#glob is a Python module for finding files whose names match a pattern. + dirname = "/sls/x10sa/config/commissioning/Data/GapsFE_0p3/" + file_name= dirname+"gap"+str(energy)+"_*.txt" + #files = sorted(glob.glob("gap12_*.txt")) + files = sorted(glob.glob(file_name)) + + n = len(files) + print(f'n ={n}') + ncols = 2 + nrows = math.ceil(n / ncols) + + fig, axes = plt.subplots(nrows, ncols, figsize=(12, 4 * nrows), squeeze=False) + + axes = axes.ravel() + + for ax, filename in zip(axes, files): + + data = np.loadtxt(filename, delimiter=",") + + x = data[:, 0] + y = data[:, 1] + + ax.plot(x, y) + ax.set_title(filename) + ax.set_xlabel("gap / mm") + ax.set_ylabel("lu_bpm") + ax.grid(True) + +# hide unused axes + for ax in axes[n:]: + ax.set_visible(False) + + plt.tight_layout() + plt.show() + + + diff --git a/pxii_bec/macros/test_move_beam.py b/pxii_bec/macros/test_move_beam.py new file mode 100644 index 0000000..4af0bcc --- /dev/null +++ b/pxii_bec/macros/test_move_beam.py @@ -0,0 +1,114 @@ +def test_daily_movebeam(meas="scint", iterations=3): + + vfm_start = get_value(dev.vfm_ydr) + hfm_start = get_value(dev.hfm_xd) + + dev.transm.put(EnergyDefaults.default_trans) + + if meas == "scint": + + xbeam_target = BeamMove.scint_target_x + ybeam_target = BeamMove.scint_target_y + + print(f"Starting VFM DR: {vfm_start:.6f}") + print(f"Starting HFM XD: {hfm_start:.6f}") + + for i in range(iterations): + + print(f"\n--- Correction {i + 1} ---") + + # Fresh beam measurement at start of iteration + x, y = read_scintXY(CameraZoom.X12_5.position) + + diff_x = xbeam_target - x + diff_y = ybeam_target - y + + print( + f"Beam position: X={x:.2f}, Y={y:.2f}\n" + f"Residual: X={diff_x:+.2f} px, " + f"Y={diff_y:+.2f} px" + ) + + # ---------------------------------------------------------- + # VFM correction + # ---------------------------------------------------------- + + if abs(diff_y) > BeamMove.scint_tolerance: + + current_vfm = get_value(dev.vfm_ydr) + + vfm_change = diff_y / BeamMove.scint_y_slope + new_vfm = current_vfm + vfm_change + + print(f"VFM: {current_vfm:.6f} -> {new_vfm:.6f} " f"(change {vfm_change:+.6f})") + + beam_y_before = y + vfm_before = current_vfm + + # umv(dev.vfm_ydr, new_vfm) + move_with_offset(dev.vfm_ydr, new_vfm) + + # Remeasure because VFM may affect both X and Y + x, y = read_scintXY(CameraZoom.X12_5.position) + + vfm_after = get_value(dev.vfm_ydr) + + dy = y - beam_y_before + dvfm = vfm_after - vfm_before + + if abs(dvfm) > 1e-5: + observed_coeff = dy / dvfm + + print( + f"VFM observed movement:\n" + f" Motor: {dvfm:+.6f}\n" + f" Beam Y: {dy:+.2f} px\n" + f" Coefficient: {observed_coeff:.0f} px/mm" + ) + + else: + print(f"Y within tolerance ({diff_y:+.2f} px) " "- no VFM move") + + # ---------------------------------------------------------- + # HFM correction + # ---------------------------------------------------------- + + # x is either: + # - the initial measurement if VFM didn't move, or + # - the updated measurement after the VFM move + diff_x = xbeam_target - x + + if abs(diff_x) > BeamMove.scint_tolerance: + + current_hfm = get_value(dev.hfm_xd) + + hfm_change = diff_x / BeamMove.scint_x_slope + new_hfm = current_hfm + hfm_change + + print(f"HFM: {current_hfm:.6f} -> {new_hfm:.6f} " f"(change {hfm_change:+.6f})") + + # umv(dev.hfm_xd, new_hfm) + move_with_offset(dev.hfm_xd, new_hfm) + + else: + print(f"X within tolerance ({diff_x:+.2f} px) " "- no HFM move") + + # Final check + x, y = read_scintXY(CameraZoom.X12_5.position) + + diff_x = xbeam_target - x + diff_y = ybeam_target - y + + print("\n--- Final result ---") + print( + f"Beam position: X={x:.2f}, Y={y:.2f}\n" + f"Residual: X={diff_x:+.2f} px, " + f"Y={diff_y:+.2f} px" + ) + + final_vfm = get_value(dev.vfm_ydr) + final_hfm = get_value(dev.hfm_xd) + + print( + f"VFM: {vfm_start:.6f} -> {final_vfm:.6f}\n" f"HFM: {hfm_start:.6f} -> {final_hfm:.6f}" + )