colormap(jet)
data = dlmread('/hao/aim2/dmsp/dmsp_idm_4s/1996Boundaries_sw_lat.txt','');
    j=2;
   
    
    
    for i = 2: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('/hao/aim2/dmsp/dmsp_idm_4s/1996Boundaries_sw_latF.txt', dataAr,'delimiter',' ','-append'); %write boundaries file
        

    
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);

    
    

    