206 lines
5.2 KiB
Matlab
206 lines
5.2 KiB
Matlab
function plotViolin(wh,plotJob)
|
|
|
|
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
|
|
|
|
%% Violin
|
|
col = plotJob.color;
|
|
|
|
% we want to fetch all realizations
|
|
if plotJob.pmd == 0
|
|
realization = 1;
|
|
else
|
|
realization = wh.parameter.realization.values(1:end);
|
|
end
|
|
|
|
%realization = 0:8;
|
|
|
|
% get all xAxis values
|
|
xAxis = wh.parameter.p_out.values;
|
|
|
|
% ber = NaN(500,16,10);
|
|
% zdw = NaN(500,1,10);
|
|
|
|
%get BER values for query
|
|
for xl = 1:numel(xAxis)
|
|
p_out = xAxis(xl);
|
|
|
|
curber = 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);
|
|
curber= removeZeros(curber);
|
|
ber(1:size(curber,1),1:size(curber,2),xl) = curber;
|
|
|
|
end
|
|
|
|
% to remove outliers set the percentile range
|
|
% a = squeeze(mean(ber,2));
|
|
% out = isoutlier(mean(a,2),"percentiles",[0 100]);
|
|
% ber = ber(~out,:,:);
|
|
% disp(sum(out));
|
|
|
|
hdfec = 3.8e-3.*ones(size(xAxis));
|
|
S = [];
|
|
wavelength={};
|
|
|
|
|
|
S = [];
|
|
S_chann = [];
|
|
|
|
wl = calcWavelengthPlan(plotJob.ch,plotJob.channelspacing,1310);
|
|
%get fec thresholds
|
|
% [C,ia,ib] =intersect(linx,xAxis);
|
|
% linear = squeeze(linear);
|
|
|
|
%ber(ber==0) = NaN;
|
|
S_chann_no_crossing = zeros(1,plotJob.ch);
|
|
for chann = 1:size(ber,2)
|
|
|
|
for realiz = 1:size(ber,1)
|
|
|
|
ber_series = squeeze(ber(realiz,chann,:)).';
|
|
if mean(ber_series) > 0.1
|
|
continue
|
|
end
|
|
|
|
a = InterX([hdfec(:)';xAxis],[ber_series;xAxis]);
|
|
|
|
if ~isempty(a)
|
|
S_chann(realiz,chann) = a(2);
|
|
% if a(2) > -7 && string(plotJob.pol) == "copolarized"
|
|
% continue
|
|
% end
|
|
S(end+1) = a(2);
|
|
wavelength{end+1} = num2str(wl(chann));
|
|
else
|
|
S(end+1) = 0;
|
|
wavelength{end+1} = num2str(wl(chann));
|
|
S_chann_no_crossing(realiz,chann) = 1;
|
|
S_chann(realiz,chann) = -1;
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
threshold = -6;
|
|
FEC_crossed = sum(S_chann < threshold & ~isnan(S_chann),1);
|
|
FEC_not_crossed = sum(S_chann >= threshold & ~isnan(S_chann),1);
|
|
failure_rate = FEC_not_crossed ./ (FEC_crossed + FEC_not_crossed) ;
|
|
|
|
|
|
S_chann(S_chann==0) = NaN;
|
|
|
|
total_avg = mean(S_chann,"all","omitnan");
|
|
|
|
%figure(2024)
|
|
%C = flip(cbrewer2('Spectral',8));
|
|
if numel(S) <= numel(wl)
|
|
vs = scatter(1:numel(S),S,50,'o','MarkerEdgeColor','black','MarkerFaceColor',plotJob.color,'LineWidth',1,'HandleVisibility','off');
|
|
%vs = scatter(1,mean(S),50,'o','MarkerEdgeColor','black','MarkerFaceColor',plotJob.color,'LineWidth',1);
|
|
|
|
else
|
|
|
|
vs = violinplot(S,wavelength,...
|
|
'ViolinColor',plotJob.color,...
|
|
'ViolinAlpha',0.1,...
|
|
'MarkerSize',1,...
|
|
'ShowMedian',false,...
|
|
'EdgeColor',plotJob.color,...
|
|
'ShowWhiskers',false,...
|
|
'ShowData',false,...
|
|
'ShowBox',false,...
|
|
'Bandwidth',0.051 ...
|
|
);
|
|
|
|
|
|
hold on
|
|
|
|
partly_failed = boolean(ceil(failure_rate));
|
|
|
|
avg = mean(S_chann,1,"omitnan");
|
|
|
|
notfailed = ~partly_failed .* avg;
|
|
notfailed(notfailed==0) = NaN;
|
|
scatter(1:size(S_chann,2),notfailed,10,'Marker','x','MarkerEdgeColor','black','MarkerFaceColor',plotJob.color,'LineWidth',0.5,'HandleVisibility','off');
|
|
|
|
|
|
hold on
|
|
partly_failed = partly_failed.*avg;
|
|
partly_failed(partly_failed==0) = NaN;
|
|
s=scatter(1:numel(failure_rate),partly_failed,10,'Marker','x','LineWidth',0.5,'HandleVisibility','off','MarkerEdgeColor','red');
|
|
s.DataTipTemplate.Interpreter = "latex";
|
|
s.DataTipTemplate.DataTipRows(1).Label = "Fail Rate: ";
|
|
s.DataTipTemplate.DataTipRows(1).Value = failure_rate;
|
|
s.DataTipTemplate.DataTipRows(2) = [];
|
|
hold off
|
|
end
|
|
|
|
% ax = gca;
|
|
% ax.XTicks
|
|
|
|
hold on
|
|
yline(total_avg,'LineWidth',1,'LineStyle','--','DisplayName','System Avg.')
|
|
fig.Position = plotJob.Position;
|
|
|
|
xticklabels(1:16);
|
|
ylabel('Penalty in dB');
|
|
xlabel('Channel Number');
|
|
ylim([-9.3,-3]);
|
|
xlim([0,plotJob.ch+1]);
|
|
grid minor;
|
|
set(gca, 'color', 'none');
|
|
legend = [];
|
|
|
|
fontsize(AxesMain,8,"points")
|
|
|
|
fig.Position = plotJob.Position;
|
|
fig.Units = "centimeters";
|
|
fig.Position = [2 2 8.5 7];
|
|
|
|
set(AxesMain,'TickLabelInterpreter','latex')
|
|
|
|
set(AxesMain.Legend,'Interpreter','latex')
|
|
|
|
|
|
|
|
if 0
|
|
ber_sorted = sort(S);
|
|
|
|
z1 = [];
|
|
penalty = mean(ber_sorted):0.01:mean(ber_sorted)+2;
|
|
|
|
for i = 1:length(penalty)
|
|
l = penalty(i);
|
|
if i == 1
|
|
z1 = [z1 sum(ber_sorted(1,:)<l ) / length(ber_sorted) ];
|
|
else
|
|
z1 = [z1 sum(ber_sorted(1,:)<l & ber_sorted(1,:)>l-0.01) / length(ber_sorted) ];
|
|
end
|
|
|
|
end
|
|
|
|
penalty_higherthan = 0.5;
|
|
probability = sum(z1(find(penalty>mean(ber_sorted)+penalty_higherthan)));
|
|
disp(['A penalty of more than 0.5 dB has a probability of: ', num2str(probability)]);
|
|
end
|
|
|
|
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 |