LALPulsar 7.1.2.1-bf6a62b
HoughValidate.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Badri Krishnan, Reinhard Prix
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/**
21 * \file
22 * \ingroup lalpulsar_bin_Hough
23 * \author A.M. Sintes, B. Krishnan
24 * \brief
25 * Monte Carlo signal injections for several h_0 values and
26 * compute the Hough transform for only one point in parameter space each time
27 */
28
29/*
30 The idea is that we would like to analize a 300 Hz band on a cluster of
31 machines. Each process should analyze 1 Hz band (or whatever).
32
33 - Read the band to be analized and the wings needed to read the originals SFTs.
34 -Read the h_0 values to be analyzed in one go
35 - Read the file containing the times and velocities generated by
36 DriveHoughColor or compute them
37 -loop over the MC injections:
38 + Generate random parameters (f, f', alpha, delata, i...)
39 + generate h(t), produce its FFT
40 + Add h(f) to SFT for a given h_o value (and all of them)
41 + get number count
42 + wite to file
43 (note if one loop fails, should print error , but continue with the next
44 value)
45
46Input shoud be from
47 SFT files
48 band, wings, nh_0, h_01, h_02....
49 ephemeris info
50 (it should also read the times and velocities used in
51 DriveHoughColor)
52
53 This code will output files containing the MC results and info about injected
54 signals.
55*/
56
57
58
60
61#define VALIDATEOUT "./outHM1/skypatch_1/HM1validate"
62#define VALIDATEIN "./outHM1/skypatch_1/HM1templates"
63
64#define TRUE (1==1)
65#define FALSE (1==0)
66
67#define SQ(x) ((x)*(x))
68
70
71/*************************************/
72
73int main( int argc, char *argv[] )
74{
75
76 static LALStatus status;
77
78 static const LALDetector *detector;
79 static LIGOTimeGPSVector timeV;
80 static REAL8Cart3CoorVector velV;
81 static REAL8Vector timeDiffV;
82 static REAL8 foft;
83 static HoughPulsarTemplate pulsarTemplate;
84
85 EphemerisData *edat = NULL;
86 CHAR *uvar_earthEphemeris = NULL;
87 CHAR *uvar_sunEphemeris = NULL;
88 SFTVector *inputSFTs = NULL;
89 REAL8 *alphaVec = NULL;
90 REAL8 *deltaVec = NULL;
91 REAL8 *freqVec = NULL;
92 REAL8 *spndnVec = NULL;
93
94 /* pgV is vector of peakgrams and pg1 is onepeakgram */
95 static UCHARPeakGram *pg1, **pgV;
96 UINT4 msp; /*number of spin-down parameters */
97 CHAR *uvar_ifo = NULL;
98 CHAR *uvar_sftDir = NULL; /* the directory where the SFT could be */
99 CHAR *uvar_fnameOut = NULL; /* The output prefix filename */
100 CHAR *uvar_fnameIn = NULL;
101 INT4 numberCount, ind;
102 UINT8 nTemplates;
103 UINT4 mObsCoh;
104 REAL8 uvar_peakThreshold;
105 REAL8 f_min, f_max, fWings, timeBase;
107 UINT4 sftlength;
108 INT4 sftFminBin;
109 UINT4 loopId, tempLoopId;
110 FILE *fpOut = NULL;
111 CHAR *fnameLog = NULL;
112 FILE *fpLog = NULL;
113 CHAR *logstr = NULL;
114 /*REAL8 asq, bsq;*/ /* square of amplitude modulation functions a and b */
115
116 /******************************************************************/
117 /* Set up the default parameters. */
118 /* ****************************************************************/
119
120 /* LAL error-handler */
122
123 msp = 1; /*only one spin-down */
124
125 /* memory allocation for spindown */
126 pulsarTemplate.spindown.length = msp;
127 pulsarTemplate.spindown.data = NULL;
128 pulsarTemplate.spindown.data = ( REAL8 * )LALMalloc( msp * sizeof( REAL8 ) );
129
130
131 uvar_peakThreshold = THRESHOLD;
132
133 uvar_earthEphemeris = ( CHAR * )LALMalloc( 1024 * sizeof( CHAR ) );
134 strcpy( uvar_earthEphemeris, EARTHEPHEMERIS );
135
136 uvar_sunEphemeris = ( CHAR * )LALMalloc( 1024 * sizeof( CHAR ) );
137 strcpy( uvar_sunEphemeris, SUNEPHEMERIS );
138
139 uvar_sftDir = ( CHAR * )LALMalloc( 1024 * sizeof( CHAR ) );
140 strcpy( uvar_sftDir, SFTDIRECTORY );
141
142 uvar_fnameOut = ( CHAR * )LALMalloc( 1024 * sizeof( CHAR ) );
143 strcpy( uvar_fnameOut, VALIDATEOUT );
144
145 uvar_fnameIn = ( CHAR * )LALMalloc( 1024 * sizeof( CHAR ) );
146 strcpy( uvar_fnameIn, VALIDATEIN );
147
149
150 /* register user input variables */
151 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_ifo, "ifo", STRING, 'i', OPTIONAL, "Detector GEO(1) LLO(2) LHO(3)" ) == XLAL_SUCCESS, XLAL_EFUNC );
152 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_earthEphemeris, "earthEphemeris", STRING, 'E', OPTIONAL, "Earth Ephemeris file" ) == XLAL_SUCCESS, XLAL_EFUNC );
153 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_sunEphemeris, "sunEphemeris", STRING, 'S', OPTIONAL, "Sun Ephemeris file" ) == XLAL_SUCCESS, XLAL_EFUNC );
154 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_sftDir, "sftDir", STRING, 'D', OPTIONAL, "SFT Directory" ) == XLAL_SUCCESS, XLAL_EFUNC );
155 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_fnameIn, "fnameIn", STRING, 'T', OPTIONAL, "Input template file" ) == XLAL_SUCCESS, XLAL_EFUNC );
156 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_fnameOut, "fnameOut", STRING, 'o', OPTIONAL, "Output filename" ) == XLAL_SUCCESS, XLAL_EFUNC );
157 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_blocksRngMed, "blocksRngMed", INT4, 'w', OPTIONAL, "RngMed block size" ) == XLAL_SUCCESS, XLAL_EFUNC );
158 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_peakThreshold, "peakThreshold", REAL8, 't', OPTIONAL, "Peak selection threshold" ) == XLAL_SUCCESS, XLAL_EFUNC );
159
160 /* read all command line variables */
161 BOOLEAN should_exit = 0;
163 if ( should_exit ) {
164 exit( 1 );
165 }
166
167 /* open log file for writing */
168 fnameLog = LALCalloc( ( strlen( uvar_fnameOut ) + strlen( ".log" ) + 10 ), 1 );
169 strcpy( fnameLog, uvar_fnameOut );
170 strcat( fnameLog, ".log" );
171 if ( ( fpLog = fopen( fnameLog, "w" ) ) == NULL ) {
172 fprintf( stderr, "Unable to open file %s for writing\n", fnameLog );
173 LALFree( fnameLog );
174 exit( 1 );
175 }
176
177 /* get the log string */
179
180 fprintf( fpLog, "## Log file for HoughValidate\n\n" );
181 fprintf( fpLog, "# User Input:\n" );
182 fprintf( fpLog, "#-------------------------------------------\n" );
183 fprintf( fpLog, "%s", logstr );
184 LALFree( logstr );
185
186 /* append an ident-string defining the exact CVS-version of the code used */
187 {
188 CHAR command[1024] = "";
189 fprintf( fpLog, "\n\n# CVS-versions of executable:\n" );
190 fprintf( fpLog, "# -----------------------------------------\n" );
191 fclose( fpLog );
192
193 sprintf( command, "ident %s | sort -u >> %s", argv[0], fnameLog );
194 /* we don't check this. If it fails, we assume that */
195 /* one of the system-commands was not available, and */
196 /* therefore the CVS-versions will not be logged */
197 if ( system( command ) ) {
198 fprintf( stderr, "\nsystem('%s') returned non-zero status!\n\n", command );
199 }
200
201 LALFree( fnameLog );
202 }
203
204 /* open output file for writing */
205 fpOut = fopen( uvar_fnameOut, "w" );
206 /*setlinebuf(fpOut);*/ /* line buffered on */
207 setvbuf( fpOut, ( char * )NULL, _IOLBF, 0 );
208
209 /*****************************************************************/
210 /* read template file */
211 /*****************************************************************/
212 {
213 FILE *fpIn = NULL;
214 INT4 r;
215 REAL8 temp1, temp2, temp3, temp4, temp5;
216 UINT8 templateCounter;
217
218 fpIn = fopen( uvar_fnameIn, "r" );
219 if ( !fpIn ) {
220 fprintf( stderr, "Unable to fine file %s\n", uvar_fnameIn );
222 }
223
224
225 nTemplates = 0;
226 do {
227 r = fscanf( fpIn, "%lf%lf%lf%lf%lf\n", &temp1, &temp2, &temp3, &temp4, &temp5 );
228 /* make sure the line has the right number of entries or is EOF */
229 if ( r == 5 ) {
230 nTemplates++;
231 }
232 } while ( r != EOF );
233 rewind( fpIn );
234
235 alphaVec = ( REAL8 * )LALMalloc( nTemplates * sizeof( REAL8 ) );
236 deltaVec = ( REAL8 * )LALMalloc( nTemplates * sizeof( REAL8 ) );
237 freqVec = ( REAL8 * )LALMalloc( nTemplates * sizeof( REAL8 ) );
238 spndnVec = ( REAL8 * )LALMalloc( nTemplates * sizeof( REAL8 ) );
239
240
241 for ( templateCounter = 0; templateCounter < nTemplates; templateCounter++ ) {
242 r = fscanf( fpIn, "%lf%lf%lf%lf%lf\n", &temp1, alphaVec + templateCounter, deltaVec + templateCounter,
243 freqVec + templateCounter, spndnVec + templateCounter );
244 }
245 fclose( fpIn );
246 }
247
248
249 /**************************************************/
250 /* read sfts */
251 /*************************************************/
252 f_min = freqVec[0]; /* initial frequency to be analyzed */
253 /* assume that the last frequency in the templates file is also the highest frequency */
254 f_max = freqVec[nTemplates - 1] ;
255
256 /* we need to add wings to fmin and fmax to account for
257 the Doppler shift, the size of the rngmed block size
258 and also nfsizecylinder. The block size and nfsizecylinder are
259 specified in terms of frequency bins...this goes as one of the arguments of
260 LALReadSFTfiles */
261 /* first correct for Doppler shift */
262 fWings = f_max * VTOT;
263 f_min -= fWings;
264 f_max += fWings;
265
266 /* create pattern to look for in SFT directory */
267
268 {
269 CHAR *tempDir = NULL;
270 SFTCatalog *catalog = NULL;
271 static SFTConstraints constraints;
272
273 /* set detector constraint */
274 constraints.detector = NULL;
275 if ( XLALUserVarWasSet( &uvar_ifo ) ) {
276 constraints.detector = XLALGetChannelPrefix( uvar_ifo );
277 }
278
279 /* get sft catalog */
280 tempDir = ( CHAR * )LALCalloc( 512, sizeof( CHAR ) );
281 strcpy( tempDir, uvar_sftDir );
282 strcat( tempDir, "/*SFT*.*" );
283 XLAL_CHECK_MAIN( ( catalog = XLALSFTdataFind( tempDir, &constraints ) ) != NULL, XLAL_EFUNC );
284
285 detector = XLALGetSiteInfo( catalog->data[0].header.name );
286
287 mObsCoh = catalog->length;
288 timeBase = 1.0 / catalog->data->header.deltaF;
289
290 XLAL_CHECK_MAIN( ( inputSFTs = XLALLoadSFTs( catalog, f_min, f_max ) ) != NULL, XLAL_EFUNC );
291
293
294 if ( XLALUserVarWasSet( &uvar_ifo ) ) {
295 LALFree( constraints.detector );
296 }
297 LALFree( tempDir );
298 XLALDestroySFTCatalog( catalog );
299
300 }
301
302
303
304 sftlength = inputSFTs->data->data->length;
305 {
306 INT4 tempFbin;
307 sftFminBin = floor( ( REAL4 )( timeBase * inputSFTs->data->f0 ) + ( REAL4 )( 0.5 ) );
308 tempFbin = floor( timeBase * inputSFTs->data->f0 + 0.5 );
309
310 if ( tempFbin - sftFminBin ) {
311 fprintf( stderr, "Rounding error in calculating fminbin....be careful! \n" );
312 }
313 }
314
315 /* loop over sfts and select peaks */
316
317 /* first the memory allocation for the peakgramvector */
318 pgV = NULL;
319 pgV = ( UCHARPeakGram ** )LALMalloc( mObsCoh * sizeof( UCHARPeakGram * ) );
320
321 /* memory for peakgrams */
322 for ( tempLoopId = 0; tempLoopId < mObsCoh; tempLoopId++ ) {
323 pgV[tempLoopId] = ( UCHARPeakGram * )LALMalloc( sizeof( UCHARPeakGram ) );
324 pgV[tempLoopId]->length = sftlength;
325 pgV[tempLoopId]->data = NULL;
326 pgV[tempLoopId]->data = ( UCHAR * )LALMalloc( sftlength * sizeof( UCHAR ) );
327
328 LAL_CALL( SFTtoUCHARPeakGram( &status, pgV[tempLoopId], inputSFTs->data + tempLoopId, uvar_peakThreshold ), &status );
329 }
330
331
332 /* having calculated the peakgrams we don't need the sfts anymore */
333 XLALDestroySFTVector( inputSFTs );
334
335
336
337 /* ****************************************************************/
338 /* setting timestamps vector */
339 /* ****************************************************************/
340 timeV.length = mObsCoh;
341 timeV.data = NULL;
342 timeV.data = ( LIGOTimeGPS * )LALMalloc( mObsCoh * sizeof( LIGOTimeGPS ) );
343
344 {
345 UINT4 j;
346 for ( j = 0; j < mObsCoh; j++ ) {
347 timeV.data[j].gpsSeconds = pgV[j]->epoch.gpsSeconds;
348 timeV.data[j].gpsNanoSeconds = pgV[j]->epoch.gpsNanoSeconds;
349 }
350 }
351
352 /******************************************************************/
353 /* compute the time difference relative to startTime for all SFTs */
354 /******************************************************************/
355 timeDiffV.length = mObsCoh;
356 timeDiffV.data = NULL;
357 timeDiffV.data = ( REAL8 * )LALMalloc( mObsCoh * sizeof( REAL8 ) );
358
359 {
360 REAL8 t0, ts, tn, midTimeBase;
361 UINT4 j;
362
363 midTimeBase = 0.5 * timeBase;
364 ts = timeV.data[0].gpsSeconds;
365 tn = timeV.data[0].gpsNanoSeconds * 1.00E-9;
366 t0 = ts + tn;
367 timeDiffV.data[0] = midTimeBase;
368
369 for ( j = 1; j < mObsCoh; ++j ) {
370 ts = timeV.data[j].gpsSeconds;
371 tn = timeV.data[j].gpsNanoSeconds * 1.00E-9;
372 timeDiffV.data[j] = ts + tn - t0 + midTimeBase;
373 }
374 }
375
376 /******************************************************************/
377 /* compute detector velocity for those time stamps */
378 /******************************************************************/
379 velV.length = mObsCoh;
380 velV.data = NULL;
381 velV.data = ( REAL8Cart3Coor * )LALMalloc( mObsCoh * sizeof( REAL8Cart3Coor ) );
382
383 {
384 VelocityPar velPar;
385 REAL8 vel[3];
386 UINT4 j;
387
388 velPar.detector = *detector;
389 velPar.tBase = timeBase;
390 velPar.vTol = ACCURACY;
391 velPar.edat = NULL;
392
393 /* read in ephemeris data */
394 XLAL_CHECK_MAIN( ( edat = XLALInitBarycenter( uvar_earthEphemeris, uvar_sunEphemeris ) ) != NULL, XLAL_EFUNC );
395 velPar.edat = edat;
396
397 /* now calculate average velocity */
398 for ( j = 0; j < velV.length; ++j ) {
399 velPar.startTime.gpsSeconds = timeV.data[j].gpsSeconds;
401
402 LAL_CALL( LALAvgDetectorVel( &status, vel, &velPar ), &status );
403 velV.data[j].x = vel[0];
404 velV.data[j].y = vel[1];
405 velV.data[j].z = vel[2];
406 }
407 }
408
409
410
411 /* amplitude modulation stuff */
412 {
414 AMCoeffsParams *amParams;
415 EarthState earth;
416 BarycenterInput baryinput; /* Stores detector location and other barycentering data */
417
418 /* detector location */
419 baryinput.site.location[0] = detector->location[0] / LAL_C_SI;
420 baryinput.site.location[1] = detector->location[1] / LAL_C_SI;
421 baryinput.site.location[2] = detector->location[2] / LAL_C_SI;
422 baryinput.dInv = 0.e0;
423 /* alpha and delta must come from the skypatch */
424 /* for now set it to something arbitrary */
425 baryinput.alpha = 0.0;
426 baryinput.delta = 0.0;
427
428 /* Allocate space for amParams stucture */
429 /* Here, amParams->das is the Detector and Source info */
430 amParams = ( AMCoeffsParams * )LALMalloc( sizeof( AMCoeffsParams ) );
431 amParams->das = ( LALDetAndSource * )LALMalloc( sizeof( LALDetAndSource ) );
432 amParams->das->pSource = ( LALSource * )LALMalloc( sizeof( LALSource ) );
433 /* Fill up AMCoeffsParams structure */
434 amParams->baryinput = &baryinput;
435 amParams->earth = &earth;
436 amParams->edat = edat;
437 amParams->das->pDetector = detector;
438 /* make sure alpha and delta are correct */
439 amParams->das->pSource->equatorialCoords.latitude = baryinput.delta;
440 amParams->das->pSource->equatorialCoords.longitude = baryinput.alpha;
441 amParams->das->pSource->orientation = 0.0;
443 amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!*/
444
445 /* timeV is start time ---> change to mid time */
446 LAL_CALL( LALComputeAM( &status, &amc, timeV.data, amParams ), &status );
447
448 /* calculate a^2 and b^2 */
449 /* for (ii=0, asq=0.0, bsq=0.0; ii<mObsCoh; ii++) */
450 /* { */
451 /* REAL8 *a, *b; */
452 /* a = amc.a + ii; */
453 /* b = amc.b + ii; */
454 /* asq += (*a) * (*a); */
455 /* bsq += (*b) * (*b); */
456 /* } */
457
458 /* free amParams */
459 LALFree( amParams->das->pSource );
460 LALFree( amParams->das );
461 LALFree( amParams );
462
463 }
464
465 /* loop over templates */
466 for ( loopId = 0; loopId < nTemplates; ++loopId ) {
467
468 /* set template parameters */
469 pulsarTemplate.f0 = freqVec[loopId];
470 pulsarTemplate.longitude = alphaVec[loopId];
471 pulsarTemplate.latitude = deltaVec[loopId];
472 pulsarTemplate.spindown.data[0] = spndnVec[loopId];
473
474
475 {
476 REAL8 f0new, vcProdn, timeDiffN;
477 REAL8 sourceDelta, sourceAlpha, cosDelta, factorialN;
478 UINT4 j, i, f0newBin;
479 REAL8Cart3Coor sourceLocation;
480
481 sourceDelta = pulsarTemplate.latitude;
482 sourceAlpha = pulsarTemplate.longitude;
483 cosDelta = cos( sourceDelta );
484
485 sourceLocation.x = cosDelta * cos( sourceAlpha );
486 sourceLocation.y = cosDelta * sin( sourceAlpha );
487 sourceLocation.z = sin( sourceDelta );
488
489 /* loop for all different time stamps,calculate frequency and produce number count*/
490 /* first initialize number count */
491 numberCount = 0;
492 for ( j = 0; j < mObsCoh; ++j ) {
493 /* calculate v/c.n */
494 vcProdn = velV.data[j].x * sourceLocation.x
495 + velV.data[j].y * sourceLocation.y
496 + velV.data[j].z * sourceLocation.z;
497
498 /* loop over spindown values to find f_0 */
499 f0new = pulsarTemplate.f0;
500 factorialN = 1.0;
501 timeDiffN = timeDiffV.data[j];
502 for ( i = 0; i < msp; ++i ) {
503 factorialN *= ( i + 1.0 );
504 f0new += pulsarTemplate.spindown.data[i] * timeDiffN / factorialN;
505 timeDiffN *= timeDiffN;
506 }
507
508 f0newBin = floor( f0new * timeBase + 0.5 );
509 foft = f0newBin * ( 1.0 + vcProdn ) / timeBase;
510
511 /* get the right peakgram */
512 pg1 = pgV[j];
513
514 /* calculate frequency bin for template */
515 ind = floor( foft * timeBase + 0.5 ) - sftFminBin;
516
517 /* update the number count */
518 numberCount += pg1->data[ind];
519 }
520
521 } /* end of block calculating frequency path and number count */
522
523
524 /******************************************************************/
525 /* printing result in the output file */
526 /******************************************************************/
527
528 fprintf( fpOut, "%d %f %f %f %g \n",
529 numberCount, pulsarTemplate.longitude, pulsarTemplate.latitude, pulsarTemplate.f0,
530 pulsarTemplate.spindown.data[0] );
531
532 } /* end of loop over templates */
533
534 /******************************************************************/
535 /* Closing files */
536 /******************************************************************/
537 fclose( fpOut );
538
539
540 /******************************************************************/
541 /* Free memory and exit */
542 /******************************************************************/
543
544 LALFree( alphaVec );
545 LALFree( deltaVec );
546 LALFree( freqVec );
547 LALFree( spndnVec );
548
549
550 for ( tempLoopId = 0; tempLoopId < mObsCoh; tempLoopId++ ) {
551 pg1 = pgV[tempLoopId];
552 LALFree( pg1->data );
553 LALFree( pg1 );
554 }
555 LALFree( pgV );
556
557 LALFree( timeV.data );
558 LALFree( timeDiffV.data );
559 LALFree( velV.data );
560
561 LALFree( pulsarTemplate.spindown.data );
562
564
566
568
570}
571
572
573/**
574 * Original antenna-pattern function by S Berukoff
575 */
577 AMCoeffs *coe,
578 LIGOTimeGPS *ts,
580{
581
582 REAL4 zeta; /* sine of angle between detector arms */
583 INT4 i; /* temporary loop index */
584 LALDetAMResponse response; /* output of LALComputeDetAMResponse */
585
586 REAL4 sumA2 = 0.0;
587 REAL4 sumB2 = 0.0;
588 REAL4 sumAB = 0.0; /* variables to store scalar products */
589 INT4 length = coe->a->length; /* length of input time series */
590
591 REAL4 cos2psi;
592 REAL4 sin2psi; /* temp variables */
593
596
597 /* Must put an ASSERT checking that ts vec and coe vec are same length */
598
599 /* Compute the angle between detector arms, then the reciprocal */
600 {
601 LALFrDetector det = params->das->pDetector->frDetector;
602 zeta = 1.0 / ( sin( det.xArmAzimuthRadians - det.yArmAzimuthRadians ) );
603 if ( params->das->pDetector->type == LALDETECTORTYPE_CYLBAR ) {
604 zeta = 1.0;
605 }
606 }
607
608 cos2psi = cos( 2.0 * params->polAngle );
609 sin2psi = sin( 2.0 * params->polAngle );
610
611 /* Note the length is the same for the b vector */
612 for ( i = 0; i < length; ++i ) {
613 REAL4 *a = coe->a->data;
614 REAL4 *b = coe->b->data;
615
616 /* Compute F_plus, F_cross */
617 LALComputeDetAMResponse( status->statusPtr, &response, params->das, &ts[i] );
618
619 /* Compute a, b from JKS eq 10,11
620 * a = zeta * (F_plus*cos(2\psi)-F_cross*sin(2\psi))
621 * b = zeta * (F_cross*cos(2\psi)+Fplus*sin(2\psi))
622 */
623 a[i] = zeta * ( response.plus * cos2psi - response.cross * sin2psi );
624 b[i] = zeta * ( response.cross * cos2psi + response.plus * sin2psi );
625
626 /* Compute scalar products */
627 sumA2 += SQ( a[i] ); /* A */
628 sumB2 += SQ( b[i] ); /* B */
629 sumAB += ( a[i] ) * ( b[i] ); /* C */
630 }
631
632 {
633 /* Normalization factor */
634 REAL8 L = 2.0 / ( REAL8 )length;
635
636 /* Assign output values and normalise */
637 coe->A = L * sumA2;
638 coe->B = L * sumB2;
639 coe->C = L * sumAB;
640 coe->D = ( coe->A * coe->B - SQ( coe->C ) );
641 /* protection against case when AB=C^2 */
642 if ( coe->D == 0 ) {
643 coe->D = 1.0e-9;
644 }
645 }
646
647 /* Normal exit */
648
650 RETURN( status );
651
652} /* LALComputeAM() */
#define DRIVEHOUGHCOLOR_EFILE
#define DRIVEHOUGHCOLOR_ENORM
#define THRESHOLD
#define EARTHEPHEMERIS
#define SUNEPHEMERIS
static void LALComputeAM(LALStatus *, AMCoeffs *coe, LIGOTimeGPS *ts, AMCoeffsParams *params)
Original antenna-pattern function by S Berukoff.
int main(int argc, char *argv[])
Definition: HoughValidate.c:73
#define VALIDATEOUT
Definition: HoughValidate.c:61
#define SQ(x)
Definition: HoughValidate.c:67
#define VALIDATEIN
Definition: HoughValidate.c:62
#define SFTDIRECTORY
REAL8 zeta
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
#define LAL_CALL(function, statusptr)
int j
void LALCheckMemoryLeaks(void)
#define LALCalloc(m, n)
#define LALMalloc(n)
#define LALFree(p)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
#define ATTATCHSTATUSPTR(statusptr)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define ACCURACY
#define L(i, j)
void SFTtoUCHARPeakGram(LALStatus *status, UCHARPeakGram *pg, const SFTtype *sft, REAL8 thr)
Convert a normalized sft into a peakgram by selecting bins in which power exceeds a threshold.
Definition: PeakSelect.c:371
#define STRING(a)
AMCoeffs amc
#define fscanf
#define fprintf
void LALComputeDetAMResponse(LALStatus *status, LALDetAMResponse *pResponse, const LALDetAndSource *pDetAndSrc, const LIGOTimeGPS *gps)
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
unsigned char BOOLEAN
unsigned char UCHAR
uint64_t UINT8
double REAL8
#define XLAL_INIT_DECL(var,...)
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
LALDETECTORTYPE_CYLBAR
#define VTOT
Total detector velocity/c TO BE CHANGED DEPENDING ON DETECTOR.
Definition: LUT.h:207
int XLALNormalizeSFTVect(SFTVector *sftVect, UINT4 blockSize, const REAL8 assumeSqrtS)
Function for normalizing a vector of SFTs.
static const INT4 r
static const INT4 a
const LALDetector * XLALGetSiteInfo(const CHAR *name)
Find the site geometry-information 'LALDetector' for given a detector name (or prefix).
Definition: SFTnaming.c:218
void XLALDestroySFTVector(SFTVector *vect)
XLAL interface to destroy an SFTVector.
Definition: SFTtypes.c:300
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
Definition: SFTcatalog.c:329
CHAR * XLALGetChannelPrefix(const CHAR *name)
Find the valid CW detector prefix.
Definition: SFTnaming.c:203
SFTVector * XLALLoadSFTs(const SFTCatalog *catalog, REAL8 fMin, REAL8 fMax)
Load the given frequency-band [fMin, fMax) (half-open) from the SFT-files listed in the SFT-'catalogu...
Definition: SFTfileIO.c:87
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
Definition: SFTcatalog.c:71
COORDINATESYSTEM_EQUATORIAL
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
void XLALDestroyUserVars(void)
void CHAR * XLALUserVarGetLog(UserVarLogFormat format)
#define XLALRegisterNamedUvar(cvar, name, type, option, category,...)
int XLALUserVarWasSet(const void *cvar)
UVAR_LOGFMT_CFGFILE
void LALAvgDetectorVel(LALStatus *status, REAL8 v[3], VelocityPar *in)
This function outputs the average velocity REAL8 v[3] of the detector during a time interval.
Definition: Velocity.c:34
#define XLAL_CHECK_MAIN(assertion,...)
XLAL_SUCCESS
XLAL_EFUNC
ts
CHAR * uvar_sftDir
#define BLOCKSRNGMED
INT4 uvar_blocksRngMed
double t0
This structure contains the per-SFT (weighted) antenna-pattern functions , with the SFT-index,...
Definition: LALComputeAM.h:63
REAL4 B
summed antenna-pattern matrix coefficient:
Definition: LALComputeAM.h:67
REAL4Vector * b
(weighted) per-SFT antenna-pattern function
Definition: LALComputeAM.h:65
REAL4 A
summed antenna-pattern matrix coefficient:
Definition: LALComputeAM.h:66
REAL4 C
summed antenna-pattern matrix coefficient:
Definition: LALComputeAM.h:68
REAL4Vector * a
(weighted) per-SFT antenna-pattern function
Definition: LALComputeAM.h:64
REAL4 D
determinant
Definition: LALComputeAM.h:69
This structure contains the parameters for the routine.
Definition: LALComputeAM.h:75
LALDetAndSource * das
det and source information
Definition: LALComputeAM.h:79
REAL4 polAngle
polarization angle
Definition: LALComputeAM.h:81
EarthState * earth
from XLALBarycenter()
Definition: LALComputeAM.h:77
EphemerisData * edat
the ephemerides
Definition: LALComputeAM.h:78
BarycenterInput * baryinput
data from Barycentring routine
Definition: LALComputeAM.h:76
Basic input structure to LALBarycenter.c.
REAL8 alpha
Source right ascension in ICRS J2000 coords (radians).
REAL8 dInv
1/(distance to source), in 1/sec.
REAL8 delta
Source declination in ICRS J2000 coords (radians)
LALDetector site
detector site info.
CHAR name[LALNameLength]
COMPLEX8Sequence * data
A vector of COMPLEX8FrequencySeries.
COMPLEX8FrequencySeries * data
Pointer to the data array.
Basic output structure of LALBarycenterEarth.c.
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
LALSource * pSource
const LALDetector * pDetector
REAL8 location[3]
REAL4 xArmAzimuthRadians
REAL4 yArmAzimuthRadians
SkyPosition equatorialCoords
REAL8 orientation
INT4 gpsNanoSeconds
A vector of 'timestamps' of type LIGOTimeGPS.
Definition: SFTfileIO.h:188
LIGOTimeGPS * data
array of timestamps
Definition: SFTfileIO.h:193
UINT4 length
number of timestamps
Definition: SFTfileIO.h:192
REAL4 * data
Three dimensional Cartessian coordinates.
Definition: LUT.h:308
REAL8 y
Definition: LUT.h:310
REAL8 x
Definition: LUT.h:309
REAL8 z
Definition: LUT.h:311
REAL8Cart3Coor * data
x.y.z
UINT4 length
number of elements
REAL8 * data
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
Definition: SFTfileIO.h:238
SFTDescriptor * data
array of data-entries describing matched SFTs
Definition: SFTfileIO.h:243
UINT4 length
number of SFTs in catalog
Definition: SFTfileIO.h:242
'Constraints' for SFT-matching: which detector, within which time-stretch and which timestamps exactl...
Definition: SFTfileIO.h:212
CHAR * detector
2-char channel-prefix describing the detector (eg 'H1', 'H2', 'L1', 'G1' etc)
Definition: SFTfileIO.h:213
SFTtype header
SFT-header info.
Definition: SFTfileIO.h:228
REAL8 longitude
REAL8 latitude
CoordinateSystem system
Explicit peakgram structure – 1 if power in bin is above threshold and 0 if below.
Definition: PeakSelect.h:114
UCHAR * data
pointer to the data {0,1}
Definition: PeakSelect.h:120
LIGOTimeGPS epoch
epoch of first series sample
Definition: PeakSelect.h:115
INT4 length
number of elements in data
Definition: PeakSelect.h:118
This structure stores the parameters required by XLALBarycenter() to calculate Earth velocity at a gi...
Definition: Velocity.h:84
EphemerisData * edat
ephemeris data pointer from XLALInitBarycenter()
Definition: Velocity.h:86
LALDetector detector
the detector
Definition: Velocity.h:85
REAL8 tBase
duration of interval
Definition: Velocity.h:88
LIGOTimeGPS startTime
start of time interval
Definition: Velocity.h:87
REAL8 vTol
fractional accuracy required for velocity (redundant for average velocity calculation)
Definition: Velocity.h:89
double f_min
double f_max