82 double EMRAT,
double SERAT,
93 static const double REarth = 6378136.55;
97 double RSun, RMoon, Rx, Love, Shida, sunFactor, moonFactor;
98 double sunDOTrx, moonDOTrx, REoRS, REoRM;
99 double lat, lon, sinlat, coslat, sinlon, coslon;
100 double latSun, lonSun, latMoon, lonMoon;
101 Triple disp, sunUnit, moonUnit, rx, tSun, tMoon, north, east, up;
103 Triple northGD, eastGD, upGD, tmp, tmp2, tmp3, tmp4;
106 << setprecision(3) << setw(23) << Sun.
X() << setw(23)
107 << Sun.
Y() << setw(23) << Sun.
Z();
109 << setprecision(3) << setw(23) << Moon.
X() << setw(23)
110 << Moon.
Y() << setw(23) << Moon.
Z();
118 sunUnit =
Triple(Sun.
X() / RSun, Sun.
Y() / RSun, Sun.
Z() / RSun);
120 Triple(Moon.
X() / RMoon, Moon.
Y() / RMoon, Moon.
Z() / RMoon);
121 rx =
Triple(site.
X() / Rx, site.
Y() / Rx, site.
Z() / Rx);
135 northGD =
Triple(-sinlat * coslon, -sinlat * sinlon, coslat);
136 eastGD =
Triple(-sinlon, coslon, 0.0);
137 upGD =
Triple(coslat * coslon, coslat * sinlon, sinlat);
154 north =
Triple(-sinlat * coslon, -sinlat * sinlon, coslat);
155 east =
Triple(-sinlon, coslon, 0.0);
156 up =
Triple(coslat * coslon, coslat * sinlon, sinlat);
159 REoRS = REarth / RSun;
161 REarth * REoRS * REoRS * REoRS * SERAT;
162 REoRM = REarth / RMoon;
164 REarth * REoRM * REoRM * REoRM / EMRAT;
172 sunDOTrx = sunUnit.
dot(rx);
173 moonDOTrx = moonUnit.
dot(rx);
176 tSun = sunUnit - sunDOTrx * rx;
177 tMoon = moonUnit - moonDOTrx * rx;
187 double poly = sinlat;
188 poly = (3.0 * poly * poly - 1.0) / 2.0;
191 if (iers == IERSConvention::IERS1996)
193 Love = 0.6026 - 0.0006 * poly;
194 Shida = 0.0831 + 0.0002 * poly;
198 Love = 0.6078 - 0.0006 * poly;
199 Shida = 0.0847 + 0.0002 * poly;
201 LOG(
DEBUG6) <<
"H2L2 " << setw(4) << icount << fixed
202 << setprecision(15) <<
" " << setw(18) << Love <<
" "
203 << setw(18) << Shida <<
" " << setw(18) << poly;
204 LOG(
DEBUG6) <<
"P2 " << setw(4) << icount << fixed << setprecision(15)
206 << 3 * (Love / 2 - Shida) * sunDOTrx * sunDOTrx -
209 << 3 * (Love / 2 - Shida) * moonDOTrx * moonDOTrx -
212 tmp = sunFactor * (Love * (1.5 * sunDOTrx * sunDOTrx - 0.5) * rx +
213 3.0 * Shida * sunDOTrx * tSun);
214 for (i = 0; i < 3; i++)
217 tmp = moonFactor * (Love * (1.5 * moonDOTrx * moonDOTrx - 0.5) * rx +
218 3.0 * Shida * moonDOTrx * tMoon);
219 for (i = 0; i < 3; i++)
224 double Shida2 = Shida;
227 tmp = sunFactor * REoRS *
228 (Love * (2.5 * sunDOTrx * sunDOTrx - 1.5) * sunDOTrx * rx +
229 Shida * (7.5 * sunDOTrx * sunDOTrx - 1.5) * tSun);
230 for (i = 0; i < 3; i++)
233 LOG(
DEBUG6) <<
"P3 " << setw(4) << icount << fixed << setprecision(15)
235 << 2.5 * (Love - 3 * Shida) * sunDOTrx * sunDOTrx *
237 1.5 * (Shida - Love) * sunDOTrx
239 << 2.5 * (Love - 3 * Shida) * moonDOTrx * moonDOTrx *
241 1.5 * (Shida - Love) * moonDOTrx;
242 LOG(
DEBUG6) <<
"X2 " << setw(4) << icount << fixed << setprecision(15)
243 <<
" " << setw(18) << 3 * Shida2 * sunDOTrx <<
" "
244 << setw(18) << 3 * Shida2 * moonDOTrx;
245 LOG(
DEBUG6) <<
"X3 " << setw(4) << icount << fixed << setprecision(15)
247 << 1.5 * Shida * (5 * sunDOTrx * sunDOTrx - 1) <<
" "
249 << 1.5 * Shida * (5 * moonDOTrx * moonDOTrx - 1);
250 LOG(
DEBUG6) <<
"RAT " << setw(4) << icount << fixed << setprecision(6)
251 <<
" " << setw(18) << SERAT << setprecision(15) <<
" "
252 << setw(22) << EMRAT << setprecision(2) <<
" " << setw(11)
254 LOG(
DEBUG6) <<
"FACT2 " << setw(4) << icount << fixed
255 << setprecision(15) <<
" " << setw(18) << sunFactor <<
" "
256 << setw(18) << moonFactor;
257 LOG(
DEBUG6) <<
"FACT3 " << setw(4) << icount << fixed
258 << setprecision(15) <<
" " << setw(18) << sunFactor * REoRS
259 <<
" " << setw(18) << moonFactor * REoRM;
261 tmp = moonFactor * REoRM *
262 (Love * (2.5 * moonDOTrx * moonDOTrx - 1.5) * moonDOTrx * rx +
263 Shida * (7.5 * moonDOTrx * moonDOTrx - 1.5) * tMoon);
264 for (i = 0; i < 3; i++)
270 tmp2[0] = northGD[0] * disp[0] + northGD[1] * disp[1] +
271 northGD[2] * disp[2];
273 eastGD[0] * disp[0] + eastGD[1] * disp[1] + eastGD[2] * disp[2];
274 tmp2[2] = upGD[0] * disp[0] + upGD[1] * disp[1] + upGD[2] * disp[2];
276 << fixed << setprecision(9) <<
" " << disp[0] <<
" "
277 << disp[1] <<
" " << disp[2] <<
" " << tmp2[0] <<
" "
278 << tmp2[1] <<
" " << tmp2[2];
280 LOG(
DEBUG6) <<
"DX0 " << setw(4) << icount << fixed << setprecision(15)
281 <<
" " << setw(18) << disp[0] <<
" " << setw(18) << disp[1]
282 <<
" " << setw(18) << disp[2];
287 tmp = -0.75 * Love *
::sin(2 * lat) *
288 (sunFactor *
::sin(2 * latSun) *
::sin(lon - lonSun) +
289 moonFactor *
::sin(2 * latMoon) *
::sin(lon - lonMoon)) *
292 - 1.5 * Shida * ::
cos(2 * lat) *
293 (sunFactor *
::sin(2 * latSun) *
::sin(lon - lonSun) +
294 moonFactor *
::sin(2 * latMoon) *
::sin(lon - lonMoon)) *
297 - 1.5 * Shida * sinlat *
298 (sunFactor * ::
sin(2 * latSun) *
::cos(lon - lonSun) +
299 moonFactor *
::sin(2 * latMoon) *
::cos(lon - lonMoon)) *
302 LOG(
DEBUG6) <<
"DX1 " << setw(4) << icount << fixed << setprecision(15)
303 <<
" " << setw(18) << tmp[0] <<
" " << setw(18) << tmp[1]
304 <<
" " << setw(18) << tmp[2];
306 for (i = 0; i < 3; i++)
312 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
314 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
315 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
317 << setprecision(9) <<
" " << tmp[0] <<
" " << tmp[1]
318 <<
" " << tmp[2] <<
" " << tmp2[0] <<
" " << tmp2[1]
325 tmp = -0.75 * Love * coslat * coslat *
327 ::sin(2 * (lon - lonSun)) +
328 moonFactor *
::cos(latMoon) *
::cos(latMoon) *
329 ::sin(2 * (lon - lonMoon))) *
332 + 0.75 * Shida * ::
sin(2 * lat) *
334 ::sin(2 * (lon - lonSun)) +
335 moonFactor *
::cos(latMoon) *
::cos(latMoon) *
336 ::sin(2 * (lon - lonMoon))) *
339 - 1.50 * Shida * coslat *
340 (sunFactor * ::
cos(latSun) *
::cos(latSun) *
341 ::cos(2 * (lon - lonSun)) +
342 moonFactor *
::cos(latMoon) *
::cos(latMoon) *
343 ::cos(2 * (lon - lonMoon))) *
346 LOG(
DEBUG6) <<
"DX2 " << setw(4) << icount << fixed << setprecision(15)
347 <<
" " << setw(18) << tmp[0] <<
" " << setw(18) << tmp[1]
348 <<
" " << setw(18) << tmp[2];
350 for (i = 0; i < 3; i++)
356 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
358 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
359 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
361 << fixed << setprecision(9) <<
" " << tmp[0] <<
" "
362 << tmp[1] <<
" " << tmp[2] <<
" " << tmp2[0] <<
" "
363 << tmp2[1] <<
" " << tmp2[2];
369 tmp = -3.0 * Shida * sinlat * sinlat *
371 ::cos(lon - lonSun) +
372 moonFactor *
::cos(latMoon) *
::sin(latMoon) *
373 ::cos(lon - lonMoon)) *
376 + 3.0 * Shida * sinlat * ::
cos(2 * lat) *
378 ::sin(lon - lonSun) +
379 moonFactor *
::cos(latMoon) *
::sin(latMoon) *
380 ::sin(lon - lonMoon)) *
383 for (i = 0; i < 3; i++)
393 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
395 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
396 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
398 << fixed << setprecision(9) <<
" " << tmp[0] <<
" "
399 << tmp[1] <<
" " << tmp[2] <<
" " << tmp2[0] <<
" "
400 << tmp2[1] <<
" " << tmp2[2];
405 tmp = -1.5 * Shida * sinlat * coslat *
407 ::cos(2 * (lon - lonSun)) +
408 moonFactor *
::cos(latMoon) *
::cos(latMoon) *
409 ::cos(2 * (lon - lonMoon))) *
412 - 1.5 * Shida * sinlat * sinlat * coslat *
413 (sunFactor * ::
cos(latSun) *
::cos(latSun) *
414 ::sin(2 * (lon - lonSun)) +
415 moonFactor *
::cos(latMoon) *
::cos(latMoon) *
416 ::sin(2 * (lon - lonMoon))) *
419 LOG(
DEBUG6) <<
"DX3 " << setw(4) << icount << fixed << setprecision(15)
420 <<
" " << setw(18) << tmp4[0] + tmp[0] <<
" " << setw(18)
421 << tmp4[1] + tmp[1] <<
" " << setw(18) << tmp4[2] + tmp[2];
423 for (i = 0; i < 3; i++)
429 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
431 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
432 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
434 << fixed << setprecision(9) <<
" " << tmp[0] <<
" "
435 << tmp[1] <<
" " << tmp[2] <<
" " << tmp2[0] <<
" "
436 << tmp2[1] <<
" " << tmp2[2];
441 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
443 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
444 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
446 << fixed << setprecision(9) <<
" " << tmp[0] <<
" "
447 << tmp[1] <<
" " << tmp[2] <<
" " << tmp2[0] <<
" "
448 << tmp2[1] <<
" " << tmp2[2];
453 static double step2diurnalData[9 * 31] = {
454 -3., 0., 2., 0., 0., -0.01, -0.01, 0.0, 0.0,
455 -3., 2., 0., 0., 0., -0.01, -0.01, 0.0, 0.0,
456 -2., 0., 1., -1., 0., -0.02, -0.01, 0.0, 0.0,
457 -2., 0., 1., 0., 0., -0.08, 0.00, 0.01, 0.01,
458 -2., 2., -1., 0., 0., -0.02, -0.01, 0.0, 0.0,
459 -1., 0., 0., -1., 0., -0.10, 0.00, 0.00, 0.00,
460 -1., 0., 0., 0., 0., -0.51, 0.00, -0.02, 0.03,
461 -1., 2., 0., 0., 0., 0.01, 0.0, 0.0, 0.0,
462 0., -2., 1., 0., 0., 0.01, 0.0, 0.0, 0.0,
463 0., 0., -1., 0., 0., 0.02, 0.01, 0.0, 0.0,
464 0., 0., 1., 0., 0., 0.06, 0.00, 0.00, 0.00,
465 0., 0., 1., 1., 0., 0.01, 0.0, 0.0, 0.0,
466 0., 2., -1., 0., 0., 0.01, 0.0, 0.0, 0.0,
467 1., -3., 0., 0., 1., -0.06, 0.00, 0.00, 0.00,
468 1., -2., 0., 1., 0., 0.01, 0.0, 0.0, 0.0,
469 1., -2., 0., 0., 0., -1.23, -0.07, 0.06, 0.01,
470 1., -1., 0., 0., -1., 0.02, 0.0, 0.0, 0.0,
471 1., -1., 0., 0., 1., 0.04, 0.0, 0.0, 0.0,
472 1., 0., 0., -1., 0., -0.22, 0.01, 0.01, 0.00,
473 1., 0., 0., 0., 0., 12.00, -0.78, -0.67, -0.03,
474 1., 0., 0., 1., 0., 1.73, -0.12, -0.10, 0.00,
475 1., 0., 0., 2., 0., -0.04, 0.0, 0.0, 0.0,
476 1., 1., 0., 0., -1., -0.50, -0.01, 0.03, 0.00,
477 1., 1., 0., 0., 1., 0.01, 0.0, 0.0, 0.0,
478 1., 1., 0., 1., -1., -0.01, 0.0, 0.0, 0.0,
479 1., 2., -2., 0., 0., -0.01, 0.0, 0.0, 0.0,
480 1., 2., 0., 0., 0., -0.11, 0.01, 0.01, 0.00,
481 2., -2., 1., 0., 0., -0.01, 0.0, 0.0, 0.0,
482 2., 0., -1., 0., 0., -0.02, 0.02, 0.0, 0.01,
483 3., 0., 0., 0., 0., 0.0, 0.01, 0.0, 0.01,
484 3., 0., 0., 1., 0., 0.0, 0.01, 0.0, 0.0};
488 TT.convertSystemTo(TimeSystem::TT);
489 double T, fhr, fmjd =
TT.dMJD();
490 T = (fmjd - 51544.0) / 36525.0;
491 fhr = (fmjd - int(fmjd)) * 24.0;
494 double s, tau, pr, h, p, zns, ps;
499 s = 218.31664563 + 481267.88194 * T - 0.0014663889 * T2 +
501 tau = fhr * 15. + 280.4606184 + 36000.7700536 * T +
502 0.00038793 * T2 - 0.0000000258 * T3;
504 pr = 1.396971278 * T + 0.000308889 * T2 + 0.000000021 * T3 +
507 h = 280.46645 + 36000.7697489 * T + 0.00030322222 * T2 +
508 0.000000020 * T3 - 0.00000000654 * T4;
509 p = 83.35324312 + 4069.01363525 * T - 0.01032172222 * T2 -
510 0.0000124991 * T3 + 0.00000005263 * T4;
511 zns = 234.95544499 + 1934.13626197 * T - 0.00207561111 * T2 -
512 0.00000213944 * T3 + 0.00000001650 * T4;
513 ps = 282.93734098 + 1.71945766667 * T + 0.00045688889 * T2 -
514 0.00000001778 * T3 - 0.00000000334 * T4;
516 tau = fmod(tau, 360.0);
519 zns = fmod(zns, 360.0);
520 ps = fmod(ps, 360.0);
523 double thetaf, ctl, stl, dr, dn, de;
525 for (i = 0; i < 31; i++)
527 thetaf = (tau + step2diurnalData[0 + 9 * i] * s +
528 step2diurnalData[1 + 9 * i] * h +
529 step2diurnalData[2 + 9 * i] * p +
530 step2diurnalData[3 + 9 * i] * zns +
531 step2diurnalData[4 + 9 * i] * ps) *
533 ctl =
::cos(thetaf + lon);
534 stl =
::sin(thetaf + lon);
535 dr = (step2diurnalData[5 + 9 * i] * stl +
536 step2diurnalData[6 + 9 * i] * ctl) *
538 dn = (step2diurnalData[7 + 9 * i] * stl +
539 step2diurnalData[8 + 9 * i] * ctl) *
540 (coslat * coslat - sinlat * sinlat);
541 de = (step2diurnalData[7 + 9 * i] * ctl -
542 step2diurnalData[8 + 9 * i] * stl) *
544 tmp[0] += dr * up[0] + de * east[0] + dn * north[0];
545 tmp[1] += dr * up[1] + de * east[1] + dn * north[1];
546 tmp[2] += dr * up[2] + dn * north[2];
550 for (i = 0; i < 3; i++) {
554 LOG(
DEBUG6) <<
"DX4 " << setw(4) << icount << fixed << setprecision(15)
555 <<
" " << setw(18) << tmp[0] <<
" " << setw(18) << tmp[1]
556 <<
" " << setw(18) << tmp[2];
558 for (i = 0; i < 3; i++)
564 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
566 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
567 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
568 LOG(
DEBUG7) <<
"7SET diurnal-band-corrections "
569 << ttag.
asGPSString() << fixed << setprecision(9) <<
" "
570 << tmp[0] <<
" " << tmp[1] <<
" " << tmp[2] <<
" "
571 << tmp2[0] <<
" " << tmp2[1] <<
" " << tmp2[2];
592 static double step2longData[9 * 5] = {
593 0, 0, 0, 1, 0, 0.47, 0.23, 0.16, 0.07,
594 0, 2, 0, 0, 0, -0.20, -0.12, -0.11, -0.05,
595 1, 0, -1, 0, 0, -0.11, -0.08, -0.09, -0.04,
596 2, 0, 0, 0, 0, -0.13, -0.11, -0.15, -0.07,
597 2, 0, 0, 1, 0, -0.05, -0.05, -0.06, -0.03};
600 for (i = 0; i < 5; i++)
603 (step2longData[0 + 9 * i] * s + step2longData[1 + 9 * i] * h +
604 step2longData[2 + 9 * i] * p + step2longData[3 + 9 * i] * zns +
605 step2longData[4 + 9 * i] * ps) *
609 dr = (step2longData[5 + 9 * i] * ctl +
610 step2longData[7 + 9 * i] * stl) *
611 (3 * sinlat * sinlat - 1) / 2;
612 dn = (step2longData[6 + 9 * i] * ctl +
613 step2longData[8 + 9 * i] * stl) *
616 tmp[0] += dr * up[0] + dn * north[0];
617 tmp[1] += dr * up[1] + dn * north[1];
618 tmp[2] += dr * up[2] + dn * north[2];
620 for (i = 0; i < 3; i++)
623 LOG(
DEBUG6) <<
"DX5 " << setw(4) << icount << fixed << setprecision(15)
624 <<
" " << setw(18) << tmp[0] <<
" " << setw(18) << tmp[1]
625 <<
" " << setw(18) << tmp[2];
627 for (i = 0; i < 3; i++)
633 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
635 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
636 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
638 << fixed << setprecision(9) <<
" " << tmp[0] <<
" "
639 << tmp[1] <<
" " << tmp[2] <<
" " << tmp2[0] <<
" "
640 << tmp2[1] <<
" " << tmp2[2];
649 tmp = -0.1196 * (1.5 * sinlat * sinlat - 0.5) * rx -
650 0.0247 *
::sin(2 * lat) * north;
652 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
654 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
655 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
656 LOG(
DEBUG7) <<
"7SET permanent-tide-not-incl. "
657 << ttag.
asGPSString() << fixed << setprecision(9) <<
" "
658 << tmp[0] <<
" " << tmp[1] <<
" " << tmp[2] <<
" "
659 << tmp2[0] <<
" " << tmp2[1] <<
" " << tmp2[2];
664 for (i = 0; i < 3; i++)
667 northGD[0] * tmp[0] + northGD[1] * tmp[1] + northGD[2] * tmp[2];
669 eastGD[0] * tmp[0] + eastGD[1] * tmp[1] + eastGD[2] * tmp[2];
670 tmp2[2] = upGD[0] * tmp[0] + upGD[1] * tmp[1] + upGD[2] * tmp[2];
672 << setprecision(9) <<
" " << tmp[0] <<
" " << tmp[1]
673 <<
" " << tmp[2] <<
" " << tmp2[0] <<
" " << tmp2[1]
685 Exception E(
"std except: " +
string(e.what()));
712 double xp,
double yp,
717 double m1, m2, upcoef;
719 if (iers == IERSConvention::IERS1996)
728 double dt((ttag.
dMJD() - 51544.5) / 365.25);
731 if (iers == IERSConvention::IERS2003)
733 xmean = (0.054 + 0.00083 * dt) / 1000.0;
734 ymean = (0.357 + 0.00395 * dt) / 1000.0;
741 if (ttag.
year() > 2010)
743 xmean = 23.513 + 7.6141 * dt;
744 ymean = 358.891 - 0.6287 * dt;
749 55.974 + (1.8243 + (0.18413 + 0.007024 * dt) * dt) * dt;
751 346.346 + (1.7896 - (0.10729 + 0.000908 * dt) * dt) * dt;
761 LOG(
DEBUG7) <<
" poletide means " << iers << fixed << setprecision(15)
762 <<
" " << m1 <<
" " << m2;
765 double lat, lon, theta, sinlat, coslat, sinlon, coslon;
778 0.009 *
::cos(2 * theta) * (m1 * coslon + m2 * sinlon);
779 disp[1] = 0.009 *
::cos(theta) * (m1 * sinlon - m2 * coslon);
781 -upcoef *
::sin(2 * theta) * (m1 * coslon + m2 * sinlon);
784 << fixed << setprecision(9) << disp[0] <<
" " << disp[1]
792 dispXYZ[0] = -sinlat * coslon * disp[0] - sinlon * disp[1] +
793 coslat * coslon * disp[2];
794 dispXYZ[1] = -sinlat * sinlon * disp[0] + coslon * disp[1] +
795 coslat * sinlon * disp[2];
796 dispXYZ[2] = coslat * disp[0] + sinlat * disp[2];