Files
Zcu111ResmReceiver/utilities/post_processing/checkFreqSamples.m
canisio 6093942ab3 include check scripts to the project.
changed pulseWidth to pulseT.
2026-04-28 15:22:03 -03:00

87 lines
2.7 KiB
Matlab

%% =========================================================
% Data
% =========================================================
X = single(raw_DPW.Data); % [512 x nFrames x nTime]
X = X(:,:,2:end); % First DPW is zeroed
X = 2*X; % Rescale (see channelizer block on PL)
[nSamples, nFrames, nTime] = size(X);
N = nSamples;
%% =========================================================
% Parameters
% =========================================================
Fs = 512e6; % Hz
f_axis = (-N/2 : N/2-1) * (Fs/N) / 1e6; % MHz
%% =========================================================
% Apply fftshift per frame (dim = 1)
% =========================================================
X_shift = fftshift(X, 1);
%% =========================================================
% Convert to power
% =========================================================
P = abs(X_shift).^2;
%% =========================================================
% OPTION 1 — Mean Spectrum (over frames AND time)
% =========================================================
P_mean = mean(P, [2 3]); % average over frames and triggers
P_mean = squeeze(P_mean); % [512 x 1]
figure;
plot(f_axis, 10*log10(P_mean + 1e-12), 'LineWidth', 1.5);
grid on;
xlabel('Frequency (MHz)');
ylabel('Power (dB)');
title('Mean Channelized Spectrum (Frames + Time)');
%% =========================================================
% OPTION 2 — Max Spectrum (detect intermittent peaks)
% =========================================================
P_max = max(P, [], [2 3]);
P_max = squeeze(P_max);
figure;
plot(f_axis, 10*log10(P_max + 1e-12), 'LineWidth', 1.5);
grid on;
xlabel('Frequency (MHz)');
ylabel('Power (dB)');
title('Max Channelized Spectrum (Frames + Time)');
%% =========================================================
% OPTION 3 — Time-Frequency Visualization
% =========================================================
% Collapse frames → keep time evolution
P_time = squeeze(mean(P, 2)); % [512 x nTime]
figure;
surf(1:nTime, f_axis, 10*log10(P_time + 1e-12), 'EdgeColor','none');
view(2);
axis tight;
xlabel('Trigger Index');
ylabel('Frequency (MHz)');
title('Channelizer Output Over Time');
colorbar;
%% =========================================================
% OPTIONAL — Frame evolution inside a single trigger
% =========================================================
t_sel = 5; % pick last capture
P_frame = squeeze(P(:,:,t_sel)); % [512 x nFrames]
figure;
surf(1:nFrames, f_axis, 10*log10(P_frame + 1e-12), 'EdgeColor','none');
view(2);
axis tight;
xlabel('Frame Index');
ylabel('Frequency (MHz)');
title(['Channelizer Output Within DPW (Trigger ', num2str(t_sel), ')']);
colorbar;