Test ComputeTLE

------------------------------------------------------------------------
See also Plot2D, TimeLabl, Mag, RK45, Date2JD, LoadGEM, ComputeTLE,
NORAD, RV2El, RVFromKepler
------------------------------------------------------------------------
%--------------------------------------------------------------------------
%   Copyright (c) 2009 Princeton Satellite Systems, Inc. All rights reserved.
%--------------------------------------------------------------------------


r = [-1799.56322;3883.60987;-5632.97758];
v = [4.03338703;-4.52428114;-4.4128827];
elOsc = RV2El(r,v);
jD0 = Date2JD([2001 2 13 0 0 29]);

[sO, c, j, mu, a] = LoadGEM(1);

sTLE = ComputeTLE( elOsc, jD0 );

% Kepler
tVec = linspace(0,3*86400,500);
[rK,vK] = RVFromKepler( elOsc, tVec );

% NORAD
rV = NORAD( tVec, [], [], 'SGP4', [], sTLE );
%r - rV.r(:,1)

sOrig = [sprintf('SGPTest \n'),...
         sprintf('1 00000U           1044.00033565  .00001712  00000-0  00000-0 0    18\n'),...
         sprintf('2 00000  98.1516 305.7348 0006329  85.2914 148.1408 14.62292261    00')];
         %sprintf('1 00000U           1044.00033565  .00001712  00000-0  34851-3 0    18\n'),...
%rV = NORAD( tVec, [], [], 'SGP4', [], sOrig );
%r - rV.r(:,1)
%el0 = RV2El( rV.r(:,1), rV.v(:,1) );
%el1 = NORADToEl( 0, 0, 1, 'SGP4', sOrig );
%elOsc - el0

% Numerical propagation
drag = 0; %2.2*8.5/448;
xP = zeros(6,length(tVec));
x  = [r;v];
h0 = tVec(2)-tVec(1);
h  = h0;
for k = 1:length(tVec)
  jD = jD0 + tVec(k)/86400;
  xP(:,k) = x;
  [x,h] = RK45( 'FOrbHF', x, h, h0, 0.05*h, 1e-10, tVec(k), [4 4 0 0 drag],jD, [0;0;0], mu, sO, c, j, a );
end

%opts = odeset('abstol',1e-12,'reltol',1e-6);
%[tOUT,yOUT] = ode45(@FOrbHF,tVec,[r;v],opts, [4 4 0 0 drag],jD, [0;0;0], mu, sO, c, j, a );

diff = xP(1:3,:) - rV.r;
[tPlot,tL] = TimeLabl( tVec );
Plot2D( tPlot, [diff;Mag(diff)], tL, {'x','y','z','|d|'}, 'Difference' )

Plot2D( tPlot, [rK;xP(1:3,:);rV.r], tL, {'x','y','z'}, 'Comparison',...
  [],{[1 4 7],[2 5 8],[3 6 9]} )

% Expect: 10 km after 3 days (no drag)

%--------------------------------------
% PSS internal file version information
%--------------------------------------