- bring FWM plots back to life!

- some dispersion plots with the great help of chatGPT :-D
This commit is contained in:
Silas Oettinghaus
2025-10-17 11:50:27 +02:00
parent 99898da519
commit 3ea6439947
13 changed files with 720 additions and 62 deletions

View File

@@ -5,6 +5,16 @@
wh = load([path filesep file]);
wh = wh.wh;
% fields = fieldnames(wh.parameter);
% for k = 1:numel(fields)
% oldParam = wh.parameter.(fields{k});
% % copy over the properties to your new class
% wh.parameter.(fields{k}) = StorageParameter(...
% oldParam.Name, oldParam.values);
% end
%
plotJob = struct();
width = 350;
height = 200;
@@ -17,15 +27,15 @@ plotJob.d = 0;
plotJob.sgm = 0;
plotJob.pol = "copolarized";
plotJob.p_in = 3;
plotJob.gamma = 0;
plotJob.pmd = 0;
plotJob.gamma = 0.0023;
plotJob.pmd = 0.1;
plotJob.channelspacing = 400e9;
plotJob.randzdw = 0;
plotJob.plot_ber_curve = 1;
plotJob.plot_ber_curve = 0;
plotJob.plot_3dber_curve = 0;
plotJob.plot_violin = 0;
plotJob.plot_violin = 1;
plotJob.plot_wavelength_sweep = 0;
plotJob.plot_wavelength_sweep_failure_rate = 0;
@@ -34,13 +44,20 @@ plotJob.dataStatArg = 'Lineplot with quartiles';
plotJob.plotTypeArg = 'Lines';
plotJob.displayname = 'a';
plotJob.title = 'title';
plotJob.figName = '16 Chann__';
plotJob.figName = '16 Chann';
plotJob.xAxisLabel = 'ROP per Channel in dBm';
plotJob.yAxisLabel = 'BER';
% createbercurves(wh,plotJob)
createviolinplots(wh,plotJob);
% createsweepplots(wh,plotJob);
%%
% createbercurves(wh,plotJob)
P = [3,6];
for i = 1:2
plotJob.p_in = P(i);
createviolinplots(wh,plotJob);
end
% createsweepplots(wh,plotJob);
%% 1
@@ -64,7 +81,7 @@ D = [0,0,0,3,0,0,0,3];
Sgm = [0,0,0,1,0,0,0,1];
colidx = [4,8,6];
P_launch = [0,3,6];
P_launch = [3,6];
fig = figure('Name',plotJob.figName);
fig.Position = plotJob.Position;
@@ -81,7 +98,7 @@ for idx = 1:(numRows * numCols)
plotJob.sgm = Sgm(idx);
plotJob.randzdw = 1;
for i = 1:3
for i = 1:length(P_launch)
plotJob.p_in = P_launch(i);
plotJob.color = cols(colidx(i),:);
@@ -199,6 +216,7 @@ end
%% 2
function createviolinplots(wh,plotJob)
width = 350;
height = 200;
s = 100;
@@ -208,30 +226,34 @@ cols = cbrewer2("paired",12);
numRows = 1;
numCols = 4;
plotJob.ch = 16;
plotJob.p_in = 3;
plotJob.randzdw = 0;
plotJob.randzdw = 1;
Pol = ["copolarized","copolarized","alternated","paired",];
Title = ["Co Pol.","Link Segmentation","Paired Pol. Interl.","Alternating Pol. Interl."];
D = [0,3,0,0];
Sgm = [0,1,0,0];
colidx = [2];
Len = [2];
colidx = [3];
Len = [10];
plotJob.figName = ['_Violin',num2str(plotJob.ch),' Channels; ',num2str(plotJob.channelspacing*1e-9),' GHz; ',num2str(plotJob.p_in),' dBm; randomized: ', num2str(plotJob.randzdw)];
fig = figure('Name',plotJob.figName);
fig.Position = plotJob.Position;
fig.Units = "centimeters";
fig.Position = [0 0 18 7];
fig = findall(groot, 'Type', 'figure', 'Name', plotJob.figName);
if isvalid(fig)
figure(fig)
% fig = get(fig);
AxesMain = fig.CurrentAxes;
hold on
% t = tiledlayout(1,4,'TileSpacing','compact','Padding','compact');
else
fig = figure('name',char(plotJob.figName));
AxesMain = gca;
hold on; grid on;
% t = tiledlayout(1,4,'TileSpacing','compact','Padding','compact');
end
t = tiledlayout(numRows,numCols,'TileSpacing','compact','Padding','compact');
for idx = 1:(numRows * numCols)
% Create subplot
%subplot(numRows, numCols, idx);
nexttile;
subplot(numRows, numCols, idx);
plotJob.pol = Pol(idx);
plotJob.d = D(idx);
@@ -295,7 +317,6 @@ annotation(fig,'textbox',...
'FontSize',8,...
'FitBoxToText','off');
copygraphics(t,'BackgroundColor','none');
% lgd = legend('$P_{\mathrm{in}}=0$ dBm','$P_{\mathrm{in}}=3$ dBm','$P_{\mathrm{in}}=6$ dBm','Interpreter','latex');
% lgd.NumColumns = 3;
% lgd.Layout.Tile = 'south';

