close all

% Read Weimer Vy information for a day of good IDM orbits
hemisphere = 'N';
%filname = '/home/emery/tieconvec/Nw05_Ealong_B_Vicross_1996_078.txt';
np = 6;
%filname = '/home/emery/tieconvec/Nw05_Ealong_B_Vicross_2005_105.txt';
np = 4;
hemisphere = 'S';
%filname = '/home/emery/tieconvec/Sw05_Ealong_B_Vicross_1996_078.txt';
%np = 3;
filname = '/home/emery/tieconvec/Sw05_Ealong_B_Vicross_2005_289.txt';
np = 8;

WEI=fopen(filname,'r');

for nn=1:np
 topwei = fgetl(WEI);
 weitop = sscanf(topwei,'%d %d %d %f %f %f %f');
 nidm(nn) = weitop(1);
 iyear = weitop(2);
 iday = weitop(3);
 Bz(nn) = weitop(4);
 By(nn) = weitop(5);
 for i=1:nidm(nn)
  linwei = fgetl(WEI);
  weidat = sscanf(linwei,'%f');
  uts(i,nn) = weidat(2);
  mlat(i,nn) = weidat(3);
  mlt(i,nn) = weidat(4);
  vy(i,nn) = weidat(11);
 end
end

% Plot polar passes for 1 day
yearS = int2str(iyear);
daynumS = int2str(iday);
PlotTitle = ([yearS,' ',daynumS,' ',hemisphere,'H Weimer (2005)'] );
for nn=1:np
data1 = [uts(:,nn)/3600. mlat(:,nn) mlt(:,nn) vy(:,nn)];  % will label start of pass in hours=uts/3600.
    if nn==1
   [out,track,lines] = satelliteTrackPlot(data1,[-3 3], 15, PlotTitle, 1,3,{});
    else
% 'Update' does not seem to work, so passed in initialize (0) and cbarmax (3)
   [out,track,lines] = satelliteTrackPlot(data1,[-3 3], 15, PlotTitle, 0,3,'Update');
    end
     hold on;
end

