% Script loads multiple runs for SXU1 tension coil runs and plots them and
% then does some analysis.
Plot_gap_int_plt(6)  % Starts on 05-23-2019  11:48:37, Ends on 05-28-2019 23:29:45  
close all
Plot_gap_int_plt(7)  % Starts on 05-29-2019  10:13:14, Ends on 06-02-2019 13:36:22
close all
Plot_gap_int_plt(8)  % Starts on 06-03-2019  12:03:12, Ends on 06-08-2019 03:37:09      
close all
Plot_gap_int_plt(9)  % Starts on 06-10-2019  09:41:37, Ends on 06-13-2019 08:31:10
close all
Plot_gap_int_plt(10)  % Starts on 06-13-2019  09:54:33, Ends on 6-18-2019 02:42:27 
close all
Plot_gap_int_plt(11)  % Starts on 06-26-2019  08:36:49, Ends on 6-27-2019 12:22:21     
close all
Plot_gap_int_plt(12)  % Starts on 06-28-2019  09:07:31, Ends on 7-5-2019 8:59:03     
close all
Plot_gap_int_plt(13)  % Starts on 07-05-2019  09:53:05, Ends on 7-7-2019 1:02:29      
close all
Plot_gap_int_plt(14)  % Starts on 07-08-2019  08:34:57, Ends on 7-10-2019 22:57:15     
close all
Plot_gap_int_plt(15)  % Starts on 07-12-2019  11:06:53, Ends on 7-16-2019 19:59:59     
close all
Plot_gap_int_plt(16)  % Starts on 07-16-2019  09:13:55, Ends on 7-18-2019 19:59:59      
close all
Plot_gap_int_plt(17)  % Starts on 07-19-2019  15:24:27, Ends on 7-22-2019 13:48:37     
close all
Plot_gap_int_plt(18)  % Starts on 07-22-2019  10:26:48, Ends on 7-23-2019 16:41:59     
close all
Plot_gap_int_plt(19)  % Starts on 07-24-2019  14:34:11, Ends on     
close all


Time_6_7_offset = 10.75; % Hours
Time_6_8_offset = (5*24) + 12 + (33/60); % Hours  5.5 days + 33 minutes from run 6 end
Time_6_9_offset = (12*24) + 9 + (30.25 + 41)/60; % Hours  12 days + 9 hours + (41 + 30.25) minutes from run 6 end
Time_6_10_offset = (15*24) + 9 + (30.25 + 54.5)/60; % Hours = 16 days + 9 hours + (30.25 + 54.5) minutes from run 6 end
Time_6_11_offset = (28*24) + 8 + (30.25 + 36.82)/60; % Hours = 28 days + 8 hours + 49 minutes from run 6 end
Time_6_12_offset = (30*24) + 9 + (30.25 + 37.75)/60; % Hours = 30 days + 9 hours + 37 minutes from run 6 end
Time_6_13_offset = (37*24) + 9 + (30.25 + 53.08)/60; % Hours = 38 days + 9 hours + 53 minutes from run 6 end
Time_6_14_offset = (40*24) + 8 + (30.25 + 35.95)/60; % Hours = 41 days + 8 hours + 36 minutes from run 6 end
Time_6_15_offset = (44*24) + 11 + (30.25 + 6.94)/60; % Hours = 45 days + 9 hours + 37 minutes from run 6 end
Time_6_16_offset = (48*24) +  9 + (30.25 + 14)/60; % Hours = 48 days + 9 hours + 14 minutes from run 6 end
Time_6_17_offset = (51*24) + 15 + (30.25 + 24.5)/60; % Hours = 51 days + 15 hours + 24.5 minutes from run 6 end
Time_6_18_offset = (54*24) + 10 + (30.25 + 26.8)/60; % Hours = 54 days + 10 hours + 26.8 minutes from run 6 end
Time_6_19_offset = (56*24) + 14 + (30.25 + 34.2)/60; % Hours = 56 days + 14 hours + 34.2 minutes from run 6 end


% plot integrals
figure('units','normalized','outerposition',[0 0 1 1])
plot(Time_plus6, GI_run6.Temp_Corr_Integral_plus, marker_make3(1))
hold
plot(Time_plus7 + Time_plus6(end) + Time_6_7_offset, GI_run7.Temp_Corr_Integral_plus, marker_make3(2))
plot(Time_plus8 + Time_plus6(end) + Time_6_8_offset, GI_run8.Temp_Corr_Integral_plus, marker_make3(3))
plot(Time_plus9 + Time_plus6(end) + Time_6_9_offset, GI_run9.Temp_Corr_Integral_plus, marker_make3(4))
plot(Time_plus10 + Time_plus6(end) + Time_6_10_offset, GI_run10.Temp_Corr_Integral_plus, marker_make3(5))
plot(Time_plus11 + Time_plus6(end) + Time_6_11_offset, GI_run11.Temp_Corr_Integral_plus, marker_make3(6))
plot(Time_plus12 + Time_plus6(end) + Time_6_12_offset, GI_run12.Temp_Corr_Integral_plus, marker_make3(7))
plot(Time_plus13 + Time_plus6(end) + Time_6_13_offset, GI_run13.Temp_Corr_Integral_plus, marker_make3(8))
plot(Time_plus14 + Time_plus6(end) + Time_6_14_offset, GI_run14.Temp_Corr_Integral_plus, marker_make3(9))
plot(Time_plus15 + Time_plus6(end) + Time_6_15_offset, GI_run15.Temp_Corr_Integral_plus, marker_make3(10))
plot(Time_plus16 + Time_plus6(end) + Time_6_16_offset, GI_run16.Temp_Corr_Integral_plus, marker_make3(11))
plot(Time_plus17 + Time_plus6(end) + Time_6_17_offset, GI_run17.Temp_Corr_Integral_plus, marker_make3(12))
plot(Time_plus18 + Time_plus6(end) + Time_6_18_offset, GI_run18.Temp_Corr_Integral_plus, marker_make3(13))
plot(Time_plus19 + Time_plus6(end) + Time_6_19_offset, GI_run19.Temp_Corr_Integral_plus, marker_make3(14))

   mark_weekends;
         
legend('Run 6 Plus Integral', 'Run 7 Plus Integral', 'Run 8 Plus Integral','Run 9 Plus Integral', 'Run 10 Plus Integral', 'Run 11 Plus Integral',  'Run 12 Plus Integral', 'Run 13 Plus Integral', 'Run 14 Plus Integral', 'Run 15 Plus Integral', 'Run 16 Plus Integral', 'Run 17 Plus Integral', 'Run 18 Plus Integral', 'Run 19 Plus Integral')

xlabel('Time (hours)');
xlabel('Plus Integral (Vs)');
title('Plus Integral vs Time for Multiple Runs');
print('Runs 6-19 Integrals.png', '-dpng', '-r0');

hline(GI_run6.Temp2_Corr_Integral_plus_mean + GI_run6.Temp2_Corr_Integral_plus_mean*1e-4,'r--','Run 6 Measurement + Run 6 Measurement*1e-4*Measurement')
hline(Integral_plus_mean6(1)-Integral_plus_mean6(1)*1e-4,'r--','Run 6 Measurement + Run 6 Measurement*1e-4*Measurement')

% plot temperatures
figure('units','normalized','outerposition',[0 0 1 1])
    plot(Time_plus6, Temp_Ambient_mean_plus6, marker_make3(1))
    hold
    plot(Time_plus7 + Time_plus6(end) + Time_6_7_offset, Temp_Ambient_mean_plus7, marker_make3(7))
    plot(Time_plus8 + Time_plus6(end) + Time_6_8_offset, Temp_Ambient_mean_plus8, marker_make3(13))
    plot(Time_plus9 + Time_plus6(end) + Time_6_9_offset, Temp_Ambient_mean_plus9, marker_make3(19))
    plot(Time_plus10 + Time_plus6(end) + Time_6_10_offset, Temp_Ambient_mean_plus10, marker_make3(25))
    plot(Time_plus11 + Time_plus6(end) + Time_6_11_offset, Temp_Ambient_mean_plus11, marker_make3(31))
    plot(Time_plus12 + Time_plus6(end) + Time_6_12_offset, Temp_Ambient_mean_plus12, marker_make3(37))
    plot(Time_plus13 + Time_plus6(end) + Time_6_13_offset, Temp_Ambient_mean_plus13, marker_make3(43))
    plot(Time_plus14 + Time_plus6(end) + Time_6_14_offset, Temp_Ambient_mean_plus14, marker_make3(1))
    plot(Time_plus15 + Time_plus6(end) + Time_6_15_offset, Temp_Ambient_mean_plus15, marker_make3(7))
    plot(Time_plus16 + Time_plus6(end) + Time_6_16_offset, Temp_Ambient_mean_plus16, marker_make3(13))
    plot(Time_plus17 + Time_plus6(end) + Time_6_17_offset, Temp_Ambient_mean_plus17, marker_make3(19))
    plot(Time_plus18 + Time_plus6(end) + Time_6_18_offset, Temp_Ambient_mean_plus18, marker_make3(25))
    plot(Time_plus19 + Time_plus6(end) + Time_6_19_offset, Temp_Ambient_mean_plus19, marker_make3(31))

            
    plot(Time_plus6, Temp_Module_mean_plus6, marker_make3(2))
    plot(Time_plus7 + Time_plus6(end) + Time_6_7_offset, Temp_Module_mean_plus7, marker_make3(8))
    plot(Time_plus8 + Time_plus6(end) + Time_6_8_offset, Temp_Module_mean_plus8, marker_make3(14))
    plot(Time_plus9 + Time_plus6(end) + Time_6_9_offset, Temp_Module_mean_plus9, marker_make3(20))
    plot(Time_plus10 + Time_plus6(end) + Time_6_10_offset, Temp_Module_mean_plus10, marker_make3(26))
    plot(Time_plus11 + Time_plus6(end) + Time_6_11_offset, Temp_Module_mean_plus11, marker_make3(32))
    plot(Time_plus12 + Time_plus6(end) + Time_6_12_offset, Temp_Module_mean_plus12, marker_make3(38))
    plot(Time_plus13 + Time_plus6(end) + Time_6_13_offset, Temp_Module_mean_plus13, marker_make3(44))
    plot(Time_plus14 + Time_plus6(end) + Time_6_14_offset, Temp_Module_mean_plus14, marker_make3(2))
    plot(Time_plus15 + Time_plus6(end) + Time_6_15_offset, Temp_Module_mean_plus15, marker_make3(8))
    plot(Time_plus16 + Time_plus6(end) + Time_6_16_offset, Temp_Module_mean_plus16, marker_make3(14))
    plot(Time_plus17 + Time_plus6(end) + Time_6_17_offset, Temp_Module_mean_plus17, marker_make3(20))
    plot(Time_plus18 + Time_plus6(end) + Time_6_18_offset, Temp_Module_mean_plus18, marker_make3(26))
    plot(Time_plus19 + Time_plus6(end) + Time_6_19_offset, Temp_Module_mean_plus19, marker_make3(32))
    
      mark_weekends;
         
legend('Ambient Temp Run 6', 'Ambient Temp Run 7', 'Ambient Temp Run 8', 'Ambient Temp Run 9', 'Ambient Temp Run 10', 'Ambient Temp Run 11', 'Ambient Temp Run 12', 'Ambient Temp Run 13', 'Ambient Temp Run 14', 'Ambient Temp Run 15',  'Ambient Temp Run 16', 'Ambient Temp Run 17', 'Ambient Temp Run 18', 'Ambient Temp Run 19', 'Carrier Temp Run 6', 'Carrier Temp Run 7', 'Carrier Temp Run 8', 'Carrier Temp Run 9', 'Carrier Temp Run 10', 'Carrier Temp Run 11', 'Carrier Temp Run 12', 'Carrier Temp Run 13', 'Carrier Temp Run 14', 'Carrier Temp Run 15', 'Carrier Temp Run 16', 'Carrier Temp Run 17', 'Carrier Temp Run 18', 'Carrier Temp Run 18')

xlabel('Time (hours)');
xlabel('Temperature (C)');
title('Temperatures vs Time for Multiple Runs');
print('Runs 6-19 Temperatures.png', '-dpng', '-r0');


 %% SXU Temperatures and Integral on same plot      
     figure('units','normalized','outerposition',[0 0 6 6])
    plot(Time_plus6, Temp_Ambient_mean_plus6, marker_make3(1))
    hold
    plot(Time_plus7 + Time_plus6(end) + Time_6_7_offset, Temp_Ambient_mean_plus7, marker_make3(7))
    plot(Time_plus8 + Time_plus6(end) + Time_6_8_offset, Temp_Ambient_mean_plus8, marker_make3(13))
    plot(Time_plus9 + Time_plus6(end) + Time_6_9_offset, Temp_Ambient_mean_plus9, marker_make3(19))
    plot(Time_plus10 + Time_plus6(end) + Time_6_10_offset, Temp_Ambient_mean_plus10, marker_make3(25))
    plot(Time_plus11 + Time_plus6(end) + Time_6_11_offset, Temp_Ambient_mean_plus11, marker_make3(31))
    plot(Time_plus12 + Time_plus6(end) + Time_6_12_offset, Temp_Ambient_mean_plus12, marker_make3(37))
    plot(Time_plus13 + Time_plus6(end) + Time_6_13_offset, Temp_Ambient_mean_plus13, marker_make3(43))
    plot(Time_plus14 + Time_plus6(end) + Time_6_14_offset, Temp_Ambient_mean_plus14, marker_make3(1))
    plot(Time_plus15 + Time_plus6(end) + Time_6_15_offset, Temp_Ambient_mean_plus15, marker_make3(7))
    plot(Time_plus16 + Time_plus6(end) + Time_6_16_offset, Temp_Ambient_mean_plus16, marker_make3(13))
    plot(Time_plus17 + Time_plus6(end) + Time_6_17_offset, Temp_Ambient_mean_plus17, marker_make3(19))
    plot(Time_plus18 + Time_plus6(end) + Time_6_18_offset, Temp_Ambient_mean_plus18, marker_make3(25))
    plot(Time_plus19 + Time_plus6(end) + Time_6_19_offset, Temp_Ambient_mean_plus19, marker_make3(31))

    plot(Time_plus6, Temp_Module_mean_plus6, marker_make3(4))
    plot(Time_plus7 + Time_plus6(end) + Time_6_7_offset, Temp_Module_mean_plus7, marker_make3(10))
    plot(Time_plus8 + Time_plus6(end) + Time_6_8_offset, Temp_Module_mean_plus8, marker_make3(16))
    plot(Time_plus9 + Time_plus6(end) + Time_6_9_offset, Temp_Module_mean_plus9, marker_make3(22))
    plot(Time_plus10 + Time_plus6(end) + Time_6_10_offset, Temp_Module_mean_plus10, marker_make3(28))
    plot(Time_plus11 + Time_plus6(end) + Time_6_11_offset, Temp_Module_mean_plus11, marker_make3(34))
    plot(Time_plus12 + Time_plus6(end) + Time_6_12_offset, Temp_Module_mean_plus12, marker_make3(40))
    plot(Time_plus13 + Time_plus6(end) + Time_6_13_offset, Temp_Module_mean_plus13, marker_make3(46))
    plot(Time_plus14 + Time_plus6(end) + Time_6_14_offset, Temp_Module_mean_plus14, marker_make3(4))
    plot(Time_plus15 + Time_plus6(end) + Time_6_15_offset, Temp_Module_mean_plus15, marker_make3(10))
    plot(Time_plus16 + Time_plus6(end) + Time_6_16_offset, Temp_Module_mean_plus16, marker_make3(16))
    plot(Time_plus17 + Time_plus6(end) + Time_6_17_offset, Temp_Module_mean_plus17, marker_make3(22))
    plot(Time_plus18 + Time_plus6(end) + Time_6_18_offset, Temp_Module_mean_plus18, marker_make3(28))
    plot(Time_plus19 + Time_plus6(end) + Time_6_19_offset, Temp_Module_mean_plus19, marker_make3(34))
    
     xlabel('Time (Hours)');
     ylabel('SXU3 Temperatures (C)');
     title('SXU3 Temperatures and Integral vs Time Runs 6 through 19'); 
     yyaxis right
     
     plot(Time_plus6, Integral_plus_mean6, marker_make3(2))
     plot(Time_plus7 + Time_plus6(end) + Time_6_7_offset, Integral_plus_mean7, marker_make3(8))
     plot(Time_plus8 + Time_plus6(end) + Time_6_8_offset, Integral_plus_mean8, marker_make3(14))
     plot(Time_plus9 + Time_plus6(end) + Time_6_9_offset, Integral_plus_mean9, marker_make3(20))
     plot(Time_plus10 + Time_plus6(end) + Time_6_10_offset, Integral_plus_mean10, marker_make3(26))
     plot(Time_plus11 + Time_plus6(end) + Time_6_11_offset, Integral_plus_mean11, marker_make3(32))
     plot(Time_plus12 + Time_plus6(end) + Time_6_12_offset, Integral_plus_mean12, marker_make3(38))
     plot(Time_plus13 + Time_plus6(end) + Time_6_13_offset, Integral_plus_mean13, marker_make3(44))
     plot(Time_plus14 + Time_plus6(end) + Time_6_14_offset, Integral_plus_mean14, marker_make3(2))
     plot(Time_plus15 + Time_plus6(end) + Time_6_15_offset, Integral_plus_mean15, marker_make3(8))
     plot(Time_plus16 + Time_plus6(end) + Time_6_16_offset, Integral_plus_mean16, marker_make3(14))
     plot(Time_plus17 + Time_plus6(end) + Time_6_17_offset, Integral_plus_mean17, marker_make3(20))
     plot(Time_plus18 + Time_plus6(end) + Time_6_18_offset, Integral_plus_mean18, marker_make3(26))
     plot(Time_plus19 + Time_plus6(end) + Time_6_19_offset, Integral_plus_mean19, marker_make3(32))

     
     ylabel('Plus Integral - No Temp Corr (Vs)');
     
     legend('Ambient Temp Run 6', 'Ambient Temp Run 7', 'Ambient Temp Run 8', 'Ambient Temp Run 9', 'Ambient Temp Run 10', 'Ambient Temp Run 11', 'Ambient Temp Run 12', 'Ambient Temp Run 13', 'Ambient Temp Run 14', 'Ambient Temp Run 15',  'Ambient Temp Run 16',  'Ambient Temp Run 17', 'Ambient Temp Run 18', 'Ambient Temp Run 19',...
            'Carrier Temp Run 6', 'Carrier Temp Run 7', 'Carrier Temp Run 8', 'Carrier Temp Run 9', 'Carrier Temp Run 10', 'Carrier Temp Run 11', 'Carrier Temp Run 12', 'Carrier Temp Run 13', 'Carrier Temp Run 14', 'Carrier Temp Run 15', 'Carrier Temp Run 16', 'Carrier Temp Run 17',  'Carrier Temp Run 18',  'Carrier Temp Run 19',...
            'Run 6 Plus Integral', 'Run 7 Plus Integral', 'Run 8 Plus Integral', 'Run 9 Plus Integral', 'Run 10 Plus Integral', 'Run 11 Plus Integral', 'Run 12 Plus Integral', 'Run 13 Plus Integral', 'Run 14 Plus Integral', 'Run 15 Plus Integral', 'Run 16 Plus Integral', 'Run 17 Plus Integral', 'Run 18 Plus Integral', 'Run 19 Plus Integral', 'Location','northeast')
     print(strcat('Temp and Int vs Time SXU3 TCRM.png'), '-dpng', '-r0');
       print(strcat('Temp and Int vs Time SXU3 TCRM.fig'), '-dpng', '-r0');
      fig_name = gcf;
      set(fig_name,'Name', 'Temp and Integral vs Time SXU3 TCRM Runs 6 through 19');
      
      all_data = [Integral_plus_mean6 Integral_plus_mean7 Integral_plus_mean8 Integral_plus_mean9 Integral_plus_mean10, Integral_plus_mean11, Integral_plus_mean12, Integral_plus_mean13, Integral_plus_mean14, Integral_plus_mean15, Integral_plus_mean16, Integral_plus_mean17, Integral_plus_mean18, Integral_plus_mean19];
      all_data_mean = mean(all_data);
       all_data_std = std(all_data);
        all_data_rerror = all_data_std/all_data_mean;
        plot_mean_stdev(all_data_mean, all_data_std, 'Vs');
        
       mark_weekends;