View File

@@ -0,0 +1,137 @@
% Select dataset
[file, path] = uigetfile("C:\Users\Silas\Documents\MATLAB\Datensätze\Raw_Cluster_Simulations\session_februar_24\wh_mi_nacht.mat");
wh = load(fullfile(path, file));
wh = wh.wh;
%% --- Plot Settings ---
cols = cbrewer2("Paired", 12);
plotJob = struct();
plotJob.Position = [100 100 600 400];
plotJob.channelspacing = 400e9;
plotJob.ch = 16;
plotJob.d = 0;
plotJob.sgm = 0;
plotJob.gamma = 0.0023;
plotJob.pmd = 0.1;
plotJob.randzdw = 1;
plotJob.plot_ber_curve = 1;
plotJob.xAxisLabel = 'ROP per $\lambda$ [dBm]';
plotJob.yAxisLabel = 'BER';
plotJob.figName = 'avg BER_vs_Plaunch_combined';
plotJob.dataStatArg = 'Lineplot with quartiles';%'All Channels; mean(PMD Realizations)';Lineplot with quartiles
plotJob.plotTypeArg = 'Lines';
plotJob.displayname = 'bla';
% --- Parameter combinations ---
Len = [2, 10];
Pol = ["copolarized", "copolarized", "alternated", "paired"];
Title = ["CoPol","LS", "API", "PPI"];
D = [0, 3, 0, 0];
Sgm = [0, 1, 0, 0];
% Pol = ["copolarized", "copolarized"];
% Title = ["CoPol","LS"];
% D = [0, 3];
% Sgm = [0, 1];
colidx = [6,4,2,2]; % color indices for different schemes
P_launch = [0,3,6]; % input power sweep
%% --- Create Figure ---
fig = findall(groot, 'Type', 'figure', 'Name', plotJob.figName);
if isvalid(fig)
figure(fig)
% fig = get(fig);
AxesMain = fig.CurrentAxes;
hold on
% t = tiledlayout(1,4,'TileSpacing','compact','Padding','compact');
else
fig = figure('name',char(plotJob.figName));
AxesMain = gca;
hold on; grid on;
% t = tiledlayout(1,4,'TileSpacing','compact','Padding','compact');
end
dsa = ["AVG"];
for d = 1
plotJob.dataStatArg = dsa(d);
cnt = 1;
for l = 1:numel(Len)
subplot(1,2,cnt);
cnt = cnt+1;
for s = 1:length(P_launch)
for p = 1:numel(Title)
plotJob.l = Len(l);
plotJob.pol = Pol(p);
plotJob.d = D(p);
plotJob.sgm = Sgm(p);
% color + style per length
baseColor = cols(colidx(p), :);
if s == 1
plotJob.linestyle = '-';
elseif s == 2
plotJob.linestyle = '--';
else
plotJob.linestyle = ':';
end
if p == 1
% plotJob.linestyle = '-';
plotJob.markerstyle = 'o';
plotJob.markersize = 2;
elseif p == 2
% plotJob.linestyle = ':';
plotJob.markerstyle = 'square';
plotJob.markersize = 2;
elseif p == 3
% plotJob.linestyle = '-';
plotJob.markerstyle = 'x';
plotJob.markersize = 6;
else
% plotJob.linestyle = '-';
plotJob.markerstyle = 'diamond';
plotJob.markersize = 2;
end
% if d == 1
% plotJob.linestyle = '-';
% else
% plotJob.linestyle = ':';
% plotJob.markerstyle = 'none';
% end
plotJob.p_in = P_launch(s);
plotJob.displayname = sprintf('%s',Title(p));
plotJob.color = baseColor;% * (1 - 0.15*(p-1)); % slight shade for powers
plotCurve(wh, plotJob);
% h = findobj(gca,'Type','Line','-not','Tag','FEC');
% set(h(p),'DisplayName',sprintf('%s (%.0f km, %.0f dBm)',Title(p),Len(l),P_launch(s)));
% title(sprintf('%d km; %d Channels, \Delta f = %.0f GHz', ...
% plotJob.l, plotJob.ch, plotJob.channelspacing*1e-9));
end
end
end
end
set(gca, 'YScale', 'log');
xlabel(plotJob.xAxisLabel);
ylabel(plotJob.yAxisLabel);
% legend('Interpreter','latex','NumColumns',2,'Location','southoutside');
grid on; box on;
copygraphics(fig, 'BackgroundColor','none');

