High Speed Auswertung und Database code

This commit is contained in:
sioe
2024-11-13 10:49:49 +01:00
parent ca769f2b3d
commit 553ed19b9f
20 changed files with 2931 additions and 66 deletions

View File

@@ -1,5 +1,10 @@
if 0
% cleanup measurement data
% remove fots from files
% merge measurments into database
if 1
folderPath = "/Volumes/NT-Labor/2024/sioe/High Speed Messungen Oktober/mpi_measurement";

View File

@@ -0,0 +1,475 @@
% Connect to SQLite database
pathToDB = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\silas_labor.db'; % Update the path as needed
db = DBHandler("pathToDB",pathToDB);
% main file path
sioe_labor_path = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor';
% Get list of all folders (including subfolders) within sioe_labor_path
folderList = dir(fullfile(sioe_labor_path, '**', '*'));
% Filter to include only directories and exclude '.' and '..'
folderNames = {folderList([folderList.isdir]).name};
folderPaths = {folderList([folderList.isdir]).folder}; % Get the full paths
folderPaths = folderPaths(~ismember(folderNames, {'.', '..'}));
folderNames = folderNames(~ismember(folderNames, {'.', '..'}));
% Combine folder names with paths
fullFolderPaths = flip(fullfile(folderPaths, folderNames));
only_mpi=0;
if only_mpi
fullFolderPaths = fullFolderPaths(contains(fullFolderPaths,"mpi"));
end
relativeFolderPaths = strrep(fullFolderPaths, sioe_labor_path, '');
disp(['Start to process ',num2str(numel(relativeFolderPaths)), ' folder in the directory']);
for f = 1:numel(fullFolderPaths)
folder = fullFolderPaths{f};
relfolder = relativeFolderPaths{f};
% Get list of all files in the specified folder and subfolders
fileList = dir(folder);
if isempty(fileList(~[fileList.isdir]))
continue
end
matches = regexp(folder, '\d+km', 'match');
% Check if a match was found
if ~isempty(matches)
length_from_foldername_km = matches{1}; % Extract the first match
length_from_foldername_km = strrep(length_from_foldername_km,'km','');
disp(['The length is: ', length_from_foldername_km]);
else
disp('No length information found in the folder name.');
end
% Loop through each file and rename if necessary
for i = 1:length(fileList)
oldName = fileList(i).name;
% Use regex to find and remove any prefix before the date string
newName = regexprep(oldName, '^[^\d]*(\d{8}_\d{6}.*)', '$1');
% Insert an underscore before "PAM" if missing
newName = regexprep(newName, '(\d{8}_\d{6})(PAM)', '$1_PAM');
% Rename the file only if a change was made
if ~strcmp(oldName, newName)
movefile(fullfile(fileList(i).folder, oldName), fullfile(fileList(i).folder, newName));
fprintf('Renamed: %s -> %s\n', oldName, newName);
end
end
% Get new list of all files in the specified folder and subfolders, we
% renamed files so we need to get the new filenames here to work on :-)
fileList = dir(folder);
% Initialize lists to store DataStorage objects based on size
big_wh_list = {}; % For large DataStorage objects
big_wh_filename = {}; % Corresponding filenames for large objects
small_wh_list = {}; % For small DataStorage objects
small_wh_filename = {}; % Corresponding filenames for small objects
% Loop through each file and categorize based on the presence of 'wh' in the filename
for i = 1:length(fileList)
fileName = fileList(i).name;
if contains(fileName, 'wh')
% Load DataStorage object from file
wh = load(fullfile(fileList(i).folder, fileName));
wh = wh.obj;
% Classify as big or small based on dimensions
if isa(wh, 'DataStorage')
if prod(wh.dim) > 2
big_wh_list{end+1} = wh;
big_wh_filename{end+1} = fileName;
else
small_wh_list{end+1} = wh;
small_wh_filename{end+1} = fileName;
end
end
end
end
% Aggregate unique parameters across all large DataStorage objects
params_merge = struct;
for c = 1:numel(big_wh_list)
fnames = fieldnames(big_wh_list{c}.parameter);
for f = 1:numel(fnames)
% Initialize field if not already present
if ~isfield(params_merge, fnames{f})
params_merge.(fnames{f}) = [];
end
% Merge unique parameter values into params_merge
a = big_wh_list{c}.parameter.(fnames{f}).values;
b = params_merge.(fnames{f});
vals_to_add = setdiff(a, b); % New values in a that aren't in b
b = sort([b, vals_to_add]); % Combine and sort values
params_merge.(fnames{f}) = b;
end
end
% Process each large DataStorage object
for w = 1:numel(big_wh_list)
wh = big_wh_list{w};
% Extract date and time for filename generation
datebody = regexp(big_wh_filename{w}, '^\d{8}_\d{6}', 'match', 'once');
% Get the total number of linear indices
totalIndices = wh.getLastLinIndice;
% Initialize the waitbar
h = waitbar(0, 'Processing DataStorage...');
% Loop over each linear index in DataStorage
for i = 1:wh.getLastLinIndice
% Update the waitbar with the current progress
waitbar(i / totalIndices, h, sprintf('Folder: %s...\n %d of %d', string(strrep(strrep(relfolder, '\', '/'),'_',' ')), i, totalIndices));
% Initialize record struct for each entry and flag for non-empty data
measurementStruct = struct();
recordIsFilled = false;
% Loop over each storage within DataStorage and gather data
storage_names = fieldnames(wh.sto);
for s = 1:length(storage_names)
% Retrieve physical values, parameter names, and stored value
[configStruct, stored_value] = wh.getPhysAndValueByLinIndex(storage_names{s}, i);
measurementStruct.(storage_names{s}) = stored_value;
if ~isempty(stored_value)
recordIsFilled = true; % Mark as filled if value is present
end
end
[configStruct.precomp_amp_max,configStruct.v_bias_for_pam] = getBias(configStruct.duobinary,configStruct.M);
isMPI = isfield(measurementStruct,'i_power');
% Process record if it contains data
if recordIsFilled
if ~isMPI
% Generate filenames with conditionally formatted parameters
% Format the L parameter value (show decimal only if non-zero)
if configStruct.lambda == floor(configStruct.lambda)
L_str = sprintf('%.0f',configStruct.lambda); % No decimal part
else
L_str = sprintf('%.1f', configStruct.lambda); % Include one decimal place
end
% Synthesize filename base with placeholders for storage types
fbody_tx = sprintf('%s_PAM_%d_L_%s_R_%d_DB_%d_ROP_%d', datebody, ...
configStruct.M, L_str, configStruct.bitrate, configStruct.duobinary, 0);
fbody_tx = strrep(fbody_tx, '.', '_'); % Replace decimal point with underscore
fbody_rx = sprintf('%s_PAM_%d_L_%s_R_%d_DB_%d_ROP_%d', datebody, ...
configStruct.M, L_str, configStruct.bitrate, configStruct.duobinary, configStruct.rop_atten);
fbody_rx = strrep(fbody_rx, '.', '_');
elseif isMPI
fbody_tx = sprintf('%s_PAM_%d_R_%d_DB_%d_I_atten_%d', datebody, ...
configStruct.M, configStruct.bitrate, configStruct.duobinary, 0);
fbody_tx = strrep(fbody_tx, '.', '_'); % Replace decimal point with underscore
fbody_rx = sprintf('%s_PAM_%d_R_%d_DB_%d_I_atten_%d', datebody, ...
configStruct.M, configStruct.bitrate, configStruct.duobinary, configStruct.interference_atten);
fbody_rx = strrep(fbody_rx, '.', '_'); % Replace decimal point with underscore
end
% Check existence of different file types (bits, symbols, raw signal, rx signal)
% BIT SEQUENCE
fn_bits = [filesep, fbody_tx, '_bits.mat'];
fp_bits = fullfile([folder, fn_bits]);
if exist(fp_bits, "file") == 2
fn_bits_rel = [relfolder, fn_bits];
else
warning(['Bits not found at: ', fn_bits]);
end
% SYMBOL SEQUENCE
fn_symbols = [filesep, fbody_tx, '_symbols.mat'];
fp_symbols = fullfile([folder, fn_symbols]);
if exist(fp_symbols, "file") == 2
fn_symbols_rel = [relfolder, fn_symbols];
else
warning(['Symbols not found at: ', fn_symbols]);
end
% RAW RX SIGNAL
fn_rxraw = [filesep, fbody_rx, '_raw_signal.mat'];
fp_rxraw = fullfile([folder, fn_rxraw]);
missing_raw_flag = 1; % Initialize as missing
if exist(fp_rxraw, "file") == 2
fn_rxraw_rel = [relfolder, fn_rxraw];
missing_raw_flag = 0;
end
% SYNCHRONIZED RX SIGNAL
fn_rxtsynch = [filesep, fbody_rx, '_rx_signal.mat'];
fp_rxtsynch = fullfile([folder, fn_rxtsynch]);
if exist(fp_rxtsynch, "file") == 2
fn_rxtsynch_rel = [relfolder, fn_rxtsynch];
matObj = matfile([folder, fn_rxtsynch]);
% If RX signal actually contains raw signal, handle as necessary
if isprop(matObj, 'Scpe_sig_raw')
sig_rx = load([folder, fn_rxtsynch]);
if missing_raw_flag
% Save as raw signal if original raw signal is missing
Scpe_sig_raw = sig_rx.Scpe_sig_raw;
save([folder, fn_rxraw], "Scpe_sig_raw");
delete([folder, fn_rxtsynch]);
else
% Check if raw and rx signal files are identical, then delete duplicate
sig_raw = load([folder, fn_rxraw]);
if isequal(sig_raw, sig_rx)
delete([folder, fn_rxtsynch]);
end
end
end
elseif missing_raw_flag
warning(['RX Signal not found at: ', fn_rxtsynch]);
end
end
% Call the duplicate check function
exists = db.checkIfRunExists('Runs', 'rx_sync_path', fn_rxtsynch_rel);
if ~exists
% Table 1: Append to Runs
newRun = db.tables.Runs; % Get the existing table structure (an empty table)
newRun = struct(...
'run_id', NaN, ... % Auto-increment, leave empty
'date_of_run', datetime(datebody, 'InputFormat', 'yyyyMMdd_HHmmss'), ...
'tx_bits_path', fn_bits_rel, ...
'tx_symbols_path', fn_symbols_rel, ...
'rx_sync_path', fn_rxtsynch_rel, ...
'rx_raw_path', fn_rxraw_rel, ...
'filename', fbody_rx ...
);
% Append the new row to the Runs table and get the generated run ID
run_id = db.appendToTable('Runs', newRun);
if isMPI
assert(configStruct.interference_atten==measurementStruct.voa.value(4),'MPI attuation differs between voa state and desired config from simulation loop.');
interference_attenuation = configStruct.interference_atten;
interference_path_length = 2;
power_mpi_interference = measurementStruct.voa.power_state(4);
power_mpi_signal = measurementStruct.voa.power_state(3);
rop_attenuation = 0;
wavelength = 1310;
fiber_length = 1;
else
interference_attenuation = NaN;
interference_path_length = NaN;
power_mpi_interference = NaN;
power_mpi_signal = NaN;
rop_attenuation = configStruct.rop_atten;
wavelength = configStruct.lambda;
fiber_length = str2double(length_from_foldername_km);
end
% Table 2: Append to Configurations
newConfig = db.tables.Configurations; % Get the existing table structure (an empty table)
newConfig = struct(...
'configuration_id', NaN, ... % Auto-increment, leave empty
'run_id', run_id, ... % Foreign key from Runs
'unique_elab_id', "20241028-dea635ef776cd18270922ba0e52c65831ff7699f", ... % Set unique_elab_id as needed
'bitrate', configStruct.bitrate, ...
'symbolrate', floor(configStruct.bitrate * 1e-9 / log2(configStruct.M)) * 1e9, ... % Calculate symbolrate if available
'pam_level', configStruct.M, ...
'db_mode', configStruct.duobinary, ... % Assuming db_mode corresponds to duobinary mode
'v_bias', configStruct.v_bias_for_pam, ...
'v_awg', 2.7, ...
'precomp_amp', configStruct.precomp_amp_max, ...
'rop_attenuation', rop_attenuation, ...
'wavelength', wavelength, ...
'fiber_length', fiber_length, ...
'is_mpi', isMPI, ... % Set false for no MPI, change as needed
'interference_path_length', interference_path_length, ... % Set NaN if not applicable
'interference_attenuation', interference_attenuation ... % Set NaN if not applicable
);
% Append the new row to the Configurations table
db.appendToTable('Configurations', newConfig);
% Table 3: Append to Measurements
newMeas = db.tables.Measurements; % Get the existing table structure (an empty table)
newMeas = struct(...
'measurement_id', NaN, ... % Auto-increment, leave empty
'run_id', run_id, ... % Foreign key from Runs
'power_laser', measurementStruct.exfo.cur_power, ...
'power_rop', measurementStruct.rop, ...
'power_pd_in', measurementStruct.pd_in, ...
'power_mpi_interference', power_mpi_interference, ...
'power_mpi_signal', power_mpi_signal, ...
'voa_class', measurementStruct.voa, ...
'pdfa_class', measurementStruct.pdfa, ...
'laser_class', measurementStruct.exfo ...
);
% Append the new row to the Measurements table
db.appendToTable('Measurements', newMeas);
% Table 4: Append to Bers
[ber, structure, settings] = getBers(configStruct,measurementStruct);
for t = 1:numel(ber)
if iscell(ber(t))
ber_ = ber(t);
ber_ = ber_{1};
else
ber_ = ber(t);
end
if ber_~=-1
newBer = struct(...
'ber_id', NaN,...
'run_id', run_id,...
'processing_structure', structure(t),...
'processing_settings', settings(t),...
'ber', jsonencode(ber_)...
);
db.appendToTable('BERs', newBer);
end
end
end
end
end
end
function [ber, structure, settings] = getBers(configStruct,measurementStruct)
if configStruct.duobinary == 0
structure(1) = "vnle";
settings(1) = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
ber(1) = measurementStruct.ber_vnle;
structure(2) = "vnle -> remove DC from error ""Noi{s}.signal = Noi{s}.signal - mean(Noi{s}.signal);"" -> burg(error) -> pf -> mlse";
settings(2) = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
ber(2) = measurementStruct.ber_vnle_mlse;
elseif configStruct.duobinary == 1
structure(1) = "tx: duobinary precode; rx: db target -> mlse -> modulo";
settings(1) = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
ber(1) = measurementStruct.ber_db;
elseif configStruct.duobinary == 2
structure(1) = "tx: duobinary precode -> encode; rx: db target -> mlse as decoder -> modulo";
settings(1) = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
ber(1) = measurementStruct.ber_db;
end
end
function [precomp_amp_max,v_bias_for_pam] = getBias(db,M)
if db == 1
ffe_only = 0;
postfilter_approach = 0;
db_channel_approach = 1;
db_coding_approach = 0;
db_precode = db_coding_approach || db_channel_approach;
if M == 4
pulsef=1;
precomp_amp_max = -50;
v_bias_for_pam = 2.3;
pulsef = 1;
elseif M == 6
pulsef=0;
precomp_amp_max = -50;
v_bias_for_pam = 2.3;
pulsef = 1;
elseif M == 8
pulsef=0;
precomp_amp_max = -50;
v_bias_for_pam=2.6;
pulsef = 0;
end
elseif db == 2
ffe_only = 0;
postfilter_approach = 0;
db_channel_approach = 0;
db_coding_approach = 1;
db_precode = db_coding_approach || db_channel_approach;
if M == 4
pulsef=1;
precomp_amp_max = -38;
v_bias_for_pam = 2.8;
pulsef = 1;
elseif M == 6
pulsef=0;
precomp_amp_max = -38;
v_bias_for_pam = 2.8;
pulsef = 1;
elseif M == 8
pulsef=0;
precomp_amp_max = -38;
v_bias_for_pam = 2.8;
pulsef = 1;
end
elseif db == 0
ffe_only = 0;
postfilter_approach = 1;
db_channel_approach = 0;
db_coding_approach = 0;
db_precode = db_coding_approach || db_channel_approach;
if M == 4
pulsef=1;
precomp_amp_max = -37;
v_bias_for_pam = 2.3;
pulsef = 1;
elseif M == 6
pulsef=0;
precomp_amp_max = -34;
v_bias_for_pam = 2.3;
pulsef = 1;
elseif M == 8
pulsef=0;
precomp_amp_max = -34;
v_bias_for_pam=2.6;
pulsef = 0;
end
end
end

View File

@@ -0,0 +1,28 @@
function checkDB(db_path)
db = DBHandler("pathToDB",db_path);
num_runs = db.fetch('SELECT COUNT(*) AS total_runs FROM Runs');
num_configs = db.fetch('SELECT COUNT(*) AS total_configurations FROM Configurations');
num_meas = db.fetch('SELECT COUNT(*) AS total_measurements FROM Measurements');
assert((num_runs{1,1}==num_configs{1,1})&&(num_configs{1,1}==num_meas{1,1}),'Different num of entries per table')
% should not be possible, but check if anyconfig or meas is without
% parent Run entry
unmatchedConfigs = db.fetch('SELECT COUNT(*) AS unmatched_configs FROM Configurations WHERE run_id NOT IN (SELECT run_id FROM Runs)');
unmatchedMeasurements = db.fetch('SELECT COUNT(*) AS unmatched_measurements FROM Measurements WHERE run_id NOT IN (SELECT run_id FROM Runs)');
if unmatchedConfigs{1,1}~=0 || unmatchedMeasurements{1,1}~=0
fprintf('Unmatched Configurations: %d\n', unmatchedConfigs{1,1});
fprintf('Unmatched Measurements: %d\n', unmatchedMeasurements{1,1});
end
%Check for any duplicate paths
db.fetch("SELECT rx_raw_path, COUNT(*) AS occurrences FROM Runs GROUP BY rx_raw_path HAVING COUNT(*) > 1");
db.fetch("SELECT rx_sync_path, COUNT(*) AS occurrences FROM Runs GROUP BY rx_sync_path HAVING COUNT(*) > 1");
db.fetch("SELECT filename, COUNT(*) AS occurrences FROM Runs GROUP BY filename HAVING COUNT(*) > 1");
end

View File

@@ -0,0 +1,52 @@
function createConfigMenu(DBHandler)
% Create the main figure window
fig = uifigure('Name', 'Configuration Query', 'Position', [100, 100, 400, 300]);
% Retrieve tables and table names using the DBHandler class
dbTables = DBHandler.getTables();
tableNames = DBHandler.getTableNames();
% Assume that the DBHandler class provides methods to get the unique
% configuration options (e.g., PAM levels, bitrates, etc.)
uniqueBitrates = unique([dbTables.bitrate]);
uniquePAMLevels = unique([dbTables.pam_level]);
uniqueWavelengths = unique([dbTables.wavelength]);
uniqueDBModes = unique([dbTables.db_mode]);
% Create dropdown menus for each configuration
lblBitrate = uilabel(fig, 'Text', 'Bitrate:', 'Position', [50, 240, 100, 20]);
dropdownBitrate = uidropdown(fig, 'Items', string(uniqueBitrates), 'Position', [150, 240, 200, 20]);
lblPAM = uilabel(fig, 'Text', 'PAM Level:', 'Position', [50, 200, 100, 20]);
dropdownPAM = uidropdown(fig, 'Items', string(uniquePAMLevels), 'Position', [150, 200, 200, 20]);
lblWavelength = uilabel(fig, 'Text', 'Wavelength:', 'Position', [50, 160, 100, 20]);
dropdownWavelength = uidropdown(fig, 'Items', string(uniqueWavelengths), 'Position', [150, 160, 200, 20]);
lblDBMode = uilabel(fig, 'Text', 'DB Mode:', 'Position', [50, 120, 100, 20]);
dropdownDBMode = uidropdown(fig, 'Items', string(uniqueDBModes), 'Position', [150, 120, 200, 20]);
% Create a button to query the configuration
btnQuery = uibutton(fig, 'Text', 'Query Configuration', 'Position', [150, 80, 200, 30], ...
'ButtonPushedFcn', @(btn, event) queryConfiguration(DBHandler, ...
dropdownBitrate.Value, ...
dropdownPAM.Value, ...
dropdownWavelength.Value, ...
dropdownDBMode.Value));
% Function to handle querying the configuration
function queryConfiguration(DBHandler, bitrate, pamLevel, wavelength, dbMode)
% Convert dropdown values to numeric if necessary
bitrate = str2double(bitrate);
pamLevel = str2double(pamLevel);
wavelength = str2double(wavelength);
dbMode = str2double(dbMode);
% Query the DBHandler class with the specified configuration
results = DBHandler.query(bitrate, pamLevel, wavelength, dbMode);
% Display the results in the command window (or update the GUI)
disp('Query Results:');
disp(results);
end
end

View File

@@ -0,0 +1,85 @@
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
%1) Get path info from DB
filterParams = db.promptFilterParameters();
filterParams = db.tables;
filterParams.Configurations = struct( ...
'bitrate', 300e9, ...
'db_mode', 0, ...
'fiber_length', 10, ...
'interference_attenuation', [], ...
'interference_path_length', [], ...
'is_mpi', 0, ...
'pam_level', 4, ...
'precomp_amp', [], ...
'rop_attenuation', 0, ...
'symbolrate', [], ...
'v_awg', [], ...
'v_bias', [], ...
'wavelength', 1310 ...
);
% filterParams.Equalizer.eq_id = 1;
% selectedFields = db.promptSelectFields();
selectedFields = {'Runs.run_id','Runs.tx_bits_path', 'Runs.tx_symbols_path', 'Runs.rx_sync_path','Runs.rx_raw_path','Configurations.db_mode'};
pathTable = db.getPathsWithFlexibleFilter(filterParams, selectedFields);
fprintf('Found %d entries for requested Configuration. IDs are: %s \n',size(pathTable,1),jsonencode(pathTable.run_id));
selectedBerFields = {'BERs.ber_id','BERs.run_id','BERs.eq_id'};
berresult = db.getPathsWithFlexibleFilter(filterParams, selectedBerFields);
%2) Process
for i = 1:size(pathTable,1)
tx_bits = load([basePath, char(pathTable.tx_bits_path(i))]);
tx_bits = tx_bits.Bits;
tx_symbols = load([basePath, char(pathTable.tx_symbols_path(i))]);
tx_symbols = tx_symbols.Symbols;
rx_sync = load([basePath, char(pathTable.rx_sync_path(i))]);
rx_sync = rx_sync.S;
%rx_raw = load([basePath, char(result.rx_raw_path(i))]);
%2.1) EQ
for o = 1:numel(rx_sync)
rx_sig = rx_sync{o};
switch pathTable.db_mode(i)
case 0
%normal signaling
eq_ = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.05,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
eq_sig = vnle(eq_,rx_sig,tx_symbols);
case 1
%db targeting => less precompensation; pre-coded
case 2
%db signaling => db encoded
end
rx_bits = PAMmapper(4,0).demap(eq_sig);
[~,~,ber_vnle(o),~] = calc_ber(rx_bits.signal,tx_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
end
%2.2) Store BER to DB Table "BERs"
% structure = ""; % Description or Comment of BER technqiue
% settings = EQ;
%
% newBer = struct(...
% 'ber_id', NaN,...
% 'run_id', current_run_id,...
% 'processing_structure', structure,...
% 'processing_settings', settings,...
% 'ber', jsonencode(ber)...
% );
%
% db.appendToTable('BERs', newBer);
end
%3) Look at BER that just ran

View File

@@ -1,5 +1,5 @@
wh = load('C:\Users\sioe\Documents\High_Speed_Measurement_2024\10km_bitrate_complete\20241030_170224_wh.mat');
wh = load('C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\highspeed_oct_2024\10km_bitrate_complete\20241030_170224_wh.mat');
wh = wh.obj;
M_vals = wh.parameter.M.values;
@@ -10,8 +10,8 @@ duobinary_vals = wh.parameter.duobinary.values;
rop_atten_vals = wh.parameter.rop_atten.values;
figure(177)
figure(18)
tiledlayout(3, 3, 'TileSpacing', 'compact', 'Padding', 'compact');
for M_choose = [8]
sgtitle(['PAM',num2str(M_choose)])
@@ -36,8 +36,8 @@ for M_choose = [8]
end
cols = linspecer(4);
subplot(3,3,l)
%subplot(3,3,l)
nexttile;
if M_choose == 4
lst = '-';
mkr = 'o';
@@ -56,24 +56,24 @@ for M_choose = [8]
fsym_vals = floor( bitrate_vals*1e-9./log2(M_choose) );
hold on
plot(bitrate_vals*1e-9,ber_db,'Color',cols(1,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','DB pre','LineStyle',lst,'HandleVisibility',hv);
plot(bitrate_vals*1e-9,ber_db_enc,'Color',cols(2,:)','Marker',mkr,'MarkerFaceColor','auto','DisplayName','DB enc','LineStyle',lst,'HandleVisibility',hv);
plot(bitrate_vals*1e-9,ber_vnle,'Color',cols(3,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','VNLE','LineStyle',lst,'HandleVisibility',hv);
plot(bitrate_vals*1e-9,ber_vnle_mlse,'Color',cols(4,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','VNLE+PF+MLSE','LineStyle',lst,'HandleVisibility',hv);
plot(bitrate_vals*1e-9,ber_db,'Color',cols(1,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','DB pre','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
plot(bitrate_vals*1e-9,ber_db_enc,'Color',cols(2,:)','Marker',mkr,'MarkerFaceColor','auto','DisplayName','DB enc','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
plot(bitrate_vals*1e-9,ber_vnle,'Color',cols(3,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','VNLE','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
plot(bitrate_vals*1e-9,ber_vnle_mlse,'Color',cols(4,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','VNLE+PF+MLSE','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
% Continue with the rest of your plot settings
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
yline(2e-2, 'DisplayName', '20%', 'LineStyle', '--','LineWidth',1, 'HandleVisibility', 'off');
xlabel('Bitrate');
ylabel('Bit Error Rate (BER)');
%xlabel('Bitrate');
ylabel('BER');
title([num2str(lambda_vals(l)),' nm']);
set(gca, 'yscale', 'log');
set(gca, 'Box', 'on');
grid on;
grid minor;
legend('Interpreter', 'none','Location','southwest');
ylim([1e-4,1e-1]);
% legend('Interpreter', 'none','Location','southwest','Visible','off','HandleVisibility','off');
ylim([8e-4,1e-1]);
xlim([bitrate_vals(1)*1e-9,bitrate_vals(end)*1e-9])
end

View File

@@ -0,0 +1,83 @@
wh = load('C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\highspeed_oct_2024\10km_bitrate_complete\20241030_170224_wh.mat');
wh = wh.obj;
M_vals = wh.parameter.M.values;
M_choose = M_vals(1);
lambda_vals = wh.parameter.lambda.values;
bitrate_vals = wh.parameter.bitrate.values;
duobinary_vals = wh.parameter.duobinary.values;
rop_atten_vals = wh.parameter.rop_atten.values;
figure(11)
l = 6;
for m = 1:numel(M_vals)
sgtitle(['Lambda: ',num2str(lambda_vals(l)),' nm'])
%for l = 1:numel(lambda_vals)
for b = 1:numel(bitrate_vals)
M_choose = M_vals(m);
cel = wh.getStoValue('ber_vnle',M_choose(1),lambda_vals(l),bitrate_vals(b),duobinary_vals(1),rop_atten_vals(1));
ber_vnle(b)=min(cel{1});
cel = wh.getStoValue('ber_vnle_mlse',M_choose(1),lambda_vals(l),bitrate_vals(b),duobinary_vals(1),rop_atten_vals(1));
ber_vnle_mlse(b)=min(cel{1});
cel = wh.getStoValue('ber_db',M_choose(1),lambda_vals(l),bitrate_vals(b),duobinary_vals(2),rop_atten_vals(1));
ber_db(b)=min(cel{1});
cel = wh.getStoValue('ber_db',M_choose(1),lambda_vals(l),bitrate_vals(b),duobinary_vals(3),rop_atten_vals(1));
ber_db_enc(b)=min(cel{1});
dcs_ = wh.getStoValue('dcs',M_choose(1),lambda_vals(l),bitrate_vals(b),duobinary_vals(2),rop_atten_vals(1));
end
cols = linspecer(4);
subplot(1,3,m)
if M_choose == 4
lst = '-';
mkr = 'o';
hv = 'on';
elseif M_choose == 6
lst = '-';
mkr = 'x';
hv = 'on';
elseif M_choose == 8
lst = '-';
mkr = 'diamond';
hv = 'on';
end
fsym_vals = floor( bitrate_vals*1e-9./log2(M_choose) );
hold on
plot(bitrate_vals*1e-9,ber_db,'Color',cols(1,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','DB pre','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
plot(bitrate_vals*1e-9,ber_db_enc,'Color',cols(2,:)','Marker',mkr,'MarkerFaceColor','auto','DisplayName','DB enc','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
plot(bitrate_vals*1e-9,ber_vnle,'Color',cols(3,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','VNLE','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
plot(bitrate_vals*1e-9,ber_vnle_mlse,'Color',cols(4,:),'Marker',mkr,'MarkerFaceColor','auto','DisplayName','VNLE+PF+MLSE','LineStyle',lst,'HandleVisibility',hv,'LineWidth',1);
% Continue with the rest of your plot settings
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
yline(2e-2, 'DisplayName', '20%', 'LineStyle', '--','LineWidth',1, 'HandleVisibility', 'off');
xlabel('Bitrate');
ylabel('Bit Error Rate (BER)');
title(['PAM ',num2str(M_choose),' ']);
set(gca, 'yscale', 'log');
set(gca, 'Box', 'on');
grid on;
grid minor;
legend('Interpreter', 'none','Location','southwest');
ylim([1e-4,1e-1]);
xlim([bitrate_vals(1)*1e-9,bitrate_vals(end)*1e-9])
%end
end