diff --git a/@MyAnalysisRoutine/MyAnalysisRoutine.m b/@MyAnalysisRoutine/MyAnalysisRoutine.m index 555d24c..c42b119 100644 --- a/@MyAnalysisRoutine/MyAnalysisRoutine.m +++ b/@MyAnalysisRoutine/MyAnalysisRoutine.m @@ -1,22 +1,18 @@ % Superclass for DAQ-compatible analysis routines % Must accept Axes as an optional argument classdef MyAnalysisRoutine < handle properties (Abstract, Access = public) Data MyTrace end properties (Abstract, GetAccess = public, SetAccess = protected) Axes end events NewAnalysisTrace end - - methods (Abstract) - triggerNewAnalysisTrace(this) - end end diff --git a/@MyDaq/MyDaq.mlapp b/@MyDaq/MyDaq.mlapp index b216153..8ad6f77 100644 Binary files a/@MyDaq/MyDaq.mlapp and b/@MyDaq/MyDaq.mlapp differ diff --git a/@MyBeta/MyBeta.m b/Measurement and analysis routines/@MyPhaseModCal/MyPhaseModCal.m similarity index 53% rename from @MyBeta/MyBeta.m rename to Measurement and analysis routines/@MyPhaseModCal/MyPhaseModCal.m index 14b5a8d..7b2e953 100644 --- a/@MyBeta/MyBeta.m +++ b/Measurement and analysis routines/@MyPhaseModCal/MyPhaseModCal.m @@ -1,124 +1,75 @@ -classdef MyBeta < handle - properties (Access=public) - name; - %Trace - Data - end +% Routine for the calibration of beta-factor characterizing the phase +% modulation of light. Data is a heterodyne signal spectrum. + +classdef MyPhaseModCal < MyAnalysisRoutine - properties (GetAccess=public, SetAccess=private) - %Struct containing GUI handles - Gui; - - beta; - enable_gui; + properties (Access = public) + Data MyTrace end - properties (Access=private) - %Input parser - Parser; + properties (GetAccess = public, SetAccess = protected) + Axes end - methods (Access=public) - function this=MyBeta(varargin) - %Parses inputs to the constructor - createParser(this); - parse(this.Parser,varargin{:}); - this.Data=this.Parser.Results.Data; - this.enable_gui=this.Parser.Results.enable_gui; + methods (Access = public) + function this = MyPhaseModCal(varargin) + p = inputParser(); + addParameter(p, 'Data', MyTrace()); + addParameter(p, 'Axes', [], @isaxes); + parse(p, varargin{:}); - %Default enables gui - if this.enable_gui - this.Gui=guihandles(eval('GuiBeta')); - initGui(this); - end - - end - - %Deletion function for cleanup - function delete(this) - if this.enable_gui - set(this.Gui.figure1,'CloseRequestFcn',''); - %Deletes the figure - delete(this.Gui.figure1); - %Removes the figure handle to prevent memory leaks - this.Gui=[]; - end - end - - %Callback for analyze button - function analyzeCallback(this) - calcBeta(this); + this.Data = p.Data; + this.Axes = p.Axes; end %Calculates beta, updates the gui with the value and stores it in %the class. function calcBeta(this) %Number of points next to peak we will use to find the area %under each peak n=10; % Finding the index of the the centeral maximum and the side bands min_pk_dist=200; [peaks,pk_inds] = findpeaks(this.Data.y,... 'minpeakdistance',min_pk_dist); %First we sort by height of the peaks amp_sort=sortrows([peaks, pk_inds]); %Then we sort the five highest peaks by location sort_mat=sortrows(amp_sort((end-4):end,:),2); %The sorted indices of the peaks ind_sort=sort_mat(:,2); % Finds indices for the data in the neighborhood of each peak %Peak 1 is the leftmost (2nd order peak), Peak 2 is the left %1st order peak, Peak 3 is the central peak etc. ind_pks=cell(5,1); for i=1:5 ind_pks{i}=(ind_sort(i)-n):(ind_sort(i)+n); end %Here we integrate the data surrounding the peaks and take the %square root of the areas. v_rms_pks=cellfun(@(x) sqrt(integrate(this.Data,x)),ind_pks); % Then we can calculate the FM beta by using: sdratio_01 = 0.5*(v_rms_pks(4)+v_rms_pks(2))/v_rms_pks(3); sdratio_02 = 0.5*(v_rms_pks(5)+v_rms_pks(1))/v_rms_pks(3); syms b; %Then find the beta by numerically solution of the bessel %functions beta_01 = double(vpasolve(besselj(1,b) == ... sdratio_01 * besselj(0,b), b, 2*sdratio_01)); beta_02 = double(vpasolve(besselj(2,b) == ... sdratio_02 * besselj(0,b), b, 2*sdratio_02)); %We use beta_02 as it is less affected by residual intensity %noise. this.beta=beta_02; %Sets the values on the GUI set(this.Gui.Beta02,'String',num2str(beta_02,5)); set(this.Gui.Beta01,'String',num2str(beta_01,5)); end end - - methods (Access=private) - %Initializes the GUI with correct callbacks - function initGui(this) - this.Gui.AnalyzeButton.Callback=@(~,~) analyzeCallback(this); - this.Gui.figure1.CloseRequestFcn=@(~,~) closeFigure(this); - end - - %The close figure function calls the deletion method. - function closeFigure(this) - delete(this); - end - - %Creates input parser for constructor - function createParser(this) - p=inputParser; - addParameter(p,'Data',MyTrace()) - addParameter(p,'enable_gui',true); - this.Parser=p; - end - end - end +