View File

@@ -6,7 +6,7 @@ fig = findall(groot, 'Type', 'figure', 'Name', plotJob.figName);
if isvalid(fig)
figure(fig)
fig = get(fig);
% fig = get(fig);
AxesMain = fig.CurrentAxes;
hold on
else
@@ -28,32 +28,39 @@ realization = wh.parameter.realization.values(1:end);
% get all xAxis values
xAxis = wh.parameter.p_out.values;
markerstyle = 'o';
linestyle = '-';
% Fetch Data from Warehouse
for xl = 1:numel(xAxis)
p_out = xAxis(xl);
if string(plotJob.dataStatArg) == "Worst"
temp = wh.getStoValue('ber',plotJob.l,plotJob.d,plotJob.sgm,string(plotJob.pol),plotJob.p_in,p_out,plotJob.pmd,plotJob.gamma,realization,plotJob.ch,1310,plotJob.channelspacing,plotJob.randzdw);
temp = removeZeros(temp);
ber(xl) = max(temp,[],'all');
ber(xl) = quantile(temp,0.9,"all");
% ber(xl) = max(temp,[],'all');
linew = 1.0;
markersz = 3;
linestyle = '-';
markersz = plotJob.markersize;
markerstyle = plotJob.markerstyle;
linestyle = plotJob.linestyle;
elseif string(plotJob.dataStatArg) == "AVG"
temp = wh.getStoValue('ber',plotJob.l,plotJob.d,plotJob.sgm,string(plotJob.pol),plotJob.p_in,p_out,plotJob.pmd,plotJob.gamma,realization,plotJob.ch,1310,plotJob.channelspacing,plotJob.randzdw);
temp = removeZeros(temp);
ber(xl) = mean(temp,'all');
linew = 1.0;
markersz = 3;
linestyle = '--';
markersz = plotJob.markersize;
markerstyle = plotJob.markerstyle;
linestyle = plotJob.linestyle;
elseif string(plotJob.dataStatArg) == "Best"
temp = wh.getStoValue('ber',plotJob.l,plotJob.d,plotJob.sgm,string(plotJob.pol),plotJob.p_in,p_out,plotJob.pmd,plotJob.gamma,realization,plotJob.ch,1310,plotJob.channelspacing,plotJob.randzdw);
temp = removeZeros(temp);
ber(xl) = min(temp,[],'all');
linew = 1.0;
markersz = 3;
linestyle = '-';
markersz = plotJob.markersize;
markerstyle = plotJob.markerstyle;
linestyle = plotJob.linestyle;
elseif string(plotJob.dataStatArg) == "All Channels; mean(PMD Realizations)"
temp = wh.getStoValue('ber',plotJob.l,plotJob.d,plotJob.sgm,string(plotJob.pol),plotJob.p_in,p_out,plotJob.pmd,plotJob.gamma,realization,plotJob.ch,1310,plotJob.channelspacing,plotJob.randzdw);
@@ -63,7 +70,8 @@ for xl = 1:numel(xAxis)
linew = 1;
markersz = 1;
linestyle = '-';
markerstyle = plotJob.markerstyle;
linestyle = plotJob.linestyle;
elseif string(plotJob.dataStatArg) == "Lineplot with quartiles"
@@ -75,14 +83,16 @@ for xl = 1:numel(xAxis)
upperq(xl) = quantile(temp,0.99,"all");
lowerq(xl) = quantile(temp,0.04,"all");
if lowerq(xl) == 0
lowerq(xl) = lowerq(xl-1);
end
% upperq(xl) = 0.5*std(tmp,1,'all','omitnan');
% lowerq(xl) = 0.5*std(tmp,1,'all','omitnan');
% upperq(xl) = max(dataNoNans);
% lowerq(xl) = min(dataNoNans);
upperq(xl) = max(temp(:));
lowerq(xl) = min(temp(:));
if lowerq(xl) == 0
lowerq(xl) = 1e-8;
end
% upperq(xl) = mean(tmp,"all","omitnan") + 1.96 * (std(tmp,1,'all','omitnan')/sqrt(numel(tmp)));
% lowerq(xl) = mean(tmp,"all","omitnan") - 1.96 * (std(tmp,1,'all','omitnan')/sqrt(numel(tmp)));
@@ -149,6 +159,7 @@ elseif string(plotJob.plotTypeArg) == "Lines"
% [xAxis,ber] = interpCurve(xAxis, ber);
% end
cols = cbrewer2('RdBu',size(ber,1));
for rlz = 1:size(ber,1)
%
if (string(plotJob.dataStatArg) == "All Channels ;All PMD Realizations")||(string(plotJob.dataStatArg) == "All Channels; mean(PMD Realizations)")
@@ -160,6 +171,7 @@ elseif string(plotJob.plotTypeArg) == "Lines"
if rlz < size(ber,1)
col = cols(rlz,:);
s = plot(xAxis,ber(rlz,:),linestyle,'Marker',"none",'MarkerSize',markersz,'LineWidth',linew,'Color',col,'Parent', AxesMain,'HandleVisibility','off');
@@ -169,22 +181,25 @@ elseif string(plotJob.plotTypeArg) == "Lines"
s.DataTipTemplate.DataTipRows(1);
s.DataTipTemplate.DataTipRows(2) = [];
else
if string(plotJob.dataStatArg) == "Lineplot with quartiles"
[hl,hp] = boundedline(xAxis,ber(rlz,:),([(ber(rlz,:)-lowerq(rlz,:));upperq(rlz,:)-ber(rlz,:)]'),'-o','alpha','Color',col,'transparency', 0.1,'linewidth',0.7);
[hl,hp] = boundedline(xAxis,ber(rlz,:),([(ber(rlz,:)-lowerq(rlz,:));upperq(rlz,:)-ber(rlz,:)]'),'-o','alpha','Color',col,'transparency', 0.06,'linewidth',0.7);
hl.MarkerFaceColor = col;
hl.MarkerSize = 3;
hl.MarkerSize = 2;
set(hp,'HandleVisibility','off');
%hp.LineWidth = 1.2;
ho = outlinebounds(hl,hp);
set(ho, 'linestyle', ':', 'color', col,'Linewidth',0.5);
set(ho, 'linestyle', ':', 'color', col,'Linewidth',0.6);
set(ho,'HandleVisibility','off');
% errorbar(xAxis,ber(rlz,:),ber(rlz,:)-lowerq(rlz,:),upperq(rlz,:)-ber(rlz,:),'-o','Color',col,'linewidth',0.7);
else
s = plot(xAxis,ber(rlz,:),linestyle,'Marker',"o",'MarkerFaceColor',col,'MarkerSize',markersz,'LineWidth',linew,'Color',col,'Parent', AxesMain,'DisplayName',[plotJob.displayname]);
s = plot(xAxis,ber(rlz,:),linestyle,'Marker',markerstyle,'MarkerFaceColor',col,'MarkerSize',markersz,'LineWidth',linew,'Color',col,'Parent', AxesMain,'DisplayName',[plotJob.displayname]);
s.DataTipTemplate.Interpreter = "latex";
s.DataTipTemplate.DataTipRows(1).Label = "Ch: ";
@@ -245,9 +260,10 @@ grid minor
fontsize(AxesMain,8,"points")
% fontname(AxesMain,"Arial")
fig.Position = plotJob.Position;
fig.Units = "centimeters";
fig.Position = [2 2 8.5 7];
% fig.Position = plotJob.Position;
% fig.Units = "centimeters";
% fig.Position = [2 2 8.5 7];
set(AxesMain,'TickLabelInterpreter','latex')
@@ -257,7 +273,7 @@ set(AxesMain.Legend,'Interpreter','latex')
ylim([1e-5,0.3]);
xlim([min(xAxis),-3]);
xlim([-10,-4]);
% annotation('textbox', [0.125, 0.32, 0.1, 0.1], 'String', "FEC 3.8e-3","LineStyle","none","FontSize",8,"FontUnits","points")

View File

@@ -155,7 +155,7 @@ ylabel('Penalty in dB');
xlabel('Channel Number');
ylim([-9.3,-3]);
xlim([0,plotJob.ch+1]);
grid minor;
% grid minor;
set(gca, 'color', 'none');
legend = [];