170 lines
7.0 KiB
Matlab
170 lines
7.0 KiB
Matlab
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
|
useGui = 0;
|
|
pamlvls = [4,6,8];
|
|
wlengths = [1302];
|
|
figoffset = 0;
|
|
|
|
figure(30)
|
|
tiledlayout(1, 3, 'TileSpacing', 'compact', 'Padding', 'compact');
|
|
|
|
for p = 1:numel(pamlvls)
|
|
nexttile;
|
|
|
|
for w = 1:numel(wlengths)
|
|
sgtitle(['Lambda: ',num2str(wlengths),' nm'])
|
|
|
|
hold on
|
|
pamlvl = pamlvls(p);
|
|
wlength = wlengths(w);
|
|
db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
|
if useGui
|
|
filterParams = db.promptFilterParameters();
|
|
selectedFields = db.promptSelectFields();
|
|
else
|
|
filterParams = db.tables;
|
|
filterParams.Configurations = struct( ...
|
|
'bitrate', [], ...
|
|
'db_mode', [], ...
|
|
'fiber_length', 10, ...
|
|
'interference_attenuation', [], ...
|
|
'interference_path_length', [], ...
|
|
'is_mpi', 0, ...
|
|
'pam_level', pamlvl, ...
|
|
'precomp_amp', [], ...
|
|
'rop_attenuation', 0, ...
|
|
'symbolrate', [], ...
|
|
'v_awg', [], ...
|
|
'v_bias', [], ...
|
|
'wavelength', wlength ...
|
|
);
|
|
|
|
selectedFields = {'Runs.run_id','BERs.ber_id','Equalizer.eq_id','Equalizer.eq_type','BERs.ber','BERs.occurrence',...
|
|
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.symbolrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp',...
|
|
'Measurements.power_rop','Measurements.power_laser','Measurements.power_pd_in'};
|
|
end
|
|
|
|
% Get data table from DB
|
|
[dataTable,~] = db.queryDB(filterParams, selectedFields);
|
|
|
|
% Grouping variables: 'bitrate' and 'eq_type'
|
|
groupVars = {'bitrate', 'eq_type'};
|
|
|
|
% Calculate mean BER for each combination of 'bitrate' and 'eq_type'
|
|
groupedData = groupsummary(dataTable, groupVars, {'mean', 'min', @(x) meanExcludingOutliers(x)}, {'ber', 'power_rop','power_pd_in'});
|
|
|
|
% Collect the run_id values for each group
|
|
groupedRunIDs = varfun(@(x) {unique(x)}, dataTable, 'GroupingVariables', groupVars, 'InputVariables', 'run_id');
|
|
groupedRunIDs.Properties.VariableNames(end) = {'GroupedRunIDs'};
|
|
|
|
% Join the grouped data with the grouped run_id list
|
|
avgdBerTable = join(groupedData, groupedRunIDs, 'Keys', groupVars);
|
|
|
|
% Define the fields that you want to use for filtering
|
|
filterFields = {'eq_type'};
|
|
|
|
% Loop over each field you want to filter by
|
|
for f = 1:numel(filterFields)
|
|
currentField = filterFields{f};
|
|
|
|
% Determine unique values for the current field
|
|
uniqueValues = unique(avgdBerTable.(currentField));
|
|
|
|
% Loop over each unique value for the current field
|
|
for i = 1:numel(uniqueValues)
|
|
currentValue = uniqueValues(i);
|
|
|
|
% Filter joinedData for the current value
|
|
if isnumeric(currentValue)
|
|
filteredData = avgdBerTable(avgdBerTable.(currentField) == currentValue, :);
|
|
else
|
|
filteredData = avgdBerTable(strcmp(avgdBerTable.(currentField), currentValue), :);
|
|
end
|
|
|
|
cols = linspecer(8);
|
|
|
|
lst = ["-",":","--"];
|
|
a=plot(filteredData.bitrate.*1e-9,filteredData.min_ber,...
|
|
'Color',cols(i,:),'MarkerSize',4,'LineWidth',1,'LineStyle',lst(w),...
|
|
'Marker','o','MarkerFaceColor','auto','MarkerEdgeColor',cols(i,:),...
|
|
'DisplayName',[char(currentValue),'; ',num2str(wlength),' nm' ]);
|
|
a.DataTipTemplate.DataTipRows(1).Label = 'Bitrate';
|
|
a.DataTipTemplate.DataTipRows(1).Format = ['%.1f',' Gbit/s'];
|
|
|
|
a.DataTipTemplate.DataTipRows(2).Label = 'BER';
|
|
a.DataTipTemplate.DataTipRows(2).Format ='%.1e';
|
|
|
|
a.DataTipTemplate.DataTipRows(3).Label = 'P_{out}';
|
|
a.DataTipTemplate.DataTipRows(3).Value = filteredData.mean_power_rop;
|
|
a.DataTipTemplate.DataTipRows(3).Format = ['%.2f',' dBm'];
|
|
|
|
a.DataTipTemplate.DataTipRows(4).Label = 'Run ID';
|
|
a.DataTipTemplate.DataTipRows(4).Value = filteredData.GroupedRunIDs;
|
|
a.DataTipTemplate.DataTipRows(4).Format = ['%d',' '];
|
|
|
|
|
|
a.DataTipTemplate.FontSize = 9;
|
|
a.DataTipTemplate.FontName = 'arial';
|
|
%
|
|
% a=scatter(filteredData.bitrate.*1e-9,filteredData.min_ber,5,'Marker','diamond',...
|
|
% 'Color',cols(i,:),'LineWidth',1,...
|
|
% 'MarkerFaceColor','auto','MarkerEdgeColor',cols(i,:),...
|
|
% 'DisplayName',currentValue);
|
|
%
|
|
% a.DataTipTemplate.DataTipRows(1).Label = 'Bitrate';
|
|
% a.DataTipTemplate.DataTipRows(1).Format = ['%.1f',' Gbit/s'];
|
|
%
|
|
% a.DataTipTemplate.DataTipRows(2).Label = 'BER';
|
|
% a.DataTipTemplate.DataTipRows(2).Format ='%.1e';
|
|
%
|
|
% a.DataTipTemplate.DataTipRows(3).Label = 'P_{out}';
|
|
% a.DataTipTemplate.DataTipRows(3).Value = filteredData.mean_power_rop;
|
|
% a.DataTipTemplate.DataTipRows(3).Format = ['%.2f',' dBm'];
|
|
%
|
|
% a.DataTipTemplate.DataTipRows(4).Label = 'Run ID';
|
|
% a.DataTipTemplate.DataTipRows(4).Value = filteredData.GroupedRunIDs;
|
|
% a.DataTipTemplate.DataTipRows(4).Format = ['%d',' '];
|
|
%
|
|
%
|
|
% a.DataTipTemplate.FontSize = 9;
|
|
% a.DataTipTemplate.FontName = 'arial';
|
|
|
|
|
|
|
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
% Continue with the rest of your plot settings
|
|
title(sprintf('%d km | %d nm | PAM %d',unique(filterParams.Configurations.fiber_length),wlength,pamlvl));
|
|
yline(2e-2, 'DisplayName', '20% O-FEC', 'LineStyle', '--', 'HandleVisibility', 'off','LineWidth',1);
|
|
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off','LineWidth',1);
|
|
xlabel('Bit Rate in Gbps');
|
|
ylabel('Bit Error Rate');
|
|
xlim([300, 480])
|
|
ylim([8e-4,0.5])
|
|
set(gca, 'yscale', 'log');
|
|
set(gca, 'Box', 'on');
|
|
grid on;
|
|
grid minor;
|
|
|
|
|
|
end
|
|
end
|
|
legend('Interpreter', 'none');
|
|
set(gcf, 'Units', 'pixels', 'Position', 1.0e+03 * [0.2483 0.7303 1.2093 0.3980]);
|
|
|
|
% Custom function using rmoutliers to calculate mean after removing outliers
|
|
function meanWithoutOutliers = meanExcludingOutliers(x)
|
|
% Remove outliers using rmoutliers with default method (based on median)
|
|
xWithoutOutliers = rmoutliers(x);
|
|
|
|
% Calculate the mean of the non-outliers
|
|
if isempty(xWithoutOutliers)
|
|
% Handle the case where all values are outliers
|
|
meanWithoutOutliers = NaN;
|
|
else
|
|
meanWithoutOutliers = mean(xWithoutOutliers);
|
|
end
|
|
end |