Bald fertig für richtige Nutzung - Move_it vergleich fertig

Complete Checkup with Move_it: this framework is an almost perfect reproduction.
This commit is contained in:
Silas Oettinghaus
2023-06-08 15:33:57 +02:00
parent 2868887a15
commit 2aeacafe78
14 changed files with 198 additions and 122 deletions

View File

@@ -33,11 +33,6 @@ classdef Electricalsignal < Signal
end
function obj = normalize(obj)
obj.signal = obj.signal/sqrt(mean(abs(obj.signal),"all"));
end
end

View File

@@ -21,11 +21,6 @@ classdef Informationsignal < Signal
end
function obj = normalize(obj)
obj.signal = obj.signal/sqrt(mean(abs(obj.signal),"all"));
end
end
end

View File

@@ -33,12 +33,6 @@ classdef Opticalsignal < Signal
end
function obj = normalize(obj)
obj.signal = obj.signal/sqrt(mean(abs(obj.signal).^2));
end
function pow = power(obj)
pow = mean(abs(obj.signal.^2)) ;

View File

@@ -106,8 +106,13 @@ classdef Signal
end
%% Add signals from one signal to another, the first object will sustain
function Sum = plus(X,Y)
Sum = X; %first input object will sustain
Sum.signal = X.signal + Y.signal;
end
%% Display length
%% Display length
function return_length = length(obj)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
@@ -135,7 +140,7 @@ classdef Signal
end
%% Resample Signal
%% Resample Signal
function obj = resample(obj,options)
arguments
@@ -203,7 +208,7 @@ classdef Signal
psd = psd/length(Fsignal);
%smoothing
psd = smooth(psd,50);
psd = smooth(psd,1000);
psd_plot = 20*log10(psd);
@@ -255,6 +260,57 @@ classdef Signal
end
%%
function obj = normalize(obj,options)
arguments
obj Signal
options.mode normalization_mode = normalization_mode.rms
end
switch options.mode
case normalization_mode.rms
obj.signal = obj.signal/sqrt(mean(abs(obj.signal).^2,"all"));
case normalization_mode.oneone
obj.signal = obj.signal/max(abs(obj.signal));
end
end
%%
function obj = delay(obj,options)
arguments
obj Opticalsignal
options.delay_meter double = 0
end
delay_t = options.delay_meter /(physconst("LightSpeed")/1.4677);
delay_n = round(delay_t .* obj.fs);
% build "long" hann window to fade the signal in and out
% -> prevent hard step in the signal!
hann_wind = hann(200);
ones_wind = ones(size(obj.signal));
ones_wind(1:100) = hann_wind(1:100);
ones_wind(end-100:end) = hann_wind(end-100:end);
% subtract average
mu = mean(obj.signal,"all");
obj.signal = obj.signal - mu;
%apply hann
obj.signal = obj.signal .* ones_wind;
%add average again
obj.signal = obj.signal + mu;
% finally circshift the signal
obj.signal=circshift(obj.signal,delay_n);
end
end
end

View File

@@ -32,7 +32,7 @@ classdef AWG
% Detailed explanation goes here
arguments
options.preset = [] ;
options.preset = 'none';
options.kover = 16;
options.repetitions = 1;
options.normalize = 1;

View File

@@ -50,6 +50,8 @@ classdef PAMmapper
pam_sig=2*pam_sig-3;
end
pam_sig = pam_sig .* 1/sqrt(5);
case 3
% 8-ASK:
@@ -86,8 +88,6 @@ classdef PAMmapper
%28.03.2023 - Silas Oett. - Extracted from digi_demod.m
%
obj.thresholds = 0;
switch log2(obj.M)
case 1
@@ -106,6 +106,7 @@ classdef PAMmapper
elseif obj.unipolar==1
thres=[0.5,1.5,2.5];
end
thres = thres .* 1/sqrt(5);
case 3
@@ -174,6 +175,8 @@ classdef PAMmapper
1-comp_real(:,:,4)+comp_real(:,:,12)];
end
data_out = data_out';
end

View File

