O-band Amp Characterization Measurement
This commit is contained in:
@@ -1,20 +1,50 @@
|
||||
function waitUntilClick()
|
||||
% Create the UI figure
|
||||
fig = uifigure('Name', 'Pause Execution', 'Position', [100 100 300 150]);
|
||||
function waitUntilClick(options)
|
||||
|
||||
% Create a label to inform the user
|
||||
uilabel(fig, 'Position', [50 80 200 40], 'Text', 'Click "Continue" to proceed', ...
|
||||
'FontSize', 14, 'HorizontalAlignment', 'center');
|
||||
% use like this to stop any computation and wait for user to press ENTER or
|
||||
% Continue button. I used this in the lab to wait until smth settled or I
|
||||
% set a device to a certain operating point...
|
||||
|
||||
% Create the "Continue" button
|
||||
continueButton = uibutton(fig, 'push', 'Text', 'Continue', 'Position', [100 20 100 40], ...
|
||||
'ButtonPushedFcn', @(src, event) closeWindow());
|
||||
% USAGE:
|
||||
% waitUntilClick;
|
||||
|
||||
% OPTIONAL: provide input text that is prompted :-)
|
||||
% usrcmd = sprintf('Laser to %d dBm',p);
|
||||
% waitUntilClick('Text',usrcmd);
|
||||
|
||||
|
||||
arguments
|
||||
options.Text string = "Click ""Continue"" to proceed"
|
||||
end
|
||||
|
||||
% Create the UI figure
|
||||
fig = uifigure('Name', 'Pause Execution', ...
|
||||
'Position', [100 100 300 150], ...
|
||||
'KeyPressFcn', @(src,event) keyHandler(event));
|
||||
|
||||
% Create a label with custom text
|
||||
uilabel(fig, ...
|
||||
'Position', [30 70 240 60], ...
|
||||
'Text', options.Text, ...
|
||||
'FontSize', 14, ...
|
||||
'HorizontalAlignment', 'center', ...
|
||||
'WordWrap','on');
|
||||
|
||||
% Create the "Continue" button
|
||||
uibutton(fig, 'push', ...
|
||||
'Text', 'Continue', ...
|
||||
'Position', [100 20 100 40], ...
|
||||
'ButtonPushedFcn', @(src, event) closeWindow());
|
||||
|
||||
% Function to close the window when "Continue" is clicked
|
||||
function closeWindow()
|
||||
delete(fig); % Close the figure window
|
||||
delete(fig);
|
||||
end
|
||||
|
||||
% Wait until the figure is closed to resume execution
|
||||
waitfor(fig);
|
||||
end
|
||||
function keyHandler(event)
|
||||
if strcmp(event.Key,'return') || strcmp(event.Key,'enter')
|
||||
closeWindow();
|
||||
end
|
||||
end
|
||||
|
||||
% Wait until the figure is closed
|
||||
waitfor(fig);
|
||||
end
|
||||
|
||||
20
Functions/Metrics/noiseFigureFromOSNR.m
Normal file
20
Functions/Metrics/noiseFigureFromOSNR.m
Normal file
@@ -0,0 +1,20 @@
|
||||
function NF_dB = noiseFigureFromOSNR(Pin_dBm, OSNR_dB, lambda_nm, Bref_nm)
|
||||
|
||||
if nargin < 4
|
||||
Bref_nm = 0.1; % OSNR reference bandwidth
|
||||
end
|
||||
|
||||
h = 6.62607015e-34; % Planck [J*s]
|
||||
c = 299792458; % speed of light [m/s]
|
||||
|
||||
lambda = lambda_nm * 1e-9;
|
||||
nu = c / lambda;
|
||||
|
||||
% convert reference bandwidth from nm to Hz
|
||||
Bref_Hz = Bref_nm*1e-9 * c / lambda^2;
|
||||
|
||||
% ASE noise power density in dBm
|
||||
Pn_dBm = 10*log10(h*nu*Bref_Hz) + 30;
|
||||
|
||||
NF_dB = Pin_dBm - OSNR_dB - Pn_dBm;
|
||||
end
|
||||
Reference in New Issue
Block a user