clf
fpath = '/hao/aim2/dmsp/dmsp_idm_4s/';
fname = {[fpath '9601/l139601Boundaries_Bz'],[fpath '9602/l139602Boundaries_Bz'],... %here put all of the names&paths
    [fpath '9603/l139603Boundaries_Bz'],[fpath '9604/l139604Boundaries_Bz'],...      %of the files you want plotted
    [fpath '9605/l139605Boundaries_Bz'],[fpath '9606/l139606Boundaries_Bz'],...
    [fpath '9607/l139607Boundaries_Bz'],[fpath '9608/l139608Boundaries_Bz'],...
    [fpath '9609/l139609Boundaries_Bz'],[fpath '9610/l139610Boundaries_Bz'],...
    [fpath '9611/l139611Boundaries_Bz'],[fpath '9612/l139612Boundaries_Bz']};


colormap(jet)

  o=omniBox(1996); %call the omni data object in
o.setfile
o.readyear


for k = 1:length(fname)
    dataAr = []; 
    str = char(fname(k));
    filename = strcat( str, '.txt');
    data = dlmread(filename,'');
    j=1;
    mark = 0;
    
    
    for i = 1:2:length(data)
       
          if data(i,6) > 60 && data(i,6) < 80
            [t, vsw] = o.inquire(data((i),2),(data((i),3) - 600),'vsw'); %find vsw value for the crossing
            [t, dsw] = o.inquire(data((i),2),(data((i),3) - 600),'dsw'); %''dsw
            dataAr(j,1) = data(i,1);
            dataAr(j,2) = data(i,2);
            dataAr(j,3) = data(i,3);
            dataAr(j,4) = data(i,4);
            dataAr(j,5) = data(i,5);
            dataAr(j,6) = data(i,6);
            dataAr(j,7) = data(i,7);
            dataAr(j,8) = data(i,8);
            dataAr(j,9) = data(i,9);
            dataAr(j,10) = vsw;
            dataAr(j,11) = dsw;
            
            [t, vsw] = o.inquire(data((i+1),2),(data((i+1),3) - 600),'vsw'); %find vsw value for the crossing
            [t, dsw] = o.inquire(data((i+1),2),(data((i+1),3) - 600),'dsw'); %''dsw
            dataAr(j+1,1) = data(i+1,1);
            dataAr(j+1,2) = data(i+1,2);
            dataAr(j+1,3) = data(i+1,3);
            dataAr(j+1,4) = data(i+1,4);
            dataAr(j+1,5) = data(i+1,5);
            dataAr(j+1,6) = data(i+1,6);
            dataAr(j+1,7) = data(i+1,7);
            dataAr(j+1,8) = data(i+1,8);
            dataAr(j+1,9) = data(i+1,9);
            dataAr(j+1,10) = vsw;
            dataAr(j+1,11) = dsw;
            
            hold on 
             if dataAr(j,10) < 600      
                scatter(dataAr(j,6),dataAr(j,5),20,sqrt((dataAr(j,8).^2) + (dataAr(j,9).^2) ))
             else
                scatter(dataAr(j,6),dataAr(j,5),20,sqrt((dataAr(j,8).^2) + (dataAr(j,9).^2) ),'Marker','+')
             end
             
             if dataAr(j+1,10) < 600      
                scatter(dataAr(j+1,6),dataAr(j+1,5),20,sqrt((dataAr(j+1,8).^2) + (dataAr(j+1,9).^2) ))
             else
                scatter(dataAr(j+1,6),dataAr(j+1,5),20,sqrt((dataAr(j+1,8).^2) + (dataAr(j+1,9).^2) ),'Marker','+')
             end
            j=j+2;
       
           
            
          end
        
       end
    
    
    dlmwrite(strcat(fpath,'1996Boundaries_sw_lat','.txt'), dataAr,'delimiter',' ','-append'); %write boundaries file
        
end
    
caxis([0 10])
xlabel('MLAT')
ylabel('MLT')
title('Boundaries 1996')
colorbar
hold off

pause
fplot= ['/hao/aim2/dmsp/dmsp_idm_4s/' '1996Boundaries_sw_lat'];
set(gcf,'PaperPositionMode','auto');
print(gcf,'-dtiff',fplot);

    
    

    