Skip to content
Snippets Groups Projects
Commit 67e2f7ae authored by Charlotte Bond's avatar Charlotte Bond
Browse files

adding file to read the tem modes specified in blocks containing finesse lines

parent 05bf1d86
No related branches found
No related tags found
No related merge requests found
...@@ -94,12 +94,12 @@ function [tunings] = FT_DR_FP_MICH_initial_tuning(infile,outfile,commands,mirror ...@@ -94,12 +94,12 @@ function [tunings] = FT_DR_FP_MICH_initial_tuning(infile,outfile,commands,mirror
tuning_threshold = 1e-10; tuning_threshold = 1e-10;
relative_err = 1e-2; relative_err = 1e-2;
% Number of zooms % Number of zooms
zooms = 3; zooms = 4;
% Number of points and ranges for the first and second round of scans % Number of points and ranges for the first and second round of scans
npoints = 1000; npoints = 1000;
range = 120; range = 180;
zoom_npoints = 500; zoom_npoints = 500;
zoom_range = 2; zoom_range = 20;
% Initilise Finesse % Initilise Finesse
FT = FT_init_Finesse(); FT = FT_init_Finesse();
...@@ -149,8 +149,9 @@ function [tunings] = FT_DR_FP_MICH_initial_tuning(infile,outfile,commands,mirror ...@@ -149,8 +149,9 @@ function [tunings] = FT_DR_FP_MICH_initial_tuning(infile,outfile,commands,mirror
% Read in intial maxtem % Read in intial maxtem
maxtem = FT_read_maxtem_from_blocks(blocks); maxtem = FT_read_maxtem_from_blocks(blocks);
% Start off with maxtem 0 % Start off with maxtem at minimum (i.e. max order of tem modes)
blocks = FT_replace_maxtem_in_blocks(blocks,0); [gc,max_order] = FT_read_TEM_from_blocks(blocks)
blocks = FT_replace_maxtem_in_blocks(blocks,max_order);
% Perform tunigns twice, once with maxtem 0 and once with the value for % Perform tunigns twice, once with maxtem 0 and once with the value for
% maxtem set in infile % maxtem set in infile
...@@ -283,8 +284,12 @@ function [tunings] = FT_DR_FP_MICH_initial_tuning(infile,outfile,commands,mirror ...@@ -283,8 +284,12 @@ function [tunings] = FT_DR_FP_MICH_initial_tuning(infile,outfile,commands,mirror
tuning(5) = phi_SRM; tuning(5) = phi_SRM;
end end
if length(commands)>0
% Writing new output file, adding command lines back in % Writing new output file, adding command lines back in
FT_write_blocks_into_file([blocks,command_blocks],outfile); FT_write_blocks_into_file([blocks,command_blocks],outfile);
else
FT_write_blocks_into_file(blocks,outfile);
end
end end
......
%--------------------------------------------------------------------------
% function [gc,max_order] = FT_read_TEM_from_blocks(blocks)
%
% A function for Matlab which reads the tem lines defining the mode content
% of the laser input beam from blocks containing FINESSE commands. This
% mode content is returned in the structure gc (see
% FT_init_gauss_coefficients.m).
%
% blocks: Block structure storing FINESSE code.
%
% gc: Structure storing coefficients describing the mode content of
% the laser beam found in blocks.
% max_order:The maximum order of the modes in the inupt beam
%
% Charlotte Bond 24.05.2013
%--------------------------------------------------------------------------
%
function [gc,max_order] = FT_read_TEM_from_blocks(blocks)
baseid = 'read_TEM_from_blocks';
% Find blocks where tems (or tem*s) are defined
% First look for tem
Gtype = 'HG';
temtype = 'tem';
block_idx = FT_find_element_in_all_blocks(blocks,1,'tem');
% If tem isn't found look for tem*
if length(block_idx)==0
Gtype = 'LG';
temtype = 'tem*';
block_idx = FT_find_element_in_all_blocks(blocks,1,'tem*');
end
if length(block_idx)==0
% If can't find tem commands all laser power(and amp) is in
% HG00 mode
Gtype = 'HG';
max_order = 0;
gc = FT_init_gauss_coefficients(Gtype,max_order);
gc = FT_set_mode_coefficient(gc,1,0,0);
else
% Otherwise read each tem/tem* mode
n=0;
for i=1:length(block_idx)
tmp_block = blocks(block_idx(i));
line_idx = FT_find_element_in_active_block(tmp_block,1,temtype);
for j=1:length(line_idx)
tmp_line = tmp_block.txt_lines(line_idx(j));
n=n+1;
% Read mode indices and coefficient
index1(n) = cell2mat(FT_parse_line(tmp_line,3));
index2(n) = cell2mat(FT_parse_line(tmp_line,4));
power = cell2mat(FT_parse_line(tmp_line,5));
phase = cell2mat(FT_parse_line(tmp_line,6));
c(n) = sqrt(power)*exp(-1i*phase*pi/180);
end
end
% Calculate maximum order of specified tem modes
if strcmp(Gtype,'HG')
max_order = max(index1+index2);
else
max_order = max(2*index1+abs(index2));
end
% Create gc structure storing mode amplitudes
gc = FT_init_gauss_coefficients(Gtype,max_order);
for n=1:length(index1)
gc = FT_set_mode_coefficient(gc,c(n),index1(n),index2(n));
end
end
end
...@@ -15,16 +15,20 @@ ...@@ -15,16 +15,20 @@
function [maxtem] = FT_read_maxtem_from_blocks(blocks) function [maxtem] = FT_read_maxtem_from_blocks(blocks)
% Find block in which maxtem is defined % Find block in which maxtem is defined
block_idx = FT_find_text_in_all_blocks(blocks,'maxtem'); block_idx = FT_find_element_in_all_blocks(blocks,1,'maxtem');
if length(block_idx)~=0 if length(block_idx)==1
% Find line in block in whih maxtem is defined % Find line in block in whih maxtem is defined
line_idx = FT_find_element_in_active_block(blocks(block_idx),1,'maxtem'); line_idx = FT_find_element_in_active_block(blocks(block_idx),1,'maxtem');
% Read maxtem from line % Read maxtem from line
maxtem = cell2mat(FT_parse_line(blocks(block_idx).txt_lines(line_idx),2)); maxtem = cell2mat(FT_parse_line(blocks(block_idx).txt_lines(line_idx),2));
else elseif length(block_idx)==0
maxtem = 0; maxtem = 0;
else
result=sprintf('Invalid kat file: maxtem declared more than once');
msgid=[baseid,'checkarguments'];
error(msgid,result)
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment