% driver to plot all TID's in a given file can add function to trend across
% multiple TID's

maven_path = '/Users/mkelrod/Desktop/ISRO_MDA/';
L1b_osdir = 'osnb_list.txt';
L1b_iodir = 'osion_list.txt';
l2_csndir = 'l2_csn_list.txt';
l2_csodir = 'l2_cso_list.txt';
l2_iondir = 'l2_ion_list.txt';
L1bosin = [maven_path L1b_osdir];
L1bioin = [maven_path L1b_iodir];
L2csin = [maven_path, l2_csndir];
L2osin = [maven_path, l2_csodir];
L2ioin = [maven_path, l2_iondir];

fid = fopen(L1bosin);
utL1 = textscan(fid,'%s','Delimiter','\n');
fclose(fid);
fnameL1 = utL1{:,1};
fsL1 = size(fnameL1,1);
for f=1:fsL1
    L1bosNAME(f,:) = fnameL1{f,:};
    TID_In(f,:) = fnameL1{f,:};
end
fid4 = fopen(L1bioin);
utL1b = textscan(fid4,'%s','Delimiter','\n');
fclose(fid4);
fnameL1io = utL1b{:,1};
fsL1io = size(fnameL1io,1);
for f=1:fsL1io
    L1bioNAME(f,:) = fnameL1io{f,:};
    TID_Inio(f,:) = fnameL1io{f,:};
end
fid1 = fopen(L2csin);
utL2a = textscan(fid1,'%s','Delimiter','\n');
fclose(fid1);
fnameL2a = utL2a{:,1};
fsL2a = size(fnameL2a,1);
for f=1:fsL2a
    L2csNAME(f,:) = fnameL2a{f,:};
    TID_CS(f,:) = fnameL2a{f,:};
end
fid2 = fopen(L2osin);
utL2b = textscan(fid2,'%s','Delimiter','\n');
fclose(fid2);
fnameL2b = utL2b{:,1};
fsL2b = size(fnameL2b,1);
for f=1:fsL2b
    L2osNAME(f,:) = fnameL2b{f,:};
    TID_OS(f,:) = fnameL2b{f,:};
end
fid3 = fopen(L2ioin);
utL2c = textscan(fid3,'%s','Delimiter','\n');
fclose(fid3);
fnameL2c = utL2c{:,1};
fsL2c = size(fnameL2c,1);
for f=1:fsL2c
    L2ioNAME(f,:) = fnameL2c{f,:};
    TID_IO(f,:) = fnameL2c{f,:};
end


TID_L1bos = str2num((TID_In(:,18:22)));
TID_L1bio = str2num((TID_Inio(:,19:23)));
TID_L2CS = str2num((TID_CS(:,22:26)));
TID_L2OS = str2num((TID_OS(:,22:26)));
TID_L2IO = str2num((TID_IO(:,22:26)));


% for k = 1:size(TID_L1bio,1)
%     if TID_L1bio(k) == TID_L2CS(k) && TID_L1bio(k) == TID_L2IO(k)
%     single_file_plot(L1bioNAME(k,:), L2csNAME(k,:), L2ioNAME(k,:))
%     elseif TID_L1bio(k) == TID_L2IO(k)
%         single_file_plot(L1bioNAME(k,:), L2ioNAME(k,:))
%     else
%         single_file_plot(L1bioNAME(k,:))
%     end
%     
% end

for l = 1:size(TID_L1bos, 1)
    if TID_L1bos(l) == TID_L2OS(l)
        single_file_plot(L1bioNAME(l,:), L2osNAME(l,:))
    else
        single_file_plot(L1bioNAME(l,:))
    end
end
    