diff --git a/Classes/00_signals/Signal.m b/Classes/00_signals/Signal.m index 228e0cd..7eaa1c0 100644 --- a/Classes/00_signals/Signal.m +++ b/Classes/00_signals/Signal.m @@ -348,6 +348,7 @@ classdef Signal options.displayname = ""; options.color = []; options.normalizeToNyquist = 0; + options.addDCoffset = 0; options.normalizeTo0dB = 0; options.max_num_lines = []; % Leave empty or omit to disable line rotation options.fft_length = []; @@ -415,6 +416,8 @@ classdef Signal ax = gca; hold on + p_dbm = p_dbm+options.addDCoffset; + for s = 1:min(size(p_dbm)) if isempty(options.color) plot(x_vec, p_dbm(:,s), 'DisplayName', options.displayname, 'LineWidth', 1); diff --git a/Classes/01_transmit/ChannelFreqResp.m b/Classes/01_transmit/ChannelFreqResp.m index 0c9fda8..cfffe17 100644 --- a/Classes/01_transmit/ChannelFreqResp.m +++ b/Classes/01_transmit/ChannelFreqResp.m @@ -206,7 +206,7 @@ classdef ChannelFreqResp < handle function plot(obj) - figure(55); + figure(); clf; Havg = obj.H; @@ -225,7 +225,7 @@ classdef ChannelFreqResp < handle xlim([0.2 .5*max(obj.faxis)*1e-9]); grid on; - figure(56); + figure(); clf; @@ -246,7 +246,7 @@ classdef ChannelFreqResp < handle xlim([0.2 .5*max(obj.faxis)*1e-9]); grid on; %%% plot for publication - figure(1234); + figure(101); hold all; box on; title('Magnitude Freq. Response'); @@ -269,6 +269,25 @@ classdef ChannelFreqResp < handle legend('Interpreter','latex') grid on; + % + figure(100); hold on; + Havg = obj.H; + Havg = Havg./max(Havg); + Hall = obj.H_all; + + for i = 1:size(Hall,1) + Hall(i,:) = Hall(i,:)./max(Hall(i,:)); + end + + %1) + col = cbrewer2('Paired',8); + hold all;box on;title('Magnitude Freq. Response'); + plot(obj.faxis/1e9, 20*log10(abs(Hall)),'linewidth',0.1,'LineStyle','-','Color',col(1,:),'HandleVisibility','off') ; + xlim([0.2 .5*max(obj.faxis)*1e-9]); + plot(obj.faxis/1e9, 20*log10(abs(Havg)),'LineWidth',2,'Color',col(2,:)); + grid on; + + end diff --git a/Classes/Warehouse_class/classes/DataStorage.m b/Classes/Warehouse_class/classes/DataStorage.m index 93a7cf4..394a12f 100644 --- a/Classes/Warehouse_class/classes/DataStorage.m +++ b/Classes/Warehouse_class/classes/DataStorage.m @@ -137,7 +137,21 @@ classdef DataStorage < handle if ~isempty(tmp) if isa(tmp,'double') - value(i,:) = tmp ; + try + value(i,:) = tmp ; + catch + a = size(value,2); + b = size(tmp,2); + if a > b + value(i,:) =[tmp,NaN(1,a-b)] ; + elseif a < b + value(i,:) = tmp(1:size(value,2)) ; + else + error('unknwon case...') + end + + + end elseif isa(tmp,'Signal') || isa(tmp,'struct') || isa(tmp,'Exfo_laser') || isa(tmp,'DC_supply') if i == 1 value = {}; diff --git a/Datatypes/clr.m b/Datatypes/clr.m index b9aa515..bda20d1 100644 --- a/Datatypes/clr.m +++ b/Datatypes/clr.m @@ -49,22 +49,5 @@ classdef clr hold off; end - function showSet(colorStruct) - % Show colors from a structure in a bar plot - names = fieldnames(colorStruct); - colors = cell2mat(struct2cell(colorStruct)'); - - figure; - hold on; - for i = 1:size(colors, 1) - fill([0 1 1 0], [i-1 i-1 i i], colors(i, :), 'EdgeColor', 'k'); - text(1.1, i-0.5, names{i}, 'FontSize', 12, 'Interpreter', 'none'); - end - ylim([0, size(colors, 1)]); - xlim([0, 1.5]); - axis off; - title('Color Preview'); - hold off; - end end end diff --git a/Functions/EQ_structures/dsp_runid.m b/Functions/EQ_structures/dsp_runid.m index 086daf4..210728a 100644 --- a/Functions/EQ_structures/dsp_runid.m +++ b/Functions/EQ_structures/dsp_runid.m @@ -95,12 +95,12 @@ try adaption= 1; use_dd_mode = 1; - use_ffe = 0; - use_dfe = 0; + use_ffe = 1; + use_dfe = 1; use_vnle_mlse = 1; - use_dbtgt = 0; - use_dbenc = 0; - use_ml_mlse = 0; + use_dbtgt = 1; + use_dbenc = 1; + use_ml_mlse = 1; addProcessingResultToDatabase = 0; @@ -140,7 +140,12 @@ try % Preprocess signal Scpe_sig = preprocessSignal(Scpe_cell{r}, Symbols, fsym); - Scpe_sig.spectrum("fignum",2223,"normalizeTo0dB",1,"displayname",'Rx'); + Scpe_sig.spectrum("fignum",200,"normalizeTo0dB",1,"displayname",'Rx','addDCoffset',-6); + + Scpe_sig.spectrum("fignum",201,"normalizeTo0dB",0,"displayname",'Rx'); + + ylim([-30,3]); + xlim([-5,100]); % Scpe_sig.spectrum("fignum",22233,"normalizeTo0dB",0,"displayname",'Rx'); % Scpe_sig.eye(fsym,M,"fignum",1024); @@ -239,10 +244,10 @@ try if use_ml_mlse %ML-based MLSE (L=2) - mu_ml = 0.01; training_epochs = 250; + mu_ml = 0.01; training_epochs = 100; ml_mlse_equalizer = ML_MLSE("epochs_tr",training_epochs,"epochs_dd",1, ... "len_tr",length(Scpe_sig),"mu_dd",mu_ml,"mu_tr",mu_ml,"order",11,"sps",2, ... - "traceback_depth",128,"L",2,"delta",4,"adaptive_mu",0); + "traceback_depth",128,"L",1,"delta",4,"adaptive_mu",0); [ml_mlse_results] = ml_mlse(ml_mlse_equalizer, M, Scpe_sig, Symbols, Tx_bits,"precode_mode",duob_mode); output.mlmlse_package{r} = ml_mlse_results; diff --git a/Functions/Job_Processing/preprocessSignal.m b/Functions/Job_Processing/preprocessSignal.m index 428c84a..ed40a6c 100644 --- a/Functions/Job_Processing/preprocessSignal.m +++ b/Functions/Job_Processing/preprocessSignal.m @@ -16,9 +16,11 @@ Scpe_sig = Scpe_sig.resample("fs_out", 2*fsym); [Scpe_sig, ~] = Scpe_sig.tsynch("reference", Symbols, "fs_ref", fsym, "debug_plots", 0); % Apply Gaussian filter +if 1 Scpe_sig = Filter('filtdegree', 8, "f_cutoff", Symbols.fs.*0.52, ... "fs", Scpe_sig.fs, "filterType", filtertypes.gaussian, ... "active", true).process(Scpe_sig); +end % Remove DC offset Scpe_sig = Scpe_sig - mean(Scpe_sig.signal); diff --git a/Functions/Lab_helper/loadFreqResp.m b/Functions/Lab_helper/loadFreqResp.m index 019ea07..e2c99e8 100644 --- a/Functions/Lab_helper/loadFreqResp.m +++ b/Functions/Lab_helper/loadFreqResp.m @@ -1,5 +1,5 @@ % Define the precomp path -precomp_path = "C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\"; +precomp_path = "C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\precomp"; % Step 1: Find all valid files (assume .mat files for ChannelFreqResp) fileList = dir(fullfile(precomp_path, '*.mat')); diff --git a/Functions/Theory/Neuer Ordner/duobinary_histogram.m b/Functions/Theory/Neuer Ordner/duobinary_histogram.m deleted file mode 100644 index a71396b..0000000 --- a/Functions/Theory/Neuer Ordner/duobinary_histogram.m +++ /dev/null @@ -1,51 +0,0 @@ - - - -figure(2) -tiledlayout(1,3) -cols = linspecer(5); -cnt = 1; -for m = [4,6,8] - - M = m; - fsym = 112e9; - fdac = 256e9; - - [Digi_sig,Symbols,Tx_bits] = PAMsource(... - "fsym",fsym,"M",M,"order",19,"useprbs",1,... - "fs_out",fdac,... - "applyclipping",0,"clipfactor",1.5,... - "applypulseform",0,"pulseformer",NaN,... - "randkey",33,... - "db_precode",1,"db_encode",0,... - "mrds_code",0,"mrds_blocklength",512).process(); - - Symbols_pre = Duobinary().precode(Symbols); - - Symbols_db = Duobinary().encode(Symbols_pre); - - if M == 4 - Symbols_db.signal = Symbols_db.signal .*sqrt(2.5); - elseif M == 6 - Symbols_db.signal = Symbols_db.signal .*sqrt(5.8); - elseif M == 8 - Symbols_db.signal = Symbols_db.signal .*sqrt(10.5); - end - - % figure(1) - % hold on - % histogram(Symbols_db.signal,"EdgeAlpha",0.3,"Normalization","probability"); - - - % figure(1) - nexttile - hold on - bar(unique(Symbols_db.signal),histcounts(int32(Symbols_db.signal),"Normalization","probability"),"FaceColor",cols(cnt,:),"FaceAlpha",0.6,"BarWidth",1-(0.2*cnt),"LineWidth",0.5,"EdgeColor",'black','DisplayName',['Duobinary PAM-',num2str(M)]); - xticks(unique(Symbols_db.signal)); - ylim([0 0.26]); - xlabel("Symbol") - - - cnt = cnt+1, - -end \ No newline at end of file diff --git a/Functions/Theory/Neuer Ordner/duobinary_transferfunction.m b/Functions/Theory/Neuer Ordner/duobinary_transferfunction.m deleted file mode 100644 index ccc7448..0000000 --- a/Functions/Theory/Neuer Ordner/duobinary_transferfunction.m +++ /dev/null @@ -1,18 +0,0 @@ - - -% Define the filter taps -h_ = {[1],[1 1],[1 2 1],[1 3 3 1]}; - -for i = 1:length(h_) - h = h_{i}; - - [H, w] = freqz(h, 1, 1024, 1); - - figure(1); - hold on - plot(w, 10*log10(abs(H)), 'LineWidth', 2,'DisplayName',['$(1+D)^2$']); %todo - xlabel('Normalized Frequency'); - ylabel('Amplitude in dB'); - grid on; - ylim([-20,10]) -end \ No newline at end of file diff --git a/Functions/beautifyBERplot.m b/Functions/beautifyBERplot.m index 2d70cee..0697abc 100644 --- a/Functions/beautifyBERplot.m +++ b/Functions/beautifyBERplot.m @@ -23,8 +23,8 @@ num_markers = length(markers); % --- style all lines consistently for i = 1:length(lines) - lines(i).LineWidth = 1.1; - lines(i).LineStyle = '-'; + lines(i).LineWidth = 1; + % lines(i).LineStyle = '-'; if string(lines(i).Marker) == "none" lines(i).Marker = markers{mod(i-1, num_markers) + 1}; end @@ -88,10 +88,23 @@ if options.logscale set(gca, 'YScale', 'log'); end +% --- Figure size in centimeters --- +% width_pt = 500; +% height_pt = 300; +% +% pt2cm = 0.03514598; % TeX point → cm +% width_cm = width_pt * pt2cm; % = 8.85 cm +% height_cm = height_pt * pt2cm; % = 2.81 cm +% +% set(gcf, 'Units', 'centimeters', 'Position', [2 2 width_cm height_cm]); +% set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 width_cm height_cm]); + +% --- Formatting --- set(findall(gca, '-property', 'Interpreter'), 'Interpreter', 'latex'); set(gcf, 'Color', 'w'); set(gca, 'Box', 'on', 'LineWidth', 0.8); grid on; -set(gca, 'FontSize', 10, 'FontName', 'Times New Roman'); +set(gca, 'FontSize', 10, 'FontName', 'Latin Modern Roman'); + end diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate.m index 1c39b25..38ff1cf 100644 --- a/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate.m +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate.m @@ -5,7 +5,7 @@ db = DBHandler("dataBase", [dataBase], "type", database_type); fp = QueryFilter(); % fp.where('Runs', 'run_id','EQUALS', 987); -M = 4; +M = 6; fp.where('Runs', 'pam_level','EQUALS', M); % fp.where('Runs', 'bitrate','LESS_THAN', 310e9); fp.where('Runs', 'fiber_length','EQUALS', 2); @@ -18,7 +18,7 @@ fp.where('Runs', 'wavelength','EQUALS', 1310); fp.where('Runs', 'rop_attenuation','EQUALS', 0); fields = db.getTableFieldNames('power_state_info'); -fields = [fields; db.getTableFieldNames('dashboard_ungrouped_new')]; +fields = [fields; db.getTableFieldNames('dashboard_ungrouped_aug_nov_2025')]; [dataTable,~] = db.queryDB(fp, fields); eqstructures = unique(dataTable.equalizer_structure); @@ -29,7 +29,7 @@ show_bitrate = true; figure(5); hold on -for eqs = [equalizer_structure.vnle, equalizer_structure.vnle_pf_mlse] +for eqs = [equalizer_structure.vnle] % figure('Name',string([char(eqs),''])); % hold on @@ -148,13 +148,14 @@ for eqs = [equalizer_structure.vnle, equalizer_structure.vnle_pf_mlse] xticks(xraw); if show_bitrate - xticks(200:25:500); - xlim([350 500]); + % xticks(200:25:500); + % xlim([350 500]); + xlim([min(xraw), max(xraw)]); else xlim([min(xraw), max(xraw)]); end - ylim([5e-4, 0.3]); + ylim([1e-4, 0.5]); end yline([2.2e-4, 4.85e-3, 2e-2],'LineWidth',1,'LineStyle','--','HandleVisibility','off'); diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate_only_best_configs.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate_only_best_configs.m index 58ef10d..e9a886e 100644 --- a/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate_only_best_configs.m +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/ber_vs_rate_only_best_configs.m @@ -17,7 +17,7 @@ fp.where('Runs', 'wavelength','EQUALS', 1310); % fp.where('Runs', 'db_mode','EQUALS', 1); fp.where('Runs', 'rop_attenuation','EQUALS', 0); -[dataTable,~] = db.queryDB(fp, db.getTableFieldNames('dashboard')); +[dataTable,~] = db.queryDB(fp, db.getTableFieldNames('dashboard_ungrouped_after_nov_2025')); eqstructures = unique(dataTable.equalizer_structure); diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_ber_best_results.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_ber_best_results.m new file mode 100644 index 0000000..b38a814 --- /dev/null +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_ber_best_results.m @@ -0,0 +1,223 @@ + + +database_type = 'mysql'; +dataBase = 'labor_highspeed'; +db = DBHandler("dataBase", [dataBase], "type", database_type); + + +% M = 4; +fp = QueryFilter(); +% fp.where('Runs', 'pam_level','EQUALS', M); +fp.where('Runs', 'fiber_length','EQUALS', 2); +fp.where('Runs', 'wavelength','LESS_THAN', 1312); +% fp.where('Runs', 'db_mode','EQUALS', 1); % 0 == high preemphasis // 1 == low preemphasis +fp.where('Runs', 'rop_attenuation','EQUALS', 0); + +fields = db.getTableFieldNames('power_state_info'); +fields = [fields; db.getTableFieldNames('dashboard_ungrouped_alltime')]; %dashboard_ungrouped_after_nov_2025 dashboard_ungrouped_aug_nov_2025 +[dataTable,~] = db.queryDB(fp, fields); + +%% +cfg = struct; +cfg.x_axis = 'grossrate'; % 'symbol rate' | 'bitrate' | 'wavelength' grossrate +cfg.y_axis = 'BER'; % 'BER' | 'GMI' | 'AIR' | ... + +cfg.y_scale = 'auto'; % auto -> log for BER*, linear otherwise +cfg.outlier = 'mad'; % simple, robust; 'none' or 'pctl' also available +cfg.show_raw = false; +cfg.show_spread = 'none'; % 'none' or 'iqr' or minmax +cfg.agg = 'min'; % or 'median' +cfg.show_precoded = 0; + +% cfg.fec_lines = [2.2e-4 4.85e-3 2e-2]; % optional +cfg.fec_lines = []; +cfg.plot.custom_colors = [ + clr.Paired.red; + clr.Paired.blue; + clr.Paired.green; + clr.Paired.orange; + clr.Paired.purple + ]; + +cfg.plot.custom_colors_scatter = [ + clr.Paired.lightred; + clr.Paired.lightblue; + clr.Paired.lightgreen; + clr.Paired.lightorange; + clr.Paired.lightpurple + ]; + + +% New styling knobs +cfg.plot.use_cbrewer2 = true; +cfg.plot.colormap = 'Paired'; +cfg.plot.paired_dark_first = false; % dark for lines, light for scatter +cfg.plot.lineWidth = 2.0; +cfg.plot.errWidth = 1.2; +cfg.plot.scatterAlpha = 0.35; +cfg.plot.legendLocation = 'best'; +cfg.plot.fecLineWidth = 2.4; % thicker FEC limits +cfg.plot.lineStyle_pre_emph_on = '-'; +cfg.plot.lineStyle_pre_emph_off = '-'; + +%% PLOT NGMI + +% Common cfg +cfg.show_precoded = 1; +cfg.group_by = {'equalizer_structure','pre_emph'}; +cfg.x_axis = 'grossrate'; +cfg.y_axis = 'NGMI'; % 'BER' | 'GMI' | 'AIR' | ... +cfg.y_scale = 'lin'; +cfg.plot.custom_colors_scatter = []; +cfg.plot.use_cbrewer2 = false; +cfg.fec_lines = []; +cfg.agg = 'max'; + +cfg.figure_number = 45; +% fig = figure(cfg.figure_number); + +lambda = 1310; +% PAM 4 +cfg.plot.custom_colors = clr.Paired.red; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters = struct('is_mpi',0,'pam_level',4, ... + 'equalizer_structure',equalizer_structure.vnle_db_mlse, ... + 'pre_emph',0,'wavelength',lambda); +cfg.show_precoded = 1; +a = plot_measurements_gpt(dataTable, cfg); +ngmi_pam4 = a.lines(1).YData; +tp = TransmissionPerformance; +netrates_vnle = tp.calculateNetRate(baudrate.* m, ... + 'NGMI', ngmi_pam4, ... + 'BER', BER_VNLE); + +cfg.plot.custom_colors = clr.Paired.red; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters = struct('is_mpi',0,'pam_level',4, ... + 'equalizer_structure',equalizer_structure.vnle_db_mlse, ... + 'pre_emph',0,'wavelength',1293); +cfg.show_precoded = 1; +plot_measurements_gpt(dataTable, cfg); + +% PAM 6 +cfg.plot.custom_colors = clr.Paired.blue; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters = struct('is_mpi',0,'pam_level',6, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',lambda); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +cfg.plot.custom_colors = clr.Paired.blue; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters = struct('is_mpi',0,'pam_level',6, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',1293); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +% PAM 8 +cfg.plot.custom_colors = clr.Paired.green; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters = struct('is_mpi',0,'pam_level',8, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',lambda); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +cfg.plot.custom_colors = clr.Paired.green; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters = struct('is_mpi',0,'pam_level',8, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',1293); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +beautifyBERplot +ylim([0.87,1.01]); +% xlim([290,480]); + +%% PLOT AIR + +% Common cfg +cfg.show_precoded = 1; +cfg.group_by = {'equalizer_structure','pre_emph'}; +cfg.x_axis = 'grossrate'; +cfg.y_axis = 'AIR'; % 'BER' | 'GMI' | 'AIR' | ... +cfg.y_scale = 'lin'; +cfg.plot.custom_colors_scatter = []; +cfg.plot.use_cbrewer2 = false; +cfg.fec_lines = []; +cfg.agg = 'max'; + +cfg.figure_number = 47; +% fig = figure(cfg.figure_number); + +lambda = 1310; + +% PAM 4 +cfg.plot.custom_colors = clr.Paired.red; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters = struct('is_mpi',0,'pam_level',4, ... + 'equalizer_structure',equalizer_structure.vnle_db_mlse, ... + 'pre_emph',0,'wavelength',lambda); +cfg.show_precoded = 1; +plot_measurements_gpt(dataTable, cfg); + + + +cfg.plot.custom_colors = clr.Paired.red; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters = struct('is_mpi',0,'pam_level',4, ... + 'equalizer_structure',equalizer_structure.vnle_db_mlse, ... + 'pre_emph',0,'wavelength',1293); +cfg.show_precoded = 1; +plot_measurements_gpt(dataTable, cfg); + +% PAM 6 +cfg.plot.custom_colors = clr.Paired.blue; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters = struct('is_mpi',0,'pam_level',6, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',lambda); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +cfg.plot.custom_colors = clr.Paired.blue; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters = struct('is_mpi',0,'pam_level',6, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',1293); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +% PAM 8 +cfg.plot.custom_colors = clr.Paired.green; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters = struct('is_mpi',0,'pam_level',8, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',lambda); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +cfg.plot.custom_colors = clr.Paired.green; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters = struct('is_mpi',0,'pam_level',8, ... + 'equalizer_structure',equalizer_structure.vnle_pf_mlse, ... + 'pre_emph',1,'wavelength',1293); +cfg.show_precoded = 0; +plot_measurements_gpt(dataTable, cfg); + +ax = gca; + +beautifyBERplot + +ylim([275,435]); +xlim([290,480]); + + +%% + + + + diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_ber_complete_results.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_ber_complete_results.m new file mode 100644 index 0000000..5cd72da --- /dev/null +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_ber_complete_results.m @@ -0,0 +1,170 @@ +database_type = 'mysql'; +dataBase = 'labor_highspeed'; +db = DBHandler("dataBase", [dataBase], "type", database_type); + + +% M = 4; +fp = QueryFilter(); +% fp.where('Runs', 'pam_level','EQUALS', M); +fp.where('Runs', 'fiber_length','EQUALS', 2); +fp.where('Runs', 'wavelength','EQUALS', 1310); +% fp.where('Runs', 'db_mode','EQUALS', 1); % 0 == high preemphasis // 1 == low preemphasis +fp.where('Runs', 'rop_attenuation','EQUALS', 0); + +fields = db.getTableFieldNames('power_state_info'); +fields = [fields; db.getTableFieldNames('dashboard_ungrouped_alltime')]; %dashboard_ungrouped_after_nov_2025 dashboard_ungrouped_aug_nov_2025 +[dataTable,~] = db.queryDB(fp, fields); + +%% +cfg = struct; +cfg.x_axis = 'grossrate'; % 'symbol rate' | 'bitrate' | 'wavelength' grossrate +cfg.y_axis = 'BER'; % 'BER' | 'GMI' | 'AIR' | ... + +cfg.y_scale = 'auto'; % auto -> log for BER*, linear otherwise +cfg.outlier = 'mad'; % simple, robust; 'none' or 'pctl' also available +cfg.show_raw = false; +cfg.show_spread = 'none'; % 'none' or 'iqr' or minmax +cfg.agg = 'min'; % or 'median' +cfg.show_precoded = 0; + +% cfg.fec_lines = [2.2e-4 4.85e-3 2e-2]; % optional +cfg.fec_lines = []; +cfg.plot.custom_colors = [ + clr.Paired.red; + clr.Paired.blue; + clr.Paired.green; + clr.Paired.orange; + clr.Paired.purple +]; + +cfg.plot.custom_colors_scatter = [ + clr.Paired.lightred; + clr.Paired.lightblue; + clr.Paired.lightgreen; + clr.Paired.lightorange; + clr.Paired.lightpurple +]; + + +% New styling knobs +cfg.plot.use_cbrewer2 = true; +cfg.plot.colormap = 'Paired'; +cfg.plot.paired_dark_first = false; % dark for lines, light for scatter +cfg.plot.lineWidth = 2.0; +cfg.plot.errWidth = 1.2; +cfg.plot.scatterAlpha = 0.35; +cfg.plot.legendLocation = 'best'; +cfg.plot.fecLineWidth = 2.4; % thicker FEC limits +cfg.plot.lineStyle_pre_emph_on = '-'; +cfg.plot.lineStyle_pre_emph_off = '-'; + + +%% Grid configuration +rows = 3; % PAM 4,6,8 +cols = 4; % DSP schemes +pam = [4 6 8]; + +cfg.figure_number = 46; +fig = figure(cfg.figure_number); clf; + +% Create extremely compact tile layout +t = tiledlayout(rows, cols, ... + 'TileSpacing','compact', ... + 'Padding','compact'); + +% Common cfg +cfg.show_precoded = 1; +cfg.group_by = {'equalizer_structure','pre_emph'}; +cfg.x_axis = 'grossrate'; +cfg.y_axis = 'BER'; +cfg.y_scale = 'log'; +cfg.plot.custom_colors_scatter = []; +cfg.plot.use_cbrewer2 = false; +cfg.fec_lines = []; +% DSP scheme definitions --------------------------------------------- +DSP(1).name = 'vnle'; +DSP(1).eq = equalizer_structure.vnle; +DSP(1).color = clr.Paired.red; +DSP(1).lightcolor = clr.Paired.lightred; + +DSP(2).name = 'VNLE PF MLSE'; +DSP(2).eq = equalizer_structure.vnle_pf_mlse; +DSP(2).color = clr.Paired.green; +DSP(2).lightcolor = clr.Paired.lightgreen; + +DSP(3).name = 'VNLE DB MLSE'; +DSP(3).eq = equalizer_structure.vnle_db_mlse; +DSP(3).color = clr.Paired.blue; +DSP(3).lightcolor = clr.Paired.lightblue; + +DSP(4).name = 'ML MLSE'; +DSP(4).eq = equalizer_structure.ml_mlse; +DSP(4).color = clr.Paired.purple; +DSP(4).lightcolor = clr.Paired.lightpurple; + + +% === Main nested loop: rows = PAM format, columns = DSP scheme === +for r = 1:rows + M = pam(r); + + for c = 1:cols + ax = nexttile(t, (r-1)*cols + c); + cfg.ax = ax; + + % ---- pre-emph = 1 (solid) ---- + cfg.plot.custom_colors = DSP(c).lightcolor; + cfg.plot.custom_linetypes = {'-'}; + cfg.filters = struct('is_mpi',0,'pam_level',M, ... + 'equalizer_structure',DSP(c).eq, ... + 'pre_emph',1); + plot_measurements_gpt(dataTable, cfg); + + % ---- pre-emph = 0 (dashed) ---- + cfg.plot.custom_colors = DSP(c).color; + cfg.plot.custom_linetypes = {'-'}; + cfg.filters.pre_emph = 0; + plot_measurements_gpt(dataTable, cfg); + + if M == 4 + ylim([1e-5 0.2]); + else + ylim([6e-4 0.2]); + end + + % % FEC limits + yline([2.2e-4 4.85e-3 2e-2],'LineWidth',1.1,'Color',[0.2 0.2 0.2], ... + 'LineStyle',':','HandleVisibility','off'); + + % Axes prettification + beautifyBERplot; + + % ===== Remove redundant labels ===== + if c > 1 + ax.YLabel = []; + end + if r < rows + ax.XLabel = []; + end + + grid(ax,'on'); box(ax,'on'); + end +end + +%this is just a ranom size but fits and is fixed now! +pos = 1e3.*[0.0983 0.6110 1.4113 0.4733]; +set(fig, 'Position', pos) + + + + +%% === EXPORT TO TIKZ === +outfile = 'C:\Users\Silas\Documents\latex\JLT_400G copy\media\matlab2tikz\compare_pre_emphasis.tikz'; + +matlab2tikz(outfile, ... + 'width','\fwidth', ... + 'height','\fheight', ... + 'showInfo',false, ... + 'extraAxisOptions',{ ... + 'legend style={font=\footnotesize}', ... + 'legend columns=1' ... + } ); \ No newline at end of file diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_pre_emphasis.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_pre_emphasis.m new file mode 100644 index 0000000..525956b --- /dev/null +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/compare_pre_emphasis.m @@ -0,0 +1,112 @@ +database_type = 'mysql'; +dataBase = 'labor_highspeed'; +db = DBHandler("dataBase", [dataBase], "type", database_type); + + +M = 4; +fp = QueryFilter(); +fp.where('Runs', 'pam_level','EQUALS', M); +fp.where('Runs', 'fiber_length','EQUALS', 2); +fp.where('Runs', 'wavelength','EQUALS', 1310); +% fp.where('Runs', 'db_mode','EQUALS', 1); % 0 == high preemphasis // 1 == low preemphasis +fp.where('Runs', 'rop_attenuation','EQUALS', 0); + +fields = db.getTableFieldNames('power_state_info'); +fields = [fields; db.getTableFieldNames('dashboard_ungrouped_aug_nov_2025')]; %dashboard_ungrouped_after_nov_2025 dashboard_ungrouped_aug_nov_2025 +[dataTable,~] = db.queryDB(fp, fields); + +%% +cfg = struct; +cfg.x_axis = 'grossrate'; % 'symbol rate' | 'bitrate' | 'wavelength' grossrate +cfg.y_axis = 'BER'; % 'BER' | 'GMI' | 'AIR' | ... + +cfg.y_scale = 'auto'; % auto -> log for BER*, linear otherwise +cfg.outlier = 'mad'; % simple, robust; 'none' or 'pctl' also available +cfg.show_raw = false; +cfg.show_spread = 'none'; % 'none' or 'iqr' or minmax +cfg.agg = 'min'; % or 'median' +cfg.show_precoded = 0; +% cfg.fec_lines = [2.2e-4 4.85e-3 2e-2]; % optional +cfg.fec_lines = []; +cfg.plot.custom_colors = [ + clr.Paired.red; + clr.Paired.blue; + clr.Paired.green; + clr.Paired.orange; + clr.Paired.purple +]; + +cfg.plot.custom_colors_scatter = [ + clr.Paired.lightred; + clr.Paired.lightblue; + clr.Paired.lightgreen; + clr.Paired.lightorange; + clr.Paired.lightpurple +]; + + +% New styling knobs +cfg.plot.use_cbrewer2 = true; +cfg.plot.colormap = 'Paired'; +cfg.plot.paired_dark_first = false; % dark for lines, light for scatter +cfg.plot.lineWidth = 2.0; +cfg.plot.errWidth = 1.2; +cfg.plot.scatterAlpha = 0.35; +cfg.plot.legendLocation = 'best'; +cfg.plot.fecLineWidth = 2.4; % thicker FEC limits +cfg.plot.lineStyle_pre_emph_on = '-'; +cfg.plot.lineStyle_pre_emph_off = '-'; + +%% +cfg.figure_number = 42; + + +% ---- VNLE, no pre-emph (solid red) ---- +cfg.plot.custom_colors = [clr.Paired.red]; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters = struct('is_mpi',0,'pam_level',M, ... + 'equalizer_structure',equalizer_structure.vnle, ... + 'pre_emph',0); +plot_measurements_gpt(dataTable, cfg); + +% ---- VNLE, with pre-emph (dashed red) ---- +cfg.plot.custom_colors = [clr.Paired.red]; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters.pre_emph = 1; +plot_measurements_gpt(dataTable, cfg); + +% ---- VNLE PF MLSE, no pre-emph (solid green) ---- +cfg.plot.custom_colors = [clr.Paired.green]; +cfg.plot.custom_linetypes = {'-'}; +cfg.filters.equalizer_structure = equalizer_structure.vnle_pf_mlse; +cfg.filters.pre_emph = 0; +plot_measurements_gpt(dataTable, cfg); + +% ---- VNLE PF MLSE, with pre-emph (dashed green) ---- +cfg.plot.custom_colors = [clr.Paired.green]; +cfg.plot.custom_linetypes = {'--'}; +cfg.filters.pre_emph = 1; +plot_measurements_gpt(dataTable, cfg); + + +% === FEC LINES (no legend) === +yline([2.2e-4 4.85e-3 2e-2], ... + 'LineWidth',1.5,'Color',[0.4 0.4 0.4], ... + 'LineStyle',':','HandleVisibility','off'); + + +% === BEAUTIFY === +% beautifyBERplot; % your function + + +%% === EXPORT TO TIKZ === +outfile = 'C:\Users\Silas\Documents\latex\JLT_400G copy\media\matlab2tikz\compare_pre_emphasis.tikz'; + +matlab2tikz(outfile, ... + 'width','\fwidth', ... + 'height','\fheight', ... + 'showInfo',false, ... + 'extraAxisOptions',{ ... + 'legend style={font=\footnotesize}', ... + 'legend columns=1' ... + } ); \ No newline at end of file diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/generate_spectrum_plots.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/generate_spectrum_plots.m new file mode 100644 index 0000000..29ec0c4 --- /dev/null +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/generate_spectrum_plots.m @@ -0,0 +1,100 @@ +dsp_options.storage_path = 'Z:\2024\sioe_labor\'; +dsp_options.max_occurences = 1; +database = DBHandler("dataBase", 'labor_highspeed', "type", 'mysql' ); + +rate = 390e9; + +%% 1 - PAM 4 with preemphasis +fp = QueryFilter(); +M = 4; +fp.where('Runs', 'pam_level','EQUALS', M); +fp.where('Runs', 'bitrate','EQUALS', rate);%360,390 +fp.where('Runs', 'fiber_length','EQUALS', 2); +fp.where('Runs', 'wavelength','EQUALS', 1310); +fp.where('Runs', 'db_mode','EQUALS', 0); +fp.where('Runs', 'rop_attenuation','EQUAL', 0); + +[dataTable,~] = db.queryDB(fp, database.getTableFieldNames('Runs')); + +dataTable = queryRunid(dataTable.run_id, database); +fsym = dataTable.symbolrate; +M = double(dataTable.pam_level); + +% Load and Sync signal data from DB +[Tx_bits, Symbols, Scpe_cell, ~] = loadAndSyncSignalDataFromDb(dataTable, dsp_options); + +% Preprocess signal +Scpe_sig = preprocessSignal(Scpe_cell{1}, Symbols, fsym); + +if rate == 390e9 +Scpe_sig.spectrum("fignum",200,"normalizeTo0dB",1,"displayname",'Rx','addDCoffset',-5.8); +elseif rate == 300e9 +Scpe_sig.spectrum("fignum",200,"normalizeTo0dB",1,"displayname",'Rx','addDCoffset',-4.7); +end +ylim([-30,3]); +xlim([-5,100]); +Scpe_sig.spectrum("fignum",201,"normalizeTo0dB",0,"displayname",'Rx'); + + +%% 1 - PAM 4 without preemphasis +fp = QueryFilter(); +M = 4; +fp.where('Runs', 'pam_level','EQUALS', M); +fp.where('Runs', 'bitrate','EQUALS', rate);%360,390 +fp.where('Runs', 'fiber_length','EQUALS', 2); +fp.where('Runs', 'wavelength','EQUALS', 1310); +fp.where('Runs', 'db_mode','EQUALS', 1); +fp.where('Runs', 'rop_attenuation','EQUAL', 0); + +[dataTable,~] = db.queryDB(fp, database.getTableFieldNames('Runs')); + +dataTable = queryRunid(dataTable.run_id, database); +fsym = dataTable.symbolrate; +M = double(dataTable.pam_level); + +% Load and Sync signal data from DB +[Tx_bits, Symbols, Scpe_cell, ~] = loadAndSyncSignalDataFromDb(dataTable, dsp_options); + +% Preprocess signal +Scpe_sig = preprocessSignal(Scpe_cell{1}, Symbols, fsym); + +Scpe_sig.spectrum("fignum",200,"normalizeTo0dB",1,"displayname",'Rx','addDCoffset',0); +ylim([-30,3]); +xlim([-5,100]); +Scpe_sig.spectrum("fignum",201,"normalizeTo0dB",0,"displayname",'Rx'); + + + +if 0 + %% show freuqncy response of filter + + measure = 1; + + freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",70,"f_ref",256e9); + % + Digi_sig = freqresp.buildOFDM(); + + Digi_sig.spectrum("fignum",1112,"displayname",['maxamp:',num2str(maxamp)]); + + Digi_sig = Filter('filtdegree',3,"f_cutoff",70e9,"fs",256e9,"filterType",filtertypes.butterworth,"active",true).process(Digi_sig); + + Digi_sig = Filter('filtdegree',3,"f_cutoff",70e9,"fs",256e9,"filterType",filtertypes.bessel_inp,"active",true).process(Digi_sig); + + freqresp.estimate(Digi_sig,"fileName",'','save',false); + + freqresp.plot() + + a = gca; + a.YTick = [-30,-20,-10,0]; + + %% system frex + + + precomp_filename ='lab_high_speed'; + precomp_path = "C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\precomp"; + freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',92e9); + freqresp.load('loadPath', precomp_path, 'fileName', precomp_filename); + + fprintf('Plotting: %s\n', precomp_filename); + freqresp.plot(); +end \ No newline at end of file diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/plot_measurements_gpt.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/plot_measurements_gpt.m similarity index 73% rename from projects/HighSpeedExperiment_2024/Auswertung_JLT/plot_measurements_gpt.m rename to projects/HighSpeedExperiment_2024/Auswertung_JLT/final/plot_measurements_gpt.m index d0b95a1..fc88501 100644 --- a/projects/HighSpeedExperiment_2024/Auswertung_JLT/plot_measurements_gpt.m +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/plot_measurements_gpt.m @@ -14,13 +14,13 @@ defaults = struct( ... 'filters' , struct, ... 'agg' , 'mean', ... 'outlier' , 'auto', ... - 'mad_z' , 3, ... + 'mad_z' , 4, ... 'pct_limits' , [2.5 97.5], ... 'min_pts_x' , 3, ... 'show_raw' , true, ... 'show_precoded', [], ... 'show_spread' , 'none', ... - 'fec_lines' , [2.2e-4 4.85e-3 2e-2], ... + 'fec_lines' , [], ... 'plot', struct() ... ); cfg = filldefaults(cfg, defaults); @@ -75,6 +75,11 @@ T = T(validXY, :); x_raw = x_raw(validXY); y_raw = y_raw(validXY); +if mean(abs(y_raw)) > 1e8 + %giga values + y_raw = y_raw.*1e-9; +end + if cfg.show_precoded && ismember('BER_precoded', T.Properties.VariableNames) y_raw_p = T.BER_precoded(validXY); else @@ -92,8 +97,29 @@ nG = max(G); % ==== Colors (cbrewer2 'Paired' with dark/ light pairs) ==== [cols_line, cols_scatter] = buildGroupColors(nG, cfg.plot); -%% ---- Plotting -figure; hold on; grid on; +%% ---- Axes / Figure handling (new unified logic) + +% Priority: +% 1) cfg.ax → use existing axes (subplots/tiles) +% 2) cfg.figure_number → select/create figure +% 3) fallback: create new figure + +if isfield(cfg,'ax') && ~isempty(cfg.ax) && isgraphics(cfg.ax,'axes') + ax = cfg.ax; % use caller-provided axes + set(gcf,'CurrentAxes',ax); +else + if isfield(cfg,'figure_number') && ~isempty(cfg.figure_number) + figure(cfg.figure_number); + else + figure; + end + ax = gca; % active axes +end + +hold(ax,'on'); +grid(ax,'on'); + + h.lines = gobjects(nG,1); h.err = gobjects(nG,1); h.scat = gobjects(nG,1); @@ -120,34 +146,32 @@ for gi = 1:nG if nnz(km) < cfg.min_pts_x, km = true(size(yy)); end yy = yy(km); - if strcmpi(cfg.agg,'median'), yu(k)=median(yy,'omitnan'); elseif strcmpi(cfg.agg,'mean'), yu(k)=mean(yy,'omitnan'); elseif strcmpi(cfg.agg,'min'), yu(k)=min(yy); end + if strcmpi(cfg.agg,'median'), yu(k)=median(yy,'omitnan'); elseif strcmpi(cfg.agg,'mean'), yu(k)=mean(yy,'omitnan'); elseif strcmpi(cfg.agg,'min'), yu(k)=min(yy); elseif strcmpi(cfg.agg,'max'), yu(k)=max(yy); end if strcmpi(cfg.show_spread,'iqr') q = prctile(yy,[25 75]); ylo(k) = max(yu(k)-q(1), eps); yhi(k) = max(q(2)-yu(k), eps); + elseif strcmpi(cfg.show_spread,'minmax') + ylo(k) = min(yy); + yhi(k) = max(yy); end end % sort [xu, ord] = sort(xu); - yu = yu(ord); ylo = ylo(ord); yhi = yhi(ord); + yu = yu(ord); + ylo = ylo(ord); + yhi = yhi(ord); % Styles % Decide if we style by pre_emph - canStyleByPre = cfg.plot.use_pre_emph_styling && ismember('pre_emph', T.Properties.VariableNames); + % --- LINE TYPE SELECTION (no pre-emphasis logic) --- + ls = cfg.plot.lineStyle_default; - if canStyleByPre - if any(strcmp(group_by,'pre_emph')) - % pre_emph is an explicit grouping key -> take it from the group table - pre = logical(grpTbl.pre_emph(gi)); - else - % pre_emph not grouped, but available in the rows -> infer from the members of this group - pre = logical(mode(T.pre_emph(G==gi))); - end - ls = tern(pre, cfg.plot.lineStyle_pre_emph_on, cfg.plot.lineStyle_pre_emph_off); - else - % no pre-emph styling → use a single default style - ls = cfg.plot.lineStyle_default; + % User-defined override (cycled) + if isfield(cfg.plot,'custom_linetypes') && ~isempty(cfg.plot.custom_linetypes) + L = cfg.plot.custom_linetypes; + ls = L{ mod(gi-1, numel(L)) + 1 }; end lbl = buildLabel(grpTbl(gi,:), group_by); @@ -156,12 +180,12 @@ for gi = 1:nG colL = cols_line(gi,:); h.lines(gi) = plot(xu, yu, ... 'LineWidth', cfg.plot.lineWidth, ... - 'Marker', cfg.plot.marker, 'MarkerSize', 5, ... + 'Marker', cfg.plot.marker, 'MarkerSize', 3, ... 'Color', colL, 'LineStyle', ls, ... 'DisplayName', char(lbl)); % Spread (IQR) in line color - if strcmpi(cfg.show_spread,'iqr') && any(isfinite(ylo)) && any(isfinite(yhi)) + if any(isfinite(ylo)) && any(isfinite(yhi)) h.err(gi) = errorbar(xu, yu, ylo, yhi, 'LineStyle','none', ... 'Color', colL, 'CapSize', cfg.plot.capSize, 'HandleVisibility','off'); h.err(gi).LineWidth = cfg.plot.errWidth; @@ -195,30 +219,38 @@ for gi = 1:nG km = outlierMask(yy, cfg, true); if nnz(km) < cfg.min_pts_x, km = true(size(yy)); end yy = yy(km); - if strcmpi(cfg.agg,'median'), ypu(k)=median(yy,'omitnan'); elseif strcmpi(cfg.agg,'mean'), ypu(k)=mean(yy,'omitnan'); elseif strcmpi(cfg.agg,'min'), ypu(k)=min(yy); end + if strcmpi(cfg.agg,'median'), ypu(k)=median(yy,'omitnan'); elseif strcmpi(cfg.agg,'mean'), ypu(k)=mean(yy,'omitnan'); elseif strcmpi(cfg.agg,'min'), ypu(k)=min(yy); elseif strcmpi(cfg.agg,'max'), ypu(k)=max(yy); end end h.lines_p(gi) = plot(xu, ypu, ... 'LineWidth', max(1.2, cfg.plot.lineWidth-0.2), ... - 'Marker', cfg.plot.marker_precoded, 'MarkerSize', 5, ... + 'Marker', cfg.plot.marker_precoded, 'MarkerSize', 3, ... 'Color', colL, 'LineStyle', ':', ... 'DisplayName', [char(lbl) ' (precoded)']); end + + end %% ---- Axes / Labels / FEC ylabel(cfg.y_axis, 'Interpreter','none'); xlabel(x_label, 'Interpreter','none'); set(gca, 'YScale', cfg.y_scale, 'FontSize', 11); -legend('Location', cfg.plot.legendLocation); box on; +% legend('Location', cfg.plot.legendLocation); box on; + +xticks(floor(xu)); +xlim([min(xu), max(xu)]) if startsWith(cfg.y_axis,"BER",'IgnoreCase',true) for v = cfg.fec_lines yline(v, '--', 'Color', cfg.plot.fecColor, ... 'LineWidth', cfg.plot.fecLineWidth, 'HandleVisibility','off'); end - ylim([1e-4, 0.3]); + ylim([1e-5, 0.5]); + yticks([1e-5, 1e-4, 1e-3, 1e-2, 1e-1]); end + + end % ===== main ===== @@ -237,7 +269,11 @@ end end function out = tern(cond, a, b) -if cond, out = a; else, out = b; end + if cond + out = a; + else + out = b; + end end function T2 = applyFilters(T, filters) @@ -274,9 +310,12 @@ switch lower(whichX) if ~ismember('pam_level', T.Properties.VariableNames) error('bitrate requires "pam_level" column.'); end - bits = log2(double(T.pam_level)); + bits = floor(log2(double(T.pam_level))*10)/10; x = (T.symbolrate .* bits) * 1e-9; - label = 'Bitrate [Gb/s]'; + label = 'Grossrate [Gb/s]'; + case 'grossrate' + x = (T.grossrate) * 1e-9; + label = 'Grossrate [Gb/s]'; otherwise if ~ismember(whichX, T.Properties.VariableNames) error('x_axis "%s" not found in table.', whichX); @@ -317,38 +356,78 @@ for i = 1:numel(group_by) key = group_by{i}; val = grpRow.(key); if iscell(val), val = val{1}; end - if islogical(val), val = tern(val,'pre-emph on','pre-emph off'); end - parts(i) = sprintf('%s=%s', key, string(val)); + if islogical(val), val = tern(val,'w/','w/o'); end + if key == "equalizer_structure" + key = ''; + val = upper(val); + val = strrep(val,'_',' '); + end + + if key == "pre_emph" + % key = strrep(key,'_','-'); + val = [val, ' pre-emph.']; + key = ''; + end + + parts(i) = sprintf('%s %s', key, string(val)); end s = strjoin(parts, ', '); end function [cols_line, cols_scatter] = buildGroupColors(nG, plotcfg) -% Build paired colors (dark for lines, light for scatter) using cbrewer2('Paired') + +% --- 1) User-provided custom colors ------------------------------- +if isfield(plotcfg,'custom_colors') && ~isempty(plotcfg.custom_colors) + C = plotcfg.custom_colors; + if size(C,1) < nG + error('custom_colors must have at least nG=%d rows.', nG); + end + cols_line = C(1:nG, :); + + % Scatter colors: either user-provided or lightened + if isfield(plotcfg,'custom_colors_scatter') && ~isempty(plotcfg.custom_colors_scatter) + Cs = plotcfg.custom_colors_scatter; + if size(Cs,1) < nG + error('custom_colors_scatter must have at least nG=%d rows.', nG); + end + cols_scatter = Cs(1:nG, :); + else + % auto-lighten scatter colors + cols_scatter = zeros(nG,3); + for i = 1:nG + cols_scatter(i,:) = lightenColor(cols_line(i,:), 0.40); + end + end + return; +end + +% --- 2) Standard behavior (using cbrewer2 or fallback) ------------ useBrewer = plotcfg.use_cbrewer2 && exist('cbrewer2','file')==2; if useBrewer - N = max(2*nG, 12); % ensure pairs available + N = max(2*nG, 12); C = cbrewer2(plotcfg.colormap, N); cols_line = zeros(nG,3); cols_scatter = zeros(nG,3); for i = 1:nG if plotcfg.paired_dark_first - dark = C(2*i-1, :); light = C(2*i, :); + dark = C(2*i-1, :); + light = C(2*i, :); else - light = C(2*i-1, :); dark = C(2*i, :); + light = C(2*i-1, :); + dark = C(2*i, :); end cols_line(i,:) = dark; cols_scatter(i,:) = light; end else - % Fallback: lines() + lightened scatter C = lines(max(nG,7)); cols_line = C(1:nG,:); cols_scatter = zeros(nG,3); for i = 1:nG - cols_scatter(i,:) = lightenColor(cols_line(i,:), 0.5); % 50% toward white + cols_scatter(i,:) = lightenColor(cols_line(i,:), 0.50); end end + end function c2 = lightenColor(c, fracTowardWhite) diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/plot_rates.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/plot_rates.m new file mode 100644 index 0000000..29b09b5 --- /dev/null +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/plot_rates.m @@ -0,0 +1,34 @@ + +path = "C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\HighSpeedExperiment_2024\Auswertung_JLT\final\rates.csv"; + +%% === Read CSV into a table === +T = readtable(path, 'Delimiter', ';', 'DecimalSeparator', ','); + +%% === Column definitions === +x = T.X_Werte; +pam_cols = {'PAM_2','PAM_4','PAM_6','PAM_8','PAM_12'}; +titles = {'PAM-2','PAM-4','PAM-6','PAM-8','PAM-12'}; + +% === Create subplots === +figure;hold on +c = linspecer(6); +for k = 1:numel(pam_cols) + + y = T.(pam_cols{k}); + valid = ~isnan(y); + + + % Scatter plot + s = scatter(x(valid), y(valid), 25, 'filled','MarkerEdgeColor',c(k,:),'MarkerFaceColor',c(k,:),'DisplayName',titles{k}); + + % Fit (2nd-order polynomial) + p = polyfit(x(valid), y(valid), 2); + xfit = linspace(min(x(valid)), max(x(valid)), 200); + yfit = polyval(p, xfit); + + % Plot fit curve + plot(xfit, yfit, 'LineWidth', 1,'linestyle',':','Color',c(k,:),'HandleVisibility','off'); + + xlabel('baud rate [GBd]'); + ylabel('net rate [Gb/s]'); +end \ No newline at end of file diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/rates.csv b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/rates.csv new file mode 100644 index 0000000..c00999e --- /dev/null +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/rates.csv @@ -0,0 +1,38 @@ +X-Werte;PAM-2;PAM-4;PAM-6;PAM-8;PAM-12 +224;204;;;; +205,5;193,4;;;; +205,1;189,7;;;; +192;168;;;; +240;;427,4;;; +225;;420,5;;; +210;;336;;; +184;;332;;; +192;;320;;; +176;;306,0869565;;; +190;;304;;; +168;;294;;; +156,2;;287,1;;; +160,8;;286,9;;; +170;;272;;; +132;;250,9505703;;; +112;;209,3457944;;; +172;;337;;; +216;;;474,6;; +147,2;;;329,9;; +132;;;319,7891753;; +143,1;;;318;; +160;;;377;; +225;;;;562,5; +200;;;;510; +160;;;;438; +180;;;;432; +180;;;;432; +144;;;;384; +143,7;;;;363,4; +144;;;;360; +136;;;;353,859497; +136;;;;342,7995295; +128;;;;329,0488432; +129,7;;;;311,2; +160;;;;413; +160;;;;;481,2 diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/run_plot_measurements.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/run_plot_measurements.m similarity index 59% rename from projects/HighSpeedExperiment_2024/Auswertung_JLT/run_plot_measurements.m rename to projects/HighSpeedExperiment_2024/Auswertung_JLT/final/run_plot_measurements.m index 739f73f..6ebf0fc 100644 --- a/projects/HighSpeedExperiment_2024/Auswertung_JLT/run_plot_measurements.m +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/final/run_plot_measurements.m @@ -2,40 +2,59 @@ database_type = 'mysql'; dataBase = 'labor_highspeed';%'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\silas_labor_newdsp_newstructure.db'; db = DBHandler("dataBase", [dataBase], "type", database_type); -M = 4; +M = 8; fp = QueryFilter(); % fp.where('Runs', 'run_id','EQUALS', 987); fp.where('Runs', 'pam_level','EQUALS', M); % fp.where('Runs', 'symbolrate','EQUALS', 165e9); %150, 165, 180, 195, 210, 225, 240 -fp.where('Runs', 'fiber_length','EQUALS', 10); +fp.where('Runs', 'fiber_length','EQUALS', 2); % fp.where('Runs', 'is_mpi','EQUALS', 0); % fp.where('Runs', 'power_pd_in','GREATER_THAN', 7); % fp.where('Runs', 'interference_path_length','EQUALS', 1000); % fp.where('Runs', 'loop_id','GREATER_THAN', 11); % fp.where('Runs', 'sir','EQUALS',18); fp.where('Runs', 'wavelength','EQUALS', 1310); -fp.where('Runs', 'db_mode','EQUALS', 1); % 0 == high preemphasis // 1 == low preemphasis +% fp.where('Runs', 'db_mode','EQUALS', 1); % 0 == high preemphasis // 1 == low preemphasis % fp.where('Runs', 'rop_attenuation','EQUALS', 0); fields = db.getTableFieldNames('power_state_info'); -fields = [fields; db.getTableFieldNames('dashboard_ungrouped_new')]; +fields = [fields; db.getTableFieldNames('dashboard_ungrouped_alltime')]; %dashboard_ungrouped_after_nov_2025 dashboard_ungrouped_aug_nov_2025 [dataTable,~] = db.queryDB(fp, fields); + %% cfg = struct; -cfg.x_axis = 'symbolrate'; % 'symbolrate' | 'bitrate' | 'wavelength' +cfg.x_axis = 'grossrate'; % 'symbol rate' | 'bitrate' | 'wavelength' grossrate cfg.y_axis = 'BER'; % 'BER' | 'GMI' | 'AIR' | ... -cfg.group_by = {'wavelength','equalizer_structure','pre_emph'}; -cfg.filters = struct('is_mpi',0,'pam_level',M,'equalizer_structure',[equalizer_structure.ml_mlse,equalizer_structure.vnle,equalizer_structure.vnle_pf_mlse,equalizer_structure.vnle_db_mlse,equalizer_structure.dfe]); +cfg.group_by = {'equalizer_structure','pre_emph'}; +cfg.filters = struct('is_mpi',0,'pam_level',M,'equalizer_structure',[equalizer_structure.ml_mlse]);%,equalizer_structure.vnle_pf_mlse,equalizer_structure.vnle]); cfg.y_scale = 'auto'; % auto -> log for BER*, linear otherwise cfg.outlier = 'mad'; % simple, robust; 'none' or 'pctl' also available -cfg.show_raw = true; -cfg.show_spread = 'none'; % 'none' or 'iqr' -cfg.agg = 'mean'; % or 'median' -cfg.show_precoded = 1; +cfg.show_raw = false; +cfg.show_spread = 'none'; % 'none' or 'iqr' or minmax +cfg.agg = 'min'; % or 'median' +cfg.show_precoded = 0; cfg.fec_lines = [2.2e-4 4.85e-3 2e-2]; % optional +cfg.figure_number = 42; +cfg.plot.custom_colors = [ + clr.Paired.red; + clr.Paired.blue; + clr.Paired.green; + clr.Paired.orange; + clr.Paired.purple +]; + +cfg.plot.custom_colors_scatter = [ + clr.Paired.lightred; + clr.Paired.lightblue; + clr.Paired.lightgreen; + clr.Paired.lightorange; + clr.Paired.lightpurple +]; + + % New styling knobs cfg.plot.use_cbrewer2 = true; cfg.plot.colormap = 'Paired'; @@ -48,4 +67,10 @@ cfg.plot.fecLineWidth = 2.4; % thicker FEC limits plot_measurements_gpt(dataTable, cfg); -% beautifyBERplot() \ No newline at end of file +% beautifyBERplot() + +%% FIG PRE EMPHASIS + + + + diff --git a/projects/HighSpeedExperiment_2024/Auswertung_JLT/run_dsp_from_db.m b/projects/HighSpeedExperiment_2024/Auswertung_JLT/run_dsp_from_db.m index 6df7d7f..b5fdd4a 100644 --- a/projects/HighSpeedExperiment_2024/Auswertung_JLT/run_dsp_from_db.m +++ b/projects/HighSpeedExperiment_2024/Auswertung_JLT/run_dsp_from_db.m @@ -1,6 +1,6 @@ % === SETTINGS === dsp_options.append_to_db = 0; -dsp_options.max_occurences = 15; +dsp_options.max_occurences = 5; experiment = "highspeed_2024"; dsp_options.mode = "load_run_id"; % 'simulate' & 'load_files' @@ -42,15 +42,15 @@ fp = QueryFilter(); % fp.where('Runs', 'run_id','EQUALS', 2776); M = 4; fp.where('Runs', 'pam_level','EQUALS', M); -% fp.where('Runs', 'bitrate','EQUALS', 300e9);%360,390 +fp.where('Runs', 'bitrate','EQUALS', 390e9);%360,390 % fp.where('Runs', 'symbolrate','EQUALS', 195e9); fp.where('Runs', 'fiber_length','EQUALS', 2); % fp.where('Runs', 'is_mpi','EQUALS', 0); % fp.where('Runs', 'interference_path_length','EQUALS', 1000); % fp.where('Runs', 'loop_id','GREATER_THAN', 11); % fp.where('Runs', 'sir','EQUALS',18); -fp.where('Runs', 'wavelength','EQUAL', 1310); -fp.where('Runs', 'db_mode','EQUALS', 1); +fp.where('Runs', 'wavelength','EQUALS', 1310); +fp.where('Runs', 'db_mode','EQUALS', 0); fp.where('Runs', 'rop_attenuation','EQUAL', 0); % fp.where('Runs', 'power_pd_in','GREATER_THAN', 7); diff --git a/projects/HighSpeedExperiment_2024/auswertung/only_show_precomp.m b/projects/HighSpeedExperiment_2024/auswertung/only_show_precomp.m index 2a8ee51..db72ac3 100644 --- a/projects/HighSpeedExperiment_2024/auswertung/only_show_precomp.m +++ b/projects/HighSpeedExperiment_2024/auswertung/only_show_precomp.m @@ -61,7 +61,7 @@ rcalpha = 0.05; Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"alpha",rcalpha); Pamsource = PAMsource(... - "fsym",fsym,"M",M,"order",19,"useprbs",1,... + "fsym",fsym,"M",M,"order",19,"useprbs",0,... "fs_out",fdac,... "applyclipping",0,"clipfactor",1.2,... "applypulseform",pulsef,"pulseformer",Pform,... @@ -87,4 +87,5 @@ Digi_sig= Digi_sig.normalize("mode","rms"); Digi_sig.spectrum("displayname","Strong Precomp","fignum",2223,"normalizeToNyquist",0,"normalizeTo0dB",0); - +ylim([-30,3]); +xlim([-5,100]); \ No newline at end of file diff --git a/projects/HighSpeedExperiment_2024/bias_evaluation.m b/projects/HighSpeedExperiment_2024/bias_evaluation.m index 3fe8d9d..43e5b7e 100644 --- a/projects/HighSpeedExperiment_2024/bias_evaluation.m +++ b/projects/HighSpeedExperiment_2024/bias_evaluation.m @@ -26,11 +26,14 @@ clf hold on cols = cbrewer2('Set1',3); for l = 1:numel(lambda_vals) + figure() for m = 1:numel(M_vals) ber_ffe = wh.getStoValue('ber_ffe',v_bias_vals,awg_vpp_vals(1),precomp_amp_max_vals(1),rop_atten_vals(1),M_vals(m),lambda_vals(l)); ber = wh.getStoValue('ber_collect',v_bias_vals,awg_vpp_vals(1),precomp_amp_max_vals(1),rop_atten_vals(1),M_vals(m),lambda_vals(l)); exfo = wh.getStoValue('exfo',v_bias_vals,awg_vpp_vals(1),precomp_amp_max_vals(1),rop_atten_vals(1),M_vals(m),lambda_vals(l)); + + lb = wh.getStoValue('exfo',v_bias_vals,awg_vpp_vals(1),precomp_amp_max_vals(1),rop_atten_vals(1),M_vals(m),lambda_vals(l)); for e = 1:numel(exfo) laser_pow(e) = exfo{e}.cur_power; @@ -42,7 +45,7 @@ for l = 1:numel(lambda_vals) rx_logbook = wh.getStoValue('rx_logbook',v_bias_vals(1),awg_vpp_vals(1),precomp_amp_max_vals(1),rop_atten_vals(1),M_vals(1),lambda_vals(1)); - subplot(1,3,l) + hold on a = scatter(v_bias_vals,min(ber,[],2),40,'LineWidth',2,'Marker','.','DisplayName',['PAM ',num2str(M_vals(m))],'MarkerEdgeColor',cols(m,:)); title([num2str(lambda_vals(l)),'nm']) @@ -66,7 +69,7 @@ for l = 1:numel(lambda_vals) % Polynomial fit (e.g., second-order polynomial) [woutliers,n] = rmoutliers( min(ber,[],2) ); - p = polyfit( v_bias_vals(~n), log10(woutliers), 4); % Adjust order as needed + p = polyfit( v_bias_vals(~n), log10(woutliers), 3); % Adjust order as needed BER_fit = polyval(p, v_bias_vals); @@ -93,6 +96,7 @@ for l = 1:numel(lambda_vals) end end +%% filename = "Z:\2024\sioe\High Speed Messungen Oktober\bias_testing_and_b2b\PAM4_b2b_bias_sweep_20241023_191202_wh_BB_BIAS_FINAL.mat"; diff --git a/projects/ML_based_MLSE/wpd_datasets.csv b/projects/ML_based_MLSE/wpd_datasets.csv new file mode 100644 index 0000000..c2059d7 --- /dev/null +++ b/projects/ML_based_MLSE/wpd_datasets.csv @@ -0,0 +1,9 @@ +FFE,,MLSE,,ML MLSE L=2,,ML MLSE L=5, +X,Y,X,Y,X,Y,X,Y +7.988476019722099,0.038632829886662855,7.9828552218736,0.02056096426419196,7.988825638727029,0.026145160025945406,7.982882115643211,0.01995262314968881 +8.984755714926044,0.02462092401494627,8.991855670103094,0.008868008219069292,8.991519497982967,0.012908315306800594,8.998027790228598,0.009002182769536628 +9.993487225459436,0.014339094903163154,9.988632900044824,0.0032424222072799827,9.994320932317347,0.005651632488900345,9.994751232631108,0.0034952501326754757 +10.989914836396235,0.007746944324122318,10.991730165844913,0.001020224273461357,10.997256835499776,0.002129417748571358,10.991689825190498,0.0010672369906432938 +12.005060510981624,0.0034952501326754757,12.001483639623487,0.00018978455660928717,11.994316450022412,0.0005679993334792185,12.007359928283282,0.0002680778116002006 +12.983254146122816,0.0013169376605490738,13.011492604213357,0.000026540740973404924,12.997722994173017,0.00012652429120320801,12.992384580905423,0.000049125201846734525 +13.99255042581802,0.0004081967712510506,14.00969520394442,0.000001975386920666194,13.995172568354999,0.00002183385565256239,14.015275661138503,0.0000038826695948713645 diff --git a/projects/standard_system/freqresp_test.m b/projects/standard_system/freqresp_test.m index d305da3..f0cab66 100644 --- a/projects/standard_system/freqresp_test.m +++ b/projects/standard_system/freqresp_test.m @@ -1,28 +1,19 @@ -measure = 0; +measure = 1; + +freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",70,"f_ref",256e9); +% +Digi_sig = freqresp.buildOFDM(); + +Digi_sig.spectrum("fignum",1112,"displayname",['maxamp:',num2str(maxamp)]); + +Digi_sig = Filter('filtdegree',3,"f_cutoff",70e9,"fs",256e9,"filterType",filtertypes.butterworth,"active",true).process(Digi_sig); + +Digi_sig = Filter('filtdegree',3,"f_cutoff",70e9,"fs",256e9,"filterType",filtertypes.bessel_inp,"active",true).process(Digi_sig); -if measure - freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",70,"f_ref",256e9); - % - Digi_sig = freqresp.buildOFDM(); -else - [Digi_sig,Symbols,Bits] = PAMsource("fsym",fsym,"M",M,"order",18,"useprbs",0,... - "fs_out",M8199.fdac,"applyclipping",1,"clipfactor",1.7,"applypulseform",1,"pulseformer",Pform,"randkey",pn_key,"mrds_code",usemrds,"mrds_blocklength",512).process(); -end +freqresp.estimate(Digi_sig,"fileName",'','save',false); -Digi_sig.spectrum("fignum",1112,"displayname",['Signal']); +freqresp.plot() -maxamp = -1; -El_sig = freqresp.precomp(Digi_sig,"maxampdb",maxamp); - -El_sig.spectrum("fignum",1112,"displayname",['maxamp:',num2str(maxamp)]); - -El_sig = Filter('filtdegree',2,"f_cutoff",60e9,"fs",256e9,"filterType",filtertypes.butterworth,"active",true).process(El_sig); - -if measure - freqresp.estimate(El_sig,"fileName",'','save',false); -end - - - -El_sig.spectrum("fignum",1112,"displayname",['after filter; maxamp:',num2str(maxamp)]); \ No newline at end of file +a = gca; +a.YTick = [-30,-20,-10,0];