% data1 = load('gaussian_beam_mea1.txt');
% data2 = load('gaussian_beam_mea2.txt');
data1 = load('VOPO_greenlight_greencpl.txt');

z1 = data1(:,1);
x1 = data1(:,2);
y1 = data1(:,3);

Z = linspace(-2000,2000, 1000);

w01 = 0.365/2; %modelled w0 radius in mm
%w02 = 0.150/2;

Zr1 = pi*w01.^2/0.000532; %Rayleight range
%Zr2 = pi*w02.^2/0.001064; %Rayleight range


wz1 = w01*sqrt(1+(Z/Zr1).^2);
%wz2 = w02*sqrt(1+(Z/Zr1).^2);

figure(3)
%subplot(1,2,1)
plot(z1,x1/2, '*r', 'LineWidth',2) %plotting radius. *25.4 if measured in inches 
title('beam size x (mm)','FontSize', 30,'FontWeight','normal') 
xlabel('distance from M2 (mm)', 'FontSize', 30)
ylabel('Gaussian beam radius (mm)','FontSize', 30)
xlim([-1500,1500])
ylim([0,2])

hold on
plot(Z+270,wz1, '--') %fitting in radius. %DO NOT add offset to y vaule in order to fit the data
%plot(Z+125,wz2, '--')

legend({'data','w0=0.183mm'},'FontSize',18,'Location','northwest');
h=suptitle('Gaussian beam radius LHO SQZ VIP green light to green coupler'); 
set(h,'FontSize',36,'FontWeight','normal');

hold off