IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5969


Ignore:
Timestamp:
Jan 12, 2006, 10:40:13 AM (20 years ago)
Author:
drobbin
Message:

Updated fxns in EOC. Updated/expanded TableParser.

Location:
trunk/psLib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/psTableParse.c

    r5892 r5969  
    11/** @file  psTableParse.c
    22 *
    3  *  @brief Parses input data tables and outputs .dat files for specified format
     3 *  @brief Parses input data tables (finals2000A.data) and outputs files for specified format
    44 *
    55 *  @ingroup psTableParse
     
    77 *  @author Dave Robbins, MHPCC
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-01-04 22:59:31 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-01-12 20:40:12 $
    1111 *
    1212 *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    1919#include <math.h>
    2020
     21static FILE *output = NULL;
     22static FILE *input = NULL;
     23
     24static void printHeader(char *filename);
     25
    2126int main(int argc, char *argv[])
    2227{
     
    2631    }
    2732    if (!strncmp(argv[1], "-h", 2) ) {
    28         printf("\n Usage:  psTableParse inputTable.data outputTable.dat columnNumbers.\n");
     33        printf("\n Usage:  psTableParse inputTable.data outputTable.dat <Sections>.\n");
    2934        printf(" i.e.    psTableParse finals.data finals.dat 1 3 4 8\n");
     35        printf("\n Sections:\n 1)MJD Date       2)X (Bull A)     3)Y (Bull A)");
     36        printf("\n 4)X (Bull B)     5)Y (Bull B)     6)dX (Bull A)");
     37        printf("\n 7)dY (Bull A)    8)dX (Bull B)    9)dY (Bull B)");
     38        printf("\n 10)UT1-UTC (Bull A)      11)UT1-UTC (Bull B)\n");
    3039        return 0;
    3140    }
    32 
    33     FILE *output;
    34     FILE *input;
    3541    input = fopen(argv[1], "r");
    3642    output = fopen(argv[2], "w");
    37     //    char data;
    3843    char data2[200];
     44    printHeader(argv[1]);
     45    fprintf(output, "#  ");
     46    for (int i = 3; i < argc; i++) {
     47        if(!strncmp(argv[i], "1", 2)) {
     48            fprintf(output, "MJD       ");
     49        }
     50        if(!strncmp(argv[i], "2", 2)) {
     51            fprintf(output, " X (A)     ");
     52        }
     53        if(!strncmp(argv[i], "3", 2)) {
     54            fprintf(output, " Y (A)     ");
     55        }
     56        if(!strncmp(argv[i], "4", 2)) {
     57            fprintf(output, " X (B)     ");
     58        }
     59        if(!strncmp(argv[i], "5", 2)) {
     60            fprintf(output, "  Y (B)     ");
     61        }
     62        if(!strncmp(argv[i], "6", 2)) {
     63            fprintf(output, " dX (A)     ");
     64        }
     65        if(!strncmp(argv[i], "7", 2)) {
     66            fprintf(output, " dY (A)     ");
     67        }
     68        if(!strncmp(argv[i], "8", 2)) {
     69            fprintf(output, " dX (B)     ");
     70        }
     71        if(!strncmp(argv[i], "9", 2)) {
     72            fprintf(output, " dY (B)     ");
     73        }
     74        if(!strncmp(argv[i], "10", 2)) {
     75            fprintf(output, "UT1-UTC (A)  ");
     76        }
     77        if(!strncmp(argv[i], "11", 2)) {
     78            fprintf(output, "UT1-UTC (B)  ");
     79        }
     80    }
     81    fprintf(output, "\n#\n#\n");
    3982    int i;
    4083    while ( fscanf(input, "%188c", data2) != EOF) {
    41         for (i = 7; i <= 14; i++) {
    42             fprintf(output, "%c", data2[i]);
    43         }
    44         fprintf(output, "  ");
    45         for (i = 97; i <= 105; i++) {
    46             if (data2[102] == ' ') {
    47                 fprintf(output, "    0.000 ");
    48                 i = 106;
    49             } else {
    50                 fprintf(output, "%c", data2[i]);
    51             }
    52         }
    53         fprintf(output, "  ");
    54         for (i = 116; i <= 124; i++) {
    55             if (data2[121] == ' ') {
    56                 fprintf(output, "   0.000");
    57                 i = 125;
    58             } else {
    59                 fprintf(output, "%c", data2[i]);
    60             }
    61         }
    62         fprintf(output, "  ");
    63         for (i = 165; i <= 174; i++) {
    64             if (data2[170] == ' ') {
    65                 fprintf(output, "     0.000 ");
    66                 i = 175;
    67             } else {
    68                 fprintf(output, "%c", data2[i]);
    69             }
    70         }
    71         fprintf(output, "  ");
    72         for (i = 175; i <= 184; i++) {
    73             if (data2[180] == ' ') {
    74                 fprintf(output, "    0.000 ");
    75                 i = 185;
    76             } else {
    77                 fprintf(output, "%c", data2[i]);
    78             }
    79         }
    80 
    81 
     84
     85        for(int j = 3; j < argc; j++) {
     86            if(!strncmp(argv[j], "1", 2) ) {
     87                for (i = 7; i <= 14; i++) {
     88                    fprintf(output, "%c", data2[i]);
     89                }
     90            }
     91            if(!strncmp(argv[j], "2", 2) ) {
     92                if (data2[23] == ' ') {
     93                    fprintf(output, "   0.000 ");
     94                } else {
     95                    for (i = 18; i <= 26; i++) {
     96                        if (i == 18 && data2[i+1] == '-' && data2[i+2] == '.') {
     97                            fprintf(output, "-0.");
     98                            i = 21;
     99                        }
     100                        if (i == 19) {
     101                            if (data2[i] == ' ' && data2[i+1] == '.') {
     102                                fprintf(output, "0");
     103                                i++;
     104                            }
     105                        }
     106                        fprintf(output, "%c", data2[i]);
     107                    }
     108                }
     109            }
     110            if(!strncmp(argv[j], "3", 2) ) {
     111                if (data2[42] == ' ') {
     112                    fprintf(output, "   0.000 ");
     113                } else {
     114                    for (i = 37; i <= 45; i++) {
     115                        if (i == 37 && data2[i+1] == '-' && data2[i+2] == '.') {
     116                            fprintf(output, "-0.");
     117                            i = 40;
     118                        }
     119                        if (i == 38) {
     120                            if (data2[i] == ' ' && data2[i+1] == '.') {
     121                                fprintf(output, "0");
     122                                i++;
     123                            }
     124                        }
     125                        fprintf(output, "%c", data2[i]);
     126                    }
     127                }
     128            }
     129            if(!strncmp(argv[j], "4", 2) ) {
     130                if (data2[139] == ' ') {
     131                    fprintf(output, "    0.000 ");
     132                    //                    i = 144;
     133                } else {
     134                    for (i = 134; i <= 143; i++) {
     135                        if (i == 135 && data2[i+1] == '-' && data2[i+2] == '.') {
     136                            fprintf(output, "-0.");
     137                            i = 138;
     138                        }
     139                        if (i == 136) {
     140                            if (data2[i] == ' ' && data2[i+1] == '.') {
     141                                fprintf(output, "0");
     142                                i++;
     143                            }
     144                        }
     145                        fprintf(output, "%c", data2[i]);
     146                    }
     147                }
     148            }
     149            if(!strncmp(argv[j], "5", 2) ) {
     150                if (data2[149] == ' ') {
     151                    fprintf(output, "    0.000 ");
     152                } else {
     153                    for (i = 144; i <= 153; i++) {
     154                        if (i == 145 && data2[i+1] == '-' && data2[i+2] == '.') {
     155                            fprintf(output, "-0.");
     156                            i = 148;
     157                        }
     158                        if (i == 146) {
     159                            if (data2[i] == ' ' && data2[i+1] == '.') {
     160                                fprintf(output, "0");
     161                                i++;
     162                            }
     163                        }
     164                        fprintf(output, "%c", data2[i]);
     165                    }
     166                }
     167            }
     168            if(!strncmp(argv[j], "6", 2) ) {
     169                if (data2[102] == ' ') {
     170                    fprintf(output, "   0.000 ");
     171                } else {
     172                    for (i = 97; i <= 105; i++) {
     173                        fprintf(output, "%c", data2[i]);
     174                    }
     175                }
     176            }
     177            if(!strncmp(argv[j], "7", 2) ) {
     178                if (data2[121] == ' ') {
     179                    fprintf(output, "   0.000 ");
     180                } else {
     181                    for (i = 116; i <= 124; i++) {
     182                        fprintf(output, "%c", data2[i]);
     183                    }
     184                }
     185            }
     186            if(!strncmp(argv[j], "8", 2) ) {
     187                if (data2[170] == ' ') {
     188                    fprintf(output, "    0.000 ");
     189                } else {
     190                    for (i = 165; i <= 174; i++) {
     191                        fprintf(output, "%c", data2[i]);
     192                    }
     193                }
     194            }
     195            if(!strncmp(argv[j], "9", 2) ) {
     196                if (data2[180] == ' ') {
     197                    fprintf(output, "    0.000 ");
     198                } else {
     199                    for (i = 175; i <= 184; i++) {
     200                        fprintf(output, "%c", data2[i]);
     201                    }
     202                }
     203            }
     204            if(!strncmp(argv[j], "10", 2) ) {
     205                if (data2[63] == ' ') {
     206                    fprintf(output, "    0.000 ");
     207                } else {
     208                    for (i = 58; i <= 67; i++) {
     209                        if (i == 58 && data2[i+1] == '-' && data2[i+2] == '.') {
     210                            fprintf(output, "-0.");
     211                            i = 61;
     212                        }
     213                        if (i == 59) {
     214                            if (data2[i] == ' ' && data2[i+1] == '.') {
     215                                fprintf(output, "0");
     216                                i++;
     217                            }
     218                        }
     219                        fprintf(output, "%c", data2[i]);
     220                    }
     221                }
     222            }
     223            if(!strncmp(argv[j], "11", 2) ) {
     224                if (data2[159] == ' ') {
     225                    fprintf(output, "     0.000 ");
     226                } else {
     227                    for (i = 154; i <= 164; i++) {
     228                        if (i == 155 && data2[i+1] == '-' && data2[i+2] == '.') {
     229                            fprintf(output, "-0.");
     230                            i = 158;
     231                        }
     232                        if (i == 156) {
     233                            if (data2[i] == ' ' && data2[i+1] == '.') {
     234                                fprintf(output, "0");
     235                                i++;
     236                            }
     237                        }
     238                        fprintf(output, "%c", data2[i]);
     239                    }
     240                }
     241            }
     242            fprintf(output, "  ");
     243        }
    82244        fprintf(output, "\n");
    83245    }
     
    88250}
    89251
     252void printHeader(char *filename)
     253{
     254    if (output == NULL) {
     255        printf("\n Unable to access output file.  Output is NULL.\n");
     256    } else {
     257        fprintf(output, "#\n#  Stripped version of %s file\n#\n#\n", filename);
     258    }
     259}
     260
  • trunk/psLib/share/pslib/iers_corr.dat

    r5794 r5969  
    35935942035.00    42.35   1.793   0.000   0.000
    36036042036.00    42.178  1.784   0.000   0.000
    361 42037.00    42  1.749   0.000   0.000
     36142037.00    42.000  1.749   0.000   0.000
    36236242038.00    41.879  1.69    0.000   0.000
    36336342039.00    41.897  1.591   0.000   0.000
     
    38938942065.00    42.372  1.61    0.000   0.000
    39039042066.00    42.14   1.53    0.000   0.000
    391 42067.00    42  1.434   0.000   0.000
     39142067.00    42.000  1.434   0.000   0.000
    39239242068.00    42.095  1.347   0.000   0.000
    39339342069.00    42.37   1.385   0.000   0.000
     
    40940942085.00    42.366  1.122   0.000   0.000
    41041042086.00    42.585  1.301   0.000   0.000
    411 42087.00    42.752  1.3 0.000   0.000
     41142087.00    42.752  1.300  0.000   0.000
    41241242088.00    42.759  1.237   0.000   0.000
    41341342089.00    42.532  1.215   0.000   0.000
     
    56656642242.00    37.181  -2.28   0.000   0.000
    56756742243.00    36.551  -2.161  0.000   0.000
    568 42244.00    36.355  -2  0.000   0.000
     56842244.00    36.355  -2.000  0.000   0.000
    56956942245.00    36.571  -2.015  0.000   0.000
    57057042246.00    36.975  -2.212  0.000   0.000
     
    63163142307.00    32.054  -1.762  0.000   0.000
    63263242308.00    32.171  -1.814  0.000   0.000
    633 42309.00    32  -1.735  0.000   0.000
     63342309.00    32.000  -1.735  0.000   0.000
    63463442310.00    31.682  -1.606  0.000   0.000
    63563542311.00    31.644  -1.598  0.000   0.000
     
    72372342399.00    40.025  1.194   0.000   0.000
    72472442400.00    39.984  1.121   0.000   0.000
    725 42401.00    39.751  1.1 0.000   0.000
     72542401.00    39.751  1.100  0.000   0.000
    72672642402.00    39.503  1.135   0.000   0.000
    72772742403.00    39.346  1.128   0.000   0.000
     
    1112111242788.00    34.767  0.353   0.000   0.000
    1113111342789.00    34.811  0.267   0.000   0.000
    1114 42790.00    34.794  0.3 0.000   0.000
     111442790.00    34.794  0.300  0.000   0.000
    1115111542791.00    34.754  0.377   0.000   0.000
    1116111642792.00    34.769  0.325   0.000   0.000
     
    1322132242998.00    22.668  -4.107  0.000   0.000
    1323132342999.00    22.859  -3.942  0.000   0.000
    1324 43000.00    23  -3.703  0.000   0.000
     132443000.00    23.000  -3.703  0.000   0.000
    1325132543001.00    22.955  -3.54   0.000   0.000
    1326132643002.00    22.739  -3.523  0.000   0.000
     
    1586158643262.00    30.823  -4.916  0.000   0.000
    1587158743263.00    30.438  -5.08   0.000   0.000
    1588 43264.00    30.183  -5  0.000   0.000
     158843264.00    30.183  -5.000  0.000   0.000
    1589158943265.00    30.125  -4.748  0.000   0.000
    1590159043266.00    30.058  -4.613  0.000   0.000
     
    2066206643742.00    9.784   -4.557  0.000   0.000
    2067206743743.00    9.223   -4.334  0.000   0.000
    2068 43744.00    9   -4.218  0.000   0.000
     206843744.00    9.000   -4.218  0.000   0.000
    2069206943745.00    9.183   -4.329  0.000   0.000
    2070207043746.00    9.42    -4.554  0.000   0.000
     
    2563256344239.00    8.94    -0.017  0.000   0.000
    2564256444240.00    9.19    0.106   0.000   0.000
    2565 44241.00    9.345   0.2 0.000   0.000
     256544241.00    9.345   0.200  0.000   0.000
    2566256644242.00    9.427   0.185   0.000   0.000
    2567256744243.00    9.562   0.103   0.000   0.000
     
    2606260644282.00    9.07    -0.245  0.000   0.000
    2607260744283.00    8.773   -0.538  0.000   0.000
    2608 44284.00    8.6 -0.902  0.000   0.000
     260844284.00    8.600  -0.902  0.000   0.000
    2609260944285.00    8.907   -1.017  0.000   0.000
    2610261044286.00    9.531   -0.834  0.000   0.000
     
    2793279344469.00    1.082   -3.255  0.000   0.000
    2794279444470.00    0.771   -3.136  0.000   0.000
    2795 44471.00    0.2 -3.009  0.000   0.000
     279544471.00    0.200  -3.009  0.000   0.000
    2796279644472.00    -0.191  -2.91   0.000   0.000
    2797279744473.00    -0.189  -2.895  0.000   0.000
    2798 44474.00    0   -3.025  0.000   0.000
     279844474.00    0.000   -3.025  0.000   0.000
    2799279944475.00    0.109   -3.242  0.000   0.000
    2800280044476.00    0.14    -3.348  0.000   0.000
     
    3238323844914.00    5.739   -1.652  0.000   0.000
    3239323944915.00    6.083   -1.478  0.000   0.000
    3240 44916.00    6.2 -1.35   0.000   0.000
     324044916.00    6.200  -1.35   0.000   0.000
    3241324144917.00    6.278   -1.16   0.000   0.000
    3242324244918.00    6.344   -0.924  0.000   0.000
     
    3299329944975.00    -17.752 6.005   0.000   0.000
    3300330044976.00    -18.316 5.936   0.000   0.000
    3301 44977.00    -18.684 5.8 0.000   0.000
     330144977.00    -18.684 5.800  0.000   0.000
    3302330244978.00    -18.614 5.759   0.000   0.000
    3303330344979.00    -18.119 5.834   0.000   0.000
     
    3484348445160.00    3.069   0.674   0.000   0.000
    3485348545161.00    3.146   0.81    0.000   0.000
    3486 45162.00    3.308   1   0.000   0.000
     348645162.00    3.308   1.000   0.000   0.000
    3487348745163.00    3.322   1.143   0.000   0.000
    3488348845164.00    3.066   1.174   0.000   0.000
     
    3504350445180.00    2.038   1.305   0.000   0.000
    3505350545181.00    1.831   1.304   0.000   0.000
    3506 45182.00    1.765   1.3 0.000   0.000
     350645182.00    1.765   1.300  0.000   0.000
    3507350745183.00    1.839   1.224   0.000   0.000
    3508350845184.00    1.923   1.147   0.000   0.000
     
    3531353145207.00    -0.065  0.861   0.000   0.000
    3532353245208.00    -0.017  0.643   0.000   0.000
    3533 45209.00    0   0.609   0.000   0.000
     353345209.00    0.000   0.609   0.000   0.000
    3534353445210.00    0.012   0.649   0.000   0.000
    3535353545211.00    -0.004  0.607   0.000   0.000
     
    3548354845224.00    -1.508  0.046   0.000   0.000
    3549354945225.00    -1.266  -0.001  0.000   0.000
    3550 45226.00    -0.933  0.1 0.000   0.000
     355045226.00    -0.933  0.100  0.000   0.000
    3551355145227.00    -0.758  0.311   0.000   0.000
    3552355245228.00    -0.827  0.484   0.000   0.000
     
    3691369145367.00    3.959   1.628   0.000   0.000
    3692369245368.00    3.572   1.993   0.000   0.000
    3693 45369.00    3.24    2.2 0.000   0.000
     369345369.00    3.24    2.200  0.000   0.000
    3694369445370.00    2.983   2.117   0.000   0.000
    3695369545371.00    2.712   1.881   0.000   0.000
     
    3934393445610.00    -5.303  0.157   0.000   0.000
    3935393545611.00    -5.058  0.62    0.000   0.000
    3936 45612.00    -5.177  0.9 0.000   0.000
     393645612.00    -5.177  0.900  0.000   0.000
    3937393745613.00    -5.331  0.866   0.000   0.000
    3938393845614.00    -5.286  0.651   0.000   0.000
     
    3986398645662.00    -0.136  2.751   0.000   0.000
    3987398745663.00    0.206   2.886   0.000   0.000
    3988 45664.00    0.5 2.984   0.000   0.000
     398845664.00    0.500  2.984   0.000   0.000
    3989398945665.00    0.717   3.07    0.000   0.000
    3990399045666.00    0.771   3.192   0.000   0.000
     
    4000400045676.00    0.122   3.994   0.000   0.000
    4001400145677.00    0.432   4.171   0.000   0.000
    4002 45678.00    0.678   4.3 0.000   0.000
     400245678.00    0.678   4.300  0.000   0.000
    4003400345679.00    0.821   4.289   0.000   0.000
    4004400445680.00    0.948   4.206   0.000   0.000
    4005400545681.00    1.109   4.207   0.000   0.000
    4006 45682.00    1.2 4.376   0.000   0.000
     400645682.00    1.200  4.376   0.000   0.000
    4007400745683.00    1.11    4.663   0.000   0.000
    4008400845684.00    0.904   4.956   0.000   0.000
     
    4035403545711.00    2.564   4.283   0.000   0.000
    4036403645712.00    2.823   4.147   0.000   0.000
    4037 45713.00    3.075   4   0.000   0.000
     403745713.00    3.075   4.000   0.000   0.000
    4038403845714.00    3.274   3.828   0.000   0.000
    4039403945715.00    3.245   3.487   0.000   0.000
     
    4057405745733.00    6.862   3.04    0.000   0.000
    4058405845734.00    6.524   2.835   0.000   0.000
    4059 45735.00    5.7 2.706   0.000   0.000
     405945735.00    5.700  2.706   0.000   0.000
    4060406045736.00    4.621   2.704   0.000   0.000
    4061406145737.00    3.543   2.888   0.000   0.000
     
    4077407745753.00    3.549   2.085   0.000   0.000
    4078407845754.00    3.615   2.083   0.000   0.000
    4079 45755.00    3.7 2.145   0.000   0.000
     407945755.00    3.700  2.145   0.000   0.000
    4080408045756.00    3.473   2.222   0.000   0.000
    4081408145757.00    3.065   2.233   0.000   0.000
     
    4168416845844.00    4.832   -0.59   0.000   0.000
    4169416945845.00    4.443   -0.459  0.000   0.000
    4170 45846.00    3.7 -0.213  0.000   0.000
     417045846.00    3.700  -0.213  0.000   0.000
    4171417145847.00    2.843   0.023   0.000   0.000
    4172417245848.00    2.126   0.099   0.000   0.000
     
    4243424345919.00    -6.273  0.211   0.000   0.000
    4244424445920.00    -6.014  0.447   0.000   0.000
    4245 45921.00    -5.757  0.3 0.000   0.000
     424545921.00    -5.757  0.300  0.000   0.000
    4246424645922.00    -5.544  -0.069  0.000   0.000
    4247424745923.00    -5.493  -0.405  0.000   0.000
     
    4384438446060.00    1.344   3.718   0.000   0.000
    4385438546061.00    1.428   3.92    0.000   0.000
    4386 46062.00    1.3 4.137   0.000   0.000
     438646062.00    1.300  4.137   0.000   0.000
    4387438746063.00    1.033   4.246   0.000   0.000
    4388438846064.00    0.766   4.277   0.000   0.000
     
    4399439946075.00    1.97    3.983   0.000   0.000
    4400440046076.00    1.522   4.333   0.000   0.000
    4401 46077.00    0.8 4.626   0.000   0.000
     440146077.00    0.800  4.626   0.000   0.000
    4402440246078.00    0.003   4.884   0.000   0.000
    4403440346079.00    -0.671  5.09    0.000   0.000
     
    4470447046146.00    5.113   1.86    0.000   0.000
    4471447146147.00    4.972   1.862   0.000   0.000
    4472 46148.00    4.868   1.7 0.000   0.000
     447246148.00    4.868   1.700  0.000   0.000
    4473447346149.00    4.822   1.537   0.000   0.000
    4474447446150.00    4.771   1.408   0.000   0.000
     
    4488448846164.00    4.747   0.484   0.000   0.000
    4489448946165.00    4.879   0.41    0.000   0.000
    4490 46166.00    5   0.264   0.000   0.000
     449046166.00    5.000   0.264   0.000   0.000
    4491449146167.00    5.018   0.147   0.000   0.000
    4492449246168.00    5.002   0.178   0.000   0.000
     
    4500450046176.00    5.808   0.823   0.000   0.000
    4501450146177.00    5.945   0.577   0.000   0.000
    4502 46178.00    6.1 0.27    0.000   0.000
     450246178.00    6.100  0.27    0.000   0.000
    4503450346179.00    6.22    -0.28   0.000   0.000
    4504450446180.00    6.345   -1.178  0.000   0.000
     
    4558455846234.00    -0.629  -0.591  0.000   0.000
    4559455946235.00    -0.406  -0.84   0.000   0.000
    4560 46236.00    0.1 -0.766  0.000   0.000
     456046236.00    0.100  -0.766  0.000   0.000
    4561456146237.00    0.599   -0.619  0.000   0.000
    4562456246238.00    0.909   -0.661  0.000   0.000
     
    4565456546241.00    1.671   -0.649  0.000   0.000
    4566456646242.00    1.531   -0.3    0.000   0.000
    4567 46243.00    1   0.123   0.000   0.000
     456746243.00    1.000   0.123   0.000   0.000
    4568456846244.00    0.25    0.479   0.000   0.000
    4569456946245.00    -0.387  0.652   0.000   0.000
     
    4659465946335.00    -6.938  0.214   0.000   0.000
    4660466046336.00    -7.223  0.595   0.000   0.000
    4661 46337.00    -7.566  1   0.000   0.000
     466146337.00    -7.566  1.000   0.000   0.000
    4662466246338.00    -7.81   1.225   0.000   0.000
    4663466346339.00    -7.853  1.188   0.000   0.000
     
    4883488346559.00    4.507   -0.005  0.000   0.000
    4884488446560.00    4.574   -0.246  0.000   0.000
    4885 46561.00    4.6 -0.292  0.000   0.000
     488546561.00    4.600  -0.292  0.000   0.000
    4886488646562.00    4.567   -0.178  0.000   0.000
    4887488746563.00    4.458   -0.148  0.000   0.000
     
    5019501946695.00    -8.762  0.35    0.000   0.000
    5020502046696.00    -8.891  0.407   0.000   0.000
    5021 46697.00    -8.7    0.6 0.000   0.000
     502146697.00    -8.7    0.600  0.000   0.000
    5022502246698.00    -8.267  0.852   0.000   0.000
    5023502346699.00    -7.799  0.972   0.000   0.000
     
    5059505946735.00    -5.603  1.789   0.000   0.000
    5060506046736.00    -5.247  2.027   0.000   0.000
    5061 46737.00    -4.795  2.2 0.000   0.000
     506146737.00    -4.795  2.200  0.000   0.000
    5062506246738.00    -4.383  2.101   0.000   0.000
    5063506346739.00    -4.163  1.671   0.000   0.000
     
    5094509446770.00    -3.056  2.302   0.000   0.000
    5095509546771.00    -2.962  2.037   0.000   0.000
    5096 46772.00    -2.605  2.2 0.000   0.000
     509646772.00    -2.605  2.200  0.000   0.000
    5097509746773.00    -2.239  2.655   0.000   0.000
    5098509846774.00    -2.014  3.083   0.000   0.000
     
    5190519046866.00    0.167   0.815   0.000   0.000
    5191519146867.00    0.146   0.884   0.000   0.000
    5192 46868.00    0.1 1.018   0.000   0.000
     519246868.00    0.100  1.018   0.000   0.000
    5193519346869.00    0.054   1.078   0.000   0.000
    5194519446870.00    -0.092  1.006   0.000   0.000
     
    5206520646882.00    0.446   0.102   0.000   0.000
    5207520746883.00    0.536   0.362   0.000   0.000
    5208 46884.00    0.6 0.5 0.000   0.000
     520846884.00    0.600   0.500  0.000   0.000
    5209520946885.00    0.514   0.543   0.000   0.000
    5210521046886.00    0.296   0.506   0.000   0.000
     
    5487548747163.00    -3.151  2.267   0.000   0.000
    5488548847164.00    -3.083  2.276   0.000   0.000
    5489 47165.00    -2.964  2.6 0.000   0.000
     548947165.00    -2.964  2.600  0.000   0.000
    5490549047166.00    -2.683  2.845   0.000   0.000
    5491549147167.00    -2.267  2.817   0.000   0.000
     
    5518551847194.00    -2.042  1.928   0.000   0.000
    5519551947195.00    -1.592  1.964   0.000   0.000
    5520 47196.00    -1.177  2   0.000   0.000
     552047196.00    -1.177  2.000   0.000   0.000
    5521552147197.00    -0.958  2.033   0.000   0.000
    5522552247198.00    -0.985  2.086   0.000   0.000
    5523552347199.00    -1.242  2.077   0.000   0.000
    5524552447200.00    -1.663  1.831   0.000   0.000
    5525 47201.00    -2.093  1.4 0.000   0.000
     552547201.00    -2.093  1.400  0.000   0.000
    5526552647202.00    -2.409  1.094   0.000   0.000
    5527552747203.00    -2.685  1.172   0.000   0.000
     
    5860586047536.00    -2.437  1.734   -1.900  0.300
    5861586147537.00    -2.425  1.635   -2.100  0.400
    5862 47538.00    -2.674  1.5 -2.100  0.600
     586247538.00    -2.674  1.500  -2.100  0.600
    5863586347539.00    -3.06   1.435   -2.200  0.700
    5864586447540.00    -3.433  1.548   -2.100  0.800
     
    6169616947845.00    -6.495  0.191   -4.300  -1.900
    6170617047846.00    -6.337  0.431   -4.300  -1.700
    6171 47847.00    -6.434  0.3 -4.300  -1.600
     617147847.00    -6.434  0.300  -4.300  -1.600
    6172617247848.00    -6.643  -0.055  -4.400  -1.400
    6173617347849.00    -6.754  -0.067  -4.400  -1.300
     
    6190619047866.00    -6.361  1.201   -3.700  -0.200
    6191619147867.00    -6.593  1.458   -4.700  0.100
    6192 47868.00    -6.927  1.7 -5.600  0.000
     619247868.00    -6.927  1.700  -5.600  0.000
    6193619347869.00    -7.324  1.798   -6.100  -0.100
    6194619447870.00    -7.52   1.614   -6.400  -0.300
     
    6473647348149.00    -15.637 -3.255  -14.800 -3.800
    6474647448150.00    -15.505 -3.212  -14.600 -4.000
    6475 48151.00    -15.167 -3  -14.700 -4.000
     647548151.00    -15.167 -3.000  -14.700 -4.000
    6476647648152.00    -14.817 -2.653  -14.800 -3.900
    6477647748153.00    -14.667 -2.311  -14.800 -3.600
     
    7164716448840.00    -20.052 -5.604  -20.200 -5.700
    7165716548841.00    -19.775 -5.851  -20.500 -5.800
    7166 48842.00    -19.707 -6  -20.400 -5.800
     716648842.00    -19.707 -6.000  -20.400 -5.800
    7167716748843.00    -19.894 -5.974  -20.300 -5.900
    7168716848844.00    -20.048 -5.886  -19.800 -6.000
     
    7406740649082.00    -11.705 -6.115  -12.000 -6.300
    7407740749083.00    -11.894 -5.905  -12.300 -6.300
    7408 49084.00    -12 -5.965  -12.600 -6.300
     740849084.00    -12.000 -5.965  -12.600 -6.300
    7409740949085.00    -12.022 -6.176  -12.700 -6.500
    7410741049086.00    -12.033 -6.353  -12.700 -6.700
     
    7707770749383.00    -18.006 -3.203  -18.800 -3.600
    7708770849384.00    -18.573 -3.17   -19.200 -3.500
    7709 49385.00    -19 -3.232  -19.800 -3.400
     770949385.00    -19.000 -3.232  -19.800 -3.400
    7710771049386.00    -19.285 -3.282  -20.000 -3.600
    7711771149387.00    -19.509 -3.312  -20.100 -3.900
     
    8178817849854.00    -22.662 -9.132  -22.500 -8.900
    8179817949855.00    -22.48  -9.105  -22.100 -8.900
    8180 49856.00    -22.234 -9  -21.700 -8.800
     818049856.00    -22.234 -9.000  -21.700 -8.800
    8181818149857.00    -22.089 -8.885  -21.500 -8.800
    8182818249858.00    -22.162 -8.757  -21.300 -8.700
     
    8724872450400.00    -37.337 -6.343  -36.800 -6.600
    8725872550401.00    -37.116 -6.538  -36.600 -6.600
    8726 50402.00    -37 -6.398  -36.300 -6.500
     872650402.00    -37.000 -6.398  -36.300 -6.500
    8727872750403.00    -37.006 -6.1    -36.200 -6.400
    8728872850404.00    -37.069 -5.847  -36.200 -6.100
     
    8982898250658.00    -45.376 -8.698  -45.900 -8.800
    8983898350659.00    -45.887 -8.873  -45.700 -8.900
    8984 50660.00    -46.307 -9  -45.400 -9.000
     898450660.00    -46.307 -9.000  -45.400 -9.000
    8985898550661.00    -46.412 -9.089  -45.000 -9.000
    8986898650662.00    -46.22  -9.118  -44.700 -8.800
     
    9557955751233.00    -47.075 -5.107  -47.100 -5.000
    9558955851234.00    -47.155 -5.161  -46.700 -5.200
    9559 51235.00    -47 -5.216  -46.200 -5.400
     955951235.00    -47.000 -5.216  -46.200 -5.400
    9560956051236.00    -46.668 -5.242  -45.800 -5.500
    9561956151237.00    -46.327 -5.26   -45.500 -5.700
     
    9563956351239.00    -46.061 -5.504  -45.400 -5.700
    9564956451240.00    -46.029 -5.696  -45.700 -5.700
    9565 51241.00    -46 -5.803  -46.000 -5.700
     956551241.00    -46.000 -5.803  -46.000 -5.700
    9566956651242.00    -46.084 -5.799  -46.300 -5.600
    9567956751243.00    -46.347 -5.754  -46.500 -5.600
  • trunk/psLib/src/astro/psEarthOrientation.c

    r5814 r5969  
    88 *  @author Robert Daniel DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-12-20 05:05:37 $
     10 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-01-12 20:40:12 $
    1212 *
    1313 *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    338338    } else
    339339        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
    343341    r_p->x = mu_p * directionVector->x + a * rp->x;
    344342    r_p->y = mu_p * directionVector->y + a * rp->y;
    345343    r_p->z = mu_p * directionVector->z + a * rp->z;
    346344
     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
    347351    psSphere *r_pSphere = psCubeToSphere(r_p);
    348352    if (r_pSphere == NULL)
     
    350354
    351355    *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     */
    362356    psFree(rp);
    363357    psFree(r_p);
     
    387381                    sunVector->y*actualVector->y +
    388382                    sunVector->z*actualVector->z);
     383    printf(" Theta = %lf\n", theta);
     384    //    theta = acos(-theta);
     385    //    printf("\n Theta = %lf\n", theta);
    389386    double r0 = PS_AU * tan(theta);
    390387    double deflection = 4.0*PS_G*PS_M/(PS_C0*PS_C0*r0);
     
    392389    // make sure the deflection is not greater than 1.75 arcsec
    393390    double limit = SEC_TO_RAD(1.75);
     391    printf(" deflection = %.13g\n", deflection);
     392    printf(" limit = %lf\n", limit);
    394393    if (deflection > limit) {
    395394        //       deflection = limit;
     
    415414    theta = 0.0;
    416415    double phi = 0.0;
    417     deflection = SEC_TO_RAD(deflection);
     416    //    deflection = SEC_TO_RAD(deflection);
    418417    theta = atan(r0/PS_AU) * tan(deflection);
     418    printf(" Theta = %.13g\n", theta);
     419    printf(" deflection = %.13g\n", deflection);
    419420    //    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);
    421424    apparent->r = theta;
    422425    apparent->d = phi;
     426
    423427    psFree(actualVector);
    424428    psFree(sunVector);
     
    621625    }
    622626    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                }
    637643            }
    638644        }
    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
    640699    return out;
    641700}
     
    760819    T += -2451545.0;
    761820    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);
    763822    //    psSphereRot *out = psSphereRotInvert(theta, 0.0, 0.0);
    764823
     
    805864    psVector *X = psVectorAlloc(numRows, PS_TYPE_F64);
    806865    psVector *Y = psVectorAlloc(numRows, PS_TYPE_F64);
    807     psVector *S = psVectorAlloc(numRows, PS_TYPE_F64);
     866    //    psVector *S = psVectorAlloc(numRows, PS_TYPE_F64);
    808867    psVector *T = psVectorAlloc(numRows, PS_TYPE_F64);
    809868    if (bulletin == PS_IERS_A) {
     
    812871            X->data.F64[rowNum] = cols[1][rowNum];
    813872            Y->data.F64[rowNum] = cols[2][rowNum];
    814             S->data.F64[rowNum] = cols[3][rowNum];
     873            //            S->data.F64[rowNum] = cols[3][rowNum];
    815874        }
    816875    } else {
     
    819878            X->data.F64[rowNum] = cols[4][rowNum];
    820879            Y->data.F64[rowNum] = cols[5][rowNum];
    821             S->data.F64[rowNum] = cols[6][rowNum];
     880            //            S->data.F64[rowNum] = cols[6][rowNum];
    822881        }
    823882    }
     
    825884    double xOut = 0.0;
    826885    double yOut = 0.0;
    827     double sOut = 0.0;
     886    //    double sOut = 0.0;
    828887    double xTerm = 0.0;
    829888    double yTerm = 0.0;
    830     double sTerm = 0.0;
     889    //    double sTerm = 0.0;
    831890    int k = 0;
    832891    for (int i = 0; i < (numRows-1); i++) {
     
    842901                xTerm = X->data.F64[m];
    843902                yTerm = Y->data.F64[m];
    844                 sTerm = S->data.F64[m];
     903                //                sTerm = S->data.F64[m];
    845904                for (int j = k-1; j <= k+2; j++) {
    846905                    if ( m != j) {
     
    848907                        xTerm *= term;
    849908                        yTerm *= term;
    850                         sTerm *= term;
     909                        //                        sTerm *= term;
    851910                    }
    852911                }
    853912                xOut += xTerm;
    854913                yOut += yTerm;
    855                 sOut += sTerm;
     914                //                sOut += sTerm;
    856915            }
    857916            i = numRows-1;
     
    860919    out->x = SEC_TO_RAD(xOut);
    861920    out->y = SEC_TO_RAD(yOut);
    862     out->s = SEC_TO_RAD(sOut);
     921    //    out->s = SEC_TO_RAD(sOut);
    863922
    864923
     
    888947    psFree(X);
    889948    psFree(Y);
    890     psFree(S);
     949    //    psFree(S);
    891950    psFree(T);
    892951    return out;
     
    9731032    CORZ = CORZ * 0.1e-3;
    9741033
     1034    CORX = SEC_TO_RAD(CORX);
     1035    CORY = SEC_TO_RAD(CORY);
     1036    CORZ = SEC_TO_RAD(CORZ);
     1037
    9751038    out->x = CORX;
    9761039    out->y = CORY;
     
    9991062    double t4 = t*t*t*t;
    10001063
    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!
    10031064    double F[5];
     1065    // Mean Anomaly of the Moon
    10041066    F[0] = DEG_TO_RAD(134.96340251) +
    10051067           SEC_TO_RAD(1717915923.2178)*t +
     
    10341096           SEC_TO_RAD(7.4722)*t2 +
    10351097           SEC_TO_RAD(0.007702)*t3 -
    1036            SEC_TO_RAD(0.0000593)*t4;
     1098           SEC_TO_RAD(0.00005939)*t4;
    10371099
    10381100    //argument values taken from table 5.1 in IERS techical note No.32
    10391101    //http://maia.usno.navy.mil/conv2000/chapter5/tn32_c5.pdf, p38
    10401102    //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)};
    10611193
    10621194    double X = 0.0;
    10631195    double Y = 0.0;
    1064     double arg = 0.0;
     1196    //    double arg = 0.0;
    10651197    //This is from eqn 131 in the ADD - Note: pj_tj isn't included the first time.
    10661198    //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;
    10681200
    10691201    // 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);
    10901255    }
    10911256
     
    10931258    pole->x = X;
    10941259    pole->y = Y;
    1095     pole->s = SEC_TO_RAD(4.7e-5) * t;
     1260    pole->s = -SEC_TO_RAD(4.7e-5) * t;
    10961261
    10971262    return pole;
     
    11591324    /*
    11601325                psSphereRot r,p,t;
    1161      
     1326
    11621327                r.q0=sin(y/2.0);
    11631328                r.q1=0;
    11641329                r.q2=0;
    11651330                r.q3=cos(y/2.0);
    1166      
     1331
    11671332                p.q0=0;
    11681333                p.q1=sin(x/2.0);
    11691334                p.q2=0;
    11701335                p.q3=cos(x/2.0);
    1171      
     1336
    11721337                t.q0=0;
    11731338                t.q1=0;
    11741339                t.q2=sin(s/2.0);
    11751340                t.q3=cos(s/2.0);
    1176      
     1341
    11771342                // calculate t*s*r.
    11781343                psSphereRot* temp = psSphereRotCombine(NULL,&t,&p);
    11791344                out = psSphereRotCombine(NULL, temp, &r);
    11801345                psFree(temp);
    1181      
     1346
    11821347                return out;
    11831348    */
  • trunk/psLib/test/astro/tst_psEarthOrientation.c

    r5824 r5969  
    55*  @author d-Rob, MHPCC
    66*
    7 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-12-21 06:15:58 $
     7*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2006-01-12 20:40:13 $
    99*
    1010*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6464static psSphere *obj = NULL;
    6565static void objSetup(void);
     66static double greatCircle(psSphere *in1, psSphere *in2);
    6667
    6768static void objSetup(void)
     
    8081}
    8182
     83//returns the great circle ANGULAR distance between 2 positions (psSphere's)
     84static double greatCircle(psSphere *in1, psSphere *in2)
     85{
     86    double r1, r2, d1, d2;
     87    r1 = in1->r;
     88    r2 = in2->r;
     89    d1 = in1->d;
     90    d2 = in2->d;
     91    double out = 0.0;
     92    double c1, c2, cd, s1, s2, sum, ac;
     93    c1 = cos(r1);
     94    c2 = cos(r2);
     95    cd = cos(d1-d2);
     96    s1 = sin(r1);
     97    s2 = sin(r2);
     98    sum = c1*c2*cd + s1*s2;
     99    if (sum > 1.0)
     100        sum = 1.0 - (sum - 1.0);
     101
     102    ac = acos(sum);
     103    printf("\n  c1=%lf, c2=%lf, cd=%lf, s1=%lf, s2=%lf, sum=%.19g, ac=%g\n", c1,c2,cd,s1,s2,sum,ac);
     104    //    out = acos(cos(r1)*cos(r2)*cos(d1-d2) + sin(r1)*sin(r2));
     105    //    if (out != 0.0) printf("\n   in greatCircle, out = %lf\n", out);
     106    return out;
     107}
     108
    82109psS32 testAberration(void)
    83110{
    84111
    85112    psSphere *apparent = NULL;
    86     psSphere *actual = psSphereAlloc();
     113    //    psSphere *actual = psSphereAlloc();
    87114    //    psSphere *direction = psSphereAlloc();
    88115    psSphere *empty = NULL;
    89116
    90     //    actual->r = 0.2;
    91     //    actual->d = 0.2;
    92     //    actual->r = DEG_TO_RAD(45.0);
    93     //    actual->d = DEG_TO_RAD(30.0);
    94     actual->r = DEG_TO_RAD(122.9153182445501);
    95     actual->d = DEG_TO_RAD(48.562968978679194);
    96     //    direction->r = 0.2035;
    97     //    direction->d = 0.2035;
    98     //    direction->r = DEG_TO_RAD(48.0);
    99     //    direction->r = DEG_TO_RAD(-157.0);
    100     //    direction->d = DEG_TO_RAD(20.7072);
     117    psCube *actualCube = psCubeAlloc();
     118    //    actual->r = DEG_TO_RAD(122.9153182445501);
     119    //    actual->d = DEG_TO_RAD(48.562968978679194);
     120    //    actualCube->x = -0.3596195125758298;
     121    //    actualCube->y = 0.5555613903455866;
     122    //    actualCube->z = 0.7496834983724809;
     123
     124    //values from After gravity deflection//
     125    actualCube->x = -0.35961949760293604;
     126    actualCube->y = 0.5555613950298085;
     127    actualCube->z = 0.7496835020836093;
     128    psSphere *actual = psCubeToSphere(actualCube);
     129
    101130    psCube *cubeDir = psCubeAlloc();
    102131    cubeDir->x = 5148.713262821658;
     
    106135    cubeDir->y += 248.46429758174693;
    107136    cubeDir->z += 0.09694774143797581;
     137    double length = sqrt(cubeDir->x*cubeDir->x+cubeDir->y*cubeDir->y+cubeDir->z*cubeDir->z);
     138    cubeDir->x = cubeDir->x/length;
     139    cubeDir->y = cubeDir->y/length;
     140    cubeDir->z = cubeDir->z/length;
    108141    psSphere *direction = psCubeToSphere(cubeDir);
     142
    109143    double speed = sqrt(cubeDir->x*cubeDir->x + cubeDir->y*cubeDir->y + cubeDir->z*cubeDir->z);
    110144    // Speed of light in vacuum (src:NIST)
    111145    double c = 299792458.0; /* m/s */
    112     speed = speed / c;
     146    //    speed = speed / c;
     147    speed = length / c;
    113148
    114149    empty = psAberration(empty, apparent, direction, speed);
     
    127162    apparent = psAberration(apparent, actual, direction, speed);
    128163
    129     printf("\nSphere Difference  =  r,d  =  %.13g, %.13g\n",
    130            (actual->r - apparent->r), (actual->d - apparent->d));
     164    //    printf("\nSphere Difference  =  r,d  =  %.13g, %.13g\n",
     165    //           (actual->r - apparent->r), (actual->d - apparent->d));
    131166    psCube *outCube = psSphereToCube(apparent);
    132167    printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g  -- \n",
    133168           outCube->x, outCube->y, outCube->z);
    134 
     169    //expected cube values
    135170    double x, y, z;
    136171    x = -0.35963388069046304;
     
    138173    z = 0.7497078321908413;
    139174
    140     printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g  -- \n\n", x, y, z);
    141 
    142     if ( fabs(x - outCube->x) > DBL_EPSILON || fabs(y - outCube->y) > DBL_EPSILON ||
    143             fabs(z - outCube->z) > DBL_EPSILON ) {
     175    printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g  -- \n", x, y, z);
     176    printf("Cube Difference  =  x,y,z  = %.13g, %.13g, %.13g \n\n",
     177           (x - outCube->x), (y - outCube->y), (z - outCube->z) );
     178    psFree(actual);
     179    //        psFree(actualCube);
     180    actualCube->x = x;
     181    actualCube->y = y;
     182    actualCube->z = z;
     183    actual = psCubeToSphere(actualCube);
     184    double xxx = greatCircle(actual, apparent);
     185    printf("   The great circle angular distance between expected & result = %.13g\n",
     186           xxx);
     187
     188    if ( fabs(x - outCube->x) > FLT_EPSILON || fabs(y - outCube->y) > FLT_EPSILON ||
     189            fabs(z - outCube->z) > FLT_EPSILON ) {
    144190        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    145191                "psAberration returned incorrect values.\n");
    146         printf("Cube Difference  =  x,y,z  = %.13g, %.13g, %.13g \n\n",
    147                (x - outCube->x), (y - outCube->y), (z - outCube->z) );
     192        printf("\nMagnitude of expected change = x,y,z = %.13g, %.13g, %.13g \n",
     193               (actualCube->x - x), (actualCube->y - y), (actualCube->z - z) );
     194        printf("Magnitude of actual change = x,y,z = %.13g, %.13g, %.13g \n",
     195               (actualCube->x - outCube->x), (actualCube->y - outCube->y),
     196               (actualCube->z - outCube->z) );
     197        psFree(actual);
     198        //        psFree(actualCube);
     199        actualCube->x = x;
     200        actualCube->y = y;
     201        actualCube->z = z;
     202        actual = psCubeToSphere(actualCube);
     203        x = greatCircle(actual, apparent);
     204        printf("   The great circle angular distance between expected & result = %.13g\n",
     205               x);
    148206        return 3;
    149207    }
    150208
    151209    psFree(outCube);
     210    psFree(actualCube);
    152211
    153212    psFree(cubeDir);
     
    162221{
    163222
    164     psSphere *actual = psSphereAlloc();
     223    //    psSphere *actual = psSphereAlloc();
    165224    psSphere *apparent = NULL;
    166225    //    psSphere *sun = psSphereAlloc();
    167226    psSphere *empty = NULL;
    168227
    169     //    sun->r = 0.2;
    170     //    sun->d = 0.2;
    171     //    actual->r = 0.61001;
    172     //    actual->d = 0.01999;
    173     actual->r = DEG_TO_RAD(122.9153182445501);
    174     actual->d = DEG_TO_RAD(48.562968978679194);
     228    psCube *actualCube = psCubeAlloc();
     229    actualCube->x = -0.3596195125758298;
     230    actualCube->y = 0.5555613903455866;
     231    actualCube->z = 0.7496834983724809;
     232    psSphere *actual = psCubeToSphere(actualCube);
    175233    psCube *sunCube = psCubeAlloc();
    176234    sunCube->x = 1.467797790127511e11;
     
    193251
    194252    apparent = psGravityDeflection(NULL, actual, sun);
     253    psSphere *result2 = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN);
     254    apparent->r *= -1.0;
     255    apparent->d *= -1.0;
    195256    psSphere *result = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN);
    196 
    197     printf("\nActual r,d = %.13g,%.13g    Apparent r,d = %.16g, %.16g \n",
    198            actual->r, actual->d, result->r, result->d);
    199     printf("Sphere Difference  =  r,d  =  %.13g, %.13g\n",
    200            (actual->r - result->r), (actual->d - result->d));
     257    //    psSphere *result = psSphereGetOffset(apparent, actual, PS_SPHERICAL, PS_RADIAN);
     258    printf(" -- actualCube = x,y,z = %.13g, %.13g, %.13g  -- \n",
     259           actualCube->x, actualCube->y, actualCube->z);
    201260    psCube *outCube = psSphereToCube(result);
    202261    printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g  -- \n",
    203262           outCube->x, outCube->y, outCube->z);
    204     psCube *outCube2 = psSphereToCube(actual);
    205     printf(" -- actualCube = x,y,z = %.13g, %.13g, %.13g  -- \n",
     263    psCube *outCube2 = psSphereToCube(result2);
     264    printf(" -- resultCube2= x,y,z = %.13g, %.13g, %.13g  -- \n",
    206265           outCube2->x, outCube2->y, outCube2->z);
    207 
    208266    double x, y, z;
    209267    x = -0.35961949760293604;
     
    211269    z = 0.7496835020836093;
    212270
    213     printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g  -- \n\n", x, y, z);
    214 
    215     if ( fabs(x - outCube->x) > DBL_EPSILON || fabs(y - outCube->y) > DBL_EPSILON ||
    216             fabs(z - outCube->z) > DBL_EPSILON ) {
    217         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    218                 "psGravityDeflection returned incorrect values.\n");
    219         printf("Cube Difference  =  x,y,z  = %.13g, %.13g, %.13g \n",
    220                (x - outCube->x), (y - outCube->y), (z - outCube->z) );
    221         return 1;
    222     }
     271    printf(" -- expectCube = x,y,z = %.13g, %.13g, %.13g  -- \n\n", x, y, z);
     272
     273    //    if ( fabs(x - outCube->x) > DBL_EPSILON || fabs(y - outCube->y) > DBL_EPSILON ||
     274    //            fabs(z - outCube->z) > DBL_EPSILON ) {
     275    //        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     276    //                "psGravityDeflection returned incorrect values.\n");
     277    printf("expect-actual=  x,y,z  = %.11g, %.11g, %.11g \n",
     278           (x - actualCube->x), (y - actualCube->y), (z - actualCube->z) );
     279    printf("result-actual=  x,y,z  = %.11g, %.11g, %.11g \n",
     280           (outCube->x - actualCube->x), (outCube->y - actualCube->y), (outCube->z - actualCube->z) );
     281    printf("expect-result=  x,y,z  = %.11g, %.11g, %.11g \n",
     282           (x - outCube->x), (y - outCube->y), (z - outCube->z) );
     283    //        return 1;
     284    //    }
     285    psFree(result2);
     286    outCube2->x = x;
     287    outCube2->y = y;
     288    outCube2->z = z;
     289    result2 = psCubeToSphere(outCube2);
     290    psFree(result);
     291    result = psSphereGetOffset(actual, result2, PS_SPHERICAL, PS_RADIAN);
     292    printf("The apparent output sphere = r,d = %.13g, %.13g\n", apparent->r, apparent->d);
     293    printf("The expected output sphere = r,d = %.13g, %.13g\n\n", result->r, result->d);
     294    psFree(result2);
    223295
    224296    psFree(outCube);
    225297    psFree(outCube2);
    226298    psFree(sunCube);
    227 
     299    psFree(actualCube);
    228300    psFree(result);
    229301    psFree(actual);
     
    275347            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    276348                    "   psEOC_PrecessionModel return incorrect values.\n");
    277             printf("\n  Precession Model output = x,y,s = %.8g, %.8g, %.8g\n",
    278                    pmodel->x, pmodel->y, pmodel->s);
    279             printf("  Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s);
    280             printf("  A difference of:   %.13g, %.13g, %.13g\n\n",
    281                    (pmodel->x - x), (pmodel->y - y), (pmodel->s - s) );
    282349            return 4;
    283350        }
     351        printf("\n  Precession Model output = x,y,s = %.8g, %.8g, %.8g\n",
     352               pmodel->x, pmodel->y, pmodel->s);
     353        printf("  Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s);
     354        printf("  A difference of:   %.13g, %.13g, %.13g\n\n",
     355               (pmodel->x - x), (pmodel->y - y), (pmodel->s - s) );
    284356    }
    285357    psFree(pmodel);
     
    348420        yy = -0.0287618408203125;
    349421        ss = 0.0;
    350         xx = SEC_TO_RAD(xx) * 1e-6;
    351         yy = SEC_TO_RAD(yy) * 1e-6;
     422        xx = SEC_TO_RAD(xx) * 1e-3;
     423        yy = SEC_TO_RAD(yy) * 1e-3;
    352424        //        if ( fabs(pcorr->x - xx) > DBL_EPSILON || fabs(pcorr->y - yy) > DBL_EPSILON
    353425        //                || fabs(pcorr->s - ss) > DBL_EPSILON) {
    354426        //            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    355427        //                    "   psEOC_PrecessionCorr return incorrect values.\n");
    356         printf("\nPrecession Correction output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n",
     428        printf("PrecessionCorr output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n",
    357429               pcorr->x, pcorr->y, pcorr->s);
    358         printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n\n", xx, yy, ss);
    359         //            printf("  A difference of:   %.13g, %.13g, %.13g\n\n",
    360         //                   (pcorr->x - xx), (pcorr->y - yy), (pcorr->s - ss) );
     430        printf("Expected output               = x,y,s = %.13g, %.13g, %.13g\n\n", xx, yy, ss);
     431        printf("  A difference of:   %.13g, %.13g, %.13g\n\n",
     432               (pcorr->x - xx), (pcorr->y - yy), (pcorr->s - ss) );
    361433        //            return 10;
    362434        //        }
    363435    }
    364436
     437
     438    double xCorr, yCorr;
     439    xCorr = 3.05224300720406e-10;
     440    yCorr = -1.39441339235822e-10;
     441    //pcorr is the *expected* output from PrecessionModel//
    365442    pcorr->x = 2.857175590089105e-4;
    366443    pcorr->y = 2.3968739377734732e-5;
    367444    pcorr->s = -1.3970066457904322e-8;
     445    pcorr->x += xCorr;
     446    pcorr->y += yCorr;
     447    psEarthPole *precess = psEOC_PrecessionModel(time2);
     448    precess->x += xCorr;
     449    precess->y += yCorr;
     450    psSphereRot *precessNutInv = psSphereRot_CEOtoGCRS(precess);
     451    psSphereRot *precessNut = psSphereRotConjugate(NULL, precessNutInv);
    368452    //    pcorr->x += 3.05224300720406e-7;
    369453    //    pcorr->y += -1.39441339235822e-7;
     
    377461        printf("\n Error at CEOtoGCRS, output psSphereRot doesn't match expected.\n");
    378462    }
    379     printf("\n  Output sphere rotation   = %.13g,%.13g,%.13g,%.13g\n",
     463    printf("  Output sphere rotation   = %.13g,%.13g,%.13g,%.13g\n",
    380464           pni->q0, pni->q1, pni->q2, pni->q3);
    381465    printf("  Expected sphere rotation = %.13g,%.13g,%.13g\n", q0,q1,q2);
     466    printf("  MY sphere rotation       = %.13g,%.13g,%.13g\n",
     467           precessNutInv->q0, precessNutInv->q1, precessNutInv->q2);
    382468    psCube *objC = psCubeAlloc();
    383469    //    objC->x = -3.5963388069046304;
    384470    //    objC->y = 0.5555192509816625;
    385471    //    objC->z = 0.7497078321908413;
    386     objSetup();
     472    //    objSetup();
     473
     474    //This is the sphere rotation for the *expected* precession output//
    387475    psSphereRot *pn = psSphereRotConjugate(NULL, pni);
    388     //    psSphere *sphere = psCubeToSphere(objC);
    389     psSphere *sphere = psSphereAlloc();
    390     *sphere = *obj;
    391     psFree(obj);
    392     psSphere *result = psSphereRotApply(NULL, pn, sphere);
    393     objC->x = -0.3598480726985338;
    394     objC->y = 0.5555012823608123;
    395     objC->z = 0.7496183628158023;
    396     psFree(sphere);
    397     sphere = psCubeToSphere(objC);
     476
     477    //    psSphere *sphere = psSphereAlloc();
     478    //    *sphere = *obj;
     479    //    psFree(obj);
     480
     481    //create a psSphere for (from) the start position given in eoc_testing//
     482    objC->x = -0.35963388069046304;
     483    objC->y = 0.5555192509816625;
     484    objC->z = 0.7497078321908413;
     485    psSphere *sphere = psCubeToSphere(objC);
     486
     487    psSphere *expect = psSphereRotApply(NULL, pn, sphere);
     488    //expected results below - stored in:  sphere  //
     489    double x,y,z;
     490    x = -0.3598480726985338;
     491    y = 0.5555012823608123;
     492    z = 0.7496183628158023;
     493    printf("\n<<Expected out      = x,y,z = %.13g, %.13g, %.13g\n", x, y, z);
    398494    psFree(objC);
    399     printf("\n Spheres:  out = %.13g, %.13g,    expect = %.13g, %.13g\n",
    400            result->r, result->d, sphere->r, sphere->d);
    401     double xx = acos(cos(result->r)*cos(sphere->r)*cos(result->d - sphere->d) + sin(result->r)*sin(sphere->r));
    402     printf("GREAT CIRCLE DIFFERENCE = %.13g \n\n", xx);
     495    objC = psSphereToCube(expect);
     496    printf("<<Expected out real = x,y,z = %.13g, %.13g, %.13g\n", objC->x, objC->y, objC->z);
     497    printf("     Difference     =      %.13g, %.13g, %.13g\n", objC->x-x, objC->y-y, objC->z-z);
     498    x = objC->x;
     499    y = objC->y;
     500    z = objC->z;
     501    psSphere *result = psSphereRotApply(NULL, precessNut, sphere);
     502    psFree(objC);
     503    objC = psSphereToCube(result);
     504    printf("<<Resulting out     = x,y,z = %.13g, %.13g, %.13g\n", objC->x, objC->y, objC->z);
     505    printf("     Difference     =      %.13g, %.13g, %.13g\n\n", objC->x-x, objC->y-y, objC->z-z);
     506
     507    double xx = greatCircle(result, expect);
     508    printf("GREAT CIRCLE DIFFERENCE = %.13g \n", xx);
     509    psFree(precess);
     510    psFree(precessNut);
     511    psFree(precessNutInv);
     512    psFree(expect);
     513    psFree(objC);
    403514
    404515    psFree(sphere);
    405516    psFree(result);
    406517    psFree(pn);
    407     //    psFree(obj);
    408518    psFree(pni);
    409 
    410519    psFree(pcorr);
    411 
    412520    psFree(time2);
    413521    if (!p_psEOCFinalize() ) {
     
    443551    }
    444552
     553    //Test for IERS bulletin A.
     554    double x, y, s;
     555    x = -6.454389659777e-07;
     556    y = 2.112606414597e-06;
     557    s = 0.0;
     558    polarMotion = psEOC_GetPolarMotion(in, PS_IERS_A);
     559    if (polarMotion == NULL) {
     560        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     561                "psEOC_GetPolarMotion returned NULL for valid input time.\n");
     562        return 4;
     563    }
     564    if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON
     565            || fabs(polarMotion->s - s) > DBL_EPSILON) {
     566        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     567                "psEOC_GetPolarMotion returned incorrect values.\n");
     568        printf("\n  <>PolarMotion output (IERSA)   = x,y,s = %.13g, %.13g, %.13g\n",
     569               polarMotion->x, polarMotion->y, polarMotion->s);
     570        printf("\n  <>PolarMotion expected (IERSA) = x,y,s = %.13g, %.13g, %.13g\n",
     571               x, y, s);
     572        //        return 5;
     573    }
     574    psFree(polarMotion);
     575
     576
    445577    //Return valid values for correct input time.  Test IERS Bulletin B.
    446578    polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B);
    447     double x, y, s;
    448     x = -6.46014230078e-7;
    449     y = 2.11194535765e-6;
    450     s = -1.66256670849e-6;
     579    x = -6.45381397904e-07;
     580    y = 2.112819726698e-06;
     581    s = 0.0;
    451582
    452583    if (polarMotion == NULL) {
     
    465596        //        return 3;
    466597    }
    467     psFree(polarMotion);
    468 
    469     //Test for IERS bulletin A.
    470     x = -6.46028774489e-7;
    471     y = 2.11172234336e-6;
    472     s = -1.66257785921e-6;
    473     polarMotion = psEOC_GetPolarMotion(in, PS_IERS_A);
    474     if (polarMotion == NULL) {
    475         psError(PS_ERR_BAD_PARAMETER_NULL, false,
    476                 "psEOC_GetPolarMotion returned NULL for valid input time.\n");
    477         return 4;
    478     }
    479     if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON
    480             || fabs(polarMotion->s - s) > DBL_EPSILON) {
    481         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    482                 "psEOC_GetPolarMotion returned incorrect values.\n");
    483         printf("\n  <>PolarMotion output (IERSA)   = x,y,s = %.13g, %.13g, %.13g\n",
    484                polarMotion->x, polarMotion->y, polarMotion->s);
    485         printf("\n  <>PolarMotion expected (IERSA) = x,y,s = %.13g, %.13g, %.13g\n",
    486                x, y, s);
    487         //        return 5;
    488     }
    489 
    490598
    491599
     
    495603        return 6;
    496604    }
    497     /*
    498         double sum = sqrt(nutationCorr->x*nutationCorr->x + nutationCorr->y*nutationCorr->y
    499                           + nutationCorr->s*nutationCorr->s);
    500         nutationCorr->x = nutationCorr->x / sum;
    501         nutationCorr->y = nutationCorr->y / sum;
    502         nutationCorr->s = nutationCorr->s / sum;
    503     */
    504     printf("  -- NutationCorr = x,y,s = %.13g, %.13g, %.13g\n\n", nutationCorr->x,
    505            nutationCorr->y, nutationCorr->s);
     605
    506606    polarMotion->x += nutationCorr->x;
    507607    polarMotion->y += nutationCorr->y;
    508608    polarMotion->s += nutationCorr->s;
    509     x = -0.13275353774074533;
    510     y = 0.4359436319739848;
    511     s = -4.2376965863576153e-10;
     609    x = -6.43607313124045e-7;
     610    y = 2.11351436973568e-6;
     611    s = -7.39617581324646e-12;
    512612
    513613    if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON
     
    525625    }
    526626
     627    psEarthPole *polarTide = psEOC_PolarTideCorr(in);
     628    polarMotion->x += polarTide->x;
     629    polarMotion->y += polarTide->y;
     630    polarMotion->s += polarTide->s;
     631    psFree(polarTide);
     632    printf("\n  PolarMotion + PolarTideCorr out = x,y,s = %.13g, %.13g, %.13g\n",
     633           polarMotion->x, polarMotion->y, polarMotion->s);
     634
    527635    if (!p_psEOCFinalize() ) {
    528636        psError(PS_ERR_BAD_PARAMETER_VALUE, false, "EOC failed finalization!\n");
     
    602710        return 3;
    603711    } else {
    604         printf("Nutation Correction output = x,y,s = %.8g, %.8g, %.8g\n\n",
     712        printf("Nutation Correction output = x,y,s = %.13g, %.13g, %.13g\n\n",
    605713               nute->x, nute->y, nute->s);
    606714    }
     
    656764    objSetup();
    657765    psSphereRot *earthRot = psSphereRotConjugate(NULL, teoceo);
    658     //    psSphere *result = psSphereRotApply(NULL, earthRot, obj);
    659     psSphere *result = psSphereRotApply(NULL, teoceo, obj);
     766    psSphere *result = psSphereRotApply(NULL, earthRot, obj);
     767    //    psSphere *result = psSphereRotApply(NULL, teoceo, obj);
    660768    psCube *cube = psSphereToCube(result);
    661769
     
    773881    psSphere *expected = psCubeToSphere(expect);
    774882    psFree(expect);
    775     double d = (6.38e6) * acos(cos(result->r)*cos(expected->r)*cos(result->d-expected->d) + sin(result->r)*sin(expected->r));
    776     printf("\n\nGreat circle difference of:  %.13g \n", d);
     883    double d = acos(cos(result->r)*cos(expected->r)*cos(result->d-expected->d) + sin(result->r)*sin(expected->r));
     884    printf("Great circle difference of:  %.13g \n", d);
    777885
    778886    psFree(expected);
     
    781889
    782890
    783     psSphere *test = psSphereAlloc();
    784     test->r = 0.0;
    785     test->d = 0.0;
    786     test = psSphereRotApply(test, rot, test);
    787     printf("\n  Sphere -test- has values r,d = %.8g, %.8g \n", test->r, test->d);
     891    //    psSphere *test = psSphereAlloc();
     892    //    test->r = 0.0;
     893    //    test->d = 0.0;
     894    //    test = psSphereRotApply(test, rot, test);
     895    //    printf("\n  Sphere -test- has values r,d = %.8g, %.8g \n", test->r, test->d);
    788896
    789897    psFree(precessionNutation);
     
    791899    psFree(cube);
    792900
    793     psFree(test);
     901    //    psFree(test);
    794902    psFree(rot);
    795903    psFree(in);
     
    875983    z = 0.7496169753347885;
    876984    printf("\n  Cube -expected- has x,y,z = %.13g,  %.13g, %.13g \n", x, y, z );
     985    temp->x = x;
     986    temp->y = y;
     987    temp->z = z;
     988    psSphere *sphere = psCubeToSphere(temp);
     989    double d = greatCircle(sphere, test);
     990
     991    printf("Great circle difference of:  %.13g \n", d);
     992    psFree(sphere);
    877993
    878994    psFree(newRot);
Note: See TracChangeset for help on using the changeset viewer.