Added manual method to isolate resonances

This commit is contained in:
Karthik 2025-06-17 13:53:41 +02:00
parent 2abd72bd60
commit 6cc4b47709

View File

@ -65,6 +65,63 @@ ylim([0 150])
set(gca, 'FontSize', 14) set(gca, 'FontSize', 14)
grid on; 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 %% Helper functions
function [t, B_ramp, a_check] = generateSmoothBRamp(FR_choice, ABKG_choice, a_start, a_end, selectedResRange, T, Nt, opts) function [t, B_ramp, a_check] = generateSmoothBRamp(FR_choice, ABKG_choice, a_start, a_end, selectedResRange, T, Nt, opts)
% Time array % Time array