Skip to content
This repository was archived by the owner on Nov 22, 2021. It is now read-only.

Commit 9fb3fb8

Browse files
author
scienceopen
committed
initial commit
1 parent 0f2d11d commit 9fb3fb8

65 files changed

Lines changed: 4217 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

anheader.m

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
function [Obs_types, ant_delta,ifound_types,eof] = anheader(file)
2+
%ANHEADER Analyzes the header of a RINEX file and outputs
3+
% the list of observation types and antenna offset.
4+
% End of file is flagged 1, else 0. Likewise for the types.
5+
% Typical call: anheader('pta.96o')
6+
7+
%Kai Borre 09-12-96
8+
%Copyright (c) by Kai Borre
9+
%$Revision: 1.0 $ $Date: 1997/09/23 $
10+
11+
fid = fopen(file,'rt');
12+
eof = 0;
13+
ifound_types = 0;
14+
Obs_types = [];
15+
ant_delta = [];
16+
17+
while 1 % Gobbling the header
18+
line = fgetl(fid);
19+
answer = findstr(line,'END OF HEADER');
20+
if ~isempty(answer), break; end;
21+
if (line == -1), eof = 1; break; end;
22+
answer = findstr(line,'ANTENNA: DELTA H/E/N');
23+
if ~isempty(answer)
24+
for k = 1:3
25+
[delta, line] = strtok(line);
26+
del = str2num(delta);
27+
ant_delta = [ant_delta del];
28+
end;
29+
end
30+
answer = findstr(line,'# / TYPES OF OBSERV');
31+
if ~isempty(answer)
32+
[NObs, line] = strtok(line);
33+
NoObs = str2num(NObs);
34+
for k = 1:NoObs
35+
[ot, line] = strtok(line);
36+
Obs_types = [Obs_types ot];
37+
end;
38+
ifound_types = 1;
39+
end;
40+
end;
41+
42+
%fclose(fid);
43+
%%%%%%%%% end anheader.m %%%%%%%%%

b_point.m

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
function pos = b_point(Eph,pr,sv,time) %%%%%
2+
%B_POINT Prepares input to the Bancroft algorithm for finding
3+
% a preliminary position of a receiver. The input is
4+
% name of ephemeris file, four or more pseudoranges
5+
% and the coordinates of the satellites.
6+
7+
%Kai Borre and C.C. Goad 11-24-96
8+
%Copyright (c) by Kai Borre
9+
%$Revision: 1.0 $ $Date: 1997/09/26 $
10+
11+
v_light = 299792458;
12+
dtr = pi/180;
13+
14+
m = size(pr,1);
15+
%%%%Eph = get_eph(efile);
16+
for t = 1:m
17+
col_Eph(t) = find_eph(Eph,sv(t),time);
18+
end
19+
20+
pos = zeros(4,1); % First guess Earth center
21+
for l = 1:2
22+
B = [];
23+
for jsat = 1:m
24+
k = col_Eph(jsat);
25+
tx_RAW = time - pr(jsat)/v_light;
26+
toc = Eph(21,k);
27+
dt = check_t(tx_RAW-toc);
28+
tcorr = (Eph(2,k)*dt + Eph(20,k))*dt + Eph(19,k);
29+
tx_GPS = tx_RAW-tcorr;
30+
dt = check_t(tx_GPS-toc);
31+
tcorr = (Eph(2,k)*dt + Eph(20,k))*dt + Eph(19,k);
32+
tx_GPS = tx_RAW-tcorr;
33+
X = satpos(tx_GPS, Eph(:,k));
34+
if l ~= 1
35+
rhosq = (X(1)-pos(1))^2+(X(2)-pos(2))^2+(X(3)-pos(3))^2;
36+
traveltime = sqrt(rhosq)/v_light;
37+
Rot_X = e_r_corr(traveltime,X);
38+
rhosq = (Rot_X(1)-pos(1))^2 + ...
39+
(Rot_X(2)-pos(2))^2 + ...
40+
(Rot_X(3)-pos(3))^2;
41+
traveltime = sqrt(rhosq)/v_light;
42+
[az,el,dist] = topocent(Rot_X, Rot_X-pos(1:3,:));
43+
trop = tropo(sin(el*dtr),h/1000,1013.0,293.0,50.0,...
44+
0.0,0.0,0.0);
45+
else trop = 0;
46+
end
47+
corrected_pseudorange = pr(jsat)+v_light*tcorr-trop;
48+
B(jsat,1) = X(1);
49+
B(jsat,2) = X(2);
50+
B(jsat,3) = X(3);
51+
B(jsat,4) = corrected_pseudorange;
52+
end; % jsat-loop
53+
pos = bancroft(B);
54+
[phi,lambda,h] = togeod(6378137, 298.257223563, ...
55+
pos(1), pos(2), pos(3));
56+
end; % l-loop
57+
clock_offset = pos(4)/v_light;
58+
pos(4) = clock_offset*1.e+9; % ns
59+
%%%%%%%%%%% b_point.m %%%%%%%%%%%%%%%%%%%%%%%%%

baseline.m

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function [omc,bas] = baseline(X_i,obs1,obs2,sats,time,Eph)
2+
% BASELINE Computation of baseline between master and rover
3+
% from pseudoranges alone
4+
5+
%Kai Borre 31-10-2001
6+
%Copyright (c) by Kai Borre
7+
%$Revision: 1.1 $ $Date: 2002/11/24 $
8+
9+
m = size(obs1,1); % number of svs
10+
% identify ephemerides columns in Eph
11+
for t = 1:m
12+
col_Eph(t) = find_eph(Eph,sats(t),time);
13+
end
14+
% preliminary guess for receiver position
15+
X_j = X_i(1:3,1);
16+
% Computation of weight matrix
17+
D = [ones(m-1,1) -eye(m-1) -ones(m-1,1) eye(m-1)];
18+
C = inv(D*D');
19+
20+
for iter = 1:8
21+
% k is the reference satellite. We select the first one
22+
[tcorr,rhok_j,Xk_ECF] = get_rho(time, obs2(1), Eph(:,col_Eph(1)),X_j);
23+
[tcorr,rhok_i,Xk_ECF] = get_rho(time, obs1(1), Eph(:,col_Eph(1)),X_i);
24+
for t = 2:m % t runs over PRNs given in sats; ref.sat. is number 1
25+
[tcorr,rhol_j,Xl_ECF] = get_rho(time, obs2(t), Eph(:,col_Eph(t)), X_j);
26+
[tcorr,rhol_i,Xl_ECF] = get_rho(time, obs1(t), Eph(:,col_Eph(t)), X_i);
27+
A(t-1,:) = [(Xk_ECF(1)-X_j(1))/rhok_j - (Xl_ECF(1)-X_j(1))/rhol_j, ...
28+
(Xk_ECF(2)-X_j(2))/rhok_j - (Xl_ECF(2)-X_j(2))/rhol_j, ...
29+
(Xk_ECF(3)-X_j(3))/rhok_j - (Xl_ECF(3)-X_j(3))/rhol_j];
30+
observed = obs1(1)-obs2(1)-obs1(t)+obs2(t);
31+
calculated = rhok_i-rhok_j-rhol_i+rhol_j;
32+
omc(t-1,1) = observed - calculated;
33+
end; % t
34+
x = inv(A'*C*A)*A'*C*omc;
35+
X_j = X_j+x;
36+
end % iter
37+
bas = X_i(1:3,1)-X_j;
38+
%%%%%%%%%%%%%%%%%%%%% baseline.m %%%%%%%%%%%%%%%%%%%%%
39+

bdata.dat

75 KB
Binary file not shown.

check_t.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function tt = check_t(t);
2+
% CHECK_T repairs over- and underflow of GPS time
3+
4+
% Written by Kai Borre
5+
% April 1, 1996
6+
7+
half_week = 302400;
8+
tt = t;
9+
10+
if t > half_week, tt = t-2*half_week; end
11+
if t < -half_week, tt = t+2*half_week; end
12+
13+
%%%%%%% end check_t.m %%%%%%%%%%%%%%%%%

chistart.m

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
function Chi2 = chistart (D,L,a,ncands,factor)
2+
%CHISTART: Computes the initial size of the search ellipsoid
3+
%
4+
% This routine computes or approximates the initial size of the
5+
% search ellipsoid. If the requested number of candidates is not
6+
% more than the dimension + 1, this is done by computing the squared
7+
% distances of partially rounded float vectors to the float vector in
8+
% the metric of the covariance matrix. Otherwise an approximation is used.
9+
%
10+
% Input arguments
11+
% L,D : LtDL-decomposition of the variance-covariance matrix of
12+
% the float ambiguities (preferably decorrelated)
13+
% a : float ambiguites (preferably decorrelated)
14+
% ncands: Requested number of candidates (default = 2)
15+
% factor: Multiplication factor for the volume of the resulting
16+
% search ellipsoid (default = 1.5)
17+
%
18+
% Output arguments:
19+
% Chi2 : Size of the search ellipsoid
20+
21+
% ----------------------------------------------------------------------
22+
% File.....: chistart.m
23+
% Date.....: 19-MAY-1999
24+
% Author...: Peter Joosten
25+
% Mathematical Geodesy and Positioning
26+
% Delft University of Technology
27+
% ----------------------------------------------------------------------
28+
29+
% ------------------
30+
% --- Initialize ---
31+
% ------------------
32+
33+
if nargin < 4; ncands = 2 ; end;
34+
if nargin < 5; factor = 1.5; end;
35+
36+
n = max(size(a));
37+
38+
% ----------------------------------------------------------------------
39+
% --- Computation depends on the number of candidates to be computed ---
40+
% ----------------------------------------------------------------------
41+
42+
if ncands == 1;
43+
44+
% ---------------------------------------------------
45+
% --- The squared norm, based on the bootstrapped ---
46+
% --- solution will be computed ---
47+
% ---------------------------------------------------
48+
49+
afloat = a;
50+
afixed = a;
51+
52+
for i = 1:n;
53+
54+
dw = 0;
55+
for j = 1:n-1;
56+
dw = dw + L(i,j) * (a(j) - afixed(j));
57+
end;
58+
59+
a(i) = a(i) - dw;
60+
afixed(i) = round (a(i));
61+
62+
end;
63+
64+
Chi2 = (afloat-afixed)' * inv(L'*diag(D)*L) * (afloat-afixed) + 1d-6;
65+
66+
elseif ncands <= n+1;
67+
68+
% ----------------------------------------------
69+
% --- The right squared norm can be computed ---
70+
% ----------------------------------------------
71+
72+
Linv = inv(L);
73+
Dinv = 1./D;
74+
75+
dist = round(a) - a;
76+
e = Linv'*dist;
77+
Chi = [zeros(1,n) sum(Dinv' .* e .* e)];
78+
79+
% ------------------------------------------
80+
% --- Compute the real squared distances ---
81+
% ------------------------------------------
82+
83+
for i = 1:n;
84+
85+
Chi(i) = 0;
86+
for j = 1:i;
87+
Chi(i) = Chi(i) + Dinv(j) * Linv(i,j) * (2*e(j)+Linv(i,j));
88+
end;
89+
Chi(i) = Chi(n+1) + abs(Chi(i));
90+
91+
end;
92+
93+
% ---------------------------------------------------------------
94+
% --- Sort the results, and return the appropriate number ---
95+
% --- Add an "eps", to make sure there is no boundary problem ---
96+
% ---------------------------------------------------------------
97+
98+
Chi = sort(Chi);
99+
Chi2 = Chi(ncands) + 1d-6;
100+
101+
else
102+
103+
% -----------------------------------------------------
104+
% An approximation for the squared norm is computed ---
105+
% -----------------------------------------------------
106+
107+
Linv = inv(L);
108+
Dinv = 1./D;
109+
110+
Vn = (2/n) * (pi ^ (n/2) / gamma(n/2));
111+
Chi2 = factor * (ncands / sqrt((prod(1 ./ Dinv)) * Vn)) ^ (2/n);
112+
113+
end;
114+
115+
% ----------------------------------------------------------------------
116+
% End of routine: chistart
117+
% ----------------------------------------------------------------------

decorrel.m

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
function [Q,Z,L,D,z] = decorrel (Q,a);
2+
%DECORREL: Decorrelate a (co)variance matrix of ambiguities
3+
%
4+
% This routine creates a decorrelated Q-matrix, by finding the
5+
% Z-matrix and performing the corresponding transformation.
6+
%
7+
% The method is described in:
8+
% The routine is based on Fortran routines written by Paul de Jonge (TUD)
9+
% and on Matlab-routines written by Kai Borre.
10+
% The resulting Z-matrix can be used as follows:
11+
% z = Zt * a; \hat(z) = Zt * \hat(a);
12+
% Q_\hat(z) = Zt * Q_\hat(a) * Z
13+
%
14+
% Input arguments:
15+
% a: Original ambiguities
16+
% Q: Variance/covariance matrux of ambiguities (original)
17+
%
18+
% Output arguments:
19+
% Q: Decorrelated variance/covariance matrix
20+
% Z: Z-transformation matrix
21+
% L: L matrix (from LtDL-decomposition of Q, optional)
22+
% D: D matrix (from LtDL-decomposition of Q, optional)
23+
% z: Transformed ambiguities (optional)
24+
25+
% ----------------------------------------------------------------------
26+
% Function.: decorrel
27+
% Date.....: 19-MAY-1999
28+
% Author...: Peter Joosten
29+
% Mathematical Geodesy and Positioning
30+
% Delft University of Technology
31+
% ----------------------------------------------------------------------
32+
33+
% -----------------------
34+
% --- Initialisations ---
35+
% -----------------------
36+
37+
n = size(Q,1);
38+
Zti = eye(n);
39+
i1 = n - 1;
40+
sw = 1;
41+
42+
% --------------------------
43+
% --- LtDL decomposition ---
44+
% --------------------------
45+
46+
[L,D] = ldldecom (Q);
47+
48+
% ------------------------------------------
49+
% --- The actual decorrelation procedure ---
50+
% ------------------------------------------
51+
52+
53+
while sw;
54+
55+
i = n;
56+
sw = 0;
57+
58+
while ( ~sw ) & (i > 1)
59+
60+
i = i - 1;
61+
if (i <= i1);
62+
63+
for j = i+1:n
64+
mu = round(L(j,i));
65+
if mu ~= 0
66+
L(j:n,i) = L(j:n,i) - mu * L(j:n,j);
67+
Zti(1:n,j) = Zti(1:n,j) + mu * Zti(1:n,i);
68+
end
69+
end
70+
71+
end;
72+
73+
delta = D(i) + L(i+1,i)^2 * D(i+1);
74+
if (delta < D(i+1))
75+
76+
lambda(3) = D(i+1) * L(i+1,i) / delta;
77+
eta = D(i) / delta;
78+
D(i) = eta * D(i+1);
79+
D(i+1) = delta;
80+
81+
Help = L(i+1,1:i-1) - L(i+1,i) .* L(i,1:i-1);
82+
L(i+1,1:i-1) = lambda(3) * L(i+1,1:i-1) + eta * L(i,1:i-1);
83+
L(i,1:i-1) = Help;
84+
L(i+1,i) = lambda(3);
85+
86+
Help = L(i+2:n,i);
87+
L(i+2:n,i) = L(i+2:n,i+1);
88+
L(i+2:n,i+1) = Help;
89+
90+
Help = Zti(1:n,i);
91+
Zti(1:n,i) = Zti(1:n,i+1);
92+
Zti(1:n,i+1) = Help;
93+
94+
i1 = i;
95+
sw = 1;
96+
97+
end;
98+
99+
end;
100+
101+
end;
102+
103+
% ---------------------------------------------------------------------
104+
% --- Return the transformed Q-matrix and the transformation-matrix ---
105+
% --- Return the decorrelated ambiguities, if they were supplied ---
106+
% ---------------------------------------------------------------------
107+
108+
Z = inv(Zti');
109+
Q = Z' * Q * Z;
110+
111+
if nargin == 2 & nargout >= 5;
112+
z = Z' * a; %
113+
end;
114+
115+
% ----------------------------------------------------------------------
116+
% End of routine: decorrel
117+
% ----------------------------------------------------------------------

0 commit comments

Comments
 (0)