Many changes for 400G DSP

Minimal Example
...
This commit is contained in:
sioe
2024-12-17 16:17:58 +01:00
parent 397cfa61dd
commit e47a4dbbbe
68 changed files with 2749 additions and 2948 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

View File

@@ -349,13 +349,13 @@ classdef Signal
% spectrum_plot(obj.signal,options.fsamp,options.figurename,options.displayname);
N = 2^(nextpow2(length(obj.signal))-2);
N = 2^(nextpow2(length(obj.signal))-9);
if options.normalizeToNyquist==0
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,obj.fs,"centered","power","mean");
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,obj.fs,"centered","psd","mean");
w=w.*1e-9;
else
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,"centered","power","mean");
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,"centered","psd","mean");
% p_lin = smooth(p_lin,0.05,'rloess');
end
@@ -365,7 +365,7 @@ classdef Signal
p_dbm = 10*log10(p_lin); %dB to dBm in case of "power"
ylab = "normalized to 0 dB";
else
p_dbm = 10*log10(p_lin)+30; %dB to dBm in case of "power"
p_dbm = 10*log10(p_lin); %dB to dBm in case of "power"
ylab = "Power (dBm)";
end
@@ -401,6 +401,125 @@ classdef Signal
end
function move_it_spectrum(obj,options)
arguments
obj
options.fignum
options.displayname = "";
options.color = [];
options.normalizeToNyquist = 0;
options.normalizeTo0dB = 0;
end
data_in = obj.signal;
if size(data_in,1) > size(data_in,2)
data_in = data_in';
end
for pol = 1:size(data_in,1)
%compute FFT of input
Data_in = fft( data_in(pol,:) );
%psd = Data_in.*conj(Data_in);
psd = Data_in;
%Use only magnitude of FFT (which was complex)
psd = abs(psd);
%Shift the spectrum to yield
psd = fftshift(psd);
%divide by N
psd = psd/length(data_in(pol,:));
psd_plot = 20*log10(psd);
% psd_plot = psd_plot - max(psd_plot);
%smoothing
% psd_smoothed = smooth(psd,1000);
%
% psd_smoothed = 10*log10(psd_smoothed);
% psd_smoothed = psd_smoothed - max(psd_smoothed);
carrier_power_time_dbm = 20*log10( mean(abs(data_in)) .^2 )+30; % dB -> +30 -> dBm
carrier_power_freq_dbm = max(psd_plot);
% psd_plot = psd_plot - max(psd_plot);
%% cspr
c = mean(data_in).^2;
s = mean(data_in.^2);
cspr = 10*log10(c / s);
testParseval = 1;
if testParseval == 1
E_FreqDomain =1/length(psd) * sum((psd.*length(psd)).^2);
%test parseval
E_TimeDomain = sum( (data_in(pol,:).^2) );
if isequal(round(E_FreqDomain,1),round(E_TimeDomain,1))
disp('Parseval is right!');
else
% disp('Something is wrong here?!');
end
end
figure(options.fignum); % If figure does not exist, create new figure
if 1
%Frequency Axis
freq_vec = linspace(-obj.fs/2,obj.fs/2,length(psd));
freq_vec = reshape(freq_vec,size(psd_plot));
if nargin == 4
p = plot(freq_vec*1e-9,psd_plot,'Linewidth',0.5,'DisplayName',options.displayname);
% plot(freq_vec*1e-9,psd_smoothed','Linewidth',1,'Color',[0 0 0],'DisplayName',[char(varargin{2}),' smoothed']);
else
p = plot(freq_vec*1e-9,psd_plot,'Linewidth',0.5);
% plot(freq_vec*1e-9,psd_smoothed','Linewidth',1,'Color',[1 1 1],'LineStyle',':');
end
%xlim([freq_vec(1)/1e9-2 freq_vec(end)/1e9+2])
xlabel('frequency [GHz]')
else
%Wavelength Axis
freq_vec = physconst('LightSpeed')*linspace(-obj.fs/2,obj.fs/2,length(psd))./((physconst('LightSpeed')/1310e-9)^2)*1e9;
freq_vec = freq_vec+1310;
if nargin == 4
plot(freq_vec',psd_plot,'Linewidth',0.5,'DisplayName',options.displayname)
else
plot(freq_vec,psd_plot','Linewidth',0.5);
end
%xlim([freq_vec(1)/1e9-2 freq_vec(end)/1e9+2])
xlabel('wavelength [nm]')
end
hold on
end
% xlim([-150 150])
% ylim([-100,0]);
ylabel('magnitude [dBm]')
legend
grid minor;
end
%% Power of signal
function pow = power(obj,options)
@@ -544,7 +663,7 @@ classdef Signal
%Cut occurences of ref signal from signal (only positive shifts)
S = {};
for c = shifts(shifts>0)
for c = shifts(shifts>=0)
sig = obj.delay(-c,'mode','samples');
sig.signal = sig.signal(1:length(b));
S{end+1,1} = sig;
@@ -557,7 +676,7 @@ classdef Signal
end
%return/keep the sinal with the highest correlation (only within positive shifts)
[~,idx]=max(pks(shifts>0));
[~,idx]=max(pks(shifts>=0));
obj.signal = S{idx}.signal;
%put signal with highest corr. to first index in S array
swap = S{1};