249 lines
8.7 KiB
Matlab
249 lines
8.7 KiB
Matlab
function plotCurve(wh,plotJob)
|
|
%PLOTCURVE Summary of this function goes here
|
|
% Detailed explanation goes here
|
|
|
|
fig = findall(groot, 'Type', 'figure', 'Name', plotJob.figName);
|
|
|
|
if isvalid(fig)
|
|
figure(fig)
|
|
fig = get(fig);
|
|
AxesMain = fig.CurrentAxes;
|
|
hold on
|
|
else
|
|
fig = figure('name',char(plotJob.figName));
|
|
AxesMain = gca;
|
|
hold on
|
|
end
|
|
|
|
col = plotJob.color;
|
|
|
|
% we want to fetch all realizations
|
|
if plotJob.pmd == 0
|
|
realization = 499;
|
|
% realization = 0:7;
|
|
else
|
|
realization = wh.parameter.realization.values(1:end);
|
|
end
|
|
realization = wh.parameter.realization.values(1:end);
|
|
% get all xAxis values
|
|
xAxis = wh.parameter.p_out.values;
|
|
|
|
% 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');
|
|
linew = 1.0;
|
|
markersz = 3;
|
|
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 = '-';
|
|
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 = '-';
|
|
|
|
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);
|
|
temp = removeZeros(temp);
|
|
|
|
ber(:,xl) = mean(temp,1,"omitnan").';
|
|
|
|
linew = 1;
|
|
markersz = 3;
|
|
linestyle = '--';
|
|
|
|
elseif string(plotJob.dataStatArg) == "Lineplot with quartiles"
|
|
|
|
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","omitnan").';
|
|
|
|
|
|
upperq(xl) = quantile(temp,0.9,"all");
|
|
lowerq(xl) = quantile(temp,0.1,"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) = 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)));
|
|
|
|
linew = 1;
|
|
markersz = 1;
|
|
linestyle = '-';
|
|
|
|
elseif string(plotJob.dataStatArg) == "All Channels ;All PMD Realizations"
|
|
|
|
tmp = reshape(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).',[],1);
|
|
ber(1:size(tmp,1),xl) = tmp;
|
|
|
|
linew = 0.3;
|
|
markersz = 2;
|
|
linestyle = ':';
|
|
end
|
|
end
|
|
|
|
xAxis = xAxis;
|
|
|
|
% Plot Data
|
|
if string(plotJob.plotTypeArg) == "Scatter"
|
|
for rlz = 1:size(ber,1)
|
|
|
|
if rlz < size(ber,1)
|
|
scatter(xAxis,ber(rlz,:),markersz,'MarkerEdgeColor',col,'MarkerFaceColor',col,'Parent', AxesMain(1),'HandleVisibility','off');
|
|
else
|
|
scatter(xAxis,ber(rlz,:),markersz,'MarkerEdgeColor',col,'MarkerFaceColor',col,'Parent', AxesMain(1),'DisplayName',[plotJob.dataStatArg,' Ch.: ', plotJob.displayname]);
|
|
end
|
|
|
|
end
|
|
|
|
elseif string(plotJob.plotTypeArg) == "Lines"
|
|
|
|
% if ~anynan(ber)
|
|
% [xAxis,ber] = interpCurve(xAxis, ber);
|
|
% end
|
|
|
|
for rlz = 1:size(ber,1)
|
|
%
|
|
if (string(plotJob.dataStatArg) == "All Channels ;All PMD Realizations")||(string(plotJob.dataStatArg) == "All Channels; mean(PMD Realizations)")
|
|
ch = mod(rlz,plotJob.ch);
|
|
if ch == 0; ch = plotJob.ch; end
|
|
else
|
|
ch = plotJob.dataStatArg;
|
|
end
|
|
|
|
if rlz <= size(ber,1)
|
|
|
|
|
|
s = plot3(xAxis,repmat(ch,1,numel(xAxis)),ber(rlz,:),linestyle,'Marker',"o",'MarkerSize',markersz,'MarkerFaceColor',plotJob.color,'LineWidth',linew,'Color',col,'Parent', AxesMain,'HandleVisibility','off');
|
|
|
|
s.DataTipTemplate.Interpreter = "latex";
|
|
s.DataTipTemplate.DataTipRows(1).Label = "Ch: ";
|
|
s.DataTipTemplate.DataTipRows(1).Value = repmat(ch,size(ber));
|
|
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,:)]'),'-*', 'alpha','Color',col,'transparency', 0.2);
|
|
hp.LineWidth = 1.2;
|
|
|
|
ho = outlinebounds(hl,hp);
|
|
set(ho, 'linestyle', ':', 'color', col);
|
|
else
|
|
|
|
s = plot(xAxis,ber(rlz,:),linestyle,'Marker',"o",'MarkerFaceColor',col,'MarkerSize',markersz,'LineWidth',linew,'Color',col,'Parent', AxesMain,'DisplayName',[plotJob.displayname]);
|
|
|
|
s.DataTipTemplate.Interpreter = "latex";
|
|
s.DataTipTemplate.DataTipRows(1).Label = "Ch: ";
|
|
s.DataTipTemplate.DataTipRows(1).Value = repmat(string(ch),size(ber));
|
|
s.DataTipTemplate.DataTipRows(1)
|
|
s.DataTipTemplate.DataTipRows(2) = [];
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
% Draw FEC Threshold Line
|
|
%get x data of first children:
|
|
%get all linear Values
|
|
if 0
|
|
linear = wh.getStoValue('ber',plotJob.l,plotJob.d,plotJob.sgm,string(plotJob.pol),plotJob.p_in,wh.parameter.p_out.values,0,0,499,"symmetric");
|
|
linear = mean(linear,2);
|
|
lincurve = findall(AxesMain, 'Type', 'line','DisplayName','Linear Baseline');
|
|
%
|
|
if isempty(lincurve)
|
|
xdata = AxesMain.Children(1).XData;
|
|
hdfec = 3.8e-3.*ones(size(xdata));
|
|
plot(xdata,linear,'-','Marker',"o",'MarkerSize',3,'LineWidth',4,'Color',[0.6400 0.6400 0.6400],'MarkerFaceColor',[0.6400 0.6400 0.6400],'Parent', AxesMain,'DisplayName','Linear Baseline');
|
|
%h = get(gca,'Children');
|
|
%set(gca,'Children',[h(2) h(1)])
|
|
end
|
|
end
|
|
|
|
feccurve = findall(AxesMain, 'Type', 'line','DisplayName','FEC $3.8*10^{-3}$');
|
|
%
|
|
if isempty(feccurve)
|
|
xdata = xAxis;
|
|
hdfec = 3.8e-3.*ones(size(xdata));
|
|
for ch = 1:plotJob.ch
|
|
plot3(xdata,repmat(ch,1,numel(xAxis)),hdfec,':','MarkerSize',4,'Color','black','MarkerFaceColor','black','LineWidth',0.5,'Parent', AxesMain,'DisplayName','FEC $3.8*10^{-3}$','HandleVisibility','off');
|
|
end
|
|
%h = get(gca,'Children');
|
|
%set(gca,'Children',[h(2) h(1)])
|
|
end
|
|
|
|
% Figure Settings
|
|
%title(AxesMain,plotJob.title,"Interpreter","none");
|
|
|
|
xlabel(AxesMain,plotJob.xAxisLabel,"Interpreter","none");
|
|
|
|
ylabel(AxesMain,plotJob.yAxisLabel,"Interpreter","none");
|
|
|
|
set(AxesMain,'zscale','log');
|
|
|
|
grid(AxesMain,'on');
|
|
|
|
grid(AxesMain,'minor');
|
|
|
|
grid minor
|
|
|
|
view(AxesMain,[42.0619302949062 23.4176470588235]);
|
|
%legend(AxesMain);
|
|
|
|
fontsize(AxesMain,8,"points")
|
|
fontname(AxesMain,"Arial")
|
|
|
|
fig.Position = plotJob.Position;
|
|
fig.Units = "centimeters";
|
|
fig.Position = [2 2 8.5 7];
|
|
|
|
set(AxesMain,'TickLabelInterpreter','none')
|
|
|
|
set(AxesMain.Legend,'Interpreter','none')
|
|
% set(gcf,'Units','centimeters')
|
|
% set(gcf,'Position',[2 2 9 4.5])
|
|
|
|
zlim([1e-4,0.3]);
|
|
|
|
xlim([min(xAxis),-3]);
|
|
|
|
|
|
annotation('textbox', [0.125, 0.32, 0.1, 0.1], 'String', "FEC 3.8e-3","LineStyle","none","FontSize",8,"FontUnits","points")
|
|
|
|
|
|
hold off
|
|
|
|
|
|
end
|
|
|
|
|
|
function vec = removeZeros(vec)
|
|
% Find rows that contain only zeros
|
|
rows_to_remove = all(vec == 0, 2);
|
|
|
|
% Remove rows with only zeros
|
|
vec(rows_to_remove, :) = [];
|
|
end
|