diff --git a/dcm_lookup_tables.org b/dcm_lookup_tables.org index 90b6344..8b87666 100644 --- a/dcm_lookup_tables.org +++ b/dcm_lookup_tables.org @@ -88,8 +88,8 @@ In this section, we suppose that we are in the frame of one fast jack (all trans Let's say with make a Bragg angle scan between 10deg and 60deg during 100s. #+begin_src matlab Fs = 10e3; % Sample Frequency [Hz] -t = 0:1/Fs:100; % Time vector [s] -theta = linspace(10, 60, length(t)); % Bragg Angle [deg] +t = 0:1/Fs:10; % Time vector [s] +theta = linspace(10, 40, length(t)); % Bragg Angle [deg] #+end_src The IcePAP steps are following the theoretical formula: @@ -190,28 +190,54 @@ exportFig('figs/generated_lut_icepap.pdf', 'width', 'wide', 'height', 'normal'); #+RESULTS: [[file:figs/generated_lut_icepap.png]] -We can see that the LUT is *not* the motion error (Figure [[fig:lut_correct_and_motion_error]]). +The current LUT implementation is the following: #+begin_src matlab motion_error_lut = zeros(size(lut_range)); for i = 1:length(lut_range) % Get points indices where the icepap step is close to the wanted one close_points = icepap_steps > 1e-6*lut_range(i) - 500e-9 & icepap_steps < 1e-6*lut_range(i) + 500e-9; % Get the corresponding motion error - motion_error_lut(i) = lut_range(i) - 1e6*mean(measured_motion(close_points)); % [um] + motion_error_lut(i) = lut_range(i) + (lut_range(i) - round(1e6*mean(measured_motion(close_points)))); % [um] end #+end_src +Let's compare the two Lookup Table in Figure [[fig:lut_comparison_two_methods]]. +#+begin_src matlab :exports none +%% Comparison of the two Generated Lookup Table +figure; +hold on; +plot(lut_range, lut, ... + 'DisplayName', 'New LUT'); +plot(lut_range, motion_error_lut, ... + 'DisplayName', 'Old LUT'); +hold off; +xlabel('IcePAP input step [um]'); ylabel('Lookup Table output [um]'); +legend('location', 'southeast'); +#+end_src + +#+begin_src matlab :tangle no :exports results :results file replace +exportFig('figs/lut_comparison_two_methods.pdf', 'width', 'wide', 'height', 'normal'); +#+end_src + +#+name: fig:lut_comparison_two_methods +#+caption: Comparison of the two lookup tables +#+RESULTS: +[[file:figs/lut_comparison_two_methods.png]] + +If we plot the "corrected steps" for all steps for both methods, we clearly see the difference (Figure [[fig:lut_correct_and_motion_error]]). + #+begin_src matlab :exports none %% Corrected motion and motion error at each step position figure; hold on; plot(lut_range, lut-lut_range, ... - 'DisplayName', 'Lookup Table Correction'); -plot(lut_range, motion_error_lut, ... - 'DisplayName', 'Motion Error'); + 'DisplayName', 'New LUT'); +plot(lut_range, motion_error_lut-lut_range, ... + 'DisplayName', 'Old LUT'); hold off; xlabel('IcePAP Steps [um]'); ylabel('Corrected motion [um]'); ylim([-110, 110]) +legend('location', 'southeast'); #+end_src #+begin_src matlab :tangle no :exports results :results file replace @@ -223,6 +249,53 @@ exportFig('figs/lut_correct_and_motion_error.pdf', 'width', 'wide', 'height', 'n #+RESULTS: [[file:figs/lut_correct_and_motion_error.png]] +Let's now implement both LUT to see which implementation is correct. +#+begin_src matlab :exports none +icepap_steps_output_new = lut(round(1e6*icepap_steps)-lut_range(1)+1); +i = round(1e6*icepap_steps)-motion_error_lut(1)+1; +i(i>length(motion_error_lut)) = length(motion_error_lut); +icepap_steps_output_old = motion_error_lut(i); +#+end_src + +#+begin_src matlab +motion_new = zeros(size(icepap_steps_output_new)); +motion_old = zeros(size(icepap_steps_output_old)); + +for i = 1:length(icepap_steps_output_new) + [~, i_step] = min(abs(icepap_steps_output_new(i) - 1e6*icepap_steps)); + motion_new(i) = measured_motion(i_step); + + [~, i_step] = min(abs(icepap_steps_output_old(i) - 1e6*icepap_steps)); + motion_old(i) = measured_motion(i_step); +end +#+end_src + +#+begin_src matlab :exports none +%% Measured Motion and Idealized Motion +% Use only middle motion where the LUT is working +i = round(0.1*length(icepap_steps)):round(0.9*length(icepap_steps)); +figure; +hold on; +plot(icepap_steps(i), motion_new(i), ... + 'DisplayName', 'Motion (new LUT)'); +plot(icepap_steps(i), motion_old(i), ... + 'DisplayName', 'Motion (old LUT)'); +plot(icepap_steps(i), perfect_motion(i), 'k--', ... + 'DisplayName', 'Ideal Motion'); +hold off; +xlabel('IcePAP Steps [m]'); ylabel('Measured Motion [m]'); +legend('location', 'southeast'); +#+end_src + +#+begin_src matlab :tangle no :exports results :results file replace +exportFig('figs/compare_old_new_lut_motion.pdf', 'width', 'wide', 'height', 'normal'); +#+end_src + +#+name: fig:compare_old_new_lut_motion +#+caption: Comparison of the obtained motion with new and old LUT +#+RESULTS: +[[file:figs/compare_old_new_lut_motion.png]] + * Attocube Calibration :noexport: diff --git a/dcm_lookup_tables.pdf b/dcm_lookup_tables.pdf index 3a91be3..2af41b5 100644 Binary files a/dcm_lookup_tables.pdf and b/dcm_lookup_tables.pdf differ diff --git a/figs/bragg_angle_icepap_steps_idealized.pdf b/figs/bragg_angle_icepap_steps_idealized.pdf index d24048a..4f172b7 100644 Binary files a/figs/bragg_angle_icepap_steps_idealized.pdf and b/figs/bragg_angle_icepap_steps_idealized.pdf differ diff --git a/figs/bragg_angle_icepap_steps_idealized.png b/figs/bragg_angle_icepap_steps_idealized.png index b44d6d8..85366fa 100644 Binary files a/figs/bragg_angle_icepap_steps_idealized.png and b/figs/bragg_angle_icepap_steps_idealized.png differ diff --git a/figs/compare_old_new_lut_motion.pdf b/figs/compare_old_new_lut_motion.pdf new file mode 100644 index 0000000..bddc8d9 Binary files /dev/null and b/figs/compare_old_new_lut_motion.pdf differ diff --git a/figs/compare_old_new_lut_motion.png b/figs/compare_old_new_lut_motion.png new file mode 100644 index 0000000..7a3fc69 Binary files /dev/null and b/figs/compare_old_new_lut_motion.png differ diff --git a/figs/generated_lut_icepap.pdf b/figs/generated_lut_icepap.pdf index 928ada8..557c5de 100644 Binary files a/figs/generated_lut_icepap.pdf and b/figs/generated_lut_icepap.pdf differ diff --git a/figs/generated_lut_icepap.png b/figs/generated_lut_icepap.png index 54b2d36..95fe6d0 100644 Binary files a/figs/generated_lut_icepap.png and b/figs/generated_lut_icepap.png differ diff --git a/figs/lut_comparison_two_methods.pdf b/figs/lut_comparison_two_methods.pdf new file mode 100644 index 0000000..4d1446a Binary files /dev/null and b/figs/lut_comparison_two_methods.pdf differ diff --git a/figs/lut_comparison_two_methods.png b/figs/lut_comparison_two_methods.png new file mode 100644 index 0000000..a2c9093 Binary files /dev/null and b/figs/lut_comparison_two_methods.png differ diff --git a/figs/lut_correct_and_motion_error.pdf b/figs/lut_correct_and_motion_error.pdf index 4b8533b..6cfa30e 100644 Binary files a/figs/lut_correct_and_motion_error.pdf and b/figs/lut_correct_and_motion_error.pdf differ diff --git a/figs/lut_correct_and_motion_error.png b/figs/lut_correct_and_motion_error.png index fc36238..199ba61 100644 Binary files a/figs/lut_correct_and_motion_error.png and b/figs/lut_correct_and_motion_error.png differ diff --git a/figs/measured_and_ideal_motion_fast_jacks.pdf b/figs/measured_and_ideal_motion_fast_jacks.pdf index 8a160a2..fcd379e 100644 Binary files a/figs/measured_and_ideal_motion_fast_jacks.pdf and b/figs/measured_and_ideal_motion_fast_jacks.pdf differ diff --git a/figs/measured_and_ideal_motion_fast_jacks.png b/figs/measured_and_ideal_motion_fast_jacks.png index 92d7029..952e4bb 100644 Binary files a/figs/measured_and_ideal_motion_fast_jacks.png and b/figs/measured_and_ideal_motion_fast_jacks.png differ