300 lines
10 KiB
Matlab
300 lines
10 KiB
Matlab
function plotBerVsZDW(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
|
|
|
|
|
|
col = plotJob.color;
|
|
|
|
% we want to fetch all realizations
|
|
realization = wh.parameter.realization.values(1:end);
|
|
|
|
% get all xAxis values
|
|
xAxis = wh.parameter.p_out.values;
|
|
|
|
% get all center wavelengths
|
|
wavelengths = wh.parameter.center_wavelength.values;
|
|
|
|
% totber = NaN(numel(realization),1,numel(xAxis),numel(wavelengths));
|
|
% ber = zeros(numel(realization),plotJob.ch,numel(xAxis),numel(wavelengths));
|
|
|
|
%get BER values for query
|
|
for w = 2:numel(wavelengths)
|
|
|
|
for xl = 1:numel(xAxis)
|
|
|
|
c_wavelen = wavelengths(w);
|
|
p_out = xAxis(xl);
|
|
|
|
% dim1 : realiz; dim2: channels, dim3: rop, dim4, c_wavelength
|
|
temp = removeZeros(wh.getStoValue('ber',plotJob.l,plotJob.d,plotJob.sgm,string(plotJob.pol),plotJob.p_in,p_out,plotJob.pmd,plotJob.gamma,realization,plotJob.ch,c_wavelen,plotJob.channelspacing,plotJob.randzdw));
|
|
ber(1:size(temp,1),:,xl,w) = temp;
|
|
|
|
end
|
|
end
|
|
|
|
hdfec = 3.8e-3.*ones(size(xAxis));
|
|
zdw_ = [];
|
|
zdw_chann = [];
|
|
zdw_tot = [];
|
|
cf_tot = [];
|
|
cf_ = [];
|
|
S = [];
|
|
Stot = [];
|
|
S_chann = [];
|
|
cf_chann = [];
|
|
|
|
cnt = 0;
|
|
%get fec thresholds
|
|
%linear = squeeze(linear);
|
|
for c_wavelen = 1:size(ber,4)
|
|
for realiz = 1:size(ber,1)
|
|
for chann = 1:size(ber,2)
|
|
|
|
%finde Schnittpunkt zwischen FEC und BER Kurve
|
|
temp_ber = squeeze(ber(realiz,chann,:,c_wavelen)).';
|
|
if ~all(temp_ber == 0)
|
|
%nur wenn nicht alles nullen sind
|
|
crossing_ch = InterX([hdfec;xAxis],[temp_ber;xAxis]);
|
|
else
|
|
continue
|
|
end
|
|
|
|
%Req. FEC Ergebnis einsortieren
|
|
if ~isempty(crossing_ch)
|
|
if crossing_ch(2) == 0
|
|
print("d")
|
|
end
|
|
S(realiz,chann,c_wavelen) = crossing_ch(2);
|
|
else
|
|
S(realiz,chann,c_wavelen) = -1;
|
|
cnt = cnt +1;
|
|
end
|
|
|
|
|
|
end
|
|
end
|
|
end
|
|
|
|
temp_max = -inf;
|
|
for i = 1:plotJob.ch
|
|
hold on
|
|
%S:: 1.dim: realiz; 2.dim: channel; 3.dim: center wavelength
|
|
%squeeze a channel:
|
|
temp_data = squeeze(S(:,i,:));
|
|
|
|
%remove realizations that have no entry (only zero)
|
|
temp_data = removeZeros(temp_data);
|
|
|
|
%replace zeros with NAN (e.g. for the wavelengths that have missing realizations)
|
|
temp_data(temp_data==0) = NaN;
|
|
|
|
%plot required ROP for channel and all realizations that cross the
|
|
%FEC limit
|
|
scatter(wavelengths,temp_data ,5,plotJob.color,'Marker','.');
|
|
|
|
% %plot mean per channel
|
|
% temp_mean = mean(temp_data,'omitnan');
|
|
% hold on
|
|
% plot(wavelengths,temp_mean,'Marker','*');
|
|
|
|
%get max overall value
|
|
temp_max = max(temp_max,max(temp_data));
|
|
end
|
|
|
|
|
|
|
|
%plot mean overall
|
|
mean_overall = squeeze(mean(S,2));
|
|
mean_overall(mean_overall==0) = NaN;
|
|
%mean_overall(mean_overall==-1) = NaN;
|
|
mean_overall=mean(mean_overall,1,'omitnan');
|
|
plot(wavelengths,mean_overall,'Color',plotJob.color);
|
|
|
|
%plot max overall
|
|
scatter(wavelengths,temp_max ,35,plotJob.color,'Marker','v');
|
|
|
|
|
|
%plot channel positions
|
|
hold on
|
|
chpos = calcWavelengthPlan(plotJob.ch, 400e9, 1310);
|
|
xline(chpos,'LineWidth',2,'Alpha',0.2);
|
|
chpos = calcWavelengthPlan(plotJob.ch, 400e9, chpos(4));
|
|
xline(chpos,'LineWidth',2,'Alpha',0.2);
|
|
|
|
fig.Position = plotJob.Position;
|
|
|
|
ylabel('Penalty in dB');
|
|
xlabel('Wavelength in nm');
|
|
|
|
xlim([min(wavelengths),max(wavelengths) ]);
|
|
|
|
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')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%
|
|
%
|
|
%
|
|
%
|
|
%
|
|
% distinct_cf = unique(cf_chann);
|
|
%
|
|
% for i = 1:length(distinct_cf)
|
|
% indices = find(cf_chann==distinct_cf(i));
|
|
% cf(i) = distinct_cf(i);
|
|
% worst_fec_cross(i) = max(S_chann(indices));
|
|
% avg_fec_cross(i) = mean(S_chann(indices));
|
|
% end
|
|
%
|
|
% avg_fec_cross = smooth(avg_fec_cross,5);
|
|
%
|
|
% figure(224)
|
|
% hold on
|
|
% scatter(cf_,S,10.*abs(S-mean(S)).*ones(size(S)),'DisplayName',['AVG'],'MarkerEdgeColor',col,'MarkerFaceColor',col,'Marker','.');
|
|
% hold on
|
|
% scatter(cf(2:end),worst_fec_cross(2:end),15,'DisplayName',['Worst'],'MarkerEdgeColor',col,'MarkerFaceColor',col,'Marker','.','HandleVisibility','off');
|
|
% plot(cf(2:end),avg_fec_cross(2:end),'DisplayName',['AVG'],'LineWidth',1,'LineStyle','-','Color',col,'Marker','none','MarkerFaceColor',col,'MarkerSize',2);
|
|
% plot(cf(2:end),worst_fec_cross(2:end),'DisplayName',['AVG'],'LineWidth',0.5,'LineStyle','-','Color',col,'Marker','none','MarkerFaceColor',col,'MarkerSize',2);
|
|
% ghzgrid = hz2nm(nm2hz(1310)+[0:1:20].*400e9);
|
|
% set(gca,'xtick',sort(ghzgrid))
|
|
% xlim([min(cf(cf~=0)), 1310.1]);
|
|
%
|
|
%
|
|
% % With matlab internal errorbar function...
|
|
% figure(221)
|
|
% %plot(cf,avg_fec_cross,'DisplayName',['AVG'],'LineWidth',1,'Color',col,'Marker','none','MarkerFaceColor',col,'MarkerSize',2);
|
|
% hold on
|
|
% %plot(cf_tot,min(S_chann(1:length(cf_tot),:),[],2),'DisplayName',['AVG'],'LineWidth',1,'LineStyle',':','Color',col,'Marker','^','MarkerFaceColor',col,'MarkerSize',2);
|
|
% plot(cf,worst_fec_cross,'DisplayName',['AVG'],'LineWidth',2,'LineStyle','-','Color',col,'Marker','none','MarkerFaceColor',col,'MarkerSize',2);
|
|
% ghzgrid = hz2nm(nm2hz(1310)+[0:1:20].*400e9);
|
|
% set(gca,'xtick',sort(ghzgrid))
|
|
% xlim([1302, 1310.1]);
|
|
% xline(ghzgrid,'LineStyle',':','Color',[.7 .7 .7]);
|
|
|
|
|
|
%with
|
|
% Stot = movmean(Stot,5);
|
|
% figure(222)
|
|
% [hl,hp] = boundedline(cf_tot,Stot,[(Stot'-min(S_chann(1:length(cf_tot),:),[],2)),(max(S_chann(1:length(cf_tot),:),[],2)-Stot')], 'alpha','Color',col,'transparency', 0.05);
|
|
% ho = outlinebounds(hl,hp);
|
|
% set(ho, 'linestyle', ':', 'color', col, 'marker', '.','linewidth',0.5);
|
|
% hold on
|
|
%
|
|
% ghzgrid = hz2nm(nm2hz(1310)+[0:1:12].*400e9);
|
|
% xline(ghzgrid);
|
|
|
|
|
|
|
|
|
|
%plot the total ber
|
|
|
|
% %figure(22);
|
|
% hold on;
|
|
% b= movmean(Stot,3);
|
|
% plot(AxesMain,cf_tot,b,'LineWidth',2,'DisplayName',[plotJob.dataStatArg,' Ch.: ', plotJob.displayname],'Color',col,'Marker','o');
|
|
% hold on
|
|
|
|
|
|
|
|
|
|
|
|
%scatter(AxesMain,zdw_,S,'Marker','+','MarkerEdgeColor',col,'MarkerFaceAlpha',0.4,'MarkerEdgeAlpha',0.4,'LineWidth',0.5,'Parent', AxesMain(1),'DisplayName',[plotJob.dataStatArg,' Ch.: ', plotJob.displayname]);
|
|
%ylim(AxesMain,[-9.3 -7]);
|
|
|
|
% for i = 1:numel(chp)
|
|
% hold on
|
|
% xline(AxesMain,chp(i),'Color',colr(i,:),'DisplayName',['CH: ', num2str(i)],'LineWidth',1.5);
|
|
% hold off
|
|
% end
|
|
|
|
|
|
|
|
|
|
%
|
|
% a = movmean(sortrows([zdw_; S]'),10,'Endpoints','discard');
|
|
%
|
|
% sorted = sortrows([zdw_; S]');
|
|
% figure(2)
|
|
% scatter(sorted(:,1),sorted(:,2))
|
|
%
|
|
% ber_sorted = sort(S);
|
|
% mean(ber_sorted);
|
|
% std(ber_sorted);
|
|
% 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 1dB has a probability of: ', num2str(probability)]);
|
|
% %
|
|
% stem(AxesMain,penalty,z1,"filled",'Marker','o','MarkerSize',2,'Color',col);
|
|
%
|
|
%
|
|
% [f1,x1]=ecdf(S(end,:));
|
|
% %figure(23);plot(AxesMain,x1,f1,'r','LineWidth',3, 'Color',col);
|
|
%
|
|
% %plot(AxesMain,a(:,1),a(:,2),'Color',col+1,'Parent', AxesMain(1));
|
|
%
|
|
% % histogram(AxesMain,S,1000,'EdgeColor','none','FaceAlpha',0.4);
|
|
%
|
|
%
|
|
%
|
|
% %
|
|
% %scatter(AxesMain,zdw_,S,'Marker','+','MarkerEdgeColor',col,'MarkerFaceAlpha',0.4,'MarkerEdgeAlpha',0.4,'LineWidth',0.5,'Parent', AxesMain(1),'DisplayName',[plotJob.dataStatArg,' Ch.: ', plotJob.displayname]);
|
|
% hold on
|
|
% %scatter(AxesMain,zdw_chann(:,1),mean(S_chann,2),'Marker','diamond','MarkerEdgeColor',col,'MarkerFaceAlpha',0.6,'LineWidth',7,'MarkerFaceColor',col,'Parent', AxesMain(1),'DisplayName',[plotJob.dataStatArg,' Ch.: ', plotJob.displayname]);
|
|
% hold off
|
|
% %
|
|
% % for rlz = 1:size(S,2)
|
|
% % zdwval = zdw_(rlz);
|
|
% % feccrossing = S(rlz);
|
|
% % scatter(AxesMain,zdwval,feccrossing,10,'MarkerEdgeColor',col,'MarkerFaceColor',col,'Parent', AxesMain(1),'DisplayName',[plotJob.dataStatArg,' Ch.: ', plotJob.displayname]);
|
|
% % end
|
|
%
|
|
% xline([1302.03471732576,1304.30061112288,1306.57440520904,1308.85614097425,1311.14586009814,1313.44360455251,1315.74941660391,1318.06333881618]);
|
|
|
|
|
|
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 |