101 lines
3.7 KiB
Matlab
101 lines
3.7 KiB
Matlab
classdef EML_test < IMDDTestCase
|
|
methods (Test, TestTags = {'unit', 'fast', 'optical', 'eml'})
|
|
function constructorStoresDerivedScalarsForDeterministicIqMode(testCase)
|
|
eml = EML( ...
|
|
"mode", eml_mode.iq_linear, ...
|
|
"fsimu", 64e9, ...
|
|
"lambda", 1550, ...
|
|
"power", 0, ...
|
|
"linewidth", 0, ...
|
|
"alpha", 0, ...
|
|
"ampl_imbal", 0, ...
|
|
"pha_imbal", 0, ...
|
|
"bias", 0, ...
|
|
"u_pi", 1, ...
|
|
"randomkey", 7);
|
|
|
|
testCase.verifyEqual(eml.mode, eml_mode.iq_linear);
|
|
testCase.verifyEqual(eml.fsimu, 64e9);
|
|
testCase.verifyEqual(eml.lambda, 1550);
|
|
testCase.verifyEqual(eml.power, 0);
|
|
testCase.verifyEqual(eml.linewidth, 0);
|
|
testCase.verifyEqual(eml.alpha, 0);
|
|
testCase.verifyEqual(eml.field, sqrt(1e-3), "AbsTol", 1e-12);
|
|
testCase.verifyEqual(eml.noisefactor, 0, "AbsTol", 1e-12);
|
|
testCase.verifyEqual(eml.phase, 0, "AbsTol", 1e-12);
|
|
end
|
|
|
|
function process_ProducesDeterministicIqLinearOutput(testCase)
|
|
eml = EML( ...
|
|
"mode", eml_mode.iq_linear, ...
|
|
"fsimu", 32e9, ...
|
|
"lambda", 1310, ...
|
|
"power", 3, ...
|
|
"linewidth", 0, ...
|
|
"alpha", 0, ...
|
|
"ampl_imbal", 0, ...
|
|
"pha_imbal", 0, ...
|
|
"bias", 0, ...
|
|
"u_pi", 2, ...
|
|
"randomkey", 11);
|
|
inputSig = makeElectricalsignal([1 + 1i; -2 + 0.5i; 0.25 - 0.75i], 32e9);
|
|
|
|
[optField, emlOut] = eml.process_(inputSig.signal);
|
|
|
|
expectedField = eml.field .* inputSig.signal ./ eml.u_pi;
|
|
|
|
testCase.verifyEqual(optField, expectedField, "AbsTol", 1e-12);
|
|
testCase.verifyEqual(emlOut.signal_len, length(inputSig));
|
|
testCase.verifyEqual(emlOut.phase, 0, "AbsTol", 1e-12);
|
|
end
|
|
|
|
function processReturnsOpticalsignalWithUpdatedMetadata(testCase)
|
|
eml = EML( ...
|
|
"mode", eml_mode.iq_linear, ...
|
|
"fsimu", 64e9, ...
|
|
"lambda", 1550, ...
|
|
"power", 0, ...
|
|
"linewidth", 0, ...
|
|
"alpha", 0, ...
|
|
"ampl_imbal", 0, ...
|
|
"pha_imbal", 0, ...
|
|
"bias", 0, ...
|
|
"u_pi", 1, ...
|
|
"randomkey", 19);
|
|
inputSig = makeElectricalsignal([1 + 1i; -1 - 1i], 64e9);
|
|
|
|
[outputSig, emlOut] = eml.process(inputSig);
|
|
|
|
expectedField = eml.field .* inputSig.signal ./ eml.u_pi;
|
|
|
|
testCase.verifyClass(outputSig, 'Opticalsignal');
|
|
testCase.verifyEqual(outputSig.signal, expectedField, "AbsTol", 1e-12);
|
|
testCase.verifyEqual(outputSig.fs, eml.fsimu);
|
|
testCase.verifyEqual(outputSig.lambda, eml.lambda * 1e-9, "AbsTol", 1e-15);
|
|
testCase.verifyEqual(height(outputSig.logbook), height(inputSig.logbook) + 1);
|
|
testCase.verifyTrue(contains(string(outputSig.logbook.Description(end)), "nm Laser"));
|
|
testCase.verifyEqual(emlOut.signal_len, length(inputSig));
|
|
end
|
|
end
|
|
end
|
|
|
|
function sig = makeElectricalsignal(values, fs)
|
|
sig = Electricalsignal(values, ...
|
|
"fs", fs, ...
|
|
"logbook", emptyLogbook());
|
|
end
|
|
|
|
function lb = emptyLogbook()
|
|
SignalType = [];
|
|
TimeStamp = [];
|
|
Length = [];
|
|
SignalPower = [];
|
|
Nase = [];
|
|
SignalCopy = [];
|
|
ModifierName = [];
|
|
ModifierCopy = {};
|
|
Description = [];
|
|
|
|
lb = table(SignalType, TimeStamp, Length, SignalPower, Nase, SignalCopy, ModifierName, ModifierCopy, Description);
|
|
end
|