% Analyze SOL1
T2G = 10000.0; % Tesla to Gauss conversion

%  Load Data
Load_bhxyzvsxyplt(3)  % no stdz
Load_bhxyzvsxyplt(4)  % 1 stdz
Load_bhxyzvsxyplt(5)  % tripped at 10 A, no stdz
Load_bhxyzvsxyplt(6)  % tripped at 10 A, 1 stdz
Load_bhxyzvsxyplt(7)  % tripped at 10 A, no stdz
Load_bhxyzvsxyplt(8)  % tripped at 10 A, 1 stdz
Load_bhxyzvsxyplt(9)  % tripped at 10 A, 1 stdz
Load_bhxyzvsxyplt(10)  % tripped at 10 A, 1 stdz

% Find indexes of 10 A measurements.
ind3_10A = find(Bhxyzvsxyplt3.Imag < 10.2 & Bhxyzvsxyplt3.Imag > 9.9);
ind4_10A = find(Bhxyzvsxyplt4.Imag < 10.2 & Bhxyzvsxyplt4.Imag > 9.9);
ind5_10A = find(Bhxyzvsxyplt5.Imag < 10.2 & Bhxyzvsxyplt5.Imag > 9.9);
ind6_10A = find(Bhxyzvsxyplt6.Imag < 10.6 & Bhxyzvsxyplt6.Imag > 9.9);
ind7_10A = find(Bhxyzvsxyplt7.Imag < 10.6 & Bhxyzvsxyplt6.Imag > 9.9);
ind8_10A = find(Bhxyzvsxyplt8.Imag < 10.6 & Bhxyzvsxyplt6.Imag > 9.9);

figure('units','normalized','outerposition',[0 0 0.9 0.9]) 
plot([1:length(ind7_10A)], (Bhxyzvsxyplt7.Bz(ind7_10A)-Bhxyzvsxyplt5.Bz(ind5_10A(1)))*T2G, 'r*');
hold
plot([1:length(ind8_10A)], (Bhxyzvsxyplt8.Bz(ind8_10A)-Bhxyzvsxyplt6.Bz(ind6_10A(1)))*T2G, 'bo');
plot([1:length(ind8_10A)], (Bhxyzvsxyplt10.Bz(ind8_10A)-Bhxyzvsxyplt9.Bz(ind6_10A(1)))*T2G, 'ksq');
xlabel('# of times ramped to 10 A');
ylabel('(2nd Run Bz- 1st run Bz) (G)');
title('(2nd Run Bz- 1st run Bz)) vs number of times ramped to 10 A)');
legend('Tripped, No Stdz Compare Run 7 - Run 5 ', 'Tripped, 1 Stdz, Run 8 - Run 6', 'Tripped, 2 Stdz, Run 10 - Run 9')


figure('units','normalized','outerposition',[0 0 0.9 0.9]) 
plot([1:length(ind5_10A)], (Bhxyzvsxyplt5.Bz(ind5_10A)-Bhxyzvsxyplt5.Bz(ind5_10A(1)))*T2G, 'bo');
hold
plot([1:length(ind6_10A)], (Bhxyzvsxyplt6.Bz(ind6_10A)-Bhxyzvsxyplt6.Bz(ind6_10A(1)))*T2G, 'r*');
xlabel('# of times ramped to 10 A');
ylabel('(Bz- first Bz) (G)');
title('(Bz- first Bz) vs number of times ramped to 10 A)');
legend('Tripped, No Stdz', 'Tripped, 1 Stdz')

% Find indexes of 5 A measurements.
ind3_5A = find(Bhxyzvsxyplt3.Imag < 5.2 & Bhxyzvsxyplt3.Imag > 4.9);
ind4_5A = find(Bhxyzvsxyplt4.Imag < 5.1 & Bhxyzvsxyplt4.Imag > 4.9);
ind5_5A = find(Bhxyzvsxyplt5.Imag < 5.1 & Bhxyzvsxyplt5.Imag > 4.9);
ind6_5A = find(Bhxyzvsxyplt6.Imag < 5.1 & Bhxyzvsxyplt6.Imag > 4.9);

figure('units','normalized','outerposition',[0 0 0.9 0.9]) 
% plot([1:length(ind3_5A)], (Bhxyzvsxyplt3.Bz(ind3_5A)-Bhxyzvsxyplt3.Bz(ind3_5A(1)))*T2G, 'bo');
% plot([1:length(ind4_5A)], (Bhxyzvsxyplt4.Bz(ind4_5A)-Bhxyzvsxyplt4.Bz(ind4_5A(1)))*T2G, 'ksq');
plot([1:length(ind5_5A)], (Bhxyzvsxyplt5.Bz(ind5_5A)-Bhxyzvsxyplt5.Bz(ind5_5A(1)))*T2G, 'bo');
hold

plot([1:length(ind6_5A)], (Bhxyzvsxyplt6.Bz(ind6_5A)-Bhxyzvsxyplt6.Bz(ind6_5A(1)))*T2G, 'r*');
xlabel('# of times ramped to 5 A');
ylabel('(Bz- first Bz) (G)');
title('(Bz- first Bz) vs number of times ramped to 5 A)');
legend('Tripped, No Stdz', 'Tripped, 1 Stdz')