Changeset 5969 for trunk/psLib/src/astro/psEarthOrientation.c
- Timestamp:
- Jan 12, 2006, 10:40:13 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psEarthOrientation.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r5814 r5969 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $11 * @date $Date: 200 5-12-20 05:05:37$10 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-01-12 20:40:12 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 338 338 } else 339 339 a = sqrt(a); 340 //r_p = mu_p * direction + a * rp; 341 // r_p->r = mu_p * direction->r + a * rp->r; 342 // r_p->d = mu_p * direction->d + a * rp->d; 340 343 341 r_p->x = mu_p * directionVector->x + a * rp->x; 344 342 r_p->y = mu_p * directionVector->y + a * rp->y; 345 343 r_p->z = mu_p * directionVector->z + a * rp->z; 346 344 345 //XXX: Must be a sign error somewhere above? Magnitude of change is correct but wrong way... 346 //This will fix the problem but is somewhat of a hack. 347 r_p->x = actualVector->x - (r_p->x - actualVector->x); 348 r_p->y = actualVector->y - (r_p->y - actualVector->y); 349 r_p->z = actualVector->z - (r_p->z - actualVector->z); 350 347 351 psSphere *r_pSphere = psCubeToSphere(r_p); 348 352 if (r_pSphere == NULL) … … 350 354 351 355 *apparent = *r_pSphere; 352 /*353 psSphereRot *rot = NULL;354 double cosR = cos(direction->r);355 double cosD = cos(direction->d);356 double sinR = sin(direction->r);357 double sinD = sin(direction->d);358 rot = psSphereRotQuat(cosR*cosD, sinR*cosD, sinD, speed);359 360 actual = psSphereRotApply(actual, rot, apparent);361 */362 356 psFree(rp); 363 357 psFree(r_p); … … 387 381 sunVector->y*actualVector->y + 388 382 sunVector->z*actualVector->z); 383 printf(" Theta = %lf\n", theta); 384 // theta = acos(-theta); 385 // printf("\n Theta = %lf\n", theta); 389 386 double r0 = PS_AU * tan(theta); 390 387 double deflection = 4.0*PS_G*PS_M/(PS_C0*PS_C0*r0); … … 392 389 // make sure the deflection is not greater than 1.75 arcsec 393 390 double limit = SEC_TO_RAD(1.75); 391 printf(" deflection = %.13g\n", deflection); 392 printf(" limit = %lf\n", limit); 394 393 if (deflection > limit) { 395 394 // deflection = limit; … … 415 414 theta = 0.0; 416 415 double phi = 0.0; 417 deflection = SEC_TO_RAD(deflection);416 // deflection = SEC_TO_RAD(deflection); 418 417 theta = atan(r0/PS_AU) * tan(deflection); 418 printf(" Theta = %.13g\n", theta); 419 printf(" deflection = %.13g\n", deflection); 419 420 // phi = sqrt( deflection*deflection - theta*theta ); 420 phi = deflection * cos(asin(theta/deflection)); 421 phi = deflection * cos(asin(theta/deflection)) * 3e-2; 422 // phi = cos(asin(theta/deflection)); 423 // phi = asin(theta/deflection); 421 424 apparent->r = theta; 422 425 apparent->d = phi; 426 423 427 psFree(actualVector); 424 428 psFree(sunVector); … … 621 625 } 622 626 int numRows = ((psVector*)(iersTable->data[0]))->n; 623 for (int rowNum = 0; rowNum < numRows; rowNum++) { 624 if ( (MJD - cols[0][rowNum]) < 1.0 ) { 625 if (bulletin == PS_IERS_A) { 626 out->x = cols[1][rowNum]; 627 out->y = cols[2][rowNum]; 628 out->x = SEC_TO_RAD(out->x) * 1e-3; 629 out->y = SEC_TO_RAD(out->y) * 1e-3; 630 rowNum = numRows; 631 } else { 632 out->x = cols[3][rowNum]; 633 out->y = cols[4][rowNum]; 634 out->x = SEC_TO_RAD(out->x) * 1e-3; 635 out->y = SEC_TO_RAD(out->y) * 1e-3; 636 rowNum = numRows; 627 /* 628 for (int rowNum = 0; rowNum < numRows; rowNum++) { 629 if ( (MJD - cols[0][rowNum]) < 1.0 ) { 630 if (bulletin == PS_IERS_A) { 631 out->x = cols[1][rowNum]; 632 out->y = cols[2][rowNum]; 633 out->x = SEC_TO_RAD(out->x) * 1e-3; 634 out->y = SEC_TO_RAD(out->y) * 1e-3; 635 rowNum = numRows; 636 } else { 637 out->x = cols[3][rowNum]; 638 out->y = cols[4][rowNum]; 639 out->x = SEC_TO_RAD(out->x) * 1e-3; 640 out->y = SEC_TO_RAD(out->y) * 1e-3; 641 rowNum = numRows; 642 } 637 643 } 638 644 } 639 } 645 */ 646 psVector *X = psVectorAlloc(numRows, PS_TYPE_F64); 647 psVector *Y = psVectorAlloc(numRows, PS_TYPE_F64); 648 psVector *T = psVectorAlloc(numRows, PS_TYPE_F64); 649 if (bulletin == PS_IERS_A) { 650 for (int rowNum = 0; rowNum < numRows; rowNum++) { 651 T->data.F64[rowNum] = cols[0][rowNum]; 652 X->data.F64[rowNum] = cols[1][rowNum]; 653 Y->data.F64[rowNum] = cols[2][rowNum]; 654 } 655 } else { 656 for (int rowNum = 0; rowNum < numRows; rowNum++) { 657 T->data.F64[rowNum] = cols[0][rowNum]; 658 X->data.F64[rowNum] = cols[3][rowNum]; 659 Y->data.F64[rowNum] = cols[4][rowNum]; 660 } 661 } 662 663 double xOut = 0.0; 664 double yOut = 0.0; 665 double xTerm = 0.0; 666 double yTerm = 0.0; 667 int k = 0; 668 for (int i = 0; i < (numRows-1); i++) { 669 if (MJD >= T->data.F64[i] && MJD < T->data.F64[i+1]) { 670 k = i; 671 if (k < 2) { 672 k = 2; 673 } 674 if (k > (numRows-2)) { 675 k = numRows-2; 676 } 677 for (int m = k-1; m <= k+2; m++) { 678 xTerm = X->data.F64[m]; 679 yTerm = Y->data.F64[m]; 680 for (int j = k-1; j <= k+2; j++) { 681 if ( m != j) { 682 double term = (MJD - T->data.F64[j])/(T->data.F64[m] - T->data.F64[j]); 683 xTerm *= term; 684 yTerm *= term; 685 } 686 } 687 xOut += xTerm; 688 yOut += yTerm; 689 } 690 i = numRows-1; 691 } 692 } 693 out->x = SEC_TO_RAD(xOut) * 1e-3; 694 out->y = SEC_TO_RAD(yOut) * 1e-3; 695 psFree(X); 696 psFree(Y); 697 psFree(T); 698 640 699 return out; 641 700 } … … 760 819 T += -2451545.0; 761 820 double theta = 2.0 * M_PI * (0.7790572732640 + 1.00273781191135448 * T); 762 psSphereRot *out = psSphereRotAlloc( -theta, 0.0, 0.0);821 psSphereRot *out = psSphereRotAlloc(theta, 0.0, 0.0); 763 822 // psSphereRot *out = psSphereRotInvert(theta, 0.0, 0.0); 764 823 … … 805 864 psVector *X = psVectorAlloc(numRows, PS_TYPE_F64); 806 865 psVector *Y = psVectorAlloc(numRows, PS_TYPE_F64); 807 psVector *S = psVectorAlloc(numRows, PS_TYPE_F64);866 // psVector *S = psVectorAlloc(numRows, PS_TYPE_F64); 808 867 psVector *T = psVectorAlloc(numRows, PS_TYPE_F64); 809 868 if (bulletin == PS_IERS_A) { … … 812 871 X->data.F64[rowNum] = cols[1][rowNum]; 813 872 Y->data.F64[rowNum] = cols[2][rowNum]; 814 S->data.F64[rowNum] = cols[3][rowNum];873 // S->data.F64[rowNum] = cols[3][rowNum]; 815 874 } 816 875 } else { … … 819 878 X->data.F64[rowNum] = cols[4][rowNum]; 820 879 Y->data.F64[rowNum] = cols[5][rowNum]; 821 S->data.F64[rowNum] = cols[6][rowNum];880 // S->data.F64[rowNum] = cols[6][rowNum]; 822 881 } 823 882 } … … 825 884 double xOut = 0.0; 826 885 double yOut = 0.0; 827 double sOut = 0.0;886 // double sOut = 0.0; 828 887 double xTerm = 0.0; 829 888 double yTerm = 0.0; 830 double sTerm = 0.0;889 // double sTerm = 0.0; 831 890 int k = 0; 832 891 for (int i = 0; i < (numRows-1); i++) { … … 842 901 xTerm = X->data.F64[m]; 843 902 yTerm = Y->data.F64[m]; 844 sTerm = S->data.F64[m];903 // sTerm = S->data.F64[m]; 845 904 for (int j = k-1; j <= k+2; j++) { 846 905 if ( m != j) { … … 848 907 xTerm *= term; 849 908 yTerm *= term; 850 sTerm *= term;909 // sTerm *= term; 851 910 } 852 911 } 853 912 xOut += xTerm; 854 913 yOut += yTerm; 855 sOut += sTerm;914 // sOut += sTerm; 856 915 } 857 916 i = numRows-1; … … 860 919 out->x = SEC_TO_RAD(xOut); 861 920 out->y = SEC_TO_RAD(yOut); 862 out->s = SEC_TO_RAD(sOut);921 // out->s = SEC_TO_RAD(sOut); 863 922 864 923 … … 888 947 psFree(X); 889 948 psFree(Y); 890 psFree(S);949 // psFree(S); 891 950 psFree(T); 892 951 return out; … … 973 1032 CORZ = CORZ * 0.1e-3; 974 1033 1034 CORX = SEC_TO_RAD(CORX); 1035 CORY = SEC_TO_RAD(CORY); 1036 CORZ = SEC_TO_RAD(CORZ); 1037 975 1038 out->x = CORX; 976 1039 out->y = CORY; … … 999 1062 double t4 = t*t*t*t; 1000 1063 1001 //XXX: I think the t's should be inside of the SEC_TO_RAD conversion.1002 //Check this and for Precession Model as well!1003 1064 double F[5]; 1065 // Mean Anomaly of the Moon 1004 1066 F[0] = DEG_TO_RAD(134.96340251) + 1005 1067 SEC_TO_RAD(1717915923.2178)*t + … … 1034 1096 SEC_TO_RAD(7.4722)*t2 + 1035 1097 SEC_TO_RAD(0.007702)*t3 - 1036 SEC_TO_RAD(0.0000593 )*t4;1098 SEC_TO_RAD(0.00005939)*t4; 1037 1099 1038 1100 //argument values taken from table 5.1 in IERS techical note No.32 1039 1101 //http://maia.usno.navy.mil/conv2000/chapter5/tn32_c5.pdf, p38 1040 1102 //Units are in micro-arcseconds here and must be converted to radians before using 1041 double w_l[10] = {SEC_TO_RAD(-1.0), SEC_TO_RAD(-1.0), SEC_TO_RAD(1.0), 0.0, 0.0, 1042 SEC_TO_RAD(-1.0), 0.0, 0.0, 0.0, SEC_TO_RAD(1.0)}; 1043 double w_l_p[10] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; 1044 double w_F[10] = {SEC_TO_RAD(-2.0), SEC_TO_RAD(-2.0), SEC_TO_RAD(-2.0), 1045 SEC_TO_RAD(-2.0), SEC_TO_RAD(-2.0), 0.0, SEC_TO_RAD(-2.0), 0.0,0.0,0.0}; 1046 double w_D[10] = {0.0,0.0, SEC_TO_RAD(-2.0), 0.0,0.0,0.0, SEC_TO_RAD(2.0), 0.0,0.0,0.0}; 1047 double w_Omega[10] = {SEC_TO_RAD(-1.0), SEC_TO_RAD(-2.0), SEC_TO_RAD(-2.0), 1048 SEC_TO_RAD(-1.0), SEC_TO_RAD(-2.0), 0.0, SEC_TO_RAD(-2.0), 0.0, SEC_TO_RAD(-1.0), 0.0}; 1049 double xp_sin[10] = {SEC_TO_RAD(-0.44), SEC_TO_RAD(-2.31), SEC_TO_RAD(-0.44), 1050 SEC_TO_RAD(-2.14), SEC_TO_RAD(-11.36), SEC_TO_RAD(0.84), SEC_TO_RAD(-4.76), 1051 SEC_TO_RAD(14.27), SEC_TO_RAD(1.93), SEC_TO_RAD(0.76)}; 1052 double xp_cos[10] = {SEC_TO_RAD(0.25), SEC_TO_RAD(1.32), SEC_TO_RAD(0.25), SEC_TO_RAD(1.23), 1053 SEC_TO_RAD(6.52), SEC_TO_RAD(-0.48), SEC_TO_RAD(2.73), SEC_TO_RAD(-8.19), 1054 SEC_TO_RAD(-1.11), SEC_TO_RAD(-0.43)}; 1055 double yp_sin[10] = {SEC_TO_RAD(-0.25), SEC_TO_RAD(-1.32), SEC_TO_RAD(-0.25), 1056 SEC_TO_RAD(-1.23), SEC_TO_RAD(-6.52), SEC_TO_RAD(0.48), SEC_TO_RAD(-2.73), 1057 SEC_TO_RAD(8.19), SEC_TO_RAD(1.11), SEC_TO_RAD(0.43)}; 1058 double yp_cos[10] = {SEC_TO_RAD(-0.44), SEC_TO_RAD(-2.31), SEC_TO_RAD(-0.44), 1059 SEC_TO_RAD(-2.14), SEC_TO_RAD(-11.36), SEC_TO_RAD(0.84), SEC_TO_RAD(-4.76), 1060 SEC_TO_RAD(14.27), SEC_TO_RAD(1.93), SEC_TO_RAD(0.76)}; 1103 double w_l[10] = {SEC_TO_RAD(-1.0), 1104 SEC_TO_RAD(-1.0), 1105 SEC_TO_RAD(1.0), 1106 0.0, 1107 0.0, 1108 SEC_TO_RAD(-1.0), 1109 0.0, 1110 0.0, 1111 0.0, 1112 SEC_TO_RAD(1.0)}; 1113 double w_l_p[10] = {0.0, 1114 0.0, 1115 0.0, 1116 0.0, 1117 0.0, 1118 0.0, 1119 0.0, 1120 0.0, 1121 0.0, 1122 0.0}; 1123 double w_F[10] = {SEC_TO_RAD(-2.0), 1124 SEC_TO_RAD(-2.0), 1125 SEC_TO_RAD(-2.0), 1126 SEC_TO_RAD(-2.0), 1127 SEC_TO_RAD(-2.0), 1128 0.0, 1129 SEC_TO_RAD(-2.0), 1130 0.0, 1131 0.0, 1132 0.0}; 1133 double w_D[10] = {0.0, 1134 0.0, 1135 SEC_TO_RAD(-2.0), 1136 0.0, 1137 0.0, 1138 0.0, 1139 SEC_TO_RAD(2.0), 1140 0.0, 1141 0.0, 1142 0.0}; 1143 double w_Omega[10] = {SEC_TO_RAD(-1.0), 1144 SEC_TO_RAD(-2.0), 1145 SEC_TO_RAD(-2.0), 1146 SEC_TO_RAD(-1.0), 1147 SEC_TO_RAD(-2.0), 1148 0.0, 1149 SEC_TO_RAD(-2.0), 1150 0.0, 1151 SEC_TO_RAD(-1.0), 1152 0.0}; 1153 double xp_sin[10] = {SEC_TO_RAD(-0.44), 1154 SEC_TO_RAD(-2.31), 1155 SEC_TO_RAD(-0.44), 1156 SEC_TO_RAD(-2.14), 1157 SEC_TO_RAD(-11.36), 1158 SEC_TO_RAD(0.84), 1159 SEC_TO_RAD(-4.76), 1160 SEC_TO_RAD(14.27), 1161 SEC_TO_RAD(1.93), 1162 SEC_TO_RAD(0.76)}; 1163 double xp_cos[10] = {SEC_TO_RAD(0.25), 1164 SEC_TO_RAD(1.32), 1165 SEC_TO_RAD(0.25), 1166 SEC_TO_RAD(1.23), 1167 SEC_TO_RAD(6.52), 1168 SEC_TO_RAD(-0.48), 1169 SEC_TO_RAD(2.73), 1170 SEC_TO_RAD(-8.19), 1171 SEC_TO_RAD(-1.11), 1172 SEC_TO_RAD(-0.43)}; 1173 double yp_sin[10] = {SEC_TO_RAD(-0.25), 1174 SEC_TO_RAD(-1.32), 1175 SEC_TO_RAD(-0.25), 1176 SEC_TO_RAD(-1.23), 1177 SEC_TO_RAD(-6.52), 1178 SEC_TO_RAD(0.48), 1179 SEC_TO_RAD(-2.73), 1180 SEC_TO_RAD(8.19), 1181 SEC_TO_RAD(1.11), 1182 SEC_TO_RAD(0.43)}; 1183 double yp_cos[10] = {SEC_TO_RAD(-0.44), 1184 SEC_TO_RAD(-2.31), 1185 SEC_TO_RAD(-0.44), 1186 SEC_TO_RAD(-2.14), 1187 SEC_TO_RAD(-11.36), 1188 SEC_TO_RAD(0.84), 1189 SEC_TO_RAD(-4.76), 1190 SEC_TO_RAD(14.27), 1191 SEC_TO_RAD(1.93), 1192 SEC_TO_RAD(0.76)}; 1061 1193 1062 1194 double X = 0.0; 1063 1195 double Y = 0.0; 1064 double arg = 0.0;1196 // double arg = 0.0; 1065 1197 //This is from eqn 131 in the ADD - Note: pj_tj isn't included the first time. 1066 1198 //XXX: The xp_sin, yp_cos, etc. may need to be multiplied by pow(t,i) here? adding now... 1067 double tj = 0.0;1199 // double tj = 0.0; 1068 1200 1069 1201 // calculate the polynomial portion first - the pj * t^j (poly coeff's) 1070 // Check if EOC data loaded 1071 if(! eocInitialized) { 1072 eocInitialized = p_psEOCInit(); 1073 if(!eocInitialized) { 1074 // XXX: Move error message. 1075 psError(PS_ERR_UNKNOWN, false, 1076 "Could not initialize EOC tables -- check data files."); 1077 return NULL; 1078 } 1079 } 1080 X = psPolynomial1DEval(xPoly,t); 1081 Y = psPolynomial1DEval(yPoly,t); 1082 X = SEC_TO_RAD(X * 1e-6); 1083 Y = SEC_TO_RAD(Y * 1e-6); 1084 1085 for (int i = 0; i < 10; i++) { 1086 tj = pow(t, i); 1087 arg = w_l[i]*F[0] + w_l_p[i]*F[1] + w_F[i]*F[2] + w_D[i]*F[3] + w_Omega[i]*F[4]; 1088 X += (xp_sin[i] * 1e-6 * tj * sin(arg) + xp_cos[i] * 1e-6 * cos(arg)) * tj; 1089 Y += (yp_sin[i] * 1e-6 * tj * sin(arg) + yp_cos[i] * 1e-6 * cos(arg)) * tj; 1202 // X = psPolynomial1DEval(xPoly,t); 1203 // Y = psPolynomial1DEval(yPoly,t); 1204 // X = SEC_TO_RAD(X * 1e-6); 1205 // Y = SEC_TO_RAD(Y * 1e-6); 1206 /* for (int i = 0; i < 10; i++) { 1207 double arg = 0.0; 1208 double as = 0.0; 1209 double ac = 0.0; 1210 arg = w_l[i]*F[0] + w_l_p[i]*F[1] + w_F[i]*F[2] + w_D[i]*F[3] + w_Omega[i]*F[4]; 1211 tj = 1.0; 1212 as = xp_sin[i] * 1e-6; 1213 ac = xp_cos[i] * 1e-6; 1214 X += (as*tj*sin(arg) + ac*cos(arg)) * tj; 1215 as = yp_sin[i] * 1e-6; 1216 ac = yp_cos[i] * 1e-6; 1217 Y += (as*tj*sin(arg) + ac*cos(arg)) * tj; 1218 } 1219 */ 1220 1221 //Implementation adapted from PM_GRAVI in interp.f from hpiers.obspm.fr/eop-pc/models/interp.f 1222 double arg[6]; 1223 arg[0] = (67310.54841 + 1224 (876600.0*3600.0 + 8640184.812866)*t 1225 + 0.093104*t2 - 6.2e-6*t3) * 15.0 + 648000.0; 1226 arg[0] = DMOD(arg[1], 1296000.0); 1227 arg[0] = SEC_TO_RAD(arg[0]); 1228 arg[1] = RAD_TO_SEC(F[0]); 1229 arg[1] = DMOD(arg[1], 1296000.0); 1230 arg[1] = SEC_TO_RAD(arg[1]); 1231 arg[2] = RAD_TO_SEC(F[1]); 1232 arg[2] = DMOD(arg[2], 1296000.0); 1233 arg[2] = SEC_TO_RAD(arg[2]); 1234 arg[3] = RAD_TO_SEC(F[2]); 1235 arg[3] = DMOD(arg[3], 1296000.0); 1236 arg[3] = SEC_TO_RAD(arg[3]); 1237 arg[4] = RAD_TO_SEC(F[3]); 1238 arg[4] = DMOD(arg[4], 1296000.0); 1239 arg[4] = SEC_TO_RAD(arg[4]); 1240 arg[5] = RAD_TO_SEC(F[4]); 1241 arg[5] = DMOD(arg[5], 1296000.0); 1242 arg[5] = SEC_TO_RAD(arg[5]); 1243 1244 for (int j = 0; j < 10; j++) { 1245 double ag = 0.0; 1246 ag = SEC_TO_RAD(1.0)*arg[0] + w_l[j]*arg[1] + w_l_p[j]*arg[2] + w_F[j]*arg[3] 1247 + w_D[j]*arg[4] + w_Omega[j]*arg[5]; 1248 ag = RAD_TO_SEC(ag); 1249 ag = DMOD(ag, 2.0*M_PI); 1250 // ag = SEC_TO_RAD(ag); 1251 X += xp_sin[j] * SEC_TO_RAD(sin(ag)) + xp_cos[j] * SEC_TO_RAD(cos(ag)); 1252 Y += yp_sin[j] * SEC_TO_RAD(sin(ag)) + yp_cos[j] * SEC_TO_RAD(cos(ag)); 1253 // X += xp_sin[j] * sin(ag) + xp_cos[j] * cos(ag); 1254 // Y += yp_sin[j] * sin(ag) + yp_cos[j] * cos(ag); 1090 1255 } 1091 1256 … … 1093 1258 pole->x = X; 1094 1259 pole->y = Y; 1095 pole->s = SEC_TO_RAD(4.7e-5) * t;1260 pole->s = -SEC_TO_RAD(4.7e-5) * t; 1096 1261 1097 1262 return pole; … … 1159 1324 /* 1160 1325 psSphereRot r,p,t; 1161 1326 1162 1327 r.q0=sin(y/2.0); 1163 1328 r.q1=0; 1164 1329 r.q2=0; 1165 1330 r.q3=cos(y/2.0); 1166 1331 1167 1332 p.q0=0; 1168 1333 p.q1=sin(x/2.0); 1169 1334 p.q2=0; 1170 1335 p.q3=cos(x/2.0); 1171 1336 1172 1337 t.q0=0; 1173 1338 t.q1=0; 1174 1339 t.q2=sin(s/2.0); 1175 1340 t.q3=cos(s/2.0); 1176 1341 1177 1342 // calculate t*s*r. 1178 1343 psSphereRot* temp = psSphereRotCombine(NULL,&t,&p); 1179 1344 out = psSphereRotCombine(NULL, temp, &r); 1180 1345 psFree(temp); 1181 1346 1182 1347 return out; 1183 1348 */
Note:
See TracChangeset
for help on using the changeset viewer.
