Files
imdd_silas/projects/Diss/MPI_revisit/plot_mpi_timesignals.m
2026-07-15 17:54:31 +02:00

150 lines
5.7 KiB
Matlab

% Diesen PLot habe ich in der Diss als Tabelle
% Create a compact 3-column by 4-row MPI time-signal figure table in LaTeX.
%
% Use these plots from 04_Experimental_Evaluation/tikz/mpi/:
% - columns: SIR = 20 dB, 30 dB, 50 dB
% - rows: path length = 1 m, 20 m, 300 m, 1000 m
% - file pattern: mpi_timesignal_<pathlen>m_<sir>_db.tikz
%
% Use a tabular layout with thin black table gridlines:
% - \arrayrulewidth = 0.2pt
% - \arrayrulecolor{black}
% - vertical and horizontal rules around all cells
% - rotated row labels for 1 m, 20 m, 300 m, 1000 m
% - center the rotated row labels vertically against the plot cells
% - use a dedicated left-column macro so the SIR 20 dB plots are slightly wider:
% - left column fwidth = 0.255\textwidth
% - inner columns fwidth = 0.240\textwidth
% - all fheight = 0.102\textheight
%
% For the TikZ plot files used in the table:
% - leftmost/SIR 20 dB plots keep the y-label:
% ylabel={Norm. Amplitude}
% - SIR 30 dB and 50 dB plots have no y-label:
% ylabel={}
% - SIR 30 dB and 50 dB plots hide y ticks:
% ytick=\empty
% - axis labels and tick labels use scriptsize:
% every axis/.append style={font=\scriptsize}
% xlabel style={font=\color{white!15!black}\scriptsize}
% ylabel style={font=\color{white!15!black}\scriptsize}
% - sigma annotation node boxes use tiny:
% \node[font=\tiny, ...]
% - node boxes:
% inner sep=0.5pt
% at (axis cs:10,...)
% sigma labels use normal math subscripts, e.g. $\sigma^2_2$, not $\sigma^2\_2$
% - all plotted line widths and grid style widths were normalized as needed:
% addplot line width=1.0pt
% - grid should be visually off:
% remove xmajorgrids and ymajorgrids
% keep style definitions available:
% grid style={line width=0.4pt, solid, color=black!20}
% minor grid style={line width=0.2pt, solid, color=black!10}
%
% db = DBHandler("type","mysql","dataBase",'labor');
% savePath = 'W:\labdata\ECOC Silas\ecoc_2025\';
for sirval = [20,30,50]
for pathlen = [1,20,300,1000]
fp = QueryFilter();
% fp.where('Runs', 'run_id','EQUALS', 987);
M = 4;
fp.where('Runs', 'pam_level','EQUALS', M);
% fp.where('Runs', 'symbolrate','NOT_EQUAL', 112e9);
fp.where('Runs', 'fiber_length','EQUALS', 0);
fp.where('Runs', 'is_mpi','EQUALS', 1);
fp.where('Runs', 'interference_path_length','EQUALS', pathlen);
% fp.where('Runs', 'loop_id','GREATER_THAN', 11);
fp.where('Runs', 'sir','GREATER_EQUAL',sirval);
fp.where('Runs','run_id','GREATER_EQUAL',3153);
% Sort results by SIR value ascending and reorder corresponding rows
[dataTable,sql_query] = db.queryDB(fp, db.getTableFieldNames('Runs'));
[~, idx] = sort(dataTable.sir, 'ascend', 'MissingPlacement', 'last');
dataTable = dataTable(idx, :);
dataTable = dataTable(1,:);
dataTable_ = dataTable;
[~, uniqueIdx] = unique(dataTable.run_id); % Get unique run_id indices
% dataTable.SIR = -7 - round(dataTable.power_mpi_interference);
fsym = dataTable.symbolrate;
M = double(dataTable_.pam_level);
duob_mode = db_mode.(strrep(char(dataTable_.db_mode),'"',''));
Tx_signal = load([savePath, char(dataTable_.tx_signal_path),'.mat']);
Tx_signal = Tx_signal.Digi_sig;
Tx_bits = load([savePath, char(dataTable_.tx_bits_path)]);
Tx_bits = Tx_bits.Bits;
Symbols_mapped = PAMmapper(M,0).map(Tx_bits);
Symbols_mapped.fs = dataTable_.symbolrate;
Symbols = load([savePath, char(dataTable_.tx_symbols_path)]);
Symbols = Symbols.Symbols;
Scpe_sig_raw = load([savePath, char(dataTable_.rx_raw_path(1))]);
Scpe_sig_raw = Scpe_sig_raw.Scpe_sig_raw;
Scpe_sig_raw = Scpe_sig_raw.normalize("mode","rms");
% Scpe_sig_raw.plot("displayname",['Scope Signal (Run ID: ',num2str(dataTable_.run_id)],"fignum",dataTable_.run_id,"clear",0);
%
% Scpe_sig_raw.spectrum("normalizeTo0dB",1);
disp(num2str(dataTable_.interference_path_length));
% Scpe_sig_raw.eye(dataTable.symbolrate,dataTable.pam_level);
[separated_levels_sig, avg_sig, plotInfo] = showLevelScatter(Scpe_sig_raw, Symbols, ...
"fsym", fsym, ...
"syncFs", 2*fsym, ...
"fignum", sirval+pathlen, ...
"normalize", true, ...
"debug_plots", false, ...
"showPlot", true, ...
"showStdAnnotations", true, ...
"yLimits", [-2.5 2.5], ...
"xLimits",[0 25],...
"scatterAlpha", 0.25, ...
"scatterSize", 1, ...
"avgLineMaxPoints", 500, ...
"avgLineSmoothWindow", 5);
title(sprintf("%d m, %d db", pathlen,sirval));
exportDir = "C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/04_Experimental_Evaluation/tikz/mpi";
exportName = string(sprintf("mpi_timesignal_v2_%dm_%d_db", pathlen,sirval));
pngFile = fullfile(exportDir, exportName + "-1.png");
tikzFile = fullfile(exportDir, exportName + ".tikz");
pngTikzPath = "04_Experimental_Evaluation/tikz/mpi/" + exportName + "-1.png";
figure(sirval + pathlen);
exportLevelScatterTikz(gca, pngFile, tikzFile, pngTikzPath, ...
"resolutionDpi", 150, ...
"generatedBy", "plot_mpi_timesignal.m");
end
end
%%
% std_levels = std(separated_levels_sig,0,2,'omitnan');
% mean_levels = mean(separated_levels_sig,2,'omitnan');
% std_tot = std(Scpe_sig_raw.signal,0,1,'omitnan');
%
% var_levels = std_levels.^2;
% p = polyfit(mean_levels, var_levels, 1);
%
% var_slope = p(1);
% var_offset = p(2);c