@@ -41,7 +41,7 @@ classdef Pulseformer
signalclass_in.signal = obj.process_(signalclass_in.signal);
% append to logbook
lbdesc = ['Applied Pulseshaping'];
lbdesc = 'Applied Pulseshaping';
signalclass_in = signalclass_in.logbookentry(lbdesc);
% write to output
@@ -83,23 +83,56 @@ classdef Pulseformer
if obj.pulseform == pulseform.rrc
%Bau das Filter (hier rrc)
racos_len = obj.pulselength ;
racos_len = obj.pulselength*2 ;
alpha = obj.rrcalpha;
h = rcosdesign(alpha,racos_len,sps);
h = h./ max(h);
end
%Apply Filter using Matlab build in fctn.
data_out = upfirdn(data_in,h,up,dn);
% Apply filter the long way (from move_it)
% block length in samples
data_in = data_in';
blen = length(data_in)*sps;
% oversample symbol sequence
symbolov=zeros(size(data_in,1),blen);
symbolov(:,1:sps:blen-sps+1)=data_in;
%cut signal, which is longer due to fir filter
st = round(up/dn*racos_len/2); %we need to cut y_out
en = round(st + (length(data_in)*up/dn) -1);
H=fft(h,blen);
% Convolution of Bit sequence with impulse response
data_out = data_out(st:en);
% cyclic convolution
data_out=ifft( fft(symbolov.') .* repmat( H,size(data_in,1),1 ).' ).';
data_out = circshift(data_out,[0 -(obj.pulselength*sps)]);
if rem(obj.fdac,obj.fsym)
data_out = data_out(1:dn:end); %!
end
% %Apply Filter using Matlab build in fctn.
% data_out = upfirdn(data_in,h,up,dn);
%
% %cut signal, which is longer due to fir filter
% st = round(up/dn*racos_len/2); %we need to cut y_out
% en = round(st + (length(data_in)*up/dn) -1);
%
% data_out = data_out(st:en);
%scaling?! see pulsef module line 696
scale = max(max([abs(real(data_out)) abs(imag(data_out))])); %find max value from real and imag part
data_out = data_out./scale;
data_out = data_out';
%Check output integrity
if round(up/dn * length(data_in)) ~= length(data_out)
warning('Check signal length after pulse shaping');
%warning('Check signal length after pulse shaping');
disp('Check signal length after pulse shaping');
end

View File

@@ -149,6 +149,7 @@ classdef Amplifier
end
function nase_numeric = generateAseNoise(~, nase, fs, dimension)
rng(2023);
nase_numeric = (randn(dimension) + 1i*randn(dimension))*sqrt(nase/2*fs) ;
end

View File

@@ -43,14 +43,13 @@ classdef Filter
function signalclass_out = process(obj,signalclass_in)
% actual processing of the signal
signalclass_in.signal = obj.process_(signalclass_in.signal);
signalclass_out = signalclass_in;
signalclass_out.signal = obj.process_(signalclass_in.signal);
% append to logbook
filterdesc = [num2str(obj.filtdegree),'. order ',char(obj.filterType),' filter with f_cutoff at ', num2str(obj.f_cutoff*1e-9), ' GHz.'];
signalclass_in = signalclass_in.logbookentry(filterdesc);
signalclass_out = signalclass_out.logbookentry(filterdesc);
% write to output
signalclass_out = signalclass_in;
end

View File

@@ -23,7 +23,7 @@ classdef Fiber
%FIBER Construct an instance of this class
% Detailed explanation goes here
arguments
options.fsimu
options.fsimu
options.fiber_length = 0
options.alpha = 0.2
options.D = 17
@@ -42,22 +42,20 @@ classdef Fiber
obj.gamma = options.gamma;
obj.dphimax = options.dphimax;
obj.b2 = -obj.D*obj.lambda0^2/(2*pi*Constant.LightSpeed);
obj.b3 = ((obj.lambda0.^2/(2*pi*Constant.LightSpeed)).^2*obj.Dslope);
obj.alpha_lin = obj.alpha/10*log(10)/1000;
end
function signalclass_out = process(obj,signalclass_in)
% actual processing of the signal (steps 1. - 3.)
signalclass_in.signal = obj.process_(signalclass_in.signal);
% actual processing of the signal (steps 1. - 3.)
signalclass_in.signal = obj.process_(signalclass_in.signal);
% append to logbook
lbdesc = 'Fiber ';
% append to logbook
lbdesc = 'Fiber ';
signalclass_in = signalclass_in.logbookentry(lbdesc);
% write to output
% write to output
signalclass_out = signalclass_in;
end
@@ -66,6 +64,10 @@ classdef Fiber
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
obj.b2 = -obj.D*obj.lambda0^2/(2*pi*Constant.LightSpeed);
obj.b3 = ((obj.lambda0.^2/(2*pi*Constant.LightSpeed)).^2*obj.Dslope);
obj.alpha_lin = obj.alpha/10*log(10)/1000;
N = length(opt_in);
faxis = linspace(-obj.fsimu/2,obj.fsimu/2,N+1);
faxis = ifftshift(faxis(:,1:end-1));
@@ -109,7 +111,7 @@ classdef Fiber
z_prop = z_prop + dz;
maxPow = obj.gamma*max(abs(yout).^2);
Leff = obj.dphimax/maxPow;
Leff = obj.dphimax/maxPow;
dz_new = Leff;

View File

@@ -20,6 +20,8 @@ classdef Scope
filtertype
lpf_bw
block_dc
%during construction
%during process
@@ -47,24 +49,17 @@ classdef Scope
options.filtertype = filtertypes.bessel_bilin;
options.lpf_bw = 120e9;
options.block_dc = 1;
end
obj.fsimu = options.fsimu;
obj.fadc = options.fadc;
obj.adcresolution = options.adcresolution;
obj.quantbuffer = options.quantbuffer;
fn = fieldnames(options);
for n = 1:numel(fn)
try
obj.(fn{n}) = options.(fn{n});
end
end
obj.rand_samplingdelay = options.rand_samplingdelay; % use a randomized sample delay INSTEAD of samplingdelay
obj.samplingdelay = options.samplingdelay; %specifiy a sampling delay
obj.freq_offset = options.freq_offset; %offset of the sampler
obj.samp_jitter = options.samp_jitter; %include jitter in [s]
obj.fixed_delay = options.fixed_delay; %fix the delay of the filter or use minimal delay for kausal system
obj.delay = options.delay; %specify a fixed delay of the filter
obj.filtertype = options.filtertype;
obj.lpf_bw = options.lpf_bw;
end
@@ -91,14 +86,17 @@ classdef Scope
% Detailed explanation goes here
% sample signal
% TODO: implement and test the delays. Also look for delay of
% lpf filter
%yout = obj.sampleSignal(xin);
% TODO: implement and test the delays.
% resample
yout = resample(xin,obj.fadc,obj.fsimu);
% quantize signal
yout = obj.quantize(yout);
if obj.block_dc
yout = yout-mean(yout,1);
end
end