[2578] | 1 |
|
---|
[5828] | 2 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 3 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2007
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
| 27 | * BKG NTRIP Client
|
---|
| 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
| 30 | * Class: t_astro, t_tides, t_tropo
|
---|
| 31 | *
|
---|
| 32 | * Purpose: Observation model
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 29-Jul-2014
|
---|
| 37 | *
|
---|
[9281] | 38 | * Changes:
|
---|
[5828] | 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
| 42 |
|
---|
[2578] | 43 | #include <cmath>
|
---|
| 44 |
|
---|
[5801] | 45 | #include "pppModel.h"
|
---|
[2578] | 46 |
|
---|
[5814] | 47 | using namespace BNC_PPP;
|
---|
[2578] | 48 | using namespace std;
|
---|
| 49 |
|
---|
[6268] | 50 | const double t_astro::RHO_DEG = 180.0 / M_PI;
|
---|
| 51 | const double t_astro::RHO_SEC = 3600.0 * 180.0 / M_PI;
|
---|
| 52 | const double t_astro::MJD_J2000 = 51544.5;
|
---|
| 53 |
|
---|
[5801] | 54 | Matrix t_astro::rotX(double Angle) {
|
---|
| 55 | const double C = cos(Angle);
|
---|
| 56 | const double S = sin(Angle);
|
---|
| 57 | Matrix UU(3,3);
|
---|
| 58 | UU[0][0] = 1.0; UU[0][1] = 0.0; UU[0][2] = 0.0;
|
---|
| 59 | UU[1][0] = 0.0; UU[1][1] = +C; UU[1][2] = +S;
|
---|
| 60 | UU[2][0] = 0.0; UU[2][1] = -S; UU[2][2] = +C;
|
---|
| 61 | return UU;
|
---|
| 62 | }
|
---|
[2578] | 63 |
|
---|
[5801] | 64 | Matrix t_astro::rotY(double Angle) {
|
---|
| 65 | const double C = cos(Angle);
|
---|
| 66 | const double S = sin(Angle);
|
---|
| 67 | Matrix UU(3,3);
|
---|
| 68 | UU[0][0] = +C; UU[0][1] = 0.0; UU[0][2] = -S;
|
---|
| 69 | UU[1][0] = 0.0; UU[1][1] = 1.0; UU[1][2] = 0.0;
|
---|
| 70 | UU[2][0] = +S; UU[2][1] = 0.0; UU[2][2] = +C;
|
---|
| 71 | return UU;
|
---|
| 72 | }
|
---|
[2578] | 73 |
|
---|
[5801] | 74 | Matrix t_astro::rotZ(double Angle) {
|
---|
| 75 | const double C = cos(Angle);
|
---|
| 76 | const double S = sin(Angle);
|
---|
| 77 | Matrix UU(3,3);
|
---|
| 78 | UU[0][0] = +C; UU[0][1] = +S; UU[0][2] = 0.0;
|
---|
| 79 | UU[1][0] = -S; UU[1][1] = +C; UU[1][2] = 0.0;
|
---|
| 80 | UU[2][0] = 0.0; UU[2][1] = 0.0; UU[2][2] = 1.0;
|
---|
| 81 | return UU;
|
---|
[2578] | 82 | }
|
---|
| 83 |
|
---|
| 84 | // Greenwich Mean Sidereal Time
|
---|
| 85 | ///////////////////////////////////////////////////////////////////////////
|
---|
[5801] | 86 | double t_astro::GMST(double Mjd_UT1) {
|
---|
[2578] | 87 |
|
---|
| 88 | const double Secs = 86400.0;
|
---|
| 89 |
|
---|
| 90 | double Mjd_0 = floor(Mjd_UT1);
|
---|
| 91 | double UT1 = Secs*(Mjd_UT1-Mjd_0);
|
---|
[9281] | 92 | double T_0 = (Mjd_0 -MJD_J2000)/36525.0;
|
---|
| 93 | double T = (Mjd_UT1-MJD_J2000)/36525.0;
|
---|
[2578] | 94 |
|
---|
| 95 | double gmst = 24110.54841 + 8640184.812866*T_0 + 1.002737909350795*UT1
|
---|
| 96 | + (0.093104-6.2e-6*T)*T*T;
|
---|
| 97 |
|
---|
| 98 | return 2.0*M_PI*Frac(gmst/Secs);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | // Nutation Matrix
|
---|
| 102 | ///////////////////////////////////////////////////////////////////////////
|
---|
[5801] | 103 | Matrix t_astro::NutMatrix(double Mjd_TT) {
|
---|
[2578] | 104 |
|
---|
| 105 | const double T = (Mjd_TT-MJD_J2000)/36525.0;
|
---|
| 106 |
|
---|
| 107 | double ls = 2.0*M_PI*Frac(0.993133+ 99.997306*T);
|
---|
| 108 | double D = 2.0*M_PI*Frac(0.827362+1236.853087*T);
|
---|
| 109 | double F = 2.0*M_PI*Frac(0.259089+1342.227826*T);
|
---|
| 110 | double N = 2.0*M_PI*Frac(0.347346- 5.372447*T);
|
---|
| 111 |
|
---|
| 112 | double dpsi = ( -17.200*sin(N) - 1.319*sin(2*(F-D+N)) - 0.227*sin(2*(F+N))
|
---|
| 113 | + 0.206*sin(2*N) + 0.143*sin(ls) ) / RHO_SEC;
|
---|
| 114 | double deps = ( + 9.203*cos(N) + 0.574*cos(2*(F-D+N)) + 0.098*cos(2*(F+N))
|
---|
| 115 | - 0.090*cos(2*N) ) / RHO_SEC;
|
---|
| 116 |
|
---|
| 117 | double eps = 0.4090928-2.2696E-4*T;
|
---|
| 118 |
|
---|
| 119 | return rotX(-eps-deps)*rotZ(-dpsi)*rotX(+eps);
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | // Precession Matrix
|
---|
| 123 | ///////////////////////////////////////////////////////////////////////////
|
---|
[5801] | 124 | Matrix t_astro::PrecMatrix(double Mjd_1, double Mjd_2) {
|
---|
[2578] | 125 |
|
---|
| 126 | const double T = (Mjd_1-MJD_J2000)/36525.0;
|
---|
| 127 | const double dT = (Mjd_2-Mjd_1)/36525.0;
|
---|
[9281] | 128 |
|
---|
[2578] | 129 | double zeta = ( (2306.2181+(1.39656-0.000139*T)*T)+
|
---|
| 130 | ((0.30188-0.000344*T)+0.017998*dT)*dT )*dT/RHO_SEC;
|
---|
| 131 | double z = zeta + ( (0.79280+0.000411*T)+0.000205*dT)*dT*dT/RHO_SEC;
|
---|
| 132 | double theta = ( (2004.3109-(0.85330+0.000217*T)*T)-
|
---|
| 133 | ((0.42665+0.000217*T)+0.041833*dT)*dT )*dT/RHO_SEC;
|
---|
| 134 |
|
---|
| 135 | return rotZ(-z) * rotY(theta) * rotZ(-zeta);
|
---|
[9281] | 136 | }
|
---|
[2578] | 137 |
|
---|
| 138 | // Sun's position
|
---|
| 139 | ///////////////////////////////////////////////////////////////////////////
|
---|
[5801] | 140 | ColumnVector t_astro::Sun(double Mjd_TT) {
|
---|
[2578] | 141 |
|
---|
| 142 | const double eps = 23.43929111/RHO_DEG;
|
---|
| 143 | const double T = (Mjd_TT-MJD_J2000)/36525.0;
|
---|
| 144 |
|
---|
| 145 | double M = 2.0*M_PI * Frac ( 0.9931267 + 99.9973583*T);
|
---|
[9281] | 146 | double L = 2.0*M_PI * Frac ( 0.7859444 + M/2.0/M_PI +
|
---|
[2578] | 147 | (6892.0*sin(M)+72.0*sin(2.0*M)) / 1296.0e3);
|
---|
| 148 | double r = 149.619e9 - 2.499e9*cos(M) - 0.021e9*cos(2*M);
|
---|
[9281] | 149 |
|
---|
| 150 | ColumnVector r_Sun(3);
|
---|
[2578] | 151 | r_Sun << r*cos(L) << r*sin(L) << 0.0; r_Sun = rotX(-eps) * r_Sun;
|
---|
| 152 |
|
---|
| 153 | return rotZ(GMST(Mjd_TT))
|
---|
[9281] | 154 | * NutMatrix(Mjd_TT)
|
---|
[2578] | 155 | * PrecMatrix(MJD_J2000, Mjd_TT)
|
---|
| 156 | * r_Sun;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | // Moon's position
|
---|
| 160 | ///////////////////////////////////////////////////////////////////////////
|
---|
[5801] | 161 | ColumnVector t_astro::Moon(double Mjd_TT) {
|
---|
[2578] | 162 |
|
---|
| 163 | const double eps = 23.43929111/RHO_DEG;
|
---|
| 164 | const double T = (Mjd_TT-MJD_J2000)/36525.0;
|
---|
| 165 |
|
---|
| 166 | double L_0 = Frac ( 0.606433 + 1336.851344*T );
|
---|
| 167 | double l = 2.0*M_PI*Frac ( 0.374897 + 1325.552410*T );
|
---|
| 168 | double lp = 2.0*M_PI*Frac ( 0.993133 + 99.997361*T );
|
---|
| 169 | double D = 2.0*M_PI*Frac ( 0.827361 + 1236.853086*T );
|
---|
| 170 | double F = 2.0*M_PI*Frac ( 0.259086 + 1342.227825*T );
|
---|
[9281] | 171 |
|
---|
| 172 | double dL = +22640*sin(l) - 4586*sin(l-2*D) + 2370*sin(2*D) + 769*sin(2*l)
|
---|
[2578] | 173 | -668*sin(lp) - 412*sin(2*F) - 212*sin(2*l-2*D)- 206*sin(l+lp-2*D)
|
---|
| 174 | +192*sin(l+2*D) - 165*sin(lp-2*D) - 125*sin(D) - 110*sin(l+lp)
|
---|
| 175 | +148*sin(l-lp) - 55*sin(2*F-2*D);
|
---|
| 176 |
|
---|
| 177 | double L = 2.0*M_PI * Frac( L_0 + dL/1296.0e3 );
|
---|
| 178 |
|
---|
[9281] | 179 | double S = F + (dL+412*sin(2*F)+541*sin(lp)) / RHO_SEC;
|
---|
[2578] | 180 | double h = F-2*D;
|
---|
[9281] | 181 | double N = -526*sin(h) + 44*sin(l+h) - 31*sin(-l+h) - 23*sin(lp+h)
|
---|
[2578] | 182 | +11*sin(-lp+h) - 25*sin(-2*l+F) + 21*sin(-l+F);
|
---|
| 183 |
|
---|
| 184 | double B = ( 18520.0*sin(S) + N ) / RHO_SEC;
|
---|
[9281] | 185 |
|
---|
[2578] | 186 | double cosB = cos(B);
|
---|
| 187 |
|
---|
| 188 | double R = 385000e3 - 20905e3*cos(l) - 3699e3*cos(2*D-l) - 2956e3*cos(2*D)
|
---|
[9281] | 189 | -570e3*cos(2*l) + 246e3*cos(2*l-2*D) - 205e3*cos(lp-2*D)
|
---|
| 190 | -171e3*cos(l+2*D) - 152e3*cos(l+lp-2*D);
|
---|
[2578] | 191 |
|
---|
[9281] | 192 | ColumnVector r_Moon(3);
|
---|
[2578] | 193 | r_Moon << R*cos(L)*cosB << R*sin(L)*cosB << R*sin(B);
|
---|
| 194 | r_Moon = rotX(-eps) * r_Moon;
|
---|
[9281] | 195 |
|
---|
| 196 | return rotZ(GMST(Mjd_TT))
|
---|
| 197 | * NutMatrix(Mjd_TT)
|
---|
[2578] | 198 | * PrecMatrix(MJD_J2000, Mjd_TT)
|
---|
| 199 | * r_Moon;
|
---|
| 200 | }
|
---|
[2579] | 201 |
|
---|
[9281] | 202 | // Tidal Correction
|
---|
[2579] | 203 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5801] | 204 | ColumnVector t_tides::displacement(const bncTime& time, const ColumnVector& xyz) {
|
---|
[2579] | 205 |
|
---|
[6078] | 206 | if (time.undef()) {
|
---|
| 207 | ColumnVector dX(3); dX = 0.0;
|
---|
| 208 | return dX;
|
---|
| 209 | }
|
---|
| 210 |
|
---|
[2579] | 211 | double Mjd = time.mjd() + time.daysec() / 86400.0;
|
---|
| 212 |
|
---|
[5801] | 213 | if (Mjd != _lastMjd) {
|
---|
| 214 | _lastMjd = Mjd;
|
---|
| 215 | _xSun = t_astro::Sun(Mjd);
|
---|
| 216 | _rSun = sqrt(DotProduct(_xSun,_xSun));
|
---|
| 217 | _xSun /= _rSun;
|
---|
| 218 | _xMoon = t_astro::Moon(Mjd);
|
---|
| 219 | _rMoon = sqrt(DotProduct(_xMoon,_xMoon));
|
---|
| 220 | _xMoon /= _rMoon;
|
---|
[2579] | 221 | }
|
---|
| 222 |
|
---|
| 223 | double rRec = sqrt(DotProduct(xyz, xyz));
|
---|
| 224 | ColumnVector xyzUnit = xyz / rRec;
|
---|
| 225 |
|
---|
| 226 | // Love's Numbers
|
---|
| 227 | // --------------
|
---|
[4151] | 228 | const double H2 = 0.6078;
|
---|
| 229 | const double L2 = 0.0847;
|
---|
[2579] | 230 |
|
---|
| 231 | // Tidal Displacement
|
---|
| 232 | // ------------------
|
---|
[5801] | 233 | double scSun = DotProduct(xyzUnit, _xSun);
|
---|
| 234 | double scMoon = DotProduct(xyzUnit, _xMoon);
|
---|
[2579] | 235 |
|
---|
| 236 | double p2Sun = 3.0 * (H2/2.0-L2) * scSun * scSun - H2/2.0;
|
---|
| 237 | double p2Moon = 3.0 * (H2/2.0-L2) * scMoon * scMoon - H2/2.0;
|
---|
| 238 |
|
---|
| 239 | double x2Sun = 3.0 * L2 * scSun;
|
---|
| 240 | double x2Moon = 3.0 * L2 * scMoon;
|
---|
[9281] | 241 |
|
---|
[2579] | 242 | const double gmWGS = 398.6005e12;
|
---|
| 243 | const double gms = 1.3271250e20;
|
---|
| 244 | const double gmm = 4.9027890e12;
|
---|
| 245 |
|
---|
[9281] | 246 | double facSun = gms / gmWGS *
|
---|
[5801] | 247 | (rRec * rRec * rRec * rRec) / (_rSun * _rSun * _rSun);
|
---|
[2581] | 248 |
|
---|
[9281] | 249 | double facMoon = gmm / gmWGS *
|
---|
[5801] | 250 | (rRec * rRec * rRec * rRec) / (_rMoon * _rMoon * _rMoon);
|
---|
[2579] | 251 |
|
---|
[9281] | 252 | ColumnVector dX = facSun * (x2Sun * _xSun + p2Sun * xyzUnit) +
|
---|
[5801] | 253 | facMoon * (x2Moon * _xMoon + p2Moon * xyzUnit);
|
---|
[2579] | 254 |
|
---|
[5801] | 255 | return dX;
|
---|
[2579] | 256 | }
|
---|
[5802] | 257 |
|
---|
| 258 | // Constructor
|
---|
| 259 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 260 | t_windUp::t_windUp() {
|
---|
| 261 | for (unsigned ii = 0; ii <= t_prn::MAXPRN; ii++) {
|
---|
| 262 | sumWind[ii] = 0.0;
|
---|
| 263 | lastEtime[ii] = 0.0;
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | // Phase Wind-Up Correction
|
---|
| 268 | ///////////////////////////////////////////////////////////////////////////
|
---|
[9281] | 269 | double t_windUp::value(const bncTime& etime, const ColumnVector& rRec,
|
---|
[5802] | 270 | t_prn prn, const ColumnVector& rSat) {
|
---|
| 271 |
|
---|
| 272 | if (etime.mjddec() != lastEtime[prn.toInt()]) {
|
---|
| 273 |
|
---|
| 274 | // Unit Vector GPS Satellite --> Receiver
|
---|
| 275 | // --------------------------------------
|
---|
| 276 | ColumnVector rho = rRec - rSat;
|
---|
| 277 | rho /= rho.norm_Frobenius();
|
---|
[9281] | 278 |
|
---|
[5802] | 279 | // GPS Satellite unit Vectors sz, sy, sx
|
---|
| 280 | // -------------------------------------
|
---|
| 281 | ColumnVector sz = -rSat / rSat.norm_Frobenius();
|
---|
| 282 |
|
---|
[5805] | 283 | ColumnVector xSun = t_astro::Sun(etime.mjddec());
|
---|
[5802] | 284 | xSun /= xSun.norm_Frobenius();
|
---|
| 285 |
|
---|
| 286 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
| 287 | ColumnVector sx = crossproduct(sy, sz);
|
---|
| 288 |
|
---|
| 289 | // Effective Dipole of the GPS Satellite Antenna
|
---|
| 290 | // ---------------------------------------------
|
---|
[9281] | 291 | ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
|
---|
[5802] | 292 | - crossproduct(rho, sy);
|
---|
[9281] | 293 |
|
---|
[5802] | 294 | // Receiver unit Vectors rx, ry
|
---|
| 295 | // ----------------------------
|
---|
| 296 | ColumnVector rx(3);
|
---|
| 297 | ColumnVector ry(3);
|
---|
| 298 |
|
---|
| 299 | double recEll[3]; xyz2ell(rRec.data(), recEll) ;
|
---|
| 300 | double neu[3];
|
---|
[9281] | 301 |
|
---|
[5802] | 302 | neu[0] = 1.0;
|
---|
| 303 | neu[1] = 0.0;
|
---|
| 304 | neu[2] = 0.0;
|
---|
| 305 | neu2xyz(recEll, neu, rx.data());
|
---|
[9281] | 306 |
|
---|
[5802] | 307 | neu[0] = 0.0;
|
---|
| 308 | neu[1] = -1.0;
|
---|
| 309 | neu[2] = 0.0;
|
---|
| 310 | neu2xyz(recEll, neu, ry.data());
|
---|
[9281] | 311 |
|
---|
[5802] | 312 | // Effective Dipole of the Receiver Antenna
|
---|
| 313 | // ----------------------------------------
|
---|
[9281] | 314 | ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
|
---|
[5802] | 315 | + crossproduct(rho, ry);
|
---|
[9281] | 316 |
|
---|
[5802] | 317 | // Resulting Effect
|
---|
| 318 | // ----------------
|
---|
[9281] | 319 | double alpha = DotProduct(dipSat,dipRec) /
|
---|
[5802] | 320 | (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
|
---|
[9281] | 321 |
|
---|
[5802] | 322 | if (alpha > 1.0) alpha = 1.0;
|
---|
| 323 | if (alpha < -1.0) alpha = -1.0;
|
---|
[9281] | 324 |
|
---|
[5802] | 325 | double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
|
---|
[9281] | 326 |
|
---|
[5802] | 327 | if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
|
---|
| 328 | dphi = -dphi;
|
---|
| 329 | }
|
---|
| 330 |
|
---|
| 331 | if (lastEtime[prn.toInt()] == 0.0) {
|
---|
| 332 | sumWind[prn.toInt()] = dphi;
|
---|
| 333 | }
|
---|
| 334 | else {
|
---|
| 335 | sumWind[prn.toInt()] = nint(sumWind[prn.toInt()] - dphi) + dphi;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
| 338 | lastEtime[prn.toInt()] = etime.mjddec();
|
---|
| 339 | }
|
---|
| 340 |
|
---|
[9281] | 341 | return sumWind[prn.toInt()];
|
---|
[5802] | 342 | }
|
---|
[5808] | 343 |
|
---|
| 344 | // Tropospheric Model (Saastamoinen)
|
---|
| 345 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 346 | double t_tropo::delay_saast(const ColumnVector& xyz, double Ele) {
|
---|
| 347 |
|
---|
| 348 | Tracer tracer("bncModel::delay_saast");
|
---|
| 349 |
|
---|
| 350 | if (xyz[0] == 0.0 && xyz[1] == 0.0 && xyz[2] == 0.0) {
|
---|
| 351 | return 0.0;
|
---|
| 352 | }
|
---|
| 353 |
|
---|
[9281] | 354 | double ell[3];
|
---|
[5808] | 355 | xyz2ell(xyz.data(), ell);
|
---|
| 356 | double height = ell[2];
|
---|
[9281] | 357 | // Prevent pp from causing segmentation fault (Loukis)
|
---|
| 358 | if (height > 40000.0 ) {
|
---|
| 359 | return 0.000000001;
|
---|
| 360 | }
|
---|
[5808] | 361 |
|
---|
| 362 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
---|
| 363 | double TT = 18.0 - height * 0.0065 + 273.15;
|
---|
| 364 | double hh = 50.0 * exp(-6.396e-4 * height);
|
---|
| 365 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
---|
| 366 |
|
---|
| 367 | double h_km = height / 1000.0;
|
---|
[9281] | 368 |
|
---|
[5808] | 369 | if (h_km < 0.0) h_km = 0.0;
|
---|
| 370 | if (h_km > 5.0) h_km = 5.0;
|
---|
[6108] | 371 | int ii = int(h_km + 1); if (ii > 5) ii = 5;
|
---|
[5808] | 372 | double href = ii - 1;
|
---|
[9281] | 373 |
|
---|
| 374 | double bCor[6];
|
---|
[5808] | 375 | bCor[0] = 1.156;
|
---|
| 376 | bCor[1] = 1.006;
|
---|
| 377 | bCor[2] = 0.874;
|
---|
| 378 | bCor[3] = 0.757;
|
---|
| 379 | bCor[4] = 0.654;
|
---|
| 380 | bCor[5] = 0.563;
|
---|
[9281] | 381 |
|
---|
[5808] | 382 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
---|
[9281] | 383 |
|
---|
[5808] | 384 | double zen = M_PI/2.0 - Ele;
|
---|
| 385 |
|
---|
| 386 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
---|
| 387 | }
|
---|
| 388 |
|
---|
[7240] | 389 | // Constructor
|
---|
| 390 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 391 | t_iono::t_iono() {
|
---|
[7246] | 392 | _psiPP = _phiPP = _lambdaPP = _lonS = 0.0;
|
---|
[7240] | 393 | }
|
---|
| 394 |
|
---|
[7246] | 395 | t_iono::~t_iono() {}
|
---|
| 396 |
|
---|
| 397 | double t_iono::stec(const t_vTec* vTec, double signalPropagationTime,
|
---|
| 398 | const ColumnVector& rSat, const bncTime& epochTime,
|
---|
| 399 | const ColumnVector& xyzSta) {
|
---|
| 400 |
|
---|
| 401 | // Latitude, longitude, height are defined with respect to a spherical earth model
|
---|
| 402 | // -------------------------------------------------------------------------------
|
---|
[7251] | 403 | ColumnVector geocSta(3);
|
---|
| 404 | if (xyz2geoc(xyzSta.data(), geocSta.data()) != success) {
|
---|
| 405 | return 0.0;
|
---|
| 406 | }
|
---|
[7246] | 407 |
|
---|
| 408 | // satellite position rotated to the epoch of signal reception
|
---|
| 409 | // -----------------------------------------------------------
|
---|
[7251] | 410 | ColumnVector xyzSat(3);
|
---|
[7246] | 411 | double omegaZ = t_CST::omega * signalPropagationTime;
|
---|
| 412 | xyzSat[0] = rSat[0] * cos(omegaZ) + rSat[1] * sin(omegaZ);
|
---|
| 413 | xyzSat[1] = rSat[1] * cos(omegaZ) - rSat[0] * sin(omegaZ);
|
---|
| 414 | xyzSat[2] = rSat[2];
|
---|
| 415 |
|
---|
| 416 | // elevation and azimuth with respect to a spherical earth model
|
---|
| 417 | // -------------------------------------------------------------
|
---|
| 418 | ColumnVector rhoV = xyzSat - xyzSta;
|
---|
| 419 | double rho = rhoV.norm_Frobenius();
|
---|
| 420 | ColumnVector neu(3);
|
---|
| 421 | xyz2neu(geocSta.data(), rhoV.data(), neu.data());
|
---|
| 422 | double sphEle = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
| 423 | if (neu[2] < 0) {
|
---|
| 424 | sphEle *= -1.0;
|
---|
| 425 | }
|
---|
| 426 | double sphAzi = atan2(neu[1], neu[0]);
|
---|
| 427 |
|
---|
| 428 | double epoch = fmod(epochTime.gpssec(), 86400.0);
|
---|
| 429 |
|
---|
| 430 | double stec = 0.0;
|
---|
| 431 | for (unsigned ii = 0; ii < vTec->_layers.size(); ii++) {
|
---|
[7256] | 432 | piercePoint(vTec->_layers[ii]._height, epoch, geocSta.data(), sphEle, sphAzi);
|
---|
[7246] | 433 | double vtec = vtecSingleLayerContribution(vTec->_layers[ii]);
|
---|
[7259] | 434 | stec += vtec * sin(sphEle + _psiPP);
|
---|
[7246] | 435 | }
|
---|
| 436 | return stec;
|
---|
[7240] | 437 | }
|
---|
| 438 |
|
---|
[7246] | 439 | double t_iono::vtecSingleLayerContribution(const t_vTecLayer& vTecLayer) {
|
---|
| 440 |
|
---|
| 441 | double vtec = 0.0;
|
---|
| 442 | int N = vTecLayer._C.Nrows()-1;
|
---|
| 443 | int M = vTecLayer._C.Ncols()-1;
|
---|
| 444 | double fac;
|
---|
| 445 |
|
---|
| 446 | for (int n = 0; n <= N; n++) {
|
---|
| 447 | for (int m = 0; m <= min(n, M); m++) {
|
---|
| 448 | double pnm = associatedLegendreFunction(n, m, sin(_phiPP));
|
---|
| 449 | double a = double(factorial(n - m));
|
---|
| 450 | double b = double(factorial(n + m));
|
---|
| 451 | if (m == 0) {
|
---|
| 452 | fac = sqrt(2.0 * n + 1);
|
---|
| 453 | }
|
---|
| 454 | else {
|
---|
| 455 | fac = sqrt(2.0 * (2.0 * n + 1) * a / b);
|
---|
| 456 | }
|
---|
| 457 | pnm *= fac;
|
---|
| 458 | double Cnm_mlambda = vTecLayer._C[n][m] * cos(m * _lonS);
|
---|
| 459 | double Snm_mlambda = vTecLayer._S[n][m] * sin(m * _lonS);
|
---|
| 460 | vtec += (Snm_mlambda + Cnm_mlambda) * pnm;
|
---|
| 461 | }
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | if (vtec < 0.0) {
|
---|
| 465 | return 0.0;
|
---|
| 466 | }
|
---|
[7259] | 467 |
|
---|
[7246] | 468 | return vtec;
|
---|
[7240] | 469 | }
|
---|
| 470 |
|
---|
[7246] | 471 | void t_iono::piercePoint(double layerHeight, double epoch, const double* geocSta,
|
---|
| 472 | double sphEle, double sphAzi) {
|
---|
[7240] | 473 |
|
---|
[7246] | 474 | double q = (t_CST::rgeoc + geocSta[2]) / (t_CST::rgeoc + layerHeight);
|
---|
| 475 |
|
---|
[7259] | 476 | _psiPP = M_PI/2 - sphEle - asin(q * cos(sphEle));
|
---|
[7246] | 477 |
|
---|
| 478 | _phiPP = asin(sin(geocSta[0]) * cos(_psiPP) + cos(geocSta[0]) * sin(_psiPP) * cos(sphAzi));
|
---|
| 479 |
|
---|
| 480 | if (( (geocSta[0]*180.0/M_PI > 0) && ( tan(_psiPP) * cos(sphAzi) > tan(M_PI/2 - geocSta[0])) ) ||
|
---|
| 481 | ( (geocSta[0]*180.0/M_PI < 0) && (-(tan(_psiPP) * cos(sphAzi)) > tan(M_PI/2 + geocSta[0])) )) {
|
---|
| 482 | _lambdaPP = geocSta[1] + M_PI - asin((sin(_psiPP) * sin(sphAzi) / cos(_phiPP)));
|
---|
| 483 | } else {
|
---|
| 484 | _lambdaPP = geocSta[1] + asin((sin(_psiPP) * sin(sphAzi) / cos(_phiPP)));
|
---|
| 485 | }
|
---|
| 486 |
|
---|
[7259] | 487 | _lonS = fmod((_lambdaPP + (epoch - 50400) * M_PI / 43200), 2*M_PI);
|
---|
[7246] | 488 |
|
---|
| 489 | return;
|
---|
[7240] | 490 | }
|
---|
[7246] | 491 |
|
---|