MPI plotting stuff
This commit is contained in:
@@ -15,12 +15,13 @@ end
|
||||
|
||||
%% Execution toggles
|
||||
|
||||
run_conventional_ffe = 0;
|
||||
run_hpf = 1;
|
||||
run_a2_tracked_levels = 0;
|
||||
run_a2_residual = 0;
|
||||
run_a1 = 0;
|
||||
run_tracking_adaptive = 0;
|
||||
run_conventional_ffe = 1;
|
||||
run_ma = 0;
|
||||
run_hpf = 0;
|
||||
run_a2_tracked_levels = 1;
|
||||
run_a2_residual = 1;
|
||||
run_a1 = 1;
|
||||
run_tracking_adaptive = 1;
|
||||
plot_output_signals = 0;
|
||||
|
||||
%% Shared fixed EQ settings
|
||||
@@ -75,12 +76,68 @@ if run_conventional_ffe
|
||||
"plain_ffe", "baseline", block_update);
|
||||
output.(char(storageName)) = ffe_results;
|
||||
|
||||
eq_noise_ffe = equalized_signal - Symbols;
|
||||
|
||||
|
||||
if plot_output_signals
|
||||
plotEqSignals(equalized_signal,Symbols,options,400,-1);
|
||||
end
|
||||
end
|
||||
|
||||
%% Conventional FFE
|
||||
|
||||
%% Moving Average Filter -> Conventional FFE
|
||||
if run_ma
|
||||
eq_ffe = FFE_plain( ...
|
||||
"sps", eq_sps, ...
|
||||
"order", eq_order, ...
|
||||
"decide", false, ...
|
||||
"adaption_technique", eq_adaption, ...
|
||||
"len_tr", eq_len_tr, ...
|
||||
"epochs_tr", eq_epochs_tr, ...
|
||||
"mu_tr", eq_mu_tr, ...
|
||||
"dd_mode", true, ...
|
||||
"epochs_dd", eq_epochs_dd, ...
|
||||
"mu_dd", 0.0012, ...
|
||||
"optmize_mus", false, ...
|
||||
"plot_mu_optimization", options.debug_plots, ...
|
||||
"save_debug", eq_save_debug);
|
||||
|
||||
%%% APPLY MA filter
|
||||
movavg_window_length = options.userParameters.bufferlen;
|
||||
movavg_window_symmetry = "causal"; % "causal" or "noncausal"
|
||||
|
||||
switch movavg_window_symmetry
|
||||
case "causal"
|
||||
dc_estimate = movmean(Scpe_sig.signal, ...
|
||||
[movavg_window_length-1,0],"Endpoints","shrink");
|
||||
case "noncausal"
|
||||
dc_estimate = movmean(Scpe_sig.signal, ...
|
||||
movavg_window_length,"Endpoints","shrink");
|
||||
otherwise
|
||||
error("mpi_recipe_dev:InvalidMovAvgSymmetry", ...
|
||||
"movavg_window_symmetry must be 'causal' or 'noncausal'.");
|
||||
end
|
||||
|
||||
Scpe_sig_filt = Scpe_sig;
|
||||
Scpe_sig_filt.signal = Scpe_sig.signal - dc_estimate;
|
||||
clear dc_estimate;
|
||||
|
||||
storageName = "MovAvg_plus_conventional_FFE";
|
||||
[ffe_results,equalized_signal] = runFfe(eq_ffe, "Moving-average + conventional FFE", ...
|
||||
Scpe_sig_filt, Symbols, Tx_bits, options);
|
||||
clear Scpe_sig_filt;
|
||||
ffe_results = attachMpiReductionConfig(ffe_results, eq_ffe, storageName, ...
|
||||
"MovAvg_plus_conventional_FFE", char(movavg_window_symmetry), block_update);
|
||||
output.(char(storageName)) = ffe_results;
|
||||
|
||||
if plot_output_signals
|
||||
plotEqSignals(equalized_signal,Symbols,options,400,-1);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
%% High Pass Filter -> Conventional FFE
|
||||
if run_hpf
|
||||
eq_ffe = FFE_plain( ...
|
||||
"sps", eq_sps, ...
|
||||
@@ -99,11 +156,12 @@ if run_hpf
|
||||
|
||||
%%% APPLY HPF in MHZ order
|
||||
f = Filter("f_cutoff",options.userParameters.hpf,"filterType","butterworth","lowpass",0,"filtdegree",4,"fs",options.fsym*2);
|
||||
Scpe_sig = f.process(Scpe_sig);
|
||||
Scpe_sig_filt = f.process(Scpe_sig);
|
||||
|
||||
storageName = "HPF_plus_conventional_FFE";
|
||||
[ffe_results,equalized_signal] = runFfe(eq_ffe, "Conventional FFE", ...
|
||||
Scpe_sig, Symbols, Tx_bits, options);
|
||||
Scpe_sig_filt, Symbols, Tx_bits, options);
|
||||
clear Scpe_sig_filt;
|
||||
ffe_results = attachMpiReductionConfig(ffe_results, eq_ffe, storageName, ...
|
||||
"HPF_plus_conventional_FFE", "hpf", block_update);
|
||||
output.(char(storageName)) = ffe_results;
|
||||
@@ -191,7 +249,7 @@ if run_a1
|
||||
"epochs_dd", eq_epochs_dd, ...
|
||||
"mu_dd", 0.012, ...
|
||||
"dc_smoothing_a1", 1, ...
|
||||
"dc_avg_bufferlength_a1", 2048, ...
|
||||
"dc_avg_bufferlength_a1", 2048, ... %was 2048
|
||||
"dc_avg_update_blocklength_a1", block_update, ...
|
||||
"save_debug", eq_save_debug);
|
||||
|
||||
@@ -238,7 +296,19 @@ if run_tracking_adaptive
|
||||
"dc_tracking", "adaptive", block_update);
|
||||
output.(char(storageName)) = ffe_results;
|
||||
|
||||
% fignum = 106;
|
||||
%
|
||||
% eq_noise = equalized_signal - Symbols;
|
||||
% dn = sprintf("FFE DCT; SIR: %d dB",options.dataTable.sir);
|
||||
% showEQNoisePSD(eq_noise, "fignum", fignum, "displayname", dn,"colormode","diverging");
|
||||
% ylim([-70 -30]);
|
||||
%
|
||||
% dn = sprintf("FFE only; SIR: %d dB",options.dataTable.sir);
|
||||
% showEQNoisePSD(eq_noise_ffe, "fignum", fignum+1, "displayname", dn,"colormode","diverging");
|
||||
% ylim([-70 -30]);
|
||||
|
||||
if plot_output_signals
|
||||
|
||||
plotEqSignals(equalized_signal,Symbols,options,450,-1);
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,8 +5,14 @@ arguments
|
||||
options.fignum (1,1) double = NaN % Default to NaN if not provided
|
||||
options.displayname (1,:) char = '' % Default to an empty string if not provided
|
||||
options.color = [];
|
||||
options.colormode (1,1) string {mustBeMember(options.colormode, ["diverging", "qualitative", "paired"])} = "diverging";
|
||||
end
|
||||
|
||||
persistent nextGroupIdx
|
||||
if isempty(nextGroupIdx)
|
||||
nextGroupIdx = 0;
|
||||
end
|
||||
|
||||
% Determine the figure number to use or create a new figure
|
||||
if isnan(options.fignum)
|
||||
fig = figure; % Create a new figure and get its handle
|
||||
@@ -15,16 +21,16 @@ end
|
||||
end
|
||||
hold on
|
||||
ax = gca;
|
||||
% N = numel(ax.Children);
|
||||
if isempty(options.color)
|
||||
N = sum(arrayfun(@(x) strcmp(x.LineStyle, '-'), ax.Children));
|
||||
cmap = linspecer(8);
|
||||
options.color = cmap(mod(N, size(cmap, 1)) + 1, :);
|
||||
linesBefore = findall(ax, 'Type', 'Line');
|
||||
|
||||
useAutomaticColor = isempty(options.color);
|
||||
if useAutomaticColor
|
||||
options.color = selectEQNoisePSDColor(ax, options.colormode);
|
||||
end
|
||||
|
||||
% Ensure the figure is ready before calling spectrum
|
||||
eq_noise = eq_noise - mean(eq_noise.signal);
|
||||
eq_noise.spectrum("displayname", options.displayname, "fignum", fig.Number, "normalizeTo0dB", 0,"color",options.color,"fft_length",4096*2);
|
||||
eq_noise.spectrum("displayname", options.displayname, "fignum", fig.Number, "normalizeTo0dB", 0,"color",options.color,"fft_length",4096);
|
||||
|
||||
if ~isnan(options.postfilter_taps)
|
||||
% Hold on to the figure for further plotting
|
||||
@@ -44,7 +50,88 @@ end
|
||||
legend('show');
|
||||
end
|
||||
|
||||
if useAutomaticColor
|
||||
nextGroupIdx = nextGroupIdx + 1;
|
||||
newLines = getNewLines(ax, linesBefore);
|
||||
tagEQNoisePSDLines(newLines, nextGroupIdx);
|
||||
recolorEQNoisePSDLines(ax, options.colormode);
|
||||
end
|
||||
|
||||
xlim([-eq_noise.fs/2* 1e-9 eq_noise.fs/2* 1e-9]);
|
||||
% ylim([-15, 0]);
|
||||
|
||||
end
|
||||
|
||||
function color = selectEQNoisePSDColor(ax, colormode)
|
||||
if colormode == "qualitative"
|
||||
N = sum(arrayfun(@(x) strcmp(x.LineStyle, '-'), ax.Children));
|
||||
cmap = linspecer(8);
|
||||
color = cmap(mod(N, size(cmap, 1)) + 1, :);
|
||||
else
|
||||
color = [0 0 0];
|
||||
end
|
||||
end
|
||||
|
||||
function newLines = getNewLines(ax, linesBefore)
|
||||
linesAfter = findall(ax, 'Type', 'Line');
|
||||
newLines = linesAfter(~ismember(linesAfter, linesBefore));
|
||||
end
|
||||
|
||||
function tagEQNoisePSDLines(lines, groupIdx)
|
||||
for lineIdx = 1:numel(lines)
|
||||
setappdata(lines(lineIdx), 'showEQNoisePSDGroupIdx', groupIdx);
|
||||
end
|
||||
end
|
||||
|
||||
function recolorEQNoisePSDLines(ax, colormode)
|
||||
if colormode == "qualitative"
|
||||
return
|
||||
end
|
||||
|
||||
lines = findall(ax, 'Type', 'Line');
|
||||
groupIdx = NaN(size(lines));
|
||||
|
||||
for lineIdx = 1:numel(lines)
|
||||
if isappdata(lines(lineIdx), 'showEQNoisePSDGroupIdx')
|
||||
groupIdx(lineIdx) = getappdata(lines(lineIdx), 'showEQNoisePSDGroupIdx');
|
||||
end
|
||||
end
|
||||
|
||||
lines = lines(~isnan(groupIdx));
|
||||
groupIdx = groupIdx(~isnan(groupIdx));
|
||||
|
||||
if isempty(lines)
|
||||
return
|
||||
end
|
||||
|
||||
groups = unique(groupIdx, 'stable');
|
||||
groups = sort(groups);
|
||||
cols = getEQNoisePSDColormap(colormode, numel(groups));
|
||||
|
||||
for groupColorIdx = 1:numel(groups)
|
||||
sameGroup = groupIdx == groups(groupColorIdx);
|
||||
set(lines(sameGroup), 'Color', cols(groupColorIdx, :));
|
||||
end
|
||||
end
|
||||
|
||||
function cols = getEQNoisePSDColormap(colormode, numColors)
|
||||
switch colormode
|
||||
case "paired"
|
||||
cols = cbrewer2('paired', numColors);
|
||||
otherwise
|
||||
cols = getDivergingWithoutBrightCenter(numColors);
|
||||
end
|
||||
end
|
||||
|
||||
function cols = getDivergingWithoutBrightCenter(numColors)
|
||||
numBaseColors = max(6, numColors);
|
||||
centerExcludeFraction = 0.3;
|
||||
|
||||
baseCols = cbrewer2('RdYlBu', numBaseColors);
|
||||
centerIdx = (numBaseColors + 1) / 2;
|
||||
excludeHalfWidth = centerExcludeFraction * numBaseColors / 2;
|
||||
keepIdx = find(abs((1:numBaseColors) - centerIdx) > excludeHalfWidth);
|
||||
sampleIdx = round(linspace(1, numel(keepIdx), numColors));
|
||||
|
||||
cols = baseCols(keepIdx(sampleIdx), :);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user