Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
IndependentDetResponseTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 David Chin, Gregory Mendell
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/*****************************************************************
21File: LALIndependentTestDetReponce.c
22
23Authors: Greg Mendell, Malik Rakhmanov Started: May 20 2003.
24
25Code: Independently tests of LALComputeDetAMResponse using
26model for F_+ and F_x given in Jaranowski, Krolak, and Schutz gr-qc/9804014.
27
28Original Author: Patrick Brian Cameron. Started: SURF Project Summer 2002.
29Original code: generated test of continuous graviational wave signals using
30the model given in Jaranowski, Krolak, and Schutz gr-qc/9804014.
31
32*******************************************************************/
33
34/* Changes:
3505/14/03 gam: Change vertexLongitudeDegrees and vertexLatitudeDegrees to vertexLongitudeRadians vertexLatitudeRadians when using FrDetector structure.
3605/15/03 gam: xArmAzimuthRadians and yArmAzimuthRadians are now measured clockwise from North; lal_gamma is the angle to the bisector of the arms, measured
37 counterclockwise from East.
3805/20/03 gam: Make code compatible with LAL instead of LALapps.
3905/20/03 gam: Last argument in LALGPStoLMST1 changed to type LALMSTUnitsAndAcc.
4005/20/03 gam: Add Brian Cameron's LALResponseFunc.c into function GenerateResponseFuncUsingLAL(int argc, char *argv[]);
4105/20/03 gam: Last argument of LALComputeDetAMResponse changed to type LALGPSandAcc.
4205/23/04 Dave Chin globally changed "time" to "timevec" to fix warnings about shadowing global declarations.
4305/30/03 gam: Change GenerateResponseFuncUsingLAL to work with params in the config file.
4409/26/03 gam: Clean up GenerateResponseFuncUsingLAL, removed unnecessary code.
4509/26/03 gam: Need to set LALTimeIntervalAndNSample time_info.accuracy = LALLEAPSEC_STRICT.
4609/29/03 gam: Return data from GenerateResponseFuncUsingLAL
4709/30/03 gam: Change name of LALComputeResponseFunc to more descriptive name GenerateResponseFuncNotUsingLAL.
4809/30/03 gam: Clean up GenerateResponseFuncNotUsingLAL, removed unnecessary code.
4909/30/03 gam: Always call GenerateResponseFuncUsingLAL
5009/30/03 gam: Removed all other unnecessary code.
5109/30/03 gam: Add code to test difference between independent and LAL values for F_+ and F_x.
5210/13/03 gam: Fix bug - when some output files requested but not others, no output occurs.
5310/13/03 gam: Use independent code from Jolien Creighton to convert GPS to Sidereal time.
5410/13/03 gam: Include GEO detector as an option.
5510/13/03 gam: Use constants independent of LAL.
5610/14/04 gam: Update definition of lal_gamma when angle between arms, zeta, != pi/2.
5710/14/04 gam: Change input RA, DEC and orientation angle (polarization angle) in config file to be in radians.
5810/14/04 gam: Use independent detector geometry values when doing independent calculation.
5910/15/04 gam: Fix bug M_PI not defined when configuring lal with --enable-gcc-flags.
60 WARNING: LHO AND LLO VALUES WERE TAKEN FROM OTHER LIGO SOURCES; GEO VALUES ARE NOT INDEPENDENT BUT TAKEN FROM LAL
61*/
62
63#include <config.h>
64
65#include <stdio.h>
66#include <stdlib.h>
67#include <math.h>
68#include <string.h>
69#include <lal/LALStdlib.h>
70#include <lal/LALgetopt.h>
71#include <lal/LALConstants.h>
72#include <lal/AVFactories.h>
73#include <lal/DetectorSite.h>
74#include <lal/DetResponse.h>
75#include <lal/Date.h>
76#include <lal/Random.h>
77
78#define usgfmt \
79 "Usage: %s [options]\n" \
80 " -h Prints this message\n" \
81 " -c configFile Use this Configure File\n" \
82 " -d lalDebugLevel Set debug level\n" \
83 "\n" \
84 "NOTE: This program can only support filenames up to 25 characters\n" \
85 " in length in the config file (this is the string length so includes\n" \
86 " the directories in the name as well), but the configFile entered at\n" \
87 " the command line can be as long as you like.\n"
88
89#define usage( program ) fprintf( stdout, usgfmt, program )
90
91/* 10/13/04 gam; independent values for pi/2, pi, and 2pi */
92#define LALIND_PI_2 1.57079633
93#define LALIND_PI 3.14159265
94#define LALIND_TWOPI 6.28318531
95/* 10/13/04 gam; allowed timing difference between LMST from LAL and independent code */
96#define LALIND_TIMETOLERANCE 32
97
98/* void GenerateResponseFuncNotUsingLAL(LALSource *pulsar, LALDetector *detector, INT4 lgthDataSet, REAL8 phiStart, REAL8Vector *timevec, REAL8Vector *fPlus, REAL8Vector *fCross); */ /* 10/14/04 gam */
99void GenerateResponseFuncNotUsingLAL(LALSource *pulsar, REAL8 inputXArmAzimuthRadians, REAL8 inputVertexLatitudeRadians, INT4 lgthDataSet, REAL8 phiStart, REAL8Vector *timevec, REAL8Vector *fPlus, REAL8Vector *fCross);
100
101void PrintLALDetector(const LALDetector *detector);
102
103void GenerateResponseFuncUsingLAL(LALStatus *status, LALSource *pulsar, LALDetector *detector, INT4 lgthDataSet, REAL8 sampleRate, LIGOTimeGPS *gps, LALDetAMResponseSeries *am_response_series_ptr);
104
105/* 10/13/03 gam: Use independent code from Jolien Creighton to convert GPS to Sidereal time. */
106REAL8 greenwich_mean_sidereal_time( INT4 gpssec, INT4 gpsnan, INT4 taiutc );
107
108/* REAL8 omegaEarth = LAL_TWOPI/LAL_DAYSID_SI; */
109/* REAL8 omegaEarthSun = LAL_TWOPI/LAL_YRSID_SI; */
110REAL8 omegaEarth = LALIND_TWOPI/(23.0*3600.0 + 56.0*60.0 + 4.091); /* Number of ordinary seconds in one sidereal day */
111REAL8 omegaEarthSun = LALIND_TWOPI/(365.0*86400.0 + 6.0*3600.0 + 9.0*60.0 + 10.0); /* Number of ordinary seconds in one sidereal year */
112REAL8 zeta = ((REAL8)LALIND_PI_2); /* 10/13/04 gam; angle between the detector arms */
113REAL8 sinZeta = 1.0; /* 10/13/04 gam */
114REAL8 zetaGEO = 94.33*((REAL8)LALIND_PI)/180.0; /* 10/13/04 gam; value from JKS paper */
115
116int main( int argc, char *argv[] )
117{
118 /* Parsing Command Line, and General Use */
119 const CHAR *program = argv[0];
120 static LALStatus status;
121 INT4 opt;
122 UINT4 i;
123 char *s;
124 int rc;
125
126 /* For reading Config File */
127 UINT4 lineSize = 80, valueSize = 25;
128 CHARVector *lineString = NULL, *valueString = NULL;
129 INT4 checkFileName = 0;
130 /* const CHAR *configFileName = NULL; */ /* 09/23/03 gam */
131 CHAR *configFileName = NULL;
132 FILE *configFile = NULL;
133
134 /* Flags */ /* 09/30/03 gam */
135 INT2 outputIndependentFPlusFCross;
136 INT2 outputLALFPlusFCross;
137 INT2 outputFPlusFCrossDiffs;
138
139 /* For computing differences */ /* 09/30/03 gam */
140 REAL4 maxFPlusDiff = 0.0;
141 REAL4 maxFCrossDiff = 0.0;
142 REAL4 tmpFPlusDiff = 0.0;
143 REAL4 tmpFCrossDiff = 0.0;
144 REAL4 tolerance = 0.0;
145 /* REAL4 tmpFPlusDenom = 0.0; */ /* Only used if testing fractional difference. Not currently used. */
146 /* REAL4 tmpFCrossDenom = 0.0; */ /* Only used if testing fractional difference. Not currently used. */
147 /* REAL4 TINY = 1.e-4; */ /* Only used if testing fractional difference. Not currently used. */
148
149 /* For File Output */
150 FILE *outFileFPlus = NULL, *outFileFCross = NULL;
151 FILE *outFileLALPlus = NULL, *outFileLALCross = NULL;
152 FILE *outFilePlusDiff = NULL, *outFileCrossDiff = NULL;
153
154 /* Used LAL structures */
155 LIGOTimeGPS gpsTime;
156 LALSource pulsar;
157 LALDetector detector;
158 LALPlaceAndGPS place_and_gps;
159 LALDetAMResponseSeries am_response_series; /* 09/30/03 gam */
160 REAL4TimeSeries plus_series, cross_series, scalar_series; /* 09/30/03 gam */
161
162 /* first num is longitude, second is latitude (radians) 05/14/03 gam */
163 LALFrDetector testFrDetector;
164
165 /* 10/14/04 gam; for independent values for detector geometry: */
166 REAL8 indXArmAzimuthRadians = 0.0;
167 REAL8 indVertexLongitudeRadians = 0.0;
168 REAL8 indVertexLatitudeRadians = 0.0;
169
170 /* Vectors For Results */
171 REAL8Vector *fPlus=NULL, *fCross=NULL;
172
173 /* Other Stuff */
174 REAL8Vector *timevec = NULL;
175 REAL8 sampleRate = 0, duration = 0;
176 UINT4 lgthDataSet = 0;
177 REAL8 phiStart = 0.0;
178 REAL8 phiStartLAL = 0.0; /* 10/13/04 gam */
179
180 /* parse options */
181 if( argc == 1)
182 {
183 usage( program );
184 return 0;
185 }
186 /* while ( 0 < ( opt = LALgetopt( argc, argv, "hc:d:" ) ) ) */ /* Added case L */ /* 05/20/03 gam */
187 while ( 0 < ( opt = LALgetopt( argc, argv, "hc:Ld:" ) ) )
188 {
189 switch ( opt )
190 {
191 case 'h':
192 usage( program );
193 return 0;
194 case 'c':
195 configFileName = LALoptarg;
196 break;
197 case 'L':
198 break;
199 case 'd':
200 break;
201 default:
202 usage( program );
203 return 1;
204 }
205 }
206
207 /*
208 * Read in Configuration File
209 */
210 configFile = fopen( configFileName, "r" );
211 if(configFile == NULL){
212 fprintf( stderr, "Error Opening ConfigFile\n" );
213 usage( program );
214 return 1;
215 }
216
217 LALCHARCreateVector(&status, &lineString, lineSize);
218 LALCHARCreateVector(&status, &valueString, valueSize);
219
220 /* Throw Away First Line Comment */
221 s = fgets(lineString->data, lineSize, configFile);
222 if (s == NULL)
223 {
224 fprintf(stderr, "Error: Unable to read ConfigFile\n");
225 exit(1);
226 }
227
228 /* Test Name */
229 strcpy(pulsar.name, "TEST");
231
232 /* R.A. of the Source */
233 s = fgets(lineString->data, lineSize, configFile);
234 if (s == NULL)
235 {
236 fprintf(stderr, "Error: Unable to read ConfigFile\n");
237 exit(1);
238 }
239 strncpy(valueString->data, lineString->data, valueSize);
240 /* pulsar.equatorialCoords.longitude = LAL_PI_180*(atof( valueString->data )); */
241 pulsar.equatorialCoords.longitude = atof( valueString->data ); /* 10/14/04 gam; input needs to be in radians already */
242
243 /* Declination of the Source */
244 s = fgets(lineString->data, lineSize, configFile);
245 if (s == NULL)
246 {
247 fprintf(stderr, "Error: Unable to read ConfigFile\n");
248 exit(1);
249 }
250 strncpy(valueString->data, lineString->data, valueSize);
251 /* pulsar.equatorialCoords.latitude = LAL_PI_180*(atof( valueString->data )); */
252 pulsar.equatorialCoords.latitude = atof( valueString->data ); /* 10/14/04 gam; input needs to be in radians already */
253
254 /* Polarization Angle */
255 s = fgets(lineString->data, lineSize, configFile);
256 if (s == NULL)
257 {
258 fprintf(stderr, "Error: Unable to read ConfigFile\n");
259 exit(1);
260 }
261 strncpy(valueString->data, lineString->data, valueSize);
262 /* pulsar.orientation = LAL_PI_180*atof( valueString->data ); */
263 pulsar.orientation = atof( valueString->data ); /* 10/14/04 gam; input needs to be in radians already */
264
265 /* Start Time */
266 s = fgets(lineString->data, lineSize, configFile);
267 if (s == NULL)
268 {
269 fprintf(stderr, "Error: Unable to read ConfigFile\n");
270 exit(1);
271 }
272 strncpy(valueString->data, lineString->data, valueSize);
273 /* gpsTime.gpsSeconds = atoi( valueString->data ); */
274 gpsTime.gpsSeconds = atol( valueString->data ); /* 09/30/03 gam */
275 gpsTime.gpsNanoSeconds = 0;
276
277 /* Sample Rate */
278 s = fgets(lineString->data, lineSize, configFile);
279 if (s == NULL)
280 {
281 fprintf(stderr, "Error: Unable to read ConfigFile\n");
282 exit(1);
283 }
284 strncpy(valueString->data, lineString->data, valueSize);
285 sampleRate = atof( valueString->data );
286
287 /* Duration */
288 s = fgets(lineString->data, lineSize, configFile);
289 if (s == NULL)
290 {
291 fprintf(stderr, "Error: Unable to read ConfigFile\n");
292 exit(1);
293 }
294 strncpy(valueString->data, lineString->data, valueSize);
295 duration = atof( valueString->data );
296
297 /* lgthDataSet = (UINT4)(duration * sampleRate) + 1; */ /* 09/30/03 gam */
298 lgthDataSet = (UINT4)(duration * sampleRate);
299
300 /* Detector Site */
301 s = fgets(lineString->data, lineSize, configFile);
302 if (s == NULL)
303 {
304 fprintf(stderr, "Error: Unable to read ConfigFile\n");
305 exit(1);
306 }
307 strncpy(valueString->data, lineString->data, valueSize);
308 if(valueString->data[0] == 'H') {
310 /* 10/14/04 gam; fill in independent values for detector geometry: */
311 indXArmAzimuthRadians = 5.6548781395;
312 indVertexLongitudeRadians = -2.08405709267;
313 indVertexLatitudeRadians = 0.810795009136;
314 }
315 if(valueString->data[0] == 'L') {
317 /* 10/14/04 gam; fill in independent values for detector geometry: */
318 indXArmAzimuthRadians = 4.40317821503;
319 indVertexLongitudeRadians = -1.5843089819;
320 indVertexLatitudeRadians = 0.533423006535;
321 }
322 if(valueString->data[0] == 'G') {
324 /* 10/14/04 gam; fill in values for detector geometry: WARNING, THESE ARE NOT INDEPENDENT BUT TAKEN FROM LAL */
325 indXArmAzimuthRadians = 1.1936010122;
326 indVertexLongitudeRadians = 0.17116780435;
327 indVertexLatitudeRadians = 0.91184982752;
328 zeta = zetaGEO; /* 10/13/04 gam; use value from above from JKS paper */
329 sinZeta = sin(zetaGEO); /* 10/13/04 gam; use value from above from JKS paper */
330 }
331 if(valueString->data[0] == 'D') {
332 fprintf( stdout, "Enter Properties of test detector\n" );
333 /* fprintf( stderr, "Detector Longitude (deg): " );
334 rc = scanf( "%lf", &testFrDetector.vertexLongitudeDegrees ); */ /* 05/14/03 gam */
335 fprintf( stdout, "Detector Longitude (radians): " );
336 rc = scanf( "%lf", &testFrDetector.vertexLongitudeRadians );
337 if (rc != 1)
338 {
339 fprintf(stderr, "Error: Unable to read input\n");
340 exit(1);
341 }
342
343 /* fprintf( stderr, "Detector Latitude (deg): " );
344 rc = scanf( "%lf" , &testFrDetector.vertexLatitudeDegrees ); */ /* 05/14/03 gam */
345 /* if (rc != 1)
346 {
347 fprintf(stderr, "Error: Unable to read input\n");
348 exit(1);
349 } */
350 fprintf( stdout, "Detector Latitude (radians): " );
351 rc = scanf( "%lf" , &testFrDetector.vertexLatitudeRadians );
352 if (rc != 1)
353 {
354 fprintf(stderr, "Error: Unable to read input\n");
355 exit(1);
356 }
357
358 /* fprintf( stderr, "Detector xArmAzimuth (deg): " ); */ /* 05/14/03 gam */
359 fprintf( stdout, "Detector xArmAzimuth (radians): " );
360 rc = scanf( "%f", &testFrDetector.xArmAzimuthRadians );
361 if (rc != 1)
362 {
363 fprintf(stderr, "Error: Unable to read input\n");
364 exit(1);
365 }
366
367 /* testFrDetector.xArmAzimuthRadians *= LAL_PI_180; */ /* 05/14/03 gam */
368 /* testFrDetector.yArmAzimuthRadians = testFrDetector.xArmAzimuthRadians + LAL_PI_2; */ /* 05/15/03 gam */
369 /* testFrDetector.yArmAzimuthRadians = testFrDetector.xArmAzimuthRadians - LAL_PI_2; */ /* 10/13/04 gam */
370 testFrDetector.yArmAzimuthRadians = testFrDetector.xArmAzimuthRadians - zeta;
371 testFrDetector.vertexElevation = 0.0;
372 testFrDetector.xArmAltitudeRadians = 0.0;
373 testFrDetector.yArmAltitudeRadians = 0.0;
374 XLALCreateDetector( &detector, &testFrDetector, LALDETECTORTYPE_IFODIFF);
375 /* 10/14/04 gam; fill in independent values for detector geometry: */
376 indXArmAzimuthRadians = testFrDetector.xArmAzimuthRadians;
377 indVertexLongitudeRadians = testFrDetector.vertexLongitudeRadians;
378 indVertexLatitudeRadians = testFrDetector.vertexLatitudeRadians;
379 }
380
381 /* tolerance */
382 s = fgets(lineString->data, lineSize, configFile);
383 if (s == NULL)
384 {
385 fprintf(stderr, "Error: Unable to read ConfigFile\n");
386 exit(1);
387 }
388 strncpy(valueString->data, lineString->data, valueSize);
389 tolerance = atof( valueString->data );
390
391 /* Open Various Output Files */
392
393 s = fgets(lineString->data, lineSize, configFile);
394 if (s == NULL)
395 {
396 fprintf(stderr, "Error: Unable to read ConfigFile\n");
397 exit(1);
398 }
399 strncpy(valueString->data, lineString->data, valueSize);
400 outputIndependentFPlusFCross = atoi( valueString->data );
401
402 if (outputIndependentFPlusFCross) {
403 /* F_Plus Filename */
404 s = fgets(lineString->data, lineSize, configFile);
405 if (s == NULL)
406 {
407 fprintf(stderr, "Error: Unable to read ConfigFile\n");
408 exit(1);
409 }
410 strncpy(valueString->data, lineString->data, valueSize);
411 i=0; checkFileName = 0;
412 while( !checkFileName ) {
413 if(valueString->data[i] == ' ') {
414 valueString->data[i] = '\0';
415 checkFileName = 1;
416 }
417 i++;
418 }
419 outFileFPlus = fopen(valueString->data, "w");
420
421 /* F_Cross Filename */
422 s = fgets(lineString->data, lineSize, configFile);
423 if (s == NULL)
424 {
425 fprintf(stderr, "Error: Unable to read ConfigFile\n");
426 exit(1);
427 }
428 strncpy(valueString->data, lineString->data, valueSize);
429 i=0; checkFileName = 0;
430 while( !checkFileName ) {
431 if(valueString->data[i] == ' ') {
432 valueString->data[i] = '\0';
433 checkFileName = 1;
434 }
435 i++;
436 }
437 outFileFCross = fopen(valueString->data, "w");
438 } else {
439 /* 10/13/03 gam; still need to get filenames */
440 s = fgets(lineString->data, lineSize, configFile);
441 if (s == NULL)
442 {
443 fprintf(stderr, "Error: Unable to read ConfigFile\n");
444 exit(1);
445 }
446 s = fgets(lineString->data, lineSize, configFile);
447 if (s == NULL)
448 {
449 fprintf(stderr, "Error: Unable to read ConfigFile\n");
450 exit(1);
451 }
452 }
453
454 s = fgets(lineString->data, lineSize, configFile);
455 if (s == NULL)
456 {
457 fprintf(stderr, "Error: Unable to read ConfigFile\n");
458 exit(1);
459 }
460 strncpy(valueString->data, lineString->data, valueSize);
461 outputLALFPlusFCross = atoi( valueString->data );
462
463 if (outputLALFPlusFCross) {
464 /* F_Plus LAL Filename */
465 s = fgets(lineString->data, lineSize, configFile);
466 if (s == NULL)
467 {
468 fprintf(stderr, "Error: Unable to read ConfigFile\n");
469 exit(1);
470 }
471 strncpy(valueString->data, lineString->data, valueSize);
472 i=0; checkFileName = 0;
473 while( !checkFileName ) {
474 if(valueString->data[i] == ' ') {
475 valueString->data[i] = '\0';
476 checkFileName = 1;
477 }
478 i++;
479 }
480 outFileLALPlus = fopen(valueString->data, "w");
481
482 /* F_Cross LAL Filename */
483 s = fgets(lineString->data, lineSize, configFile);
484 if (s == NULL)
485 {
486 fprintf(stderr, "Error: Unable to read ConfigFile\n");
487 exit(1);
488 }
489 strncpy(valueString->data, lineString->data, valueSize);
490 i=0; checkFileName = 0;
491 while( !checkFileName ) {
492 if(valueString->data[i] == ' ') {
493 valueString->data[i] = '\0';
494 checkFileName = 1;
495 }
496 i++;
497 }
498 outFileLALCross = fopen(valueString->data, "w");
499 } else {
500 /* 10/13/03 gam; still need to get filenames */
501 s = fgets(lineString->data, lineSize, configFile);
502 if (s == NULL)
503 {
504 fprintf(stderr, "Error: Unable to read ConfigFile\n");
505 exit(1);
506 }
507 s = fgets(lineString->data, lineSize, configFile);
508 if (s == NULL)
509 {
510 fprintf(stderr, "Error: Unable to read ConfigFile\n");
511 exit(1);
512 }
513 }
514
515 s = fgets(lineString->data, lineSize, configFile);
516 if (s == NULL)
517 {
518 fprintf(stderr, "Error: Unable to read ConfigFile\n");
519 exit(1);
520 }
521 strncpy(valueString->data, lineString->data, valueSize);
522 outputFPlusFCrossDiffs = atoi( valueString->data );
523
524 if (outputFPlusFCrossDiffs) {
525
526 /* F_Plus LAL Filename */
527 s = fgets(lineString->data, lineSize, configFile);
528 if (s == NULL)
529 {
530 fprintf(stderr, "Error: Unable to read ConfigFile\n");
531 exit(1);
532 }
533 strncpy(valueString->data, lineString->data, valueSize);
534 i=0; checkFileName = 0;
535 while( !checkFileName ) {
536 if(valueString->data[i] == ' ') {
537 valueString->data[i] = '\0';
538 checkFileName = 1;
539 }
540 i++;
541 }
542 outFilePlusDiff = fopen(valueString->data, "w");
543
544 /* F_Cross LAL Filename */
545 s = fgets(lineString->data, lineSize, configFile);
546 if (s == NULL)
547 {
548 fprintf(stderr, "Error: Unable to read ConfigFile\n");
549 exit(1);
550 }
551 strncpy(valueString->data, lineString->data, valueSize);
552 i=0; checkFileName = 0;
553 while( !checkFileName ) {
554 if(valueString->data[i] == ' ') {
555 valueString->data[i] = '\0';
556 checkFileName = 1;
557 }
558 i++;
559 }
560 outFileCrossDiff = fopen(valueString->data, "w");
561 } else {
562 /* 10/13/03 gam; still need to get filenames */
563 s = fgets(lineString->data, lineSize, configFile);
564 if (s == NULL)
565 {
566 fprintf(stderr, "Error: Unable to read ConfigFile\n");
567 exit(1);
568 }
569 s = fgets(lineString->data, lineSize, configFile);
570 if (s == NULL)
571 {
572 fprintf(stderr, "Error: Unable to read ConfigFile\n");
573 exit(1);
574 }
575 }
576
577 fclose(configFile);
578
579 /* Echo Parameters */
580 if( lalDebugLevel > 0)
581 {
582 /* 10/14/04 gam; reformat: */
583 fprintf( stdout, "\n" );
584 fprintf( stdout, "Source Info:\n" );
585 fprintf( stdout, "RA (radians): %e\n", pulsar.equatorialCoords.longitude );
586 fprintf( stdout, "Dec (radians): %e\n", pulsar.equatorialCoords.latitude );
587 fprintf( stdout, "Polarization (radians): %f\n", pulsar.orientation );
588 fprintf( stdout, "For GPS Seconds, NanoSeconds: %10d, %10d\n", gpsTime.gpsSeconds, gpsTime.gpsNanoSeconds );
589 fprintf( stdout, "Sampling Rate (Hz): %f\n", sampleRate );
590 fprintf( stdout, "Length of Data Set (seconds): %f\n", duration );
591 fprintf( stdout, "Ang. Vel. of Earth (radians/s) = %e\n", omegaEarth );
592 fprintf( stdout, "Ang. Vel. of Earth about the Sun (radians/s) = %e\n", omegaEarthSun );
593 fprintf( stdout, "Independent detector vertex longitude: %.11g\n", indVertexLongitudeRadians ); /* 10/14/04 gam */
594 fprintf( stdout, "Independent detector vertex latitude: %.11g\n", indVertexLatitudeRadians ); /* 10/14/04 gam */
595 fprintf( stdout, "Independent detector xArm Azimuth: %.11g\n", indXArmAzimuthRadians ); /* 10/14/04 gam */
596 PrintLALDetector( &detector );
597 }
598
599 /*
600 * Start Computing Signal
601 */
602 place_and_gps.p_detector = &detector;
603 place_and_gps.p_gps = &gpsTime;
604
605 /* Compute Local Sidereal Time at the start of the data set*/
606
607 phiStartLAL = XLALGreenwichMeanSiderealTime(place_and_gps.p_gps) + atan2(place_and_gps.p_detector->location[1], place_and_gps.p_detector->location[0]);
608 phiStartLAL = fmod(phiStartLAL,LAL_TWOPI); /* put into interval 0 to 2pi */
609 if(lalDebugLevel > 0) {
610 fprintf(stdout, "Local Mean Sidereal Time from LAL (radians) = %f\n", phiStartLAL);
611 fflush(stdout);
612 }
613
614 /****************************************************************************/
615 /* !!! 10/13/03 gam; get Local Mean Sidereal Time from independent code !!! */
616 /* Use routine from Jolien Creighton. the last argument is integer TAI - UTC which is the number
617 of leap seconds (the difference between atomic time and UTC); assume 32 is accurate enough. */
618 /* Also note sidereal time is alway the angle the vernal equinoix is west of the local
619 meridian; i.e., between 0 and 2pi in radians. However, the detector longitude is measured
620 + when east of Greenwich and - when west of Greenwich. */ /* 10/14/04 gam; update with ind detector geometry. */
621 phiStart = greenwich_mean_sidereal_time( (INT4)gpsTime.gpsSeconds, (INT4)gpsTime.gpsNanoSeconds, 32 );
622 if (indVertexLongitudeRadians > 0.0) {
623 phiStart = phiStart + indVertexLongitudeRadians; /* convert GMST to LMST for eastern longitude */
624 } else {
625 phiStart = phiStart + ((REAL8)LALIND_TWOPI) + indVertexLongitudeRadians; /* convert GMST to LMST for western logitude */
626 }
627 phiStart = fmod(phiStart,LALIND_TWOPI); /* put into interval 0 to 2pi */
628 if(lalDebugLevel > 0) {
629 fprintf( stdout, "Local Mean Sidereal Time from independent code (radians) = %f\n", phiStart );
630 fflush(stdout);
631 }
632
633 if ( fabs(phiStart - phiStartLAL)*3600.0*24.0/((REAL8)LALIND_TWOPI) > ((REAL8)LALIND_TIMETOLERANCE)) {
634 fprintf(stderr, "\nERROR: Local Mean Sidereal Time from LAL and independent code differ by more than %.6g seconds!\n\n",((REAL8)LALIND_TIMETOLERANCE));
635 fflush(stderr);
636 exit(1);
637 }
638
639 /* Intialize Arrays */
640 if(lalDebugLevel > 1) fprintf( stdout, "Creating Vectors.\n" );
641
642 LALDCreateVector(&status, &fPlus, lgthDataSet);
643 LALDCreateVector(&status, &fCross, lgthDataSet);
644 LALDCreateVector(&status, &timevec, lgthDataSet);
645
646 plus_series.data = NULL;
647 cross_series.data = NULL;
648 scalar_series.data = NULL;
649 am_response_series.pPlus = &(plus_series);
650 am_response_series.pCross = &(cross_series);
651 am_response_series.pScalar = &(scalar_series);
652
653 LALSCreateVector(&status, &(am_response_series.pPlus->data), lgthDataSet);
654 LALSCreateVector(&status, &(am_response_series.pCross->data), lgthDataSet);
655 LALSCreateVector(&status, &(am_response_series.pScalar->data), lgthDataSet);
656
657 /* make time array */
658 for(i = 0;i<lgthDataSet;i++)
659 {
660 timevec->data[i] = i*(1.0/sampleRate);
661 }
662
663 if(lalDebugLevel > 1) {
664 fprintf(stdout, "Computing Independent Response Functions.\n" );
665 fflush(stdout);
666 }
667
668 /* GenerateResponseFuncNotUsingLAL(&pulsar, &detector, lgthDataSet, phiStart, timevec, fPlus, fCross ); */ /* 10/14/04 gam */
669 GenerateResponseFuncNotUsingLAL(&pulsar, indXArmAzimuthRadians, indVertexLatitudeRadians, lgthDataSet, phiStart, timevec, fPlus, fCross );
670
671 if(lalDebugLevel > 1) {
672 fprintf(stdout, "Computing Response Functions Using LAL.\n" );
673 fflush(stdout);
674 }
675
676 GenerateResponseFuncUsingLAL(&status, &pulsar, &detector, lgthDataSet, sampleRate, &gpsTime, &am_response_series);
677
678 /* Write out files */
679 if (outputIndependentFPlusFCross) {
680 if(lalDebugLevel > 1) fprintf( stdout, "Writing Independent F_+ and F_x to File.\n" );
681 for (i = 0;i<lgthDataSet; i++) {
682 fprintf(outFileFPlus, "%.15f\n", fPlus->data[i]);
683 fprintf(outFileFCross, "%.15f\n", fCross->data[i]);
684 }
685 fclose(outFileFPlus);
686 fclose(outFileFCross);
687 }
688 if (outputLALFPlusFCross) {
689 if(lalDebugLevel > 1) fprintf( stdout, "Writing LAL F_+ and F_x to File.\n" );
690 for (i = 0; i < lgthDataSet; ++i) {
691 fprintf(outFileLALPlus, "%.15f\n", am_response_series.pPlus->data->data[i]);
692 fprintf(outFileLALCross, "%.15f\n", am_response_series.pCross->data->data[i]);
693 }
694 fclose(outFileLALPlus);
695 fclose(outFileLALCross);
696
697 }
698
699 /* Compute differences; write out differences if requested */ /* 09/30/03 gam */
700 if(lalDebugLevel > 1) fprintf( stdout, "Computing differences LAL F_+ - Independent F_+ and LAL F_x - Independent F_x.\n" );
701 if (outputFPlusFCrossDiffs && lalDebugLevel > 1) fprintf( stdout, "Writing differences LAL F_+ - Independent F_+ and LAL F_x - Independent F_x to File.\n" );
702 maxFPlusDiff = 0.0; /* initialize */
703 maxFCrossDiff = 0.0; /* initialize */
704 for (i = 0; i < lgthDataSet; ++i) {
705 tmpFPlusDiff = am_response_series.pPlus->data->data[i] - (REAL4)fPlus->data[i];
706 tmpFCrossDiff = am_response_series.pCross->data->data[i] - (REAL4)fCross->data[i];
707 /* tmpFPlusDenom and tmpFCrossDenom used for testing fractional difference. Not currently used. */
708 /* tmpFPlusDenom = fabs((REAL4)fPlus->data[i]); */
709 /* tmpFCrossDenom = fabs((REAL4)fCross->data[i]); */
710 if (outputFPlusFCrossDiffs) {
711 fprintf(outFilePlusDiff, "%.15f\n", tmpFPlusDiff);
712 fprintf(outFileCrossDiff, "%.15f\n", tmpFCrossDiff);
713 }
714 /* Code for testing absolute difference */
715 tmpFPlusDiff = fabs(tmpFPlusDiff);
716 if (tmpFPlusDiff > maxFPlusDiff) maxFPlusDiff = tmpFPlusDiff;
717 tmpFCrossDiff = fabs(tmpFCrossDiff);
718 if (tmpFCrossDiff > maxFCrossDiff) maxFCrossDiff = tmpFCrossDiff;
719 /* Code for testing fractional difference. Not currently used. */
720 /* if (tmpFPlusDenom > TINY) {
721 tmpFPlusDiff = fabs(tmpFPlusDiff)/tmpFPlusDenom;
722 if (tmpFPlusDiff > maxFPlusDiff) maxFPlusDiff = tmpFPlusDiff;
723 }
724 if (tmpFCrossDenom > TINY) {
725 tmpFCrossDiff = fabs(tmpFCrossDiff)/tmpFCrossDenom;
726 if (tmpFCrossDiff > maxFCrossDiff) maxFCrossDiff = tmpFCrossDiff;
727 } */
728 }
729 if (outputFPlusFCrossDiffs) {
730 fclose(outFilePlusDiff);
731 fclose(outFileCrossDiff);
732 }
733 if(lalDebugLevel > 0) {
734 fprintf(stdout, "\nmaxFPlusDiff, tolerance = %.6e, %.6e\n",maxFPlusDiff, tolerance );
735 fprintf(stdout, "\nmaxFCrossDiff, tolerance = %.6e, %.6e\n",maxFCrossDiff, tolerance);
736 fflush(stdout);
737 }
738
739 /* Free memory, and then test difference */
740 LALSDestroyVector(&status, &(am_response_series.pPlus->data));
741 LALSDestroyVector(&status, &(am_response_series.pCross->data));
742 LALSDestroyVector(&status, &(am_response_series.pScalar->data));
743
744 LALCHARDestroyVector( &status, &lineString );
745 LALCHARDestroyVector( &status, &valueString );
746 LALDDestroyVector( &status, &fPlus );
747 LALDDestroyVector( &status, &fCross );
748 LALDDestroyVector( &status, &timevec );
749
750 /* Test differences. End with error if difference exceed tolerance. */
751 if (maxFPlusDiff > tolerance || maxFCrossDiff > tolerance) {
752 if (maxFPlusDiff > tolerance) {
753 fprintf(stderr, "\nERROR: LAL F_+ - Independent F_+ Difference Test Failed!\n\n");
754 fflush(stderr);
755 }
756 if (maxFCrossDiff > tolerance) {
757 fprintf(stderr, "\nERROR: LAL F_x - Independent F_x Difference Test Failed!\n\n");
758 fflush(stderr);
759 }
760 exit(1);
761 }
762
763 if(lalDebugLevel > 0) {
764 fprintf(stdout, "\nALL LALIndependentTestDetResponse Tests Passed!\n");
765 fflush(stdout);
766 }
767
768 return 0;
769}
770
771/* void GenerateResponseFuncNotUsingLAL(LALSource *pulsar, LALDetector *detector, INT4 lgthDataSet,
772 REAL8 phiStart, REAL8Vector *timevec, REAL8Vector *fPlus, REAL8Vector *fCross) */
773/* 10/14/04 gam; make inputXArmAzimuthRadians and inputVertexLatitudeRadians inputs */
774void GenerateResponseFuncNotUsingLAL(LALSource *pulsar, REAL8 inputXArmAzimuthRadians, REAL8 inputVertexLatitudeRadians,
775 INT4 lgthDataSet, REAL8 phiStart, REAL8Vector *timevec, REAL8Vector *fPlus, REAL8Vector *fCross)
776{
777 REAL8 aCoeff, bCoeff;
778 /* REAL8 gammaAngle = detector->frDetector.xArmAzimuthRadians + LAL_PI_4; */ /* 05/15/03 gam */
779 /* REAL8 gammaAngle = LAL_PI_2 + LAL_PI_4 - detector->frDetector.xArmAzimuthRadians; */ /* 10/14/04 gam */
780 /* REAL8 gammaAngle = ((REAL8)LALIND_PI_2) + zeta/2.0 - detector->frDetector.xArmAzimuthRadians; */ /* 10/14/04 gam */
781 REAL8 gammaAngle = ((REAL8)LALIND_PI_2) + zeta/2.0 - inputXArmAzimuthRadians;
782
783 /* REAL8 detLatitude = LAL_PI_180*detector->frDetector.vertexLatitudeDegrees; */ /* 05/14/03 gam */
784 /* REAL8 detLatitude = detector->frDetector.vertexLatitudeRadians; */ /* 10/14/04 gam */
785 REAL8 detLatitude = inputVertexLatitudeRadians;
786 INT4 i;
787
788 /* Compute Fplus and Fcross from JKS */ /* 09/30/03 gam aCoeff and bCoeff no longer vectors */
789 for(i = 0;i<lgthDataSet; i++) {
790 aCoeff = sin(2.0*gammaAngle)*(3.0 - cos(2.0*detLatitude))*(3.0 - cos(2.0*pulsar->equatorialCoords.latitude))
791 *cos(2.0*(pulsar->equatorialCoords.longitude - phiStart - omegaEarth*timevec->data[i]))/16.0;
792 aCoeff -= 0.25*cos(2.0*gammaAngle)*sin(detLatitude)*(3 - cos(2.0*pulsar->equatorialCoords.latitude))
793 *sin(2.0*(pulsar->equatorialCoords.longitude - phiStart - omegaEarth*timevec->data[i]));
794 aCoeff += 0.25*sin(2.0*gammaAngle)*sin(2.0*detLatitude)*sin(2.0*pulsar->equatorialCoords.latitude)
795 *cos(pulsar->equatorialCoords.longitude - phiStart - omegaEarth*timevec->data[i]);
796 aCoeff -= 0.5*cos(2.0*gammaAngle)*cos(detLatitude)*sin(2.0*pulsar->equatorialCoords.latitude)
797 *sin(pulsar->equatorialCoords.longitude - phiStart - omegaEarth*timevec->data[i]);
798 aCoeff += 0.75*sin(2.0*gammaAngle)*cos(detLatitude)*cos(detLatitude)
799 *cos(pulsar->equatorialCoords.latitude)*cos(pulsar->equatorialCoords.latitude);
800
801 bCoeff = cos(2*gammaAngle)*sin(detLatitude)*sin(pulsar->equatorialCoords.latitude)
802 *cos(2.0*(pulsar->equatorialCoords.longitude-phiStart-omegaEarth*timevec->data[i]));
803 bCoeff += 0.25*sin(2.0*gammaAngle)*(3.0-cos(2.0*detLatitude))*sin(pulsar->equatorialCoords.latitude)
804 *sin(2.0*(pulsar->equatorialCoords.longitude-phiStart-omegaEarth*timevec->data[i]));
805 bCoeff += cos(2*gammaAngle)*cos(detLatitude)*cos(pulsar->equatorialCoords.latitude)
806 *cos(pulsar->equatorialCoords.longitude-phiStart-omegaEarth*timevec->data[i]);
807 bCoeff += 0.5*sin(2.0*gammaAngle)*sin(2.0*detLatitude)*cos(pulsar->equatorialCoords.latitude)
808 *sin(pulsar->equatorialCoords.longitude-phiStart-omegaEarth*timevec->data[i]);
809 /* Note: Assumes Interferometer Arms are Perpendicular */
810 fPlus->data[i] = sinZeta*( aCoeff*cos(2.0*pulsar->orientation) + bCoeff*sin(2.0*pulsar->orientation) ); /* 10/13/04 gam; add sinZeta */
811 fCross->data[i] = sinZeta*( bCoeff*cos(2.0*pulsar->orientation) - aCoeff*sin(2.0*pulsar->orientation) ); /* 10/13/04 gam; add sinZeta */
812 }
813 return;
814}
815
816void PrintLALDetector(const LALDetector *detector)
817{
818 /* REAL8 lal_gamma = detector->frDetector.xArmAzimuthRadians + LAL_PI_4; */ /* 05/15/03 gam */
819 /* REAL8 lal_gamma = LAL_PI_2 + LAL_PI_4 - detector->frDetector.xArmAzimuthRadians; */ /* 10/14/04 gam */
820 REAL8 lal_gamma = ((REAL8)LAL_PI_2) + zeta/2.0 - detector->frDetector.xArmAzimuthRadians;
821 REAL8 computedZeta = fabs(detector->frDetector.xArmAzimuthRadians - detector->frDetector.yArmAzimuthRadians); /* 10/14/04 gam */
822
823 /* 10/14/04 gam; add in rest of structure and reformat: */
824
825 if ( computedZeta > ((REAL8)LAL_PI) ) {
826 computedZeta = ((REAL8)LAL_TWOPI) - computedZeta;
827 }
828
829 fprintf( stdout,"Detector name: %s,\n", detector->frDetector.name);
830 fprintf( stdout,"Detector struct location array = { %.6e, %.6e, %.6e },\n", detector->location[0],
831 detector->location[1], detector->location[2] );
832
833 /* fprintf( stdout, "Location = %.6g, %.6g, %.6g,\n",
834 detector->frDetector.vertexLongitudeDegrees,
835 detector->frDetector.vertexLatitudeDegrees,
836 detector->frDetector.vertexElevation); */ /* 05/14/03 gam */
837 fprintf( stdout, "frDetector struct vertex long. (radians), lat. (radians), elev. = %.11g, %.11g, %.11g\n",
840 detector->frDetector.vertexElevation);
841
842 fprintf( stdout, "frDetector struct xarm azimuth, yarm azimuth, xarm altitude (clockwise from north), yarm altitude (all in radians) = %.11g, %.11g, %.11g, %.11g\n",
847
848 fprintf( stdout, "Detector angle between arms and angle to arm bisector counter-clockwise from east = %.11g, %.11g\n", computedZeta, lal_gamma);
849 fprintf( stdout, "\n" );
850 return;
851}
852
853void GenerateResponseFuncUsingLAL(LALStatus *status, LALSource *pulsar, LALDetector *detector, INT4 lgthDataSet, REAL8 sampleRate, LIGOTimeGPS *gps, LALDetAMResponseSeries *am_response_series_ptr)
854{
855 LALDetAndSource det_and_pulsar;
856 LALDetAMResponse am_response;
857 LALPlaceAndGPS place_and_gps; REAL8 lmsthours;
858
860
863
864 if (lalDebugLevel > 1) {
865 /* fprintf(stdout,"status->statusCode = %i \n", status->statusCode);
866 fprintf(stdout,"status->statusPtr->statusCode = %i \n", status->statusPtr->statusCode); */
867 printf("Source Info\n");
868 printf("RA: %e\n", pulsar->equatorialCoords.longitude);
869 printf("Dec: %e\n", pulsar->equatorialCoords.latitude);
870 printf("Psi: %e\n", pulsar->orientation);
871 printf("Detector location: (%7.4e, %7.4e, %7.4e)\n",
872 detector->location[0], detector->location[1],
873 detector->location[2]);
874 fprintf(stdout, "GPS = {%10d, %9d}\n", gps->gpsSeconds, gps->gpsNanoSeconds);
875 }
876
877 /* Add detector and source into structures */
878 place_and_gps.p_detector = detector;
879 place_and_gps.p_gps = gps;
880 det_and_pulsar.pDetector = detector;
881 det_and_pulsar.pSource = pulsar;
882
883 lmsthours = XLALGreenwichMeanSiderealTime(place_and_gps.p_gps) + atan2(place_and_gps.p_detector->location[1], place_and_gps.p_detector->location[0]);
884
885 if (lalDebugLevel > 1) {
886 fprintf(stdout, "In GenerateResponseFuncUsingLAL LMST = %7e \n", lmsthours); /* 10/13/04 gam */
887 }
888
889 /* LALComputeDetAMResponse(&status, &am_response, &det_and_pulsar, &gps); */ /* 05/20/03 gam */
890 LALComputeDetAMResponse(status->statusPtr, &am_response, &det_and_pulsar, gps);
892
893 time_info.epoch.gpsSeconds = gps->gpsSeconds;
894 time_info.epoch.gpsNanoSeconds = gps->gpsNanoSeconds;
895 time_info.deltaT = 1.0/sampleRate;
896 time_info.nSample = lgthDataSet;
897
898 if (lalDebugLevel > 1) {
899 printf("Start computing AM response vectors\n");
900 /* fprintf(stdout, "am_response_series_ptr->pPlus->data->length = %d\n", am_response_series_ptr->pPlus->data->length);
901 fprintf(stdout, "am_response_series_ptr->pCross->data->length = %d\n", am_response_series_ptr->pCross->data->length);
902 fprintf(stdout, "am_response_series_ptr->pScalar->data->length = %d\n", am_response_series_ptr->pScalar->data->length); */
903 fprintf(stdout, "timeinfo = %d %d %g %d\n",time_info.epoch.gpsSeconds,time_info.epoch.gpsNanoSeconds,time_info.deltaT,time_info.nSample);
904 fflush(stdout);
905 }
906
907 LALComputeDetAMResponseSeries(status->statusPtr, am_response_series_ptr, &det_and_pulsar, &time_info);
909
910 if (lalDebugLevel > 1) {
911 printf("Done computing AM response vectors\n");
912 /* printf("am_response_series_ptr->pPlus->data->length = %d\n", am_response_series_ptr->pPlus->data->length);
913 printf("am_response_series_ptr->pCross->data->length = %d\n", am_response_series_ptr->pCross->data->length);
914 printf("am_response_series_ptr->pScalar->data->length = %d\n", am_response_series_ptr->pScalar->data->length); */
915 }
916
918 RETURN(status);
919}
920
921
922/* 10/13/03 gam: Use independent code from Jolien Creighton to convert GPS to Sidereal time. */
923/* Notes from Jolien:
924Here is my GPS -> Sidereal conversion routine, which is entirely
925independent of the code in LAL. (I didn't write the code in LAL,
926and I didn't even look at it while writing this routine.) There
927are some references in comments in the code.
928
929For some reason, I represent sidereal time in the range [0,2pi).
930You can change a couple of lines at the end if you want it in a
931different range.
932
933The code was not written to be greatly efficient. Instead it is
934a rather plodding and straightforward implementation for testing
935purposes.
936
937I have checked the routine with the USNO observatory sidereal time
938calculator and I find that it agrees to around ~1ms or less, I think...
939(you should double check).
940
941You need to give the routine the integer TAI - UTC which is the number
942of leap seconds (the difference between atomic time and UTC). The
943value is currently 32 I think (and has been for the past year or two).
944This is, of course, non-algorithmic so you just have to look it up
945(and wait for new leap seconds to be announced).
946
947If you want accuracy better than about 1s of sidereal time, you probably
948need to do a very careful monitoring of the Earth's motion, so this
949routine will not be sufficient. It does give you the "correct" sidereal
950time, but the exact position of quasars will drift around by up to a
951fraction of a second before a leap second is added. So unless you are
952monitoring this motion, I'm not sure how meaningful it is to require
953too much more accuracy in sidereal time.
954
955Cheers
956Jolien
957*/
959{
960 /* cf. S. Aoki et al., A&A 105, 359 (1982) eqs. 13 & 19 */
961 /* also cf. http://aa.usno.navy.mil */
962 /* Note: 00h UT 01 Jan 2000 has JD=2451544.5 and GPS=630720013 */
963 const REAL8 JD_12h_01_Jan_2000 = 2451545.0;
964 const REAL8 JD_00h_01_Jan_2000 = 2451544.5;
965 const REAL8 GPS_00h_01_Jan_2000 = 630720013;
966 const REAL8 TAIUTC_00h_01_Jan_2000 = 32; /* leap seconds: TAI - UTC */
967
968
969 REAL8 t;
970 REAL8 dpU;
971 REAL8 TpU;
972 REAL8 gmst;
973
974 /* compute number of seconds since 00h UT 01 Jan 2000 */
975 t = gpssec - GPS_00h_01_Jan_2000;
976 t += 1e-9 * gpsnan;
977 t += taiutc - TAIUTC_00h_01_Jan_2000;
978
979 /* compute number of days since 12h UT 01 Jan 2000 */
980 dpU = floor( t / ( 24.0 * 3600.0 ) ); /* full days since 0h UT 01
981Jan 2000 */
982 dpU += JD_00h_01_Jan_2000 - JD_12h_01_Jan_2000; /* i.e., -0.5 */
983
984 /* compute number of centuries since 12h UT 31 Dec 1899 */
985 TpU = dpU / 36525.0;
986
987 /* compute the gmst at 0h of the current day */
988 gmst = 24110.54841
989 + TpU * ( 8640184.812866
990 + TpU * ( 0.093104
991 - TpU * 6.2e-6 ) ); /* seconds */
992
993 /* add the sidereal time since the start of the day */
994 t = fmod( t, 24.0 * 3600.0 ); /* seconds since start of day */
995 gmst += t * 1.002737909350795; /* corrections omitted */
996
997 /* convert to fractions of a day and to radians */
998 gmst = fmod( gmst / ( 24.0 * 3600.0 ), 1.0 ); /* fraction of day */
999 /* gmst *= 2.0 * M_PI; */ /* radians */ /* 10/15/04 gam */
1000 gmst *= ((REAL8)LALIND_TWOPI); /* radians */
1001
1002 return gmst;
1003}
const char * program
@ LALDetectorIndexLLODIFF
Definition: DetectorSite.h:41
@ LALDetectorIndexGEO600DIFF
Definition: DetectorSite.h:43
@ LALDetectorIndexLHODIFF
Definition: DetectorSite.h:40
#define LALIND_TWOPI
int main(int argc, char *argv[])
#define LALIND_TIMETOLERANCE
REAL8 greenwich_mean_sidereal_time(INT4 gpssec, INT4 gpsnan, INT4 taiutc)
REAL8 omegaEarthSun
#define LALIND_PI
#define usage(program)
#define LALIND_PI_2
void GenerateResponseFuncNotUsingLAL(LALSource *pulsar, REAL8 inputXArmAzimuthRadians, REAL8 inputVertexLatitudeRadians, INT4 lgthDataSet, REAL8 phiStart, REAL8Vector *timevec, REAL8Vector *fPlus, REAL8Vector *fCross)
REAL8 omegaEarth
void PrintLALDetector(const LALDetector *detector)
void GenerateResponseFuncUsingLAL(LALStatus *status, LALSource *pulsar, LALDetector *detector, INT4 lgthDataSet, REAL8 sampleRate, LIGOTimeGPS *gps, LALDetAMResponseSeries *am_response_series_ptr)
#define CHECKSTATUSPTR(statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int LALgetopt(int argc, char *const *argv, const char *optstring)
Definition: LALgetopt.c:172
char * LALoptarg
Definition: LALgetopt.c:64
#define fprintf
LALDetector * XLALCreateDetector(LALDetector *detector, const LALFrDetector *frDetector, LALDetectorType type)
UNDOCUMENTED.
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
Pre-existing detectors.
void LALComputeDetAMResponse(LALStatus *status, LALDetAMResponse *pResponse, const LALDetAndSource *pDetAndSrc, const LIGOTimeGPS *gps)
Definition: DetResponse.c:401
void LALComputeDetAMResponseSeries(LALStatus *status, LALDetAMResponseSeries *pResponseSeries, const LALDetAndSource *pDetAndSource, const LALTimeIntervalAndNSample *pTimeInfo)
Computes REAL4TimeSeries containing time series of response amplitudes.
Definition: DetResponse.c:526
#define LAL_PI_2
pi/2
Definition: LALConstants.h:181
#define LAL_PI
Archimedes's constant, pi.
Definition: LALConstants.h:179
#define LAL_TWOPI
2*pi is circumference of a circle divided by its radius
Definition: LALConstants.h:180
double REAL8
Double precision real floating-point number (8 bytes).
int16_t INT2
Two-byte signed integer.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
#define lalDebugLevel
Definition: LALDebugLevel.h:58
@ LALDETECTORTYPE_IFODIFF
IFO in differential mode.
Definition: LALDetectors.h:240
@ COORDINATESYSTEM_EQUATORIAL
The sky-fixed equatorial coordinate system.
void LALCHARCreateVector(LALStatus *, CHARVector **, UINT4)
void LALCHARDestroyVector(LALStatus *, CHARVector **)
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
void LALSDestroyVector(LALStatus *, REAL4Vector **)
void LALSCreateVector(LALStatus *, REAL4Vector **, UINT4)
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
Convenience wrapper, calling XLALGreenwichSiderealTime() with the equation of equinoxes set to 0.
Vector of type CHAR, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:73
CHAR * data
Pointer to the data array.
Definition: LALDatatypes.h:78
This structure encapsulates the detector AM (beam pattern) coefficients for one source at one instanc...
Definition: DetResponse.h:140
This structure aggregates together three REAL4TimeSeries objects containing time series of detector A...
Definition: DetResponse.h:153
REAL4TimeSeries * pCross
timeseries of detector response to -polarized gravitational radiation
Definition: DetResponse.h:155
REAL4TimeSeries * pPlus
timeseries of detector response to -polarized gravitational radiation
Definition: DetResponse.h:154
REAL4TimeSeries * pScalar
timeseries of detector response to scalar gravitational radiation (NB: not yet implemented....
Definition: DetResponse.h:156
This structure aggregates a pointer to a LALDetector and a LALSource.
Definition: DetResponse.h:128
LALSource * pSource
Pointer to LALSource object containing information about the source.
Definition: DetResponse.h:130
const LALDetector * pDetector
Pointer to LALDetector object containing information about the detector.
Definition: DetResponse.h:129
Detector structure.
Definition: LALDetectors.h:278
REAL8 location[3]
The three components, in an Earth-fixed Cartesian coordinate system, of the position vector from the ...
Definition: LALDetectors.h:279
LALFrDetector frDetector
The original LALFrDetector structure from which this was created.
Definition: LALDetectors.h:282
Detector frame data structure Structure to contain the data that appears in a FrDetector structure in...
Definition: LALDetectors.h:255
REAL8 vertexLongitudeRadians
The geodetic longitude of the vertex in radians.
Definition: LALDetectors.h:258
REAL8 vertexLatitudeRadians
The geodetic latitude of the vertex in radians.
Definition: LALDetectors.h:259
REAL4 vertexElevation
The height of the vertex above the reference ellipsoid in meters.
Definition: LALDetectors.h:260
REAL4 xArmAzimuthRadians
The angle clockwise from North to the projection of the X arm (or bar's cylidrical axis) into the lo...
Definition: LALDetectors.h:262
REAL4 yArmAltitudeRadians
The angle up from the local tangent plane of the reference ellipsoid to the Y arm in radians (unused...
Definition: LALDetectors.h:263
REAL4 yArmAzimuthRadians
The angle clockwise from North to the projection of the Y arm into the local tangent plane of the re...
Definition: LALDetectors.h:264
REAL4 xArmAltitudeRadians
The angle up from the local tangent plane of the reference ellipsoid to the X arm (or bar's cylidric...
Definition: LALDetectors.h:261
CHAR name[LALNameLength]
A unique identifying string.
Definition: LALDetectors.h:256
This structure stores pointers to a LALDetector and a LIGOTimeGPS.
Definition: Date.h:102
LIGOTimeGPS * p_gps
Pointer to a GPS time structure.
Definition: Date.h:104
const LALDetector * p_detector
pointer to a detector
Definition: Date.h:103
This structure contains gravitational wave source position (in Equatorial coördinates),...
Definition: DetResponse.h:105
SkyPosition equatorialCoords
equatorial coordinates of source, in decimal RADIANS
Definition: DetResponse.h:107
REAL8 orientation
Orientation angle ( ) of source: counter-clockwise angle -axis makes with a line perpendicular to mer...
Definition: DetResponse.h:108
CHAR name[LALNameLength]
name of source, eg catalog number
Definition: DetResponse.h:106
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
This structure encapsulates time and sampling information for computing a LALDetAMResponseSeries.
Definition: DetResponse.h:168
LIGOTimeGPS epoch
The start time of the time series.
Definition: DetResponse.h:169
UINT4 nSample
The total number of samples to be computed.
Definition: DetResponse.h:171
REAL8 deltaT
The sampling interval , in seconds.
Definition: DetResponse.h:170
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
Definition: LALDatatypes.h:458
INT4 gpsSeconds
Seconds since 0h UTC 6 Jan 1980.
Definition: LALDatatypes.h:459
INT4 gpsNanoSeconds
Residual nanoseconds.
Definition: LALDatatypes.h:460
Time series of REAL4 data, see DATATYPE-TimeSeries types for more details.
Definition: LALDatatypes.h:570
REAL4Sequence * data
The sequence of sampled data.
Definition: LALDatatypes.h:576
REAL4 * data
Pointer to the data array.
Definition: LALDatatypes.h:150
Vector of type REAL8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:154
REAL8 * data
Pointer to the data array.
Definition: LALDatatypes.h:159
REAL8 longitude
The longitudinal coordinate (in radians), as defined above.
REAL8 latitude
The latitudinal coordinate (in radians), as defined above.
CoordinateSystem system
The coordinate system in which latitude/longitude are expressed.