|
1 | | -function [z,uTx,uTarRx,uTarTx]=Cart2RuvStdRefrac(zC,useHalfRange,zTx,zRx,M,Ns,includeW,ce,ellipsOpts) |
| 1 | +function [z,uTx,uTarRx,uTarTx]=Cart2RuvStdRefrac(zC,useHalfRange,zTx,zRx,M,Ns,includeW,ce,rE,spherCent) |
2 | 2 | %%CART2RUVSTDREFRAC Convert points in Cartesian coordinates (either the |
3 | 3 | % global system or a local system at the receiver) into local |
4 | 4 | % bistatic r-u-v coordinates of the receiver, accounting for how a |
|
34 | 34 | % vector of the local coordinate system of the receiver is the |
35 | 35 | % pointing direction of the receiver. If this matrix is omitted, |
36 | 36 | % then the identity matrix is used. |
37 | | -% Ns The atmospheric refractivity reduced to the WGS-84 reference |
38 | | -% ellipsoid. Note that the refractivity is (n-1)*1e6, where n is |
39 | | -% the index of refraction. The function reduceStdRefrac2Spher can |
40 | | -% be used to reduce a refractivity to the ellipsoidal surface. |
41 | | -% This function does not allowe different refractivities to be |
42 | | -% used as the transmitter and receiver. If this parameter is |
43 | | -% omitted or an empty matrix is passed, a default value of 313 is |
44 | | -% used. |
| 37 | +% Ns The atmospheric refractivity reduced to the reference sphere. |
| 38 | +% Note that the refractivity is (n-1)*1e6, where n is the index |
| 39 | +% of refraction. The function reduceStdRefrac2Spher can be used |
| 40 | +% to reduce a refractivity to the surface of a reference |
| 41 | +% ellipsoid. This function does not allow different |
| 42 | +% refractivities to be used as the transmitter and receiver. If |
| 43 | +% this parameter is omitted or an empty matrix is passed, a |
| 44 | +% default value of 313 is used. |
45 | 45 | % includeW An optional boolean value indicating whether a third direction |
46 | 46 | % cosine component should be included. The u and v direction |
47 | 47 | % cosines are two parts of a 3D unit vector. Generally, one might |
|
62 | 62 | % values for the two constants are expConst=0.005577; and |
63 | 63 | % multConst=7.32; If ce is omitted or an empty matrix is passed, |
64 | 64 | % the value based on the standard model is used. |
65 | | -% ellipOpts Optioanlly, a structure that contains elements changing the |
66 | | -% reference ellipsoid used. Possible entries are a for the |
67 | | -% semi-major axis and f for the flattening factor. If this |
68 | | -% parameter is omitted or an empty matrix is passed, then |
69 | | -% a=Constants.WGS84SemiMajorAxis and f=Constants.WGS84Flattening. |
| 65 | +% rE,spherCent The radius of the Earth to use for the spherical Earth |
| 66 | +% approximation used in the model and also the offset between the |
| 67 | +% global model and the local spherical model. It is assumed that |
| 68 | +% zC,zTx,and zRx are all given in the global model and will need |
| 69 | +% to be transformed to the local model to the used. If rE is |
| 70 | +% omitted or an empty matrix is passed, then the default of |
| 71 | +% [rE,spherCent]=osculatingSpher4LatLon(Cart2Ellipse(zRx)) is |
| 72 | +% used. The defaults here mean that a WGS-84 reference ellipsoid |
| 73 | +% is approximated by the local osculating sphere. |
70 | 74 | % |
71 | 75 | %OUTPUTS: z The 3XN (or 4XN if includeW is true) matrix of location vectors |
72 | 76 | % of the points in bistatic [r;u;v] coordinates. If |
|
107 | 111 | % |
108 | 112 | %EXAMPLE: |
109 | 113 | %Here, we have two radars and one target near Hawaii. |
110 | | -% latLonRx=[20.269202;-155.852051]*(pi/180);%Degrees converted to radians. |
| 114 | +% latLonRx=deg2rad([20.269202;-155.852051]); |
111 | 115 | % AltRx=0; |
112 | | -% latLonTx=[20.724568;-155.978394]*(pi/180); |
| 116 | +% latLonTx=deg2rad([20.724568;-155.978394]); |
113 | 117 | % AltTx=0; |
114 | | -% latLonTar=[20.835390;-155.313721]*(pi/180); |
| 118 | +% latLonTar=deg2rad([20.835390;-155.313721]); |
115 | 119 | % AltTar=8e3;%8km target altitude. |
116 | 120 | % %Convert locations to Cartesian. |
117 | 121 | % zRx=ellips2Cart([latLonRx;AltRx]); |
|
120 | 124 | % |
121 | 125 | % %The receiver faces 45 degrees East of North and 15 degrees up from the |
122 | 126 | % %local ellipsoidal level. |
123 | | -% M=findRFTransParam([latLonRx;AltRx],45*(pi/180),15*(pi/180)); |
| 127 | +% M=findRFTransParam([latLonRx;AltRx],deg2rad(45),deg2rad(15)); |
124 | 128 | % Ns=350;%Assumed refractivity at the sea surface. |
125 | 129 | % useHalfRange=false; |
126 | 130 | % includeW=true;%Include third dimension of unit vector. |
127 | | -% [z,uTx,uTarRx,uTarTx]=Cart2RuvStdRefrac(zTar,useHalfRange,zTx,zRx,M,Ns,includeW) |
128 | | -% zNoRefrac=Cart2Ruv(zTar,useHalfRange,zTx,zRx,M,includeW) |
129 | | -% %One will see that the bistatic range differs by z(1)-zNoRefrac(1)=31.0806 |
130 | | -% %meters and the direction differs by |
131 | | -% %angBetweenVecs(z(2:end),zNoRefrac(2:end))*(180/pi)=0.0927 degrees. |
| 131 | +% [z,uTx,uTarRx,uTarTx]=Cart2RuvStdRefrac(zTar,useHalfRange,zTx,zRx,M,Ns,includeW); |
| 132 | +% zNoRefrac=Cart2Ruv(zTar,useHalfRange,zTx,zRx,M,includeW); |
| 133 | +% z(1)-zNoRefrac(1)%Bistatic range difference of 31.0813 meters |
| 134 | +% %Direction difference of 0.0927 degrees |
| 135 | +% rad2deg(angBetweenVecs(z(2:end),zNoRefrac(2:end))) |
132 | 136 | % |
133 | 137 | %REFERENCES: |
134 | 138 | %[1] D. F. Crouse, "Basic tracking using 3D monostatic and bistatic |
|
180 | 184 | ce=log(Ns/(Ns+DeltaN))/1000;%Units of inverse meters. |
181 | 185 | end |
182 | 186 |
|
183 | | -%Default parameters for the reference ellipsoid. |
184 | | -a=Constants.WGS84SemiMajorAxis; |
185 | | -f=Constants.WGS84Flattening; |
186 | | -if(nargin>8&&~isempty(ellipsOpts)) |
187 | | - if(isfield(ellipsOpts,'a')) |
188 | | - a=ellipsOpts.a; |
189 | | - end |
190 | | - |
191 | | - if(isfield(ellipsOpts,'f')) |
192 | | - f=ellipsOpts.f; |
193 | | - end |
| 187 | +if(nargin<9||isempty(rE)) |
| 188 | + %Use the radius of the Earth that is the radius of the osculating |
| 189 | + %sphere at the location of the observed. This will be the radius used |
| 190 | + %in the local spherical Earth approximation for computing atmospheric |
| 191 | + %refraction. This uses the WGS-84 reference ellipsoid. |
| 192 | + [rE,spherCent]=osculatingSpher4LatLon(Cart2Ellipse(zRx)); |
194 | 193 | end |
195 | 194 |
|
| 195 | +%Adjust all the Cartesian values based on the osculating sphere. |
| 196 | +zC=zC-spherCent; |
| 197 | +zTx=zTx-spherCent; |
| 198 | +zRx=zRx-spherCent; |
| 199 | + |
196 | 200 | %Allocate space |
197 | 201 | if(includeW) |
198 | 202 | z=zeros(4,numMeas); |
|
205 | 209 |
|
206 | 210 | if(any(zRx~=zTx))%If the scenario is bistatic |
207 | 211 | for curMeas=1:numMeas |
208 | | - [r1,uTx(:,curMeas),uTarTx(:,curMeas)]=atmosRefracMeas(zTx,zC(:,curMeas),Ns,ce,a,f); |
209 | | - [r2,uArrive,uTarRx(:,curMeas)]=atmosRefracMeas(zRx,zC(:,curMeas),Ns,ce,a,f); |
| 212 | + [r2,uArrive,uTarRx(:,curMeas)]=atmosRefracMeas(zRx,zC(:,curMeas),Ns,ce,rE); |
| 213 | + [r1,uTx(:,curMeas),uTarTx(:,curMeas)]=atmosRefracMeas(zTx,zC(:,curMeas),Ns,ce,rE); |
| 214 | + |
210 | 215 | r=(r1+r2); |
211 | 216 | u=M*uArrive; |
212 | 217 |
|
|
224 | 229 | end |
225 | 230 | else%The scenario is monostatic. |
226 | 231 | for curMeas=1:numMeas |
227 | | - [range,uArrive,uTarRx(:,curMeas)]=atmosRefracMeas(zTx,zC(:,curMeas),Ns,ce,a,f); |
| 232 | + [range,uArrive,uTarRx(:,curMeas)]=atmosRefracMeas(zTx,zC(:,curMeas),Ns,ce,rE); |
228 | 233 | uTx=uArrive; |
229 | 234 | r=2*range;%Round-trip range. |
230 | 235 | u=M*uArrive; |
|
247 | 252 | end |
248 | 253 | end |
249 | 254 |
|
250 | | -function [range,uArrive,uDepart]=atmosRefracMeas(xObs,xObj,Ns,ce,a,f) |
| 255 | +function [range,uArrive,uDepart]=atmosRefracMeas(xObs,xObj,Ns,ce,rE) |
251 | 256 | %%ATMOSREFRACMEAS Given the location of an observer and an object in the |
252 | 257 | % atmosphere of the Earth, find the delay and angle of |
253 | 258 | % arrival of a signal from the object to the observer, |
|
267 | 272 | % increasing the height by 1km, the model is that the |
268 | 273 | % refractivity changes by deltaN=-multConst*exp(expConst*N). |
269 | 274 | % deltaN cannot be negative. |
270 | | -% a,f The semi-major axis and the flattening factor of the |
271 | | -% reference ellipsoid to use. |
| 275 | +% rE The radius of the Earth to use in the spherical Earth |
| 276 | +% approximation. An osculating sphere near a sensor is |
| 277 | +% suggested. |
272 | 278 | % |
273 | 279 | %OUTPUTS: range The apparent one-way range (in meters) of the signal from |
274 | 280 | % the transmitter to the target and back to the receiver. |
|
295 | 301 | %May 2014 David F. Crouse, Naval Research Laboratory, Washington D.C. |
296 | 302 | %(UNCLASSIFIED) DISTRIBUTION STATEMENT A. Approved for public release. |
297 | 303 |
|
298 | | -%The location of the observer in ellipsoidal coordinates. |
299 | | -plhPoint=Cart2Ellipse(xObs,[],a,f); |
300 | | - |
301 | | -%Find the radius of the Earth at the location of the observer. Use the |
302 | | -%ellipsoidal Earth approximation. This will be the radius used in the local |
303 | | -%spherical Earth approximation for computing atmospheric refraction. |
304 | | -r0=norm(proj2Ellips(xObs,a,f)); |
305 | | - |
306 | 304 | %We need the conversion from the 3D coordinate system of the observer and |
307 | 305 | %object into the 2D coordinate system used for raytracing. The 2D |
308 | 306 | %coordinate system has the center of the Earth as its origin and the x-y |
309 | 307 | %axes are in the plane of the vector from the observer to the target. One |
310 | 308 | %vector common to both coordinate systems in the local up vector, which |
311 | 309 | %will be the local y axis. The second vector common to both will be the |
312 | 310 | %local x vector, which will be the projection of xObj-xObs onto the local |
313 | | -%tangent plane. Here, the vertical is the WGS-84 vertical, since the |
314 | | -%precision of the model is low enough that the difference between the |
315 | | -%WGS-84 vertical and the gravitational vertical should not matter. |
316 | | -uENU=getENUAxes(plhPoint); |
| 311 | +%tangent plane. Here, the vertical is the spherical model vertical. Since |
| 312 | +%the precision of the model is low enough that the difference between the |
| 313 | +%spherical and gravitational verticals shouldn't matter. |
| 314 | +uENU=getENUAxes(Cart2Ellipse(xObs,[],rE,0)); |
317 | 315 | uVertGlobal=uENU(:,3); |
318 | 316 | uVertLocal=[0;1;0]; |
319 | 317 |
|
|
356 | 354 | %refraction is not a constant 1. |
357 | 355 | yMax=norm([x1Init;y1Init]); |
358 | 356 |
|
359 | | - range=((exp(ce*(r0-y0Init))-exp(ce*(r0-yMax)))*Ns)/(1e6*ce)+yMax-y0Init; |
| 357 | + range=((exp(ce*(rE-y0Init))-exp(ce*(rE-yMax)))*Ns)/(1e6*ce)+yMax-y0Init; |
360 | 358 |
|
361 | 359 | uArrive=vec2TarGlobal/norm(vec2TarGlobal); |
362 | 360 | uDepart=-uArrive; |
|
369 | 367 | %The initial guess is just the linear solution. The solver requires a fixed |
370 | 368 | %number of steps. 20 is probably sufficient for things near the Earth. that |
371 | 369 | %is, up to distances of, say 400km. We can scale the number of steps as 20 |
372 | | -%for every 400 kilometers with a minum of, say 10. |
| 370 | +%for every 400 kilometers with a minimum of, say 10. |
373 | 371 | %Things outside of the atmosphere should use the astronomical refraction |
374 | 372 | %routines. |
375 | 373 | numSteps=max(20,ceil(20*norm(vec2TarLocal)/400e3)); |
|
381 | 379 |
|
382 | 380 | %Now, solve the differential equation. |
383 | 381 | oldOpts=bvpset(); |
384 | | -newOpts=bvpset(oldOpts,'RelTol',1e-8,'AbsTol',1e-8,'FJacobian',@(x,y)odefunJacob(x,y,Ns,r0,ce),'BCJacobian',@bcfunJacob);%Increase the accuracy. |
385 | | -sol=bvp5c(@(x,y)expDiffEq(x,y,Ns,r0,ce),@(y0,y1)bcfun(y0,y1,y0Init,y1Init),solInit,newOpts); |
| 382 | +newOpts=bvpset(oldOpts,'RelTol',1e-8,'AbsTol',1e-8,'FJacobian',@(x,y)odefunJacob(x,y,Ns,rE,ce),'BCJacobian',@bcfunJacob);%Increase the accuracy. |
| 383 | +sol=bvp5c(@(x,y)expDiffEq(x,y,Ns,rE,ce),@(y0,y1)bcfun(y0,y1,y0Init,y1Init),solInit,newOpts); |
386 | 384 |
|
387 | 385 | %Get the refraction-corrupted range measurement for a signal traveling from |
388 | 386 | %the object to the observer. |
389 | | -range=integral(@(x)pathFun2D(x,sol,Ns,r0,ce),x0Init,x1Init,'AbsTol',eps(1),'RelTol',1e-15); |
| 387 | +range=integral(@(x)pathFun2D(x,sol,Ns,rE,ce),x0Init,x1Init,'AbsTol',eps(1),'RelTol',1e-15); |
390 | 388 |
|
391 | 389 | if(nargout>1) |
392 | 390 | %Get the angle of arrival for a signal traveling from the object to the |
|
406 | 404 | end |
407 | 405 | end |
408 | 406 |
|
409 | | -function val=pathFun2D(x,sol,Ns,r0,ce) |
| 407 | +function val=pathFun2D(x,sol,Ns,rE,ce) |
410 | 408 | %This function is used to integrate the time taken |
411 | 409 | y=deval(x,sol); |
412 | | - val=(1+NRefracExp(x,y(1,:),Ns,r0,ce)).*sqrt(1+y(2,:).^2); |
| 410 | + val=(1+NRefracExp(x,y(1,:),Ns,rE,ce)).*sqrt(1+y(2,:).^2); |
413 | 411 | end |
414 | 412 |
|
415 | 413 | function res=bcfun(y0,y1,y0Init,y1Init) |
|
430 | 428 | 1 0]; |
431 | 429 | end |
432 | 430 |
|
433 | | -function J=odefunJacob(x,y,Ns,r0,ce) |
| 431 | +function J=odefunJacob(x,y,Ns,rE,ce) |
434 | 432 | %The Jacobian of the differential equation for raytracing the 2D |
435 | 433 | %exponential atmospheric model. |
436 | | - expVal=NRefracExp(x,y(1),Ns,r0,ce); |
| 434 | + expVal=NRefracExp(x,y(1),Ns,rE,ce); |
437 | 435 |
|
438 | 436 | J=zeros(2,2); |
439 | 437 | J(1,2)=1; |
440 | 438 | J(2,1)=ce*(1+y(2)^2)*(-expVal)*(ce*y(1)*(x*y(2)-y(1))*sqrt(x^2+y(1)^2)+x*(x+y(1)*y(2))*(expVal+1))/((x^2+y(1)^2)^(3/2)*(expVal+1)^2); |
441 | 439 | J(2,2)=ce*(x-2*y(1)*y(2)+3*x*y(2)^2)*expVal/((expVal+1)*sqrt(x^2+y(1)^2)); |
442 | 440 | end |
443 | 441 |
|
444 | | -function dxdy=expDiffEq(x,y,Ns,r0,ce) |
| 442 | +function dxdy=expDiffEq(x,y,Ns,rE,ce) |
445 | 443 | %Find the refractivity at location (x,y). |
446 | | - expVal=NRefracExp(x,y(1),Ns,r0,ce); |
| 444 | + expVal=NRefracExp(x,y(1),Ns,rE,ce); |
447 | 445 |
|
448 | 446 | dxdy=[y(2) |
449 | 447 | ce*(1+y(2)^2)*(x*y(2)-y(1))*expVal/((expVal+1)*sqrt(x^2+y(1)^2))]; |
450 | 448 | end |
451 | 449 |
|
452 | | -function nRefrac=NRefracExp(x,y,Ns,r0,ce) |
| 450 | +function nRefrac=NRefracExp(x,y,Ns,rE,ce) |
453 | 451 | %The refractivity. This is 10^6*(index of refraction-1) |
454 | | - nRefrac=1e-6*Ns*exp(-ce*(sqrt(x.^2+y.^2)-r0)); |
| 452 | + nRefrac=1e-6*Ns*exp(-ce*(sqrt(x.^2+y.^2)-rE)); |
455 | 453 | end |
456 | 454 |
|
457 | 455 | %LICENSE: |
|
0 commit comments