138 lines
6.2 KiB
Matlab
138 lines
6.2 KiB
Matlab
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
|
useGui = 0;
|
|
pamlvls = [4, 6, 8];
|
|
wlengths = [1310];
|
|
db = DBHandler("pathToDB", [basePath, 'silas_labor.db']);
|
|
|
|
for w = 1:numel(wlengths)
|
|
for p = 1:numel(pamlvls)
|
|
% Load data from database
|
|
joinedData = loadDataFromDB(db, pamlvls(p), wlengths(w), useGui);
|
|
|
|
% Plot filtered data
|
|
figure(pamlvls(p));
|
|
hold on;
|
|
plotFilteredData(joinedData, wlengths(w));
|
|
% Continue with the rest of your plot settings
|
|
finalizePlot();
|
|
end
|
|
end
|
|
|
|
|
|
% Custom function to load data from database
|
|
function joinedData = loadDataFromDB(db, pamlvl, wlength, useGui)
|
|
if useGui
|
|
filterParams = db.promptFilterParameters();
|
|
selectedFields = db.promptSelectFields();
|
|
else
|
|
filterParams = db.tables;
|
|
filterParams.Configurations = struct( ...
|
|
'bitrate', [], 'db_mode', [], 'fiber_length', 1, ...
|
|
'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);
|
|
|
|
% Extract unique rows for each run_id
|
|
uniqueConfigFields = {'run_id', 'pam_level', 'bitrate', 'symbolrate', 'fiber_length', 'wavelength', 'precomp_amp', 'db_mode'};
|
|
[~, uniqueIdx] = unique(dataTable.run_id);
|
|
configDetails = dataTable(uniqueIdx, uniqueConfigFields);
|
|
|
|
% Calculate the mean BER for each combination of 'run_id' and 'eq_type'
|
|
groupedData = groupsummary(dataTable, {'run_id', 'eq_type'}, {'mean', 'min', @(x) meanExcludingOutliers(x)}, {'ber', 'power_rop', 'power_pd_in'});
|
|
|
|
% Join groupedData with configDetails on the run_id field
|
|
joinedData = join(groupedData, configDetails, 'Keys', 'run_id');
|
|
end
|
|
|
|
% Custom function to plot filtered data
|
|
function plotFilteredData(joinedData, wlength)
|
|
filterFields = {'eq_type'};
|
|
cols = linspecer(8);
|
|
lst = ["-", ":", "--"];
|
|
|
|
% Loop over each field you want to filter by
|
|
for f = 1:numel(filterFields)
|
|
currentField = filterFields{f};
|
|
uniqueValues = unique(joinedData.(currentField));
|
|
|
|
for i = 1:numel(uniqueValues)
|
|
currentValue = uniqueValues(i);
|
|
|
|
% Filter joinedData for the current value
|
|
if isnumeric(currentValue)
|
|
filteredData = joinedData(joinedData.(currentField) == currentValue, :);
|
|
else
|
|
filteredData = joinedData(strcmp(joinedData.(currentField), currentValue), :);
|
|
end
|
|
|
|
% Group and average BERs of several run ids => repeated measurements in lab!
|
|
groupVars = {'bitrate'};
|
|
groupedDataWithMeans = groupsummary(filteredData, groupVars, {'mean', 'min'}, {'mean_ber', 'min_ber', 'fun1_ber', 'mean_power_rop', 'mean_power_pd_in'});
|
|
[~, uniqueIdx] = unique(filteredData.bitrate);
|
|
constantFields = filteredData(uniqueIdx, {'bitrate', 'GroupCount', 'pam_level', 'symbolrate', 'fiber_length', 'wavelength', 'precomp_amp', 'db_mode'});
|
|
groupedRunIDs = varfun(@(x) {unique(x)}, filteredData, 'GroupingVariables', groupVars, 'InputVariables', 'run_id');
|
|
groupedRunIDs.Properties.VariableNames(end) = {'GroupedRunIDs'};
|
|
groupedDataWithMeans = join(groupedDataWithMeans, constantFields, 'Keys', 'bitrate');
|
|
groupedDataWithMeans = join(groupedDataWithMeans, groupedRunIDs, 'Keys', 'bitrate');
|
|
filteredData = groupedDataWithMeans;
|
|
|
|
% Plotting
|
|
a = plot(filteredData.bitrate .* 1e-9, filteredData.mean_fun1_ber, ...
|
|
'Color', cols(i, :), 'MarkerSize', 4, 'LineWidth', 1, 'LineStyle', lst(mod(wlength - 1, numel(lst)) + 1), ...
|
|
'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_mean_power_rop;
|
|
a.DataTipTemplate.DataTipRows(3).Format = ['%.2f', ' dBm'];
|
|
a.DataTipTemplate.DataTipRows(4).Label = 'Baudr';
|
|
a.DataTipTemplate.DataTipRows(4).Value = filteredData.bitrate .* 1e-9;
|
|
a.DataTipTemplate.DataTipRows(4).Format = ['%.1f', ' GBd'];
|
|
a.DataTipTemplate.DataTipRows(5).Label = 'Run ID';
|
|
a.DataTipTemplate.DataTipRows(5).Value = filteredData.GroupedRunIDs;
|
|
a.DataTipTemplate.FontSize = 9;
|
|
a.DataTipTemplate.FontName = 'arial';
|
|
end
|
|
end
|
|
end
|
|
|
|
% Custom function to finalize the plot settings
|
|
function finalizePlot()
|
|
yline(2e-2, 'DisplayName', '20% O-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
|
|
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
|
|
xlabel('Bit Rate in GBps');
|
|
ylabel('Bit Error Rate (BER)');
|
|
xlim([300, 480]);
|
|
set(gca, 'yscale', 'log');
|
|
set(gca, 'Box', 'on');
|
|
grid on;
|
|
grid minor;
|
|
legend('Interpreter', 'none');
|
|
end
|
|
|
|
% Custom function using rmoutliers to calculate mean after removing outliers
|
|
function meanWithoutOutliers = meanExcludingOutliers(x)
|
|
[xWithoutOutliers,outlierpos] = rmoutliers(x);
|
|
if isempty(xWithoutOutliers)
|
|
meanWithoutOutliers = NaN;
|
|
else
|
|
meanWithoutOutliers = mean(xWithoutOutliers);
|
|
end
|
|
|
|
end
|