From 6cc4b47709a951c2708565e009f61199813d60b2 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Tue, 17 Jun 2025 13:53:41 +0200 Subject: [PATCH] Added manual method to isolate resonances --- Estimations/LinearizeScatteringLengthScan.m | 57 +++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Estimations/LinearizeScatteringLengthScan.m b/Estimations/LinearizeScatteringLengthScan.m index 271d2e5..38df7a6 100644 --- a/Estimations/LinearizeScatteringLengthScan.m +++ b/Estimations/LinearizeScatteringLengthScan.m @@ -65,6 +65,63 @@ ylim([0 150]) set(gca, 'FontSize', 14) grid on; +%% Isolate from spectrum manually + +% Get the full spectrum +[B, a_s] = getFullFeschbachSpectrum(1, 2); % Using new FR params and middle a_bkg + +% Define the plotting range +x_limits = [1.15, 2.7]; +y_limits = [0, 150]; + +% Find indices within our x-range +mask = (B >= x_limits(1)) & (B <= x_limits(2)); +B_plot = B(mask); +a_s_plot = a_s(mask); + +% Identify resonances to mask (looking at the spectrum, we'll mask around 2.174G and 2.336G) +resonances_to_mask = [2.174, 2.336]; +mask_width = 0.1; % Width to mask around each resonance (in G) + +% Create a mask for the regions to keep (1 = keep, 0 = mask) +keep_mask = true(size(B_plot)); +for res = resonances_to_mask + keep_mask = keep_mask & (B_plot < (res - mask_width) | B_plot > (res + mask_width)); +end + +% Create masked version +B_masked = B_plot(keep_mask); +a_s_masked = a_s_plot(keep_mask); + +% Interpolate over the masked regions +a_s_interp = interp1(B_masked, a_s_masked, B_plot, 'pchip'); + +% Plotting +figure(3); +hold on; + +% Plot the original spectrum +plot(B_plot, a_s_plot, 'b-', 'DisplayName', 'Original spectrum'); + +% Plot the masked regions in red +for res = resonances_to_mask + mask_region = (B_plot >= (res - mask_width)) & (B_plot <= (res + mask_width)); + plot(B_plot(mask_region), a_s_plot(mask_region), 'r-', 'LineWidth', 2, 'DisplayName', 'Unwanted Resonance'); +end + +% Plot the interpolated curve +plot(B_plot, a_s_interp, 'g--', 'LineWidth', 1.5, 'DisplayName', 'Interpolated'); + +% Formatting +xlim(x_limits); +ylim(y_limits); +xlabel('Magnetic Field (G)'); +ylabel('Scattering Length (a_0)'); +title('Dy-164 Feshbach Spectrum with Masked Resonances'); +legend('Location', 'best'); +grid on; +hold off; + %% Helper functions function [t, B_ramp, a_check] = generateSmoothBRamp(FR_choice, ABKG_choice, a_start, a_end, selectedResRange, T, Nt, opts) % Time array