00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #include <lal/LALBarycenter.h>
00067 #include <lal/LALInitBarycenter.h>
00068 #include <lal/DetectorSite.h>
00069 #include <lal/Date.h>
00070
00071 NRCSID(LALBARYCENTERTESTC,"$Id: LALBarycenterTest.c,v 1.11 2007/06/08 14:41:52 bema Exp $");
00072
00073
00074 #define LALBARYCENTERTESTC_ENOM 0
00075 #define LALBARYCENTERTESTC_EOPEN 1
00076 #define LALBARYCENTERTESTC_EOUTOFRANGEE 4
00077 #define LALBARYCENTERTESTC_EOUTOFRANGES 8
00078 #define LALBARYCENTERTESTC_EBADSOURCEPOS 16
00079 #define LALBARYCENTERTESTC_EEPHFILE 32
00080
00081 #define LALBARYCENTERTESTC_MSGENOM "Nominal exit"
00082 #define LALBARYCENTERTESTC_MSGEOPEN "Error checking failed to catch missing ephemeris file."
00083 #define LALBARYCENTERTESTC_MSGEOUTOFRANGEE "Failed to catch that tgps not in range of earth.dat file"
00084 #define LALBARYCENTERTESTC_MSGEOUTOFRANGES "Failed to catch that tgps not in range of sun.dat file"
00085 #define LALBARYCENTERTESTC_MSGEBADSOURCEPOS "Failed to catch bad source position"
00086 #define LALBARYCENTERTESTC_MSGEEPHFILE "Failed to catch error reading ephemeris file."
00087
00088
00089
00090
00091
00092
00093
00094 INT4 lalDebugLevel=7;
00095
00096 BarycenterInput baryinput;
00097 EmissionTime emit;
00098 LIGOTimeGPS tGPS;
00099 EarthState earth;
00100
00101 INT4 t2000 = 630720013;
00102 INT4 t1998 = 630720013-730*86400-1;
00103
00104 int
00105 main( void )
00106 {
00107 static LALStatus stat;
00108
00109 INT4 i,k;
00110 EphemerisData *edat = NULL;
00111 LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT};
00112 INT4 tmpLeap;
00113
00114
00115
00116
00117 char eEphFileBad[] = "earth47.dat";
00118 char eEphFile[] = "earth98.dat";
00119 char sEphFile[] = "sun98.dat";
00120
00121
00122 REAL8 alpha,delta;
00123
00124
00125 #if 0
00126 REAL8 dInv;
00127 #endif
00128
00129 edat = (EphemerisData *)LALMalloc(sizeof(EphemerisData));
00130
00131 #define DEBUG 1
00132 #if (DEBUG)
00133
00134
00135
00136 (*edat).ephiles.earthEphemeris = eEphFileBad;
00137 (*edat).ephiles.sunEphemeris = sEphFile;
00138 (*edat).leap = 12;
00139 LALInitBarycenter(&stat, edat);
00140
00141 if ( stat.statusCode != LALINITBARYCENTERH_EOPEN)
00142 {
00143 printf( "Got error code %d and message '%s', but expected error code %d\n",
00144 stat.statusCode, stat.statusDescription, LALINITBARYCENTERH_EOPEN);
00145 return LALBARYCENTERTESTC_EOPEN;
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 #endif
00166
00167
00168
00169
00170
00171
00172 (*edat).ephiles.earthEphemeris = eEphFile;
00173 (*edat).ephiles.sunEphemeris = sEphFile;
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 (*edat).leap = 12;
00187
00188 LALInitBarycenter(&stat, edat);
00189 printf("stat.statusCode = %d\n",stat.statusCode);
00190 REPORTSTATUS(&stat);
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 {
00207
00208
00209
00210
00211 LALDetector cachedDetector;
00212 cachedDetector = lalCachedDetectors[LALDetectorIndexGEO600DIFF];
00213 baryinput.site.location[0]=cachedDetector.location[0]/LAL_C_SI;
00214 baryinput.site.location[1]=cachedDetector.location[1]/LAL_C_SI;
00215 baryinput.site.location[2]=cachedDetector.location[2]/LAL_C_SI;
00216 }
00217
00218 #if (DEBUG)
00219
00220
00221
00222 tGPS.gpsSeconds = t1998+5.e7;
00223 tGPS.gpsNanoSeconds = 0;
00224 LALBarycenterEarth(&stat, &earth, &tGPS, edat);
00225 if ( stat.statusCode != LALBARYCENTERH_EOUTOFRANGEE
00226 || strcmp(stat.statusDescription, LALBARYCENTERH_MSGEOUTOFRANGEE) )
00227 {
00228 printf( "Got error code %d and message %s\n",
00229 stat.statusCode, stat.statusDescription );
00230 printf( "Expected error code %d and message %s\n",
00231 LALBARYCENTERH_EOUTOFRANGEE, LALBARYCENTERH_MSGEOUTOFRANGEE);
00232 return LALBARYCENTERTESTC_EOUTOFRANGEE;
00233 }
00234
00235
00236
00237
00238 tGPS.gpsSeconds = t1998+3600;
00239 tGPS.gpsNanoSeconds = 0;
00240
00241 LALBarycenterEarth(&stat, &earth, &tGPS, edat);
00242
00243
00244 baryinput.alpha= 120.e0;
00245 baryinput.delta=60.e0;
00246 baryinput.dInv=0.e0;
00247
00248 LALBarycenter(&stat, &emit, &baryinput, &earth);
00249 if ( stat.statusCode != LALBARYCENTERH_EBADSOURCEPOS
00250 || strcmp(stat.statusDescription,LALBARYCENTERH_MSGEBADSOURCEPOS) )
00251 {
00252 printf( "Got error code %d and message %s\n",
00253 stat.statusCode, stat.statusDescription );
00254 printf( "Expected error code %d and message %s\n",
00255 LALBARYCENTERH_EBADSOURCEPOS, LALBARYCENTERH_MSGEBADSOURCEPOS);
00256 return LALBARYCENTERTESTC_EBADSOURCEPOS;
00257 }
00258
00259 #endif
00260
00261
00262
00263
00264
00265 for (i=0;i < 10; i++){
00266
00267
00268
00269 tGPS.gpsSeconds = t1998;
00270 tGPS.gpsSeconds +=i*3600*50;
00271 tGPS.gpsNanoSeconds = 0;
00272
00273
00274 LALLeapSecs(&stat, &tmpLeap, &tGPS, &lsfas);
00275 edat->leap = (INT2)tmpLeap;
00276
00277 LALBarycenterEarth(&stat, &earth, &tGPS, edat);
00278 REPORTSTATUS(&stat);
00279
00280
00281
00282
00283 for (k=0;k<3;k++){
00284
00285 alpha=(LAL_PI/12.0)*(14.e0 + 51.e0/60.e0 +
00286 +38.56024702e0/3.6e3) + LAL_PI*k/10.e0;
00287 delta=(LAL_PI/180.e0)*(12.e0+ 19.e0/60.e0
00288 +59.1434800e0/3.6e3);
00289
00290 baryinput.alpha = alpha;
00291 baryinput.delta = delta;
00292 baryinput.dInv = 0.e0;
00293
00294 baryinput.tgps.gpsSeconds = tGPS.gpsSeconds;
00295 baryinput.tgps.gpsNanoSeconds = tGPS.gpsNanoSeconds;
00296
00297 LALBarycenter(&stat, &emit, &baryinput, &earth);
00298 REPORTSTATUS(&stat);
00299
00300 printf("%d %d %d %25.17e %25.17e\n", k,
00301 tGPS.gpsSeconds, tGPS.gpsNanoSeconds,
00302 (emit.deltaT + tGPS.gpsSeconds + tGPS.gpsNanoSeconds*1.e-9),
00303 emit.tDot);
00304
00305 printf("%d %d %25.17e\n",
00306 emit.te.gpsSeconds, emit.te.gpsNanoSeconds, emit.deltaT);
00307
00308 printf("%25.17e %25.17e %25.17e\n",
00309 emit.rDetector[0],emit.rDetector[1],emit.rDetector[2]);
00310
00311 printf("%25.17e %25.17e %25.17e\n",
00312 emit.vDetector[0],emit.vDetector[1],emit.vDetector[2]);
00313 }
00314 }
00315 LALFree(edat->ephemE);
00316 LALFree(edat->ephemS);
00317 LALFree(edat);
00318 LALCheckMemoryLeaks();
00319 return 0;
00320 }
00321
00322
00323
00324