LAL  7.5.0.1-89842e6
DetResponseTest.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 David Chin, Jolien Creighton
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  Author: David Chin <dwchin@umich.edu> +1-734-709-9119
22 */
23 
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <ctype.h>
27 #include <string.h>
28 #include <math.h>
29 #include <errno.h>
30 #include <time.h>
31 #include <lal/LALConfig.h>
32 
33 #include <lal/AVFactories.h>
34 #include <lal/SeqFactories.h>
35 #include <lal/LALStdlib.h>
36 #include <lal/DetectorSite.h>
37 #include <lal/TimeDelay.h>
38 #include <lal/DetResponse.h>
39 #include <lal/Units.h>
40 
41 #include <lal/PrintFTSeries.h>
42 #include <lal/StreamOutput.h>
43 
44 #ifdef __GNUC__
45 #define UNUSED __attribute__ ((unused))
46 #else
47 #define UNUSED
48 #endif
49 
50 #define FALSE 0
51 #define TRUE 1
52 #define LALDR_MATRIXSIZE 3
53 
54 #define TESTDR_MIN(a, b) (((a) < (b)) ? (a) : (b))
55 
56 /* these two constants are for the sky grid */
57 #define NUM_DEC 21
58 #define NUM_RA 24
59 
60 const INT4 lim = NUM_RA * NUM_DEC;
61 const INT4 declim = (NUM_DEC-1)/2;
62 
63 typedef REAL8 LALDR_3Vector[3];
64 typedef REAL8 LALDR_33Matrix[3][3];
65 
67 
68 
69 
70 /*
71  * globals
72  */
74 int verbose_level = 0;
75 const INT4 oneBillion = 1000000000;
76 
77 const REAL8 zero_tolerance = 0.;
80 
86 
87 /* source specified by RA, Dec; the numbers represent degrees */
94 
95 /* this #if is so I can use Emacs's hide-ifdef-mode to make this
96  block invisible, making this file a little easier to scroll through */
97 #if 1
98 /* static void REAL4VectorSubtraction(REAL4Vector * pA,
99  REAL4Vector * pB,
100  REAL4Vector *pAminusB); */
101 /*static REAL4 REAL4VectorRMS(REAL4Vector *pVector); */
102 static void PrintLALDetector(const LALDetector * detector);
103 static void PrintDetResponse(const LALDetAMResponse * const response,
104  const char * const title);
105 
106 
107 /* static void make_me_an_Sarray_sequence(LALStatus *status,
108  REAL4ArraySequence **sequence,
109  UINT4 rows, UINT4 cols, UINT4 length); */
110 
111 /* static void print_diagnostics(LALStatus * const status,
112  REAL4ArraySequence *sequence); */
113 
114 
115 static BOOLEAN almost_equal_real4_p(REAL4 a, REAL4 b, REAL4 tolerance);
116 
117 static BOOLEAN almost_equal_real8_p(REAL8 a, REAL8 b, REAL8 tolerance);
118 
119 static BOOLEAN almost_equal_real4_relative_p(REAL4 computed, REAL4 expected,
120  REAL4 tolerance);
121 
122 static BOOLEAN matrix_ok_p(LALDR_33Matrix * computed,
123  LALDR_33Matrix * expected,
124  REAL8 tolerance);
125 static BOOLEAN vector_ok_p(LALDR_3Vector * computed,
126  LALDR_3Vector * expected,
127  REAL8 tolerance);
128 
129 static BOOLEAN vector_relative_ok_p(LALDR_3Vector * computed,
130  const LALDR_3Vector * expected,
131  REAL8 tolerance);
132 
133 static void print_m_results_maybe(const char * title,
134  LALDR_33Matrix * computed,
135  LALDR_33Matrix * expected);
136 
137 static void print_v_results_maybe(const char * title,
138  LALDR_3Vector * computed,
139  LALDR_3Vector * expected);
140 
141 static void print_s_results_maybe(const char * title,
142  REAL8 computed, REAL8 expected);
143 
144 static int print_separator_maybe(void);
145 
146 static int print_small_separator_maybe(void);
147 
148 static int print_passed_maybe(void);
149 
150 
152  LALDetAndSource * det_and_src,
153  LIGOTimeGPS *gps,
154  LALDetAMResponse * expected_resp,
155  REAL4 tolerance);
156 
157 static void handle_detresponse_test(BOOLEAN passed_p, int line);
158 
159 static BOOLEAN frdetector_ok_p(LALFrDetector * computed,
160  const LALFrDetector * expected);
161 
162 static BOOLEAN detector_ok_p(LALDetector * computed,
163  const LALDetector * expected);
164 #endif
165 
166 static REAL8 deg_to_rad(REAL8 degrees)
167 {
168  return degrees * (REAL8)LAL_PI / (REAL8)180.;
169 }
170 
171 static REAL8 rad_to_deg(REAL8 radians)
172 {
173  return radians * (REAL8)180. / (REAL8)LAL_PI;
174 }
175 
176 
177 /* axis for LALDR_EulerRotation() */
178 typedef enum { xAxis = 1, yAxis = 2, zAxis = 3 } LALDR_Axis_t;
179 
180 /* This #if is so I can hide this block in Emacs's hide-ifdef-mode */
181 #if 1
182 static void
184  REAL8 v1, REAL8 v2, REAL8 v3)
185 {
186  (*v)[0] = v1;
187  (*v)[1] = v2;
188  (*v)[2] = v3;
189 }
190 
191 /*
192  * Cross product of two 3-vectors:
193  * result = a x b
194  */
195 static void
197  LALDR_3Vector * a,
198  LALDR_3Vector * b)
199 {
200  (*result)[0] = (*a)[1]*(*b)[2] - (*a)[2]*(*b)[1];
201  (*result)[1] = -(*a)[0]*(*b)[2] + (*a)[2]*(*b)[0];
202  (*result)[2] = (*a)[0]*(*b)[1] - (*a)[1]*(*b)[0];
203 
204  return;
205 } /* END: LALDR_CrossProd3Vector() */
206 
207 
208 
209 /*
210  * Dot product of two 3-vectors
211  */
212 static REAL8
214  LALDR_3Vector * b)
215 {
216  INT4 i;
217  REAL8 result = 0.;
218 
219  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
220  result += (*a)[i] * (*b)[i];
221 
222  return result;
223 } /* END: LALDR_DotProd3Vector() */
224 
225 
226 
227 static void
229  LALDR_3Vector * u,
230  LALDR_3Vector * v)
231 {
232  INT4 i;
233  INT4 j;
234 
235  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
236  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
237  (*a)[i][j] = (*u)[i] * (*v)[j];
238 
239  return;
240 }
241 
242 
243 
244 /*
245  * Scalar product of two 3x3 matrices
246  */
247 static REAL8
249 {
250  INT4 i, j;
251  REAL8 result = 0.;
252 
253  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
254  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
255  result += (*a)[i][j] * (*b)[i][j];
256 
257  return result;
258 } /* END: LALDR_DotProd33Matrix() */
259 
260 
261 
262 
263 /*
264  * Sets all elements of a 3x3 matrix
265  */
266 static void
268  REAL8 a11, REAL8 a12, REAL8 a13,
269  REAL8 a21, REAL8 a22, REAL8 a23,
270  REAL8 a31, REAL8 a32, REAL8 a33)
271 {
272  (*matrix)[0][0] = a11; (*matrix)[0][1] = a12; (*matrix)[0][2] = a13;
273 
274  (*matrix)[1][0] = a21; (*matrix)[1][1] = a22; (*matrix)[1][2] = a23;
275 
276  (*matrix)[2][0] = a31; (*matrix)[2][1] = a32; (*matrix)[2][2] = a33;
277 
278  return;
279 } /* END: LALDR_Set33Matrix() */
280 
281 
282 
283 #if 0 /* NOT USED */
284 /*
285  * Copy matrix source to matrix target
286  */
287 static void
288 LALDR_Copy33Matrix(LALDR_33Matrix * target, LALDR_33Matrix * source)
289 {
290  INT4 i, j;
291 
292  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
293  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
294  (*target)[i][j] = (*source)[i][j];
295 
296  return;
297 } /* END: LALDR_Copy33Matrix() */
298 #endif
299 
300 
301 
302 /*
303  * Zero matrix
304  */
305 static void
307 {
308  LALDR_Set33Matrix(matrix,
309  0., 0., 0.,
310  0., 0., 0.,
311  0., 0., 0.);
312  return;
313 }
314 
315 
316 
317 /*
318  * Matrix multiply
319  */
320 static void
322  LALDR_33Matrix * matrixL,
323  LALDR_33Matrix * matrixR)
324 {
325  /* loop counters */
326  INT4 i, j, k;
327 
328  /*
329  * Zero out output matrix
330  */
331  LALDR_Set33Matrix(product,
332  0., 0., 0.,
333  0., 0., 0.,
334  0., 0., 0.);
335 
336  /*
337  * Multiply the matrices: matrixL * matrixR
338  */
339  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
340  for (k = 0; k < LALDR_MATRIXSIZE; ++k)
341  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
342  (*product)[i][k] += (*matrixL)[i][j] * (*matrixR)[j][k];
343 
344  return;
345 }
346 
347 
348 
349 /*
350  * Scalar multiply
351  */
352 static void
354  REAL8 coefficient,
355  LALDR_33Matrix * matrix)
356 {
357  INT4 i, j;
358 
359  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
360  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
361  (*result)[i][j] = coefficient * (*matrix)[i][j];
362 
363  return;
364 }
365 
366 
367 
368 /*
369  * Add matrix
370  */
371 static void
373  LALDR_33Matrix * matrix1,
374  LALDR_33Matrix * matrix2)
375 {
376  INT4 i, j;
377 
378  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
379  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
380  (*result)[i][j] = (*matrix1)[i][j] + (*matrix2)[i][j];
381 
382  return;
383 }
384 
385 
386 
387 #if 0 /* NOT USED */
388 /*
389  * Subtract matrices (M1 - M2)
390  */
391 static void
392 LALDR_Subtract33Matrix(LALDR_33Matrix * result,
393  LALDR_33Matrix * matrix1,
394  LALDR_33Matrix * matrix2)
395 {
396  INT4 i, j;
397 
398  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
399  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
400  (*result)[i][j] = (*matrix1)[i][j] - (*matrix2)[i][j];
401 
402  return;
403 }
404 #endif
405 
406 
407 
408 /*
409  * Transpose matrix
410  */
411 static void
413  LALDR_33Matrix * matrix)
414 {
415  INT4 i, j;
416 
417  /*
418  * Zero out output matrix
419  */
420  LALDR_Set33Matrix(transpose,
421  0., 0., 0.,
422  0., 0., 0.,
423  0., 0., 0.);
424 
425  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
426  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
427  (*transpose)[i][j] = (*matrix)[j][i];
428 
429  return;
430 }
431 
432 
433 
434 #if 0 /* NOT USED */
435 /*
436  * The L2 norm of a matrix
437  */
438 static REAL8
439 LALDR_L2Norm33Matrix(LALDR_33Matrix * matrix)
440 {
441  INT4 i, j;
442  REAL8 l2norm = 0.;
443 
444  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
445  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
446  l2norm += (*matrix)[i][j] * (*matrix)[i][j];
447 
448  l2norm = sqrt((double)l2norm);
449 
450  return l2norm;
451 }
452 #endif
453 
454 
455 
456 
457 #if 0 /* NOT USED */
458 /*
459  * The RMS norm of a matrix: RMS sum of all elements.
460  */
461 static REAL8
462 LALDR_RMSNorm33Matrix(LALDR_33Matrix * matrix)
463 {
464  INT4 i, j;
465  REAL8 rmsnorm = 0.;
466 
467  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
468  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
469  rmsnorm += (*matrix)[i][j] * (*matrix)[i][j];
470 
471  rmsnorm = sqrt((double)rmsnorm / 9.);
472 
473  return rmsnorm;
474 }
475 #endif
476 
477 
478 
479 #if 0 /* NOT USED */
480 /*
481  * The "infinity" norm of a matrix: max over all elems
482  */
483 static REAL8
484 LALDR_InfNorm33Matrix(LALDR_33Matrix * matrix)
485 {
486  INT4 i, j;
487  REAL8 infnorm = 0.;
488 
489  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
490  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
491  if (fabs((double)((*matrix)[i][j])) > infnorm)
492  infnorm = fabs((*matrix)[i][j]);
493 
494  return infnorm;
495 }
496 #endif
497 
498 
499 
500 /*
501  * Print out matrix
502  */
503 static void
505  const CHAR *varname,
506  UINT4 format,
507  FILE *file,
508  const CHAR *graph_title)
509 {
510  /* counters */
511  INT4 i, j;
512 
513  REAL8 max;
514 
515 
516  /*
517  * Human-readable format
518  */
519  if (format == 0)
520  {
521  fprintf(file, "%s:\n", varname);
522  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
523  {
524  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
525  fprintf(file, "% 20.14e\t", (*matrix)[i][j]);
526 
527  fprintf(file, "\n");
528  }
529  }
530 
531 
532  /*
533  * Maple V.3 format: makes a patchcontour plot
534  */
535  if (format == 1)
536  {
537  max = 0.;
538  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
539  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
540  if (fabs((*matrix)[i][j]) > max)
541  max = fabs((*matrix)[i][j]);
542 
543 
544  /* load linalg and plots packages for Maple; plot options */
545  fprintf(file, "with(linalg): with(plots):\n");
546  fprintf(file, "setoptions3d(shading=ZHUE,style=PATCHCONTOUR,");
547  fprintf(file, "projection=0.5,axes=BOXED,");
548  fprintf(file, "title=`%s (abs. max = %10.5e)`):\n",
549  graph_title, fabs(max));
550 
551  /* input "varname" is name of variable */
552  fprintf(file, "%s := array(1 .. 3, 1 .. 3,[",
553  varname);
554 
555  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
556  for (j = 0; j < LALDR_MATRIXSIZE; ++j)
557  {
558  /* last entry doesn't have trailing comma */
559  if (i == 2 && j == 2)
560  fprintf(file, "(3, 3)=%20.14e)",
561  fabs((*matrix)[i][j]));
562  else
563  fprintf(file, "(%d, %d)=%20.14e,",
564  j, i, fabs((*matrix)[i][j]));
565  }
566 
567  fprintf(file, "]):\n");
568  fprintf(file, "matrixplot(%s);\n", varname);
569  }
570 
571  fflush(file);
572 
573  return;
574 }
575 
576 
577 
578 static void
580  const CHAR * varname,
581  FILE * file)
582 {
583  /* counter */
584  INT4 i;
585 
586  fprintf(file, "%s:\n", varname);
587  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
588  fprintf(file, "% 20.14e\t", (*vector)[i]);
589 
590  fprintf(file, "\n");
591  fflush(file);
592  return;
593 }
594 
595 
596 
597 
598 
599 
600 #if 0 /* NOT USED */
601 /*
602  * Returns a rotation matrix representing rotation by angle "theta" about
603  * axis "axis"
604  *
605  * theta in RADIANS
606  */
607 static void
608 LALDR_EulerRotation(LALDR_33Matrix * rotationMatrix,
609  REAL8 theta,
610  LALDR_Axis_t axis)
611 {
612  REAL8 cosTheta, sinTheta;
613 
614  cosTheta = cos((double)theta);
615  sinTheta = sin((double)theta);
616 
617  switch (axis)
618  {
619  case zAxis:
620  LALDR_Set33Matrix(rotationMatrix,
621  cosTheta, sinTheta, 0.,
622  -sinTheta, cosTheta, 0.,
623  0., 0., 1.);
624  break;
625 
626  case yAxis:
627  LALDR_Set33Matrix(rotationMatrix,
628  cosTheta, 0., -sinTheta,
629  0., 1., 0.,
630  sinTheta, 0., cosTheta);
631  break;
632 
633  case xAxis:
634  LALDR_Set33Matrix(rotationMatrix,
635  1., 0., 0.,
636  0., cosTheta, sinTheta,
637  0., -sinTheta, cosTheta);
638  break;
639  }
640 
641  return;
642 }
643 #endif
644 #endif
645 
646 
647 REAL4 skygrid_avg(const skygrid_t response);
648 void skygrid_square(skygrid_t square, const skygrid_t input);
649 REAL4 skygrid_rms(const skygrid_t input);
650 void skygrid_sqrt(skygrid_t result, const skygrid_t input);
652 void skygrid_print(const char * comments, const skygrid_t input,
653  const char * filename);
654 void skygrid_fabs(skygrid_t absgrid, const skygrid_t input);
655 void skygrid_add(skygrid_t sum, const skygrid_t a, const skygrid_t b);
656 void skygrid_subtract(skygrid_t sum, const skygrid_t a, const skygrid_t b);
657 void skygrid_scalar_mult(skygrid_t result, const skygrid_t a, REAL4 b);
658 
659 void setup_global_detectors(void);
660 void set_source_params(LALSource * source, const char *name, REAL8 ra_rad,
661  REAL8 dec_rad, REAL8 orien_rad);
662 void print_source_maybe(const LALSource * source);
663 void setup_global_sources(void);
665 
666 void find_zero_gmst(void);
667 
668 typedef enum
669  {
672  gwpol_cross = 2
673  }
675 
676 /* response function in local horizon coordinates (from GRASP)
677  * psi = source orientation
678  * theta = source polar angle = Pi/2 - altitude
679  * phi = source azimuth
680  * pol = selects which response, F+ or Fx, to compute */
682 
683 /* error-handled fopen */
684 FILE *xfopen(const char *path, const char *mode);
685 int xfclose(FILE *stream);
686 
687 /* wrapped laldr_strlcpy() to guarantee NUL termination */
688 char *laldr_strlcpy(char *dst, const char *src, size_t len);
689 
690 /* static int local_strncasecmp(const char *, const char *, size_t); */
691 
692 /*
693  * Test modules
694  */
698 
699 /* FIXME */
701 
702 /* Yes, I do mean for the following block to be #if'ed out */
703 #if 0
704 /*
705  * This computes the effective longitude and latitude of a detector, given
706  * an LALDetector. It stuffs its results in a SkyPosition structure in
707  * RADIANS.
708  */
709 static void
710 LALDR_GetEffectiveLoc(SkyPosition *eff_loc, const LALDetector *detector)
711 {
712  REAL8 theta_x, phi_x;
713  REAL8 theta_y, phi_y;
714  REAL8 sinTheta;
715 
716  LALDR_3Vector e_xarm;
717  LALDR_3Vector e_yarm;
718 
719  LALDR_3Vector normal;
720 
721  SkyPosition delta_loc;
722 
723 
724  /*
725  * First, we need the unit vectors representing the arm directions
726  */
727 
728  /* polar angle, x-arm */
729  theta_x = LAL_PI_2 - detector->frDetector.xArmAltitudeRadians;
730 
731  /* azimuthal angle. I want it measure anti-clockwise from S, the LAL
732  * convention measures anti-clockwise of E */
733  phi_x = LAL_PI_2 + detector->frDetector.xArmAzimuthRadians;
734 
735  /* and the unit vector is: */
736  sinTheta = sin(theta_x);
737  e_xarm[0] = sinTheta * cos(phi_x);
738  e_xarm[1] = sinTheta * sin(phi_x);
739  e_xarm[2] = cos(theta_x);
740 
741  /* polar angle, y-arm */
742  theta_y = LAL_PI_2 - detector->frDetector.yArmAltitudeRadians;
743 
744  /* azimuthal angle. I want it measure anti-clockwise from S, the LAL
745  * convention measures anti-clockwise of E */
746  phi_y = LAL_PI_2 + detector->frDetector.yArmAzimuthRadians;
747 
748  /* and the unit vector is: */
749  sinTheta = sin(theta_y);
750  e_yarm[0] = sinTheta * cos(phi_y);
751  e_yarm[1] = sinTheta * sin(phi_y);
752  e_yarm[2] = cos(theta_y);
753 
754  /* so, the normal to the plane of the detector is */
755  LALDR_CrossProd3Vector(normal, e_xarm, e_yarm);
756 
757  /* then, polar angles of this normal vector will tell me the residuals
758  * of the latitude and longitude, though not directly:
759  *
760  * say a = decrease in longitude
761  * b = decrease in latitude
762  *
763  * an active rotation formed by
764  *
765  * R_x = [ 1 0 0
766  * 0 cos(a) -sin(a)
767  * 0 sin(a) cos(a) ]
768  *
769  * R_y = [ cos(b) 0 sin(b)
770  * 0 1 0
771  * -sin(b) 0 cos(b) ]
772  *
773  * and acting on e_z = [0 0 1] should give me the normal vector as computed
774  * by doing the crossproduct of the arms above. We then solve for the
775  * angles a and b:
776  *
777  * normal = R_y * R_x * e_z
778  * = [ sin(b)*cos(a) -sin(a) cos(b)*cos(a) ]
779  *
780  * so,
781  * a = arcsin(-normal[2])
782  * b = arctan(normal[1] / normal[3])
783  */
784  delta_loc.longitude = asin(-normal[1]);
785  delta_loc.latitude = atan2(normal[0], normal[2]);
786 
787  /* And thus, the effective location is */
788  eff_loc->longitude = deg_to_rad(detector->frDetector.vertexLongitudeDegrees)
789  - delta_loc.longitude;
790  eff_loc->latitude = deg_to_rad(detector->frDetector.vertexLatitudeDegrees)
791  - delta_loc.latitude;
792 
793  return;
794 
795 } /* END: GetEffectiveLoc() */
796 #endif
797 
798 
799 
800 int main(int argc, char *argv[])
801 {
802  static LALStatus status;
803  LALSource pulsar;
804  LALFrDetector frdet; /* Framelib detector info */
805  LALDetector detector;
806  LIGOTimeGPS gps;
807  struct tm utcDate;
808  LALDetAndSource det_and_pulsar;
809  LALDetAMResponse am_response;
810  LALDetAMResponse expected_resp;
811 
812  LALDetAMResponseSeries am_response_series = {NULL,NULL,NULL};
813  REAL4TimeSeries plus_series, cross_series, scalar_series,
814  circ_series, sum_series;
815  REAL4 mean;
816  /* REAL4Vector diffVector; */
817  LALTimeIntervalAndNSample time_info;
818 
819  INT4 k;
820  INT4 i, j;
821  INT4 cnt;
822  REAL4 tolerance;
823 
824  REAL8 tmpgmst;
825  REAL8 gmst1;
826 
827  skygrid_t plus;
828  skygrid_t cross;
829  skygrid_t sqsum;
830  skygrid_t plus_sq_time_avg;
831  skygrid_t cross_sq_time_avg;
832  skygrid_t sum_of_sq_time_avg;
833  skygrid_t tmpskygrid;
834  skygrid_t tmpskygrid2;
835  FILE *file_plus_sq_avg = NULL;
836  FILE *file_cross_sq_avg = NULL;
837  FILE *file_plus_at_0_0 = NULL;
838  FILE *file_cross_at_0_0 = NULL;
839  FILE *file_plus_at_2_10 = NULL;
840  FILE *file_cross_at_2_10 = NULL;
841  FILE *file_cross_at_4_15 = NULL;
842  FILE *file_plus_at_4_15 = NULL;
843  FILE *file_cross_at_m4_15 = NULL;
844  FILE *file_plus_at_m4_15 = NULL;
845  FILE *file_sum_sq_avg = NULL;
846  FILE *file_sum_sq = NULL;
847  FILE *file_theta = NULL;
848  FILE *file_phi = NULL;
849 
850  if (argc >= 3)
851  {
852  verbose_level = atoi(argv[2]);
854  }
855 
858 
859 
860  /* this section is just for finding out a time when GMST is equal to 0 */
861  /* and the answer is: GPS = 13675020:943750000 */
862  if (lalDebugLevel == 69)
863  {
864  find_zero_gmst();
865  goto conclusion;
866  }
867 
868 
869  /* "crab pulsar" test, to compare with numbers produced by Greg Mendell
870  * and Malik Rakhmanov */
871  if (lalDebugLevel == 13)
872  {
874  goto conclusion;
875  }
876 
878  {
879  exit(2);
880  }
881 
882  /*
883  * TEST 0: Test of matrix/vector manipulations
884  */
885  if (!passed_matrix_test_p())
886  {
887  fprintf(stderr, "Matrix test failed");
888  exit(3);
889  }
890 
891  /*********************************************/
892 
893  if (verbose_p)
894  {
895  printf("TEST OF XLALCreateDetector()\n");
896  printf("---------------------------\n\n");
897  printf("Manual inspection required.\n");
898  }
899 
900  (void)laldr_strlcpy(frdet.name, "Reference", LALNameLength);
902  frdet.vertexLatitudeRadians = deg_to_rad(0.);
903  frdet.vertexElevation = 0.;
904  frdet.xArmAltitudeRadians = 0.;
905  frdet.yArmAltitudeRadians = 0.;
906  frdet.xArmAzimuthRadians = deg_to_rad(90.);
907  frdet.yArmAzimuthRadians = deg_to_rad(0.);
908 
909  XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF);
910 
911  if (verbose_p)
912  {
913  PrintLALDetector(&detector);
914  }
915 
917 
918  /*********************************************/
919 
920  /* parameters come from LIGO-T980044-10 (Althouse, et al.)
921  * and we note that the suffix number 10 is greater than A....
922  * I know consistency is the hobgoblin etc. etc. but this is a bit
923  * ridiculous.
924  *
925  * The referenced paper gives:
926  * LHO -- x-arm azimuth = N 35.9994deg W
927  * altitude = -6.195e-04 rad
928  * -- y-arm azimuth = S 54.0006deg W
929  * altitude = +1.25e-05 rad
930  *
931  * LLO -- x-arm azimuth = S 72.2835deg W
932  * altitude = -3.121e-04 rad
933  * -- y-arm azimuth = S 17.7165deg E
934  * altitude = -6.107e-04 rad
935  *
936  * Which gives us the following in conventional bearing notation,
937  * i.e. degrees clockwise from North
938  *
939  * 1. LHO -- x-arm azimuth = 324.0006deg =
940  * y-arm azimuth = 234.0006deg =
941  * (check: x-arm azi - y-arm azi = 90.0000deg)
942  *
943  * 2. LLO -- x-arm azimuth = 252.2835deg =
944  * y-arm azimuth = 162.2835deg =
945  * (check: x-arm azi - y-arm azi = 90.0000deg)
946  *
947  */
948 
949  /* First, pass a LALFrDetector using Frame spec for azimuths (East of
950  North) */
951  (void)laldr_strlcpy(frdet.name, "LHO, from FrDetector struct (Frame spec)",
952  LALNameLength);
953  frdet.vertexLongitudeRadians = (REAL8)deg_to_rad(-119. - 25./60. - 27.5657/3600.);
954  frdet.vertexLatitudeRadians = (REAL8)deg_to_rad(46. + 27./60. + 18.528/3600.);
955  frdet.vertexElevation = 142.554;
956  frdet.xArmAltitudeRadians = -6.195e-04;
957  frdet.yArmAltitudeRadians = 1.250e-05;
958  frdet.xArmAzimuthRadians = deg_to_rad(324.0006);
959  frdet.yArmAzimuthRadians = deg_to_rad(234.0006);
960 
961  XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF);
962 
964  {
965  if (verbose_p)
966  {
967  fprintf(stderr, "WARNING: LHO computed w/ Frame spec != LHO cached\n");
968  }
969  }
970 
971 
972  if (verbose_p)
973  {
974  printf("LHO tensor converted from LALFrDetector (Frame spec):\n");
975  PrintLALDetector(&detector);
976  printf("\n- - - - -\n");
977  }
978 
979  /* Second, pass a LALFrDetector using LAL (package-tools) spec for azi
980  (counterclockwise from East) */
981  (void)laldr_strlcpy(frdet.name, "LHO, from FrDetector struct (package-tools spec)",
982  LALNameLength);
983  frdet.vertexLongitudeRadians = (REAL8)deg_to_rad(-119. - 25./60. - 27.5657/3600.);
984  frdet.vertexLatitudeRadians = (REAL8)deg_to_rad(46. + 27./60. + 18.528/3600.);
985  frdet.vertexElevation = 142.554;
986  frdet.xArmAltitudeRadians = -6.195e-04;
987  frdet.yArmAltitudeRadians = 1.250e-05;
988  frdet.xArmAzimuthRadians = deg_to_rad(125.9994);
989  frdet.yArmAzimuthRadians = deg_to_rad(215.9994);
990  /* check: y-arm azi - x-arm azi = 90deg */
991 
992  XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF);
993 
995  {
996  if (verbose_p)
997  fprintf(stderr, "WARNING: LHO computed w/ package-tools spec != LHO cached\n");
998  }
999 
1000 
1001  if (verbose_p)
1002  {
1003  printf("LHO tensor converted from LALFrDetector (package-tools spec):\n");
1004  PrintLALDetector(&detector);
1005  printf("\n- - -\n");
1006  }
1007 
1008  /* Third, use data from the CreateDetector (DetectorSite.h) doco */
1009  (void)laldr_strlcpy(frdet.name, "LHO, from FrDetector struct (numbers from doco)",
1010  LALNameLength);
1011  frdet.vertexLongitudeRadians = (REAL8)deg_to_rad(-119. - 25./60. - 27.5657/3600.);
1012  frdet.vertexLatitudeRadians = (REAL8)deg_to_rad(46. + 27./60. + 18.528/3600.);
1013  frdet.vertexElevation = 142.554;
1014  frdet.xArmAltitudeRadians = -6.195e-04;
1015  frdet.yArmAltitudeRadians = 1.250e-05;
1016  frdet.xArmAzimuthRadians = deg_to_rad(324.0006);
1017  frdet.yArmAzimuthRadians = deg_to_rad(234.0006);
1018  /* check: y-arm azi - x-arm azi = -90deg ; ok, i think. */
1019 
1020  XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF);
1021 
1023  {
1024  if (verbose_p)
1025  fprintf(stderr,
1026  "WARNING: LHO computed w/ numbers from LAL documentation != LHO cached\n");
1027  }
1028 
1029  if (verbose_p)
1030  {
1031  printf("LHO tensor converted from LALFrDetector (numbers from doco):\n");
1032  PrintLALDetector(&detector);
1033  printf("\n- - -\n");
1034  }
1035 
1036 
1037 
1038  /* Fourth, look at the cached detector for comparison */
1040 
1041  if (verbose_p)
1042  {
1043  printf("LHO tensor, cached by DetectorSite:\n");
1044  PrintLALDetector(&detector);
1045  }
1046 
1048 
1049 
1050  /*********************************************/
1051 
1052  /*
1053  * Let's try to make a trivial detector...
1054  * My "greenwich_equator" from the old AM code is at location (0,0),
1055  * with arms pointing south and west.
1056  */
1057  (void)laldr_strlcpy(frdet.name, "TRIVIAL 1", LALNameLength);
1058  frdet.vertexLongitudeRadians = 0.;
1059  frdet.vertexLatitudeRadians = 0.;
1060  frdet.vertexElevation = 0.;
1061  frdet.xArmAltitudeRadians = 0.;
1062  frdet.yArmAltitudeRadians = 0.;
1063  frdet.xArmAzimuthRadians = deg_to_rad(180.);
1064  frdet.yArmAzimuthRadians = deg_to_rad( 90.);
1065 
1066  if (!XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF) && lalDebugLevel)
1067  {
1068  fprintf(stderr,
1069  "LALTestDetResponse0: XLALCreateDetector failed, line %i, %s\n",
1070  __LINE__, "$Id$");
1071  REPORTSTATUS(&status);
1072  return status.statusCode;
1073  }
1074 
1075 
1076  if (verbose_p)
1077  {
1078  printf("TRIVIAL 1 (converted from FrDetector):\n");
1079  PrintLALDetector(&detector);
1080  }
1081 
1083 
1084 
1085  /*********************************************/
1086 
1087  tolerance = 0.05;
1088 
1089  if (verbose_p)
1090  {
1091  printf("TEST OF LALDetAMResponse()\n");
1092  printf("--------------------------\n\n");
1093  printf("Tolerance = % 15.8e\n\n", tolerance);
1094  }
1095 
1096  /*
1097  * TEST 1: test LALDetAMResponse() at particular points
1098  */
1099 
1100  /* Set a GPS time that's close to 0h GMST1. (Found this by trial and
1101  * error.) */
1102  gps.gpsSeconds = 61094;
1103  gps.gpsNanoSeconds = 640000000;
1104 
1105  /* Set up a source at (RA=0, Dec=0, orientation=0, at time GMST1=0) */
1106  (void)laldr_strlcpy(pulsar.name, "TEST PULSAR 1", LALNameLength);
1107  pulsar.equatorialCoords.longitude = 0.; /* RA */
1108  pulsar.equatorialCoords.latitude = 0.; /* Dec */
1110  pulsar.orientation = LAL_PI_2; /* orientation */
1111 
1112 
1113  /* Stuff Detector and Source into structure */
1114  det_and_pulsar.pDetector = &detector;
1115  det_and_pulsar.pSource = &pulsar;
1116 
1117  /*** expect (1, 0) */
1118  expected_resp.plus = 1.;
1119  expected_resp.cross = 0.;
1120  expected_resp.scalar = 0.;
1121 
1123  &gps, &expected_resp,
1124  tolerance),
1125  __LINE__);
1126 
1128 
1129  /*** expect (0, -1) */
1130  pulsar.orientation = -LAL_PI_4;
1131  expected_resp.plus = 0.;
1132  expected_resp.cross = -1.;
1133  expected_resp.scalar = 0.;
1134 
1136  &gps, &expected_resp,
1137  tolerance),
1138  __LINE__);
1139 
1141 
1142  /*** expect (-1, 0) */
1143  pulsar.orientation = 0;
1144  expected_resp.plus = -1.;
1145  expected_resp.cross = 0.;
1146  expected_resp.scalar = 0.;
1147 
1149  &gps, &expected_resp,
1150  tolerance),
1151  __LINE__);
1152 
1154 
1155  /*** expect (0.5, -sqrt(3)/2.) */
1156  pulsar.orientation = -LAL_PI/3.;
1157  expected_resp.plus = 0.5;
1158  expected_resp.cross = -sqrt(3.)/2.;
1159  expected_resp.scalar = 0.;
1160 
1162  &gps, &expected_resp,
1163  tolerance),
1164  __LINE__);
1165 
1167 
1168  /* switch detector to something less trivial */
1169  (void)laldr_strlcpy(frdet.name, "TRIVIAL 2", LALNameLength);
1170  frdet.vertexLongitudeRadians = deg_to_rad(0.);
1171  frdet.vertexLatitudeRadians = deg_to_rad(15.);
1172  frdet.vertexElevation = 0.;
1173  frdet.xArmAltitudeRadians = 0.;
1174  frdet.yArmAltitudeRadians = 0.;
1175  frdet.xArmAzimuthRadians = deg_to_rad(180.);
1176  frdet.yArmAzimuthRadians = deg_to_rad( 90.);
1177 
1178  XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF);
1179 
1180  if (verbose_p)
1181  PrintLALDetector(&detector);
1182 
1183  /* switch source to be overhead the detector */
1184  (void)laldr_strlcpy(pulsar.name, "TEST PULSAR 2", LALNameLength);
1185  pulsar.equatorialCoords.longitude = deg_to_rad(0.);
1186  pulsar.equatorialCoords.latitude = deg_to_rad(15.);
1187  pulsar.orientation = -LAL_PI_2;
1188 
1189  det_and_pulsar.pDetector = &detector;
1190  det_and_pulsar.pSource = &pulsar;
1191 
1192  /*** expect (1, 0 ) */
1193  expected_resp.plus = 1.;
1194  expected_resp.cross = 0.;
1195  expected_resp.scalar = 0.;
1196 
1198  &gps, &expected_resp,
1199  tolerance),
1200  __LINE__);
1201 
1203 
1204  /*** expect (0, -1) */
1205  pulsar.orientation = -LAL_PI_2/2.;
1206  expected_resp.plus = 0.;
1207  expected_resp.cross = -1.;
1208  expected_resp.scalar = 0.;
1209 
1211  &gps, &expected_resp,
1212  tolerance),
1213  __LINE__);
1214 
1216 
1217  /*** expect (-1, 0) */
1218  pulsar.orientation = 0.;
1219  expected_resp.plus = -1.;
1220  expected_resp.cross = 0.;
1221  expected_resp.scalar = 0.;
1222 
1224  &gps, &expected_resp,
1225  tolerance),
1226  __LINE__);
1227 
1229 
1230  /*** expect (0.5, -sqrt(3)/2) */
1231  pulsar.orientation = -LAL_PI/3.;
1232  expected_resp.plus = 0.5;
1233  expected_resp.cross = -sqrt(3.)/2.;
1234  expected_resp.scalar = 0.;
1235 
1237  &gps, &expected_resp,
1238  tolerance),
1239  __LINE__);
1240 
1242 
1243 
1244  /*** expect () */
1245  pulsar.orientation = -LAL_PI_2;
1246  pulsar.equatorialCoords.longitude = 0.;
1247  pulsar.equatorialCoords.latitude = 0.;
1248 
1249  (void)laldr_strlcpy(frdet.name, "TRIVIAL 1", LALNameLength);
1250  frdet.vertexLongitudeRadians = 0.;
1252  frdet.vertexElevation = 0.;
1253  frdet.xArmAltitudeRadians = 0.;
1254  frdet.yArmAltitudeRadians = 0.;
1255  frdet.xArmAzimuthRadians = deg_to_rad(180.);
1256  frdet.yArmAzimuthRadians = deg_to_rad( 90.);
1257 
1258  if (!XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF) && lalDebugLevel)
1259  {
1260  fprintf(stderr,
1261  "LALTestDetResponse0: XLALCreateDetector failed, line %i, %s\n",
1262  __LINE__, "$Id$");
1263  REPORTSTATUS(&status);
1264  return status.statusCode;
1265  }
1266 
1267  utcDate.tm_sec = 46;
1268  utcDate.tm_min = 20;
1269  utcDate.tm_hour = 8;
1270  utcDate.tm_mday = 17;
1271  utcDate.tm_mon = 4; /* may */
1272  utcDate.tm_year = 1994 - 1900;
1273  utcDate.tm_wday = 2;
1274  utcDate.tm_yday = 136;
1275  utcDate.tm_isdst = 0;
1276 
1277  XLALGPSSet(&gps, XLALUTCToGPS(&utcDate), 0);
1278 
1279  tmpgmst = XLALGreenwichMeanSiderealTime(&gps);
1280 
1281  if (verbose_p)
1282  printf("GMST1 = % 14.9e rad.\n", tmpgmst);
1283 
1284  expected_resp.plus = 0.5;
1285  expected_resp.cross = 0.;
1286  expected_resp.scalar = 0.;
1287 
1288  det_and_pulsar.pDetector = &detector;
1289  det_and_pulsar.pSource = &pulsar;
1290 
1291  if (verbose_p)
1292  {
1293  PrintLALDetector(&detector);
1294  fflush(stdout);
1295  }
1296 
1298  &gps, &expected_resp, tolerance),
1299  __LINE__);
1300 
1302 
1303 
1304  /* switch detector to LHO */
1306 
1307  /* switch source */
1308  (void)laldr_strlcpy(pulsar.name, "TEST PULSAR 3", LALNameLength);
1309  pulsar.equatorialCoords.longitude = deg_to_rad(16.037547 * 15.);
1310  pulsar.equatorialCoords.latitude = deg_to_rad(46.475430);
1311  pulsar.orientation = -LAL_PI_2;
1312 
1313  utcDate.tm_sec = 46;
1314  utcDate.tm_min = 20;
1315  utcDate.tm_hour = 8;
1316  utcDate.tm_mday = 17;
1317  utcDate.tm_mon = 4; /* may */
1318  utcDate.tm_year = 1994 - 1900;
1319  utcDate.tm_wday = 2;
1320  utcDate.tm_yday = 136;
1321  utcDate.tm_isdst = 0;
1322 
1323  XLALGPSSet(&gps, XLALUTCToGPS(&utcDate), 0);
1324 
1325  det_and_pulsar.pDetector = &detector;
1326  det_and_pulsar.pSource = &pulsar;
1327 
1328  /* expect (3.08260644404358e-01, -9.51301793267616e-01 */
1329  expected_resp.plus = 3.08260644404358e-01;
1330  expected_resp.cross = -9.51301793267616e-01;
1331  expected_resp.scalar = 0.;
1332 
1334  &gps, &expected_resp,
1335  tolerance),
1336  __LINE__);
1337 
1339 
1340  /* change to even less trivial detector */
1341  (void)laldr_strlcpy(frdet.name, "TRIVIAL 3", LALNameLength);
1342  frdet.vertexLongitudeRadians = deg_to_rad(15.);
1343 
1344  XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF);
1345 
1346  if (verbose_p)
1347  PrintLALDetector(&detector);
1348 
1349 
1350  /* now have to choose a source whose RA is 15 degrees towards the East;
1351  whaddaya know? that's 1 hour */
1352  pulsar.equatorialCoords.longitude = deg_to_rad(15.);
1353 
1354  det_and_pulsar.pDetector = &detector;
1355  det_and_pulsar.pSource = &pulsar;
1356 
1357  /*
1358  * Compute a time series AM response
1359  */
1360  if (verbose_p)
1361  printf("Starting vector test\n");
1362 
1363  /* fake detector */
1364  detector.location[0] = 0.;
1365  detector.location[1] = 0.;
1366  detector.location[2] = LAL_AWGS84_SI;
1367  detector.response[0][0] = 0.;
1368  detector.response[1][1] = 0.5;
1369  detector.response[2][2] = -0.5;
1370  detector.response[0][1] = detector.response[1][0] = 0.;
1371  detector.response[0][2] = detector.response[2][0] = 0.;
1372  detector.response[1][2] = detector.response[2][1] = 0.;
1373  detector.type = LALDETECTORTYPE_ABSENT;
1374  (void)laldr_strlcpy(detector.frDetector.name, "FAKE", LALNameLength);
1375 
1376 
1377  /* Make a fake detector by specifying frame format detector */
1378  (void)laldr_strlcpy(frdet.name, "FAKE FAKE, NOT THE REAL MCCOY", LALNameLength);
1380  frdet.vertexLatitudeRadians = (REAL8)deg_to_rad(90.); /* @ N pole */
1381  frdet.vertexElevation = 0.;
1382  frdet.xArmAltitudeRadians = 0.;
1383  frdet.yArmAltitudeRadians = 0.;
1384  frdet.xArmAzimuthRadians = deg_to_rad(90.);
1385  frdet.yArmAzimuthRadians = deg_to_rad( 0.);
1386 
1387  XLALCreateDetector(&detector, &frdet, LALDETECTORTYPE_IFODIFF);
1388 
1389  /* override - try the cached LHO */
1390  /* detector = lalCachedDetectors[LALDetectorIndexLHODIFF]; */
1391 
1392  if (verbose_p)
1393  {
1394  printf("Series test...\n");
1395  PrintLALDetector(&detector);
1396  }
1397 
1398  plus_series.data = NULL;
1399  cross_series.data = NULL;
1400  scalar_series.data = NULL;
1401  circ_series.data = NULL;
1402  sum_series.data = NULL;
1403 
1404  am_response_series.pPlus = &(plus_series);
1405  am_response_series.pCross = &(cross_series);
1406  am_response_series.pScalar = &(scalar_series);
1407 
1408  LALSCreateVector(&status, &(am_response_series.pPlus->data), 1);
1409  LALSCreateVector(&status, &(am_response_series.pCross->data), 1);
1410  LALSCreateVector(&status, &(am_response_series.pScalar->data), 1);
1411  LALSCreateVector(&status, &(circ_series.data), 1);
1412  LALSCreateVector(&status, &(sum_series.data), 1);
1413 
1414  if (lalDebugLevel > 0)
1415  {
1416  printf("am_response_series.pPlus->data->length = %d\n",
1417  am_response_series.pPlus->data->length);
1418  printf("am_response_series.pCros->data->length = %d\n",
1419  am_response_series.pCross->data->length);
1420  printf("am_response_series.pScalar->data->length = %d\n",
1421  am_response_series.pScalar->data->length);
1422  printf("circ_series.data->length = %d\n", circ_series.data->length);
1423  printf("sum_series.data->length = %d\n", sum_series.data->length);
1424  }
1425 
1426  time_info.epoch.gpsSeconds = 61094;
1427  time_info.epoch.gpsNanoSeconds = 640000000;
1428  time_info.deltaT = 60;
1429  /* time_info.nSample = 17*24*60; */
1430  time_info.nSample = 24*60;
1431 
1433  &am_response_series,
1434  &det_and_pulsar,
1435  &time_info);
1436 
1437  if (status.statusCode && verbose_p)
1438  {
1439  fprintf(stderr,
1440  "LALTestDetResponse0: error in LALComputeDetAMResponseSeries, line %i, %s\n",
1441  __LINE__, "$Id$");
1442  return status.statusCode;
1443  }
1444 
1445  if (lalDebugLevel > 0)
1446  {
1447  printf("Done computing AM response vectors\n");
1448 
1449  printf("am_response_series.pPlus->data->length = %d\n",
1450  am_response_series.pPlus->data->length);
1451  printf("am_response_series.pCross->data->length = %d\n",
1452  am_response_series.pCross->data->length);
1453  printf("am_response_series.pScalar->data->length = %d\n",
1454  am_response_series.pScalar->data->length);
1455 
1456  printf("TimeSeries data written to files plus_series.txt, ");
1457  printf("cross_series.txt, and scalar_series.txt\n");
1458 
1459  LALSPrintTimeSeries(am_response_series.pPlus, "plus_series.txt");
1460  LALSPrintTimeSeries(am_response_series.pCross, "cross_series.txt");
1461  LALSPrintTimeSeries(am_response_series.pScalar, "scalar_series.txt");
1462 
1463  /* compute circular response */
1464  /* need to resize vector */
1465  LALSDestroyVector(&status, &(circ_series.data));
1466  LALSCreateVector(&status, &(circ_series.data),
1467  am_response_series.pPlus->data->length);
1468  printf("circ_series.data->length = %d\n", circ_series.data->length);
1469 
1470  LALSDestroyVector(&status, &(sum_series.data));
1471  LALSCreateVector(&status, &(sum_series.data),
1472  am_response_series.pPlus->data->length);
1473  printf("sum_series.data->length = %d\n", sum_series.data->length);
1474 
1475  circ_series.epoch = am_response_series.pPlus->epoch;
1476  circ_series.deltaT = am_response_series.pPlus->deltaT;
1477  circ_series.f0 = am_response_series.pPlus->f0;
1478  circ_series.sampleUnits = lalDimensionlessUnit;
1479 
1480  sum_series.epoch = am_response_series.pPlus->epoch;
1481  sum_series.deltaT = am_response_series.pPlus->deltaT;
1482  sum_series.f0 = am_response_series.pPlus->f0;
1483  sum_series.sampleUnits = lalDimensionlessUnit;
1484 
1485  mean = 0.;
1486  for (k = 0; k < (INT4)(circ_series.data->length); ++k)
1487  {
1488  /* sqrt(Fplus^2 + Fcross^2) */
1489  circ_series.data->data[k] =
1490  sqrt(am_response_series.pPlus->data->data[k] *
1491  am_response_series.pPlus->data->data[k] +
1492  am_response_series.pCross->data->data[k] *
1493  am_response_series.pCross->data->data[k]);
1494 
1495  /* (Fplus + Fcross)^2 */
1496  sum_series.data->data[k] =
1497  (am_response_series.pPlus->data->data[k]
1498  + am_response_series.pCross->data->data[k])
1499  * (am_response_series.pPlus->data->data[k]
1500  + am_response_series.pCross->data->data[k]);
1501 
1502  mean += sum_series.data->data[k];
1503  }
1504 
1505  mean /= (REAL8)(sum_series.data->length);
1506 
1507  printf("mean = % 14.7e\n", mean);
1508 
1509  LALSPrintTimeSeries(&circ_series, "circ_series.txt");
1510  LALSPrintTimeSeries(&sum_series, "sum_series.txt");
1511  }
1512 
1513  if (lalDebugLevel & 8)
1514  {
1515  printf("plus: (");
1516  for (k = 0; k < (INT4)(time_info.nSample); ++k)
1517  {
1518  printf("% 14.6e, ", am_response_series.pPlus->data->data[k]);
1519  }
1520  printf(")\n");
1521 
1522  printf("cross: (");
1523  for (k = 0; k < (INT4)(time_info.nSample); ++k)
1524  {
1525  printf("% 14.6e, ", am_response_series.pCross->data->data[k]);
1526  }
1527  printf(")\n");
1528 
1529  printf("scalar: (");
1530  for (k = 0; k < (INT4)(time_info.nSample); ++k)
1531  {
1532  printf("% 14.6e, ", am_response_series.pScalar->data->data[k]);
1533  }
1534  printf(")\n");
1535 
1536 
1537  /* print out quadrature sum of plus- and cross-response */
1538  printf("sqrt(PLUS^2 + CROSS^2): (");
1539  for (k = 0; k < (INT4)(time_info.nSample); ++k)
1540  {
1541  printf("% 1.6e, ", sqrt(am_response_series.pPlus->data->data[k] *
1542  am_response_series.pPlus->data->data[k] +
1543  am_response_series.pCross->data->data[k] *
1544  am_response_series.pCross->data->data[k]));
1545  }
1546  printf(")\n");
1547  }
1548 
1549 
1551 
1552 
1553  /*
1554  * Loop over whole sky
1555  */
1556  if (verbose_p && lalDebugLevel)
1557  {
1558  printf("ALOHA\n");
1559  printf("time_info.nSample = %d\n", time_info.nSample);
1560  }
1561 
1562  /* use Livingston */
1563  /* detector = lalCachedDetectors[LALDetectorIndexLLODIFF]; */
1564 
1565  if (lalDebugLevel >= 1)
1566  {
1567  gmst1 = 0.;
1568 
1569  printf("\nStarting whole-sky test...\n");
1570  det_and_pulsar.pDetector = &det_north_pole;
1571  PrintLALDetector(det_and_pulsar.pDetector);
1572  printf("NUM_RA = %d; NUM_DEC = %d\n", NUM_RA, NUM_DEC);
1573 
1574  file_plus_sq_avg = xfopen("plus_sq_avg.txt", "w");
1575  file_cross_sq_avg = xfopen("cross_sq_avg.txt", "w");
1576  file_plus_at_0_0 = xfopen("plus_at_0_0.txt", "w");
1577  file_cross_at_0_0 = xfopen("cross_at_0_0.txt", "w");
1578  file_plus_at_2_10 = xfopen("plus_at_2_10.txt", "w");
1579  file_cross_at_2_10 = xfopen("cross_at_2_10.txt", "w");
1580  file_plus_at_4_15 = xfopen("plus_at_4_15.txt", "w");
1581  file_cross_at_4_15 = xfopen("cross_at_4_15.txt", "w");
1582  file_plus_at_m4_15 = xfopen("plus_at_m4_15.txt", "w");
1583  file_cross_at_m4_15 = xfopen("cross_at_m4_15.txt", "w");
1584  file_sum_sq_avg = xfopen("sum_sq_avg.txt", "w");
1585  file_sum_sq = xfopen("sum_sq.txt", "w");
1586  file_theta = xfopen("theta.txt", "w");
1587  file_phi = xfopen("phi.txt", "w");
1588 
1589  printf("Done opening files.\n");
1590 
1591  /* Set a GPS time that's close to 0h GMST1. Found this by trial and
1592  * error:
1593  * GPS = 13675020:943728537; gmst1 = 2.68743469376486e-10
1594  * Later, need to use a Science Run time period. */
1595  gps.gpsSeconds = 13675020;
1596  gps.gpsNanoSeconds = 943728537;
1597 
1598  printf("N sample = %d\n", time_info.nSample);
1599 
1600  pulsar.orientation = deg_to_rad(45.);
1601 
1602  for (k = 0; k < (int)time_info.nSample; ++k)
1603  {
1604  gmst1 = XLALGreenwichMeanSiderealTime(&gps);
1605 
1606  if (verbose_level & 16)
1607  printf("GRAR: k = %6d; gmst1 = % 20.14e\n", k, gmst1);
1608 
1609  for (j = 0; j < NUM_RA; ++j)
1610  {
1611  pulsar.equatorialCoords.longitude =
1612  (REAL8)j/(REAL8)NUM_RA * ((REAL8)LAL_TWOPI); /* RA */
1613 
1614  for (i = -declim; i <= declim; ++i)
1615  {
1616  cnt = j*NUM_DEC + i + declim;
1617 
1618  if (verbose_level & 16)
1619  printf("OY: k = %6d; j = %6d; i = %6d\n", k, j, i);
1620 
1621  pulsar.equatorialCoords.latitude =
1622  asin((REAL8)i/(REAL8)declim);
1623 
1624  if (k == 0 && j == 0 && i == -declim)
1625  printf("FOO: gmst1 = % 20.14e\n", gmst1);
1626  LALComputeDetAMResponse(&status, &am_response,
1627  &det_and_pulsar, &gps);
1628 
1629  plus[cnt] = am_response.plus;
1630  cross[cnt] = am_response.cross;
1631  sqsum[cnt] = (plus[cnt] * plus[cnt])
1632  + (cross[cnt] * cross[cnt]);
1633 
1634  if (i == 0 && j == 0)
1635  {
1636  fprintf(file_plus_at_0_0, "%4d % 14.9e %9d % 14.9e\n",
1637  k, gmst1, gps.gpsSeconds, plus[cnt]);
1638  fprintf(file_cross_at_0_0, "%4d % 14.9e %9d % 14.9e\n",
1639  k, gmst1, gps.gpsSeconds,
1640  cross[cnt]);
1641  fprintf(file_sum_sq, "%4d % 14.9e %9d % 14.9e\n",
1642  k, gmst1, gps.gpsSeconds,
1643  sqsum[cnt]);
1644  }
1645 
1646  if (i == 2 && j == 10)
1647  {
1648  fprintf(file_plus_at_2_10, "% 14.9e % 14.9e\n",
1649  gmst1, plus[cnt]);
1650  fprintf(file_cross_at_2_10, "% 14.9e % 14.9e\n",
1651  gmst1, cross[cnt]);
1652  }
1653 
1654  if (i == 4 && j == 15)
1655  {
1656  fprintf(file_plus_at_4_15, "% 14.9e % 14.9e\n", gmst1,
1657  plus[cnt]);
1658  fprintf(file_cross_at_4_15, "% 14.9e % 14.9e\n",
1659  gmst1, cross[cnt]);
1660  }
1661 
1662  if (i == -4 && j == 15)
1663  {
1664  fprintf(file_plus_at_m4_15, "% 14.9e\n", plus[cnt]);
1665  fprintf(file_cross_at_m4_15, "% 14.9e\n", cross[cnt]);
1666  }
1667  }
1668  }
1669 
1670  /* print out avg. square over sky for each time step */
1671  skygrid_square(tmpskygrid, plus);
1672  fprintf(file_plus_sq_avg, "% 14.9e\n", skygrid_avg(tmpskygrid));
1673 
1674  skygrid_square(tmpskygrid2, cross);
1675  fprintf(file_cross_sq_avg, "% 14.9e\n", skygrid_avg(tmpskygrid2));
1676 
1677  skygrid_scalar_mult(tmpskygrid, tmpskygrid, 1./time_info.nSample);
1678  skygrid_add(plus_sq_time_avg, plus_sq_time_avg, tmpskygrid);
1679 
1680  skygrid_scalar_mult(tmpskygrid2, tmpskygrid2, 1./time_info.nSample);
1681  skygrid_add(cross_sq_time_avg, cross_sq_time_avg, tmpskygrid2);
1682 
1683  skygrid_add(sum_of_sq_time_avg, plus_sq_time_avg, cross_sq_time_avg);
1684 
1685  if (k == 0)
1686  {
1687  skygrid_print("LAL-computed response to plus", plus,
1688  "plus.txt");
1689  skygrid_print("LAL-computed response to cross", cross,
1690  "cross.txt");
1691 
1692  skygrid_square(tmpskygrid, plus);
1693  skygrid_square(tmpskygrid2, cross);
1694  skygrid_add(tmpskygrid, tmpskygrid, tmpskygrid2);
1695  printf("BAR: gmst1 = % 20.15e\n", gmst1);
1696  printf("avg(F+^2 + Fx^2) = % 14.8e\n", skygrid_avg(tmpskygrid));
1697  }
1698 
1699  /* increment observation time */
1700  XLALGPSAdd(&gps, 600.0);
1701  }
1702  printf("\n");
1703 
1704  skygrid_print("LAL-computed time avg. of square of response to plus",
1705  plus_sq_time_avg, "plus_sq_time_avg.txt");
1706  skygrid_print("LAL-computed time avg. of square of response to cross",
1707  cross_sq_time_avg, "cross_sq_time_avg.txt");
1708  skygrid_print("LAL-computed time avg. of sum of squares of response to plus and cross",
1709  sum_of_sq_time_avg, "sum_of_sq_time_avg.txt");
1710 
1711  fprintf(file_plus_sq_avg, "\n");
1712  fprintf(file_cross_sq_avg, "\n");
1713  fprintf(file_plus_at_0_0, "\n");
1714  fprintf(file_cross_at_0_0, "\n");
1715  fprintf(file_plus_at_2_10, "\n");
1716  fprintf(file_cross_at_2_10, "\n");
1717  fprintf(file_plus_at_4_15, "\n");
1718  fprintf(file_cross_at_4_15, "\n");
1719  fprintf(file_plus_at_m4_15, "\n");
1720  fprintf(file_cross_at_m4_15, "\n");
1721  fprintf(file_sum_sq_avg, "\n");
1722  fprintf(file_sum_sq, "\n");
1723 
1724  if (verbose_p)
1725  printf("avg(F+^2 + Fx^2) = % 14.8e\n", skygrid_avg(sqsum));
1726 
1727  xfclose(file_plus_sq_avg);
1728  xfclose(file_cross_sq_avg);
1729  xfclose(file_plus_at_0_0);
1730  xfclose(file_cross_at_0_0);
1731  xfclose(file_plus_at_2_10);
1732  xfclose(file_cross_at_2_10);
1733  xfclose(file_plus_at_4_15);
1734  xfclose(file_cross_at_4_15);
1735  xfclose(file_plus_at_m4_15);
1736  xfclose(file_cross_at_m4_15);
1737  xfclose(file_sum_sq_avg);
1738  xfclose(file_sum_sq);
1739  xfclose(file_theta);
1740  xfclose(file_phi);
1741  }
1742 
1743  if (verbose_p)
1744  {
1745  printf("GRASP plus = % 14.9e\n", resp_local(0., 0., 0., gwpol_plus));
1746  printf(" cross = % 14.9e\n", resp_local(0., 0., 0., gwpol_cross));
1747 
1748  printf("GRASP plus = % 14.9e\n", resp_local(LAL_PI_4, 0., 0., gwpol_plus));
1749  printf(" cross = % 14.9e\n", resp_local(LAL_PI_4, 0., 0., gwpol_cross));
1750 
1751  fflush(stdout);
1752  }
1753 
1755 
1756  if (verbose_p)
1757  printf("\n\nGOODBYE.\n");
1758 
1759  /*
1760  * Housekeeping
1761  */
1762  LALSDestroyVector(&status, &(am_response_series.pPlus->data));
1763  LALSDestroyVector(&status, &(am_response_series.pCross->data));
1764  LALSDestroyVector(&status, &(am_response_series.pScalar->data));
1765  LALSDestroyVector(&status, &(circ_series.data));
1766  LALSDestroyVector(&status, &(sum_series.data));
1767 
1768  conclusion:
1770 
1771  return 0;
1772 } /* END: main() */
1773 
1774 
1775 #if 0 /* NOT USED */
1776 /*
1777  * subtracts two REAL4Vectors; user must do all allocation beforehand
1778  */
1779 static void REAL4VectorSubtraction(REAL4Vector *pA,
1780  REAL4Vector *pB,
1781  REAL4Vector *pAminusB)
1782 {
1783  UINT4 i;
1784 
1785  /* Check for compatible dimensions */
1786  if ((pA->length != pB->length) || (pAminusB->length != pA->length) ||
1787  (pAminusB->length != pB->length))
1788  {
1789  fprintf(stderr, "VectorSubtraction: ERROR: incompatible dimensions\n");
1790  exit(13);
1791  }
1792 
1793  for (i = 0; i < pA->length; ++i)
1794  {
1795  pAminusB->data[i] = pA->data[i] - pB->data[i];
1796  }
1797 
1798  return;
1799 }
1800 #endif
1801 
1802 #if 0 /* NOT USED */
1803 static REAL4 REAL4VectorRMS(REAL4Vector *pVector)
1804 {
1805  UINT4 i;
1806  REAL4 result = 0.;
1807 
1808  for (i = 0; i < pVector->length; ++i)
1809  {
1810  result += pVector->data[i] * pVector->data[i];
1811  }
1812 
1813  result /= pVector->length;
1814 
1815  return sqrt(result);
1816 }
1817 #endif
1818 
1819 
1820 static void
1822 {
1823  printf( "Detector = \n");
1824  printf("{\n");
1825  printf(" { % 22.15e, % 22.15e, % 22.15e },\n",
1826  detector->location[0],
1827  detector->location[1],
1828  detector->location[2]);
1829  printf(" {\n");
1830  printf(" { % 22.15e, % 22.15e, % 22.15e },\n",
1831  detector->response[0][0],
1832  detector->response[0][1],
1833  detector->response[0][2]);
1834  printf( " { % 22.15e, % 22.15e, % 22.15e },\n",
1835  detector->response[1][0],
1836  detector->response[1][1],
1837  detector->response[1][2]);
1838  printf( " { % 22.15e, % 22.15e, % 22.15e }\n },\n",
1839  detector->response[2][0],
1840  detector->response[2][1],
1841  detector->response[2][2]);
1842  printf(" {\n");
1843  printf(" \"%s\",\n", detector->frDetector.name);
1844  printf(" vertex longitude = % 22.15e,\n",
1846  printf(" vertex latitude = % 22.15e,\n",
1847  detector->frDetector.vertexLatitudeRadians);
1848  printf(" vertex elevation = % 22.15e,\n",
1849  detector->frDetector.vertexElevation);
1850  printf(" X-arm altitude = % 22.15e,\n",
1851  detector->frDetector.xArmAltitudeRadians);
1852  printf(" X-arm azimuth = % 22.15e,\n",
1853  detector->frDetector.xArmAzimuthRadians);
1854  printf(" Y-arm altitude = % 22.15e,\n",
1855  detector->frDetector.yArmAltitudeRadians);
1856  printf(" Y-arm azimuth = % 22.15e\n }\n}\n",
1857  detector->frDetector.yArmAzimuthRadians);
1858  return;
1859 }
1860 
1861 
1862 
1863 
1865  LALDR_33Matrix * expected,
1866  REAL8 tolerance)
1867 {
1868  INT4 i, j;
1869  BOOLEAN retval;
1870 
1871  for (i = 0; i < 2; ++i)
1872  for (j = 0; j < 2; ++j)
1873  {
1874  if (!almost_equal_real8_p((REAL8)((*computed)[i][j]),
1875  (REAL8)((*expected)[i][j]),
1876  tolerance))
1877  {
1878  if (verbose_p)
1879  {
1880  LALDR_Print33Matrix(expected,
1881  "INFO: matrix_ok_p(): expected",
1882  0, stdout, "");
1883  LALDR_Print33Matrix(computed,
1884  "INFO: matrix_ok_p(): computed",
1885  0, stdout, "");
1886  }
1887 
1888  retval = FALSE;
1889  }
1890  else
1891  {
1892  retval = TRUE;
1893  }
1894  }
1895 
1896  return retval;
1897 }
1898 
1899 
1900 
1902  LALDR_3Vector * expected,
1903  REAL8 tolerance)
1904 {
1905  INT4 i;
1906  BOOLEAN retval;
1907 
1908  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
1909  {
1910  if (!almost_equal_real8_p((*computed)[i], (*expected)[i], tolerance))
1911  {
1912  if (verbose_p)
1913  {
1914  LALDR_Print3Vector(computed, "INFO: vector_ok_p(): computed",
1915  stdout);
1916  LALDR_Print3Vector(expected, "INFO: vector_ok_p(): expected",
1917  stdout);
1918  }
1919 
1920  retval = FALSE;
1921  }
1922  else
1923  {
1924  retval = TRUE;
1925  }
1926  }
1927 
1928  return retval;
1929 }
1930 
1931 
1932 
1933 
1935  const LALDR_3Vector * expected,
1936  REAL8 tolerance)
1937 {
1938  /* do this term-by-term rather than using a metric. bah. */
1939  INT4 i;
1940  REAL8 relative_diff;
1941  BOOLEAN retval;
1942 
1943  for (i = 0; i < LALDR_MATRIXSIZE; ++i)
1944  {
1945  relative_diff = fabs((*computed)[i]/(*expected)[i] - 1.);
1946 
1947  if (relative_diff <= tolerance)
1948  {
1949  retval = TRUE;
1950  }
1951  else
1952  {
1953  retval = FALSE;
1954  }
1955  }
1956 
1957  return retval;
1958 }
1959 
1960 
1961 
1962 
1963 static void print_m_results_maybe(const char * title,
1964  LALDR_33Matrix * computed,
1965  LALDR_33Matrix * expected)
1966 {
1967  size_t i;
1968  size_t title_length = strlen(title);
1969 
1970  if (verbose_p)
1971  {
1972  printf("%s:\n", title);
1973  for (i = 0; i < title_length + 1; ++i)
1974  printf("-");
1975  printf("\n");
1976  LALDR_Print33Matrix(computed, "Computed", 0, stdout, "");
1977  LALDR_Print33Matrix(expected, "Expected", 0, stdout, "");
1978  }
1979 }
1980 
1981 
1982 
1983 static void print_v_results_maybe(const char * title,
1984  LALDR_3Vector * computed,
1985  LALDR_3Vector * expected)
1986 {
1987  size_t i;
1988  size_t title_length = strlen(title);
1989 
1990  if (verbose_p)
1991  {
1992  printf("%s:\n", title);
1993  for (i = 0; i < title_length + 1; ++i)
1994  printf("-");
1995  printf("\n");
1996  LALDR_Print3Vector(computed, "Computed", stdout);
1997  LALDR_Print3Vector(expected, "Expected", stdout);
1998  }
1999 }
2000 
2001 
2002 static void print_s_results_maybe(const char * title,
2003  REAL8 computed,
2004  REAL8 expected)
2005 {
2006  size_t i;
2007  size_t title_length = strlen(title);
2008 
2009  if (verbose_p)
2010  {
2011  printf("%s:\n", title);
2012  for (i = 0; i < title_length + 1; ++i)
2013  printf("-");
2014  printf("\n");
2015  printf("Computed = %22.14e\n", computed);
2016  printf("Expected = %22.14e\n", expected);
2017  }
2018 }
2019 
2020 
2021 
2022 static int print_separator_maybe(void)
2023 {
2024  if (verbose_p)
2025  return printf("\n* * * * * * * * * *\n\n");
2026  else
2027  return 0;
2028 }
2029 
2030 
2031 
2033 {
2034  if (verbose_p)
2035  return printf("\n- - - - -\n\n");
2036  else
2037  return 0;
2038 }
2039 
2040 
2041 
2042 static int print_passed_maybe(void)
2043 {
2044  if (verbose_p)
2045  return printf("\nPASS\n");
2046  else
2047  return 0;
2048 }
2049 
2050 
2051 
2053 {
2054  if (lalDebugLevel >= 8)
2055  {
2056  printf("almost_equal_real4_p() info:\n");
2057  printf(" a = % 16.10e\n b = % 16.10e\n", a, b);
2058  printf(" (REAL4)fabs(a - b) = % 16.10e\n", (REAL4)fabs(a - b));
2059  printf(" tolerance = % 16.10e\n\n", tolerance);
2060  }
2061  if (tolerance == 0.)
2062  return (a == b);
2063  else
2064  return ((REAL4)fabs(a - b) <= tolerance);
2065 }
2066 
2067 
2068 
2070 {
2071  if (tolerance == 0.)
2072  return (a == b);
2073  else
2074  return ((REAL8)fabs(a - b) <= tolerance);
2075 }
2076 
2077 
2078 
2080  REAL4 tolerance)
2081 {
2082  REAL4 relative_err;
2083 
2084  if (tolerance == 0.)
2085  {
2086  return (computed == expected);
2087  }
2088  else
2089  {
2090  relative_err = fabs(computed - expected)/fabs(expected);
2091  if (relative_err <= tolerance)
2092  return TRUE;
2093  else
2094  return FALSE;
2095  }
2096 }
2097 
2098 
2099 
2101  LALDetAndSource * det_and_src,
2102  LIGOTimeGPS * gps,
2103  LALDetAMResponse * expected_resp,
2104  REAL4 tolerance)
2105 
2106 {
2107  LALDetAMResponse computed_resp;
2108  BOOLEAN resp_plus_ok_p;
2109  BOOLEAN resp_cross_ok_p;
2110  BOOLEAN resp_scalar_ok_p;
2111  BOOLEAN result;
2112  REAL4 computed_circ_resp, expected_circ_resp;
2113 
2114  LALComputeDetAMResponse(status, &computed_resp, det_and_src, gps);
2115 
2116  expected_circ_resp = sqrt((expected_resp->plus) * (expected_resp->plus)
2117  + (expected_resp->cross) * (expected_resp->cross));
2118 
2119  computed_circ_resp = sqrt(computed_resp.plus * computed_resp.plus
2120  + computed_resp.cross * computed_resp.cross);
2121 
2122 
2123  if (verbose_p)
2124  {
2125  PrintDetResponse(&computed_resp, "Computed");
2126  PrintDetResponse(expected_resp, "Expected");
2127  }
2128 
2129  if (expected_resp->plus == 0.)
2130  {
2131  resp_plus_ok_p = almost_equal_real4_p(computed_resp.plus,
2132  expected_resp->plus,
2133  tolerance);
2134  }
2135  else
2136  {
2137  resp_plus_ok_p = almost_equal_real4_relative_p(computed_resp.plus,
2138  expected_resp->plus,
2139  tolerance);
2140  }
2141 
2142  if (lalDebugLevel >= 2)
2143  {
2144  printf("INFO: detresponse_ok_p(): resp_plus_ok_p = %d\n",
2145  resp_plus_ok_p);
2146  printf(" computed = % 14.10e\n",
2147  computed_resp.plus);
2148  printf(" expected = % 14.10e\n",
2149  expected_resp->plus);
2150  }
2151 
2152  if (expected_resp->cross == 0.)
2153  resp_cross_ok_p = almost_equal_real4_p(computed_resp.cross,
2154  expected_resp->cross,
2155  tolerance);
2156  else
2157  resp_cross_ok_p = almost_equal_real4_relative_p(computed_resp.cross,
2158  expected_resp->cross,
2159  tolerance);
2160 
2161  if (lalDebugLevel >= 2)
2162  {
2163  printf("INFO: detresponse_ok_p(): resp_cross_ok_p = %d\n",
2164  resp_cross_ok_p);
2165  printf(" computed = % 14.10e\n",
2166  computed_resp.cross);
2167  printf(" expected = % 14.10e\n",
2168  expected_resp->cross);
2169  }
2170 
2171  resp_scalar_ok_p = almost_equal_real4_p(computed_resp.scalar,
2172  expected_resp->scalar,
2173  tolerance);
2174 
2175  result = (resp_plus_ok_p && resp_cross_ok_p && resp_scalar_ok_p);
2176 
2177  if (result == FALSE && verbose_p)
2178  {
2179  printf("INFO: detresponse_ok_p(): circ_resp -- computed = % 10.6e\n",
2180  computed_circ_resp);
2181  printf(" expected = % 10.6e\n",
2182  expected_circ_resp);
2183  }
2184 
2185  return result;
2186 }
2187 
2188 
2189 
2190 void handle_detresponse_test(BOOLEAN passed_p, int line)
2191 {
2192  if (!passed_p)
2193  {
2194  fprintf(stderr, "ERROR in LALComputeDetAMResponse(): computed result != expected result; line %d\n", line);
2195  exit (1);
2196  }
2197  else
2198  {
2200  }
2201 }
2202 
2203 
2204 
2205 
2206 static void PrintDetResponse(const LALDetAMResponse * const response,
2207  const char * const title)
2208 {
2209  REAL4 circ_response = sqrt((response->plus) * (response->plus)
2210  + (response->cross) * (response->cross));
2211 
2212  printf("%s:\n", title);
2213  printf(" plus = % 15.8e } circular = % 15.8e\n",
2214  response->plus, circ_response);
2215  printf(" cross = % 15.8e } \n", response->cross);
2216  printf(" scalar = % 15.8e\n", response->scalar);
2217 }
2218 
2219 
2220 
2222  const LALFrDetector * expected)
2223 {
2224  /* let's not bother with comparing the name */
2225 
2226  return (almost_equal_real8_p(computed->vertexLongitudeRadians,
2227  expected->vertexLongitudeRadians,
2228  2.*real8_tolerance)
2230  expected->vertexLatitudeRadians,
2231  2.*real8_tolerance)
2233  expected->vertexElevation,
2234  2.*real8_tolerance)
2236  expected->xArmAltitudeRadians,
2237  2.*real8_tolerance)
2239  expected->xArmAzimuthRadians,
2240  2.*real8_tolerance)
2242  expected->yArmAltitudeRadians,
2243  2.*real8_tolerance)
2245  expected->yArmAzimuthRadians,
2246  2.*real8_tolerance));
2247 }
2248 
2249 
2250 
2251 
2253  const LALDetector * expected)
2254 {
2255  LALDR_33Matrix tmp_computed;
2256  LALDR_33Matrix tmp_expected;
2257 
2258  LALDR_Set33Matrix(&tmp_computed,
2259  computed->response[0][0], computed->response[0][1],
2260  computed->response[0][2],
2261  computed->response[1][0], computed->response[1][1],
2262  computed->response[1][2],
2263  computed->response[2][0], computed->response[2][1],
2264  computed->response[2][2]);
2265 
2266  LALDR_Set33Matrix(&tmp_expected,
2267  expected->response[0][0], expected->response[0][1],
2268  expected->response[0][2],
2269  expected->response[1][0], expected->response[1][1],
2270  expected->response[1][2],
2271  expected->response[2][0], expected->response[2][1],
2272  expected->response[2][2]);
2273 
2274 
2275  return (vector_relative_ok_p(&(computed->location), &(expected->location),
2276  1.e-4)
2277  && matrix_ok_p(&tmp_computed, &tmp_expected, 1.e-4)
2278  && computed->type == expected->type
2279  && frdetector_ok_p(&(computed->frDetector), &(expected->frDetector)));
2280 }
2281 
2282 
2283 
2284 REAL4 skygrid_avg(const skygrid_t response)
2285 {
2286  INT4 i, j, cnt;
2287  REAL4 retval = 0.;
2288 
2289  for (j = 0; j < NUM_RA; ++j)
2290  {
2291  for (i = -declim+1; i <= declim-1; ++i)
2292  {
2293  cnt = j*NUM_DEC + i + declim;
2294  retval += response[cnt];
2295  }
2296  }
2297 
2298  /*
2299  for (i = 0; i < lim; ++i)
2300  retval += response[i];
2301  */
2302 
2303  retval /= lim;
2304 
2305  return retval;
2306 }
2307 
2308 
2309 
2310 
2311 void skygrid_square(skygrid_t square, const skygrid_t input)
2312 {
2313  INT4 i;
2314 
2315  for (i = 0; i < lim; ++i)
2316  square[i] = (input[i]) * (input[i]);
2317 
2318 }
2319 
2320 
2321 
2322 
2323 void skygrid_sqrt(skygrid_t result, const skygrid_t input)
2324 {
2325  INT4 i;
2326 
2327  for (i = 0; i < lim; ++i)
2328  result[i] = (REAL4)sqrt((double)(input[i]));
2329 }
2330 
2331 
2332 
2334 {
2335  skygrid_t tmpgrid;
2336 
2337  skygrid_square(tmpgrid, input);
2338  return (REAL4)(sqrt(skygrid_avg(tmpgrid)));
2339 }
2340 
2341 
2342 
2344 {
2345  INT4 i;
2346 
2347  for (i = 0; i < lim; ++i)
2348  dest[i] = src[i];
2349 
2350  return i;
2351 }
2352 
2353 
2354 
2355 void skygrid_print(const char * comments,
2356  const skygrid_t input, const char * filename)
2357 {
2358  INT4 i, j;
2359  FILE * outfile = NULL;
2360 
2361  outfile = xfopen(filename, "w");
2362 
2363  if (comments != (char *)NULL)
2364  fprintf(outfile, "# %s\n", comments);
2365 
2366  for (i = 0; i < NUM_RA; ++i)
2367  {
2368  for (j = 0; j < NUM_DEC; ++j)
2369  fprintf(outfile, "% 14.8e\t", input[i*NUM_DEC + j]);
2370  fprintf(outfile, "\n");
2371  }
2372 
2373  xfclose(outfile);
2374 }
2375 
2376 
2377 
2378 void skygrid_fabs(skygrid_t absgrid, const skygrid_t input)
2379 {
2380  INT4 i;
2381 
2382  for (i = 0; i < lim; ++i)
2383  absgrid[i] = fabs(input[i]);
2384 }
2385 
2386 
2387 
2388 void skygrid_add(skygrid_t sum, const skygrid_t a, const skygrid_t b)
2389 {
2390  INT4 i;
2391 
2392  for (i = 0; i < lim; ++i)
2393  sum[i] = a[i] + b[i];
2394 }
2395 
2397 {
2398  INT4 i;
2399 
2400  for (i = 0; i < lim; ++i)
2401  sum[i] = a[i] - b[i];
2402 }
2403 
2405 {
2406  INT4 i;
2407 
2408  for (i = 0; i < lim; ++i)
2409  result[i] = b * a[i];
2410 }
2411 
2412 #if 0 /* NOT USED */
2413 /*
2414  * only handle 2-dimensional arrays
2415  */
2416 static void make_me_an_Sarray_sequence(LALStatus *status,
2417  REAL4ArraySequence **sequence,
2418  UINT4 rows, UINT4 cols, UINT4 length)
2419 {
2420  CreateArraySequenceIn params;
2421  UINT4Vector dimLength;
2422  UINT4 data[3];
2423  data[0] = 2;
2424  data[1] = rows;
2425  data[2] = cols;
2426  dimLength.length = 3;
2427  dimLength.data = data;
2428  params.length = length;
2429  params.dimLength = &dimLength;
2430 
2431  LALSCreateArraySequence(status, sequence, &params);
2432 }
2433 #endif
2434 
2435 
2436 
2437 #if 0 /* NOT USED */
2438 static void print_diagnostics(LALStatus * const status,
2439  REAL4ArraySequence *sequence)
2440 {
2441  UINT4 i;
2442 
2443  printf("statusCode = %d\n", status->statusCode);
2444  printf("sequence->length = %u\n", sequence->length);
2445  printf("sequence->dimLength->length = %u\n", sequence->dimLength->length);
2446  for (i = 0; i < sequence->dimLength->length; ++i)
2447  {
2448  printf("sequence->dimLength->data[%d] = % 5d\n", i,
2449  sequence->dimLength->data[i]);
2450  }
2451 }
2452 #endif
2453 
2454 
2455 FILE *xfopen(const char *path, const char *mode)
2456 {
2457  FILE *f = NULL;
2458 
2459  f = fopen(path, mode);
2460 
2461  if (f == NULL)
2462  {
2463  fprintf(stderr, "%s: ", path);
2464  perror("could not open file");
2465  exit(errno);
2466  }
2467  return f;
2468 }
2469 
2470 int xfclose(FILE *stream)
2471 {
2472  if (stream != (FILE *)NULL)
2473  return fclose(stream);
2474  else
2475  return 0;
2476 }
2477 
2479 {
2480  REAL8 cos_theta, cos_sq_theta, cos_2_psi, sin_2_psi;
2481  REAL8 half_cos_sq_theta_p1_cos_2_phi, cos_theta_sin_2_phi;
2482  REAL8 retval;
2483 
2484  cos_theta = cos(theta);
2485  cos_sq_theta = cos_theta * cos_theta;
2486  cos_2_psi = cos(2. * psi);
2487  sin_2_psi = sin(2. * psi);
2488  cos_theta_sin_2_phi = cos_theta * sin(2. * phi);
2489  half_cos_sq_theta_p1_cos_2_phi = (cos_sq_theta + 1.) * cos(2. * phi) / 2.;
2490 
2491 
2492  if (pol == gwpol_plus)
2493  retval = half_cos_sq_theta_p1_cos_2_phi * cos_2_psi
2494  - cos_theta_sin_2_phi * sin_2_psi;
2495  else if (pol == gwpol_cross)
2496  retval = half_cos_sq_theta_p1_cos_2_phi * sin_2_psi
2497  + cos_theta_sin_2_phi * cos_2_psi;
2498  else
2499  retval = 0.;
2500 
2501  return (REAL4)retval;
2502 }
2503 
2504 
2505 
2507 {
2508  /*
2509  LALDetector det_north_pole;
2510  LALDetector det_south_pole;
2511  LALDetector det_green_equator;
2512  LALDetector det_green_tropic_of_cancer;
2513  LALDetector det_foo_tropic_of_cancer;
2514  */
2515  static BOOLEAN global_detectors_set_p = FALSE;
2516  LALFrDetector frdet;
2517 
2518  if (verbose_level & 4)
2519  printf("global_detectors_set_p = %d\n", global_detectors_set_p);
2520 
2521 
2522  if (global_detectors_set_p == FALSE)
2523  {
2524  /* Det. @ North Pole */
2525  (void)laldr_strlcpy(frdet.name, "North Pole", LALNameLength);
2526  frdet.vertexLongitudeRadians = deg_to_rad(0.);
2527  frdet.vertexLatitudeRadians = deg_to_rad(90.);
2528  frdet.vertexElevation = 0.;
2529  frdet.xArmAltitudeRadians = 0.;
2530  frdet.yArmAltitudeRadians = 0.;
2531  frdet.xArmAzimuthRadians = deg_to_rad(180.);
2532  frdet.yArmAzimuthRadians = deg_to_rad(90.);
2533 
2535 
2536  if (verbose_level & 4)
2537  {
2540  }
2541 
2542  /* Det. @ South Pole */
2543  (void)laldr_strlcpy(frdet.name, "South Pole", LALNameLength);
2544  frdet.vertexLongitudeRadians = deg_to_rad(0.);
2545  frdet.vertexLatitudeRadians = deg_to_rad(-90.);
2546  frdet.vertexElevation = 0.;
2547  frdet.xArmAltitudeRadians = 0.;
2548  frdet.yArmAltitudeRadians = 0.;
2549  frdet.xArmAzimuthRadians = deg_to_rad(180.);
2550  frdet.yArmAzimuthRadians = deg_to_rad(90.);
2551 
2553 
2554  if (verbose_level & 4)
2555  {
2558  }
2559 
2560  /* Det. @ (0, 0) on Earth */
2561  (void)laldr_strlcpy(frdet.name, "Greenwich-Equator", LALNameLength);
2562  frdet.vertexLongitudeRadians = deg_to_rad(0.);
2563  frdet.vertexLatitudeRadians = deg_to_rad(0.);
2564  frdet.vertexElevation = 0.;
2565  frdet.xArmAltitudeRadians = 0.;
2566  frdet.yArmAltitudeRadians = 0.;
2567  frdet.xArmAzimuthRadians = deg_to_rad(180.);
2568  frdet.yArmAzimuthRadians = deg_to_rad(90.);
2569 
2571 
2572  if (verbose_level & 4)
2573  {
2576  }
2577 
2578  /* Det. @ (0, 23.5) on Earth */
2579  (void)laldr_strlcpy(frdet.name, "Greenwich-Tropic of Cancer", LALNameLength);
2580  frdet.vertexLongitudeRadians = deg_to_rad(0.);
2581  frdet.vertexLatitudeRadians = deg_to_rad(23.5);
2582  frdet.vertexElevation = 0.;
2583  frdet.xArmAltitudeRadians = 0.;
2584  frdet.yArmAltitudeRadians = 0.;
2585  frdet.xArmAzimuthRadians = deg_to_rad(180.);
2586  frdet.yArmAzimuthRadians = deg_to_rad(90.);
2587 
2589 
2590  if (verbose_level & 4)
2591  {
2594  }
2595 
2596  /* Det. @ (38.4, 23.5) on Earth */
2597  (void)laldr_strlcpy(frdet.name, "Foo-Tropic of Cancer", LALNameLength);
2598  frdet.vertexLongitudeRadians = deg_to_rad(38.4);
2599  frdet.vertexLatitudeRadians = deg_to_rad(23.5);
2600  frdet.vertexElevation = 0.;
2601  frdet.xArmAltitudeRadians = 0.;
2602  frdet.yArmAltitudeRadians = 0.;
2603  frdet.xArmAzimuthRadians = deg_to_rad(180.);
2604  frdet.yArmAzimuthRadians = deg_to_rad(90.);
2605 
2607 
2608  if (verbose_level & 4)
2609  {
2612  }
2613 
2614  global_detectors_set_p = TRUE;
2615  }
2616 
2617  return;
2618 } /* END: setup_global_detectors() */
2619 
2620 
2621 
2623 {
2624  return TRUE;
2625 }
2626 
2627 
2628 
2629 char *laldr_strlcpy(char *dst, const char *src, size_t len)
2630 {
2631  char *retval = strncpy(dst, src, len-1);
2632  if (verbose_level & 8)
2633  {
2634  printf("sizeof(dst) = %zu\n", sizeof(dst));
2635  printf("strlen(src) = %zu\n", strlen(src));
2636  printf("TESTDR_MIN(len, strlen(src)+1) = %zu\n",
2637  TESTDR_MIN(len, strlen(src)+1));
2638  }
2639  dst[TESTDR_MIN(len, strlen(src) + 1) - 1] = '\0';
2640  return retval;
2641 }
2642 
2643 
2644 
2645 
2647 {
2648  /* compute the response using a local horizon coordinate system */
2649  LIGOTimeGPS gps;
2650  LALSource pulsar;
2651  LALDetAndSource det_and_pulsar = { (LALDetector *)NULL,
2652  (LALSource *)NULL} ;
2653  LALDetAMResponse am_response;
2654 
2655  REAL8 gmst1 = 0.;
2656  REAL8 altitude = 0.;
2657  REAL8 azimuth = 0.;
2658  INT4 cnt = 0;
2659  INT4 i, j, k;
2660  skygrid_t plus;
2661  skygrid_t cross;
2662  skygrid_t resp_plus;
2663  skygrid_t resp_cros;
2664  skygrid_t tmp1, tmp2, tmp3;
2665  REAL8 fudge_factor = 0.;
2666  FILE *rms_diff_plus_file = (FILE *)NULL;
2667  FILE *rms_diff_cros_file = (FILE *)NULL;
2668 
2669  if (verbose_level & 4)
2670  printf("\n\nSTARTING FUDGE FACTOR TEST NOW...\n");
2671 
2672  rms_diff_plus_file = xfopen("ff_rms_diff_plus_vs_fudge.txt", "w");
2673  rms_diff_cros_file = xfopen("ff_rms_diff_cros_vs_fudge.txt", "w");
2674 
2675  /* compute LAL response at pole... */
2676  gps.gpsSeconds = 13675020;
2677  gps.gpsNanoSeconds = 943728537;
2678  gmst1 = XLALGreenwichMeanSiderealTime(&gps);
2679 
2680  if (verbose_level & 4)
2681  printf("gmst1 = % 20.14e\n", gmst1);
2682 
2683  set_source_params(&pulsar, "FOOBAR", 0., -LAL_PI_2, (REAL8)LAL_PI_2);
2684 
2685  det_and_pulsar.pDetector = &det_north_pole;
2686  det_and_pulsar.pSource = &pulsar;
2687 
2688  if (verbose_level & 4)
2689  PrintLALDetector(det_and_pulsar.pDetector);
2690  print_source_maybe(det_and_pulsar.pSource);
2691 
2692  for (j = 0; j < NUM_RA; ++j)
2693  {
2694  det_and_pulsar.pSource->equatorialCoords.longitude =
2695  (REAL8)j/(REAL8)NUM_RA * LAL_TWOPI; /* RA */
2696 
2697  for (i = -declim; i <= declim; ++i)
2698  {
2699  cnt = j*NUM_DEC + i + declim;
2700 
2701  det_and_pulsar.pSource->equatorialCoords.latitude =
2702  asin((REAL8)i/(REAL8)declim);
2703 
2704  LALComputeDetAMResponse(status, &am_response,
2705  &det_and_pulsar, &gps);
2706 
2707  plus[cnt] = am_response.plus;
2708  cross[cnt] = am_response.cross;
2709  }
2710  }
2711 
2712  /* loop over fudge factors */
2713  if (verbose_p)
2714  printf(" Starting to loop over fudge_factor...\n");
2715 
2716  for (k = -128; k < 129; ++k)
2717  {
2718  fudge_factor = ((double)k) / 256. * (double)(LAL_PI_2)/16.;
2719 
2720  if (verbose_level & 8)
2721  {
2722  printf("k = %d\n", k);
2723  printf("fudge_factor = % 20.14e\n", fudge_factor);
2724  }
2725 
2726  for (j = 0; j < NUM_RA; ++j)
2727  {
2728  azimuth = (REAL8)j/(REAL8)NUM_RA * (REAL8)LAL_TWOPI + fudge_factor;
2729 
2730  for (i = -declim; i <= declim; ++i)
2731  {
2732  cnt = j*NUM_DEC + i + declim;
2733  altitude = asin(((REAL8)i)/((REAL8)declim));
2734 
2735  if (verbose_level & 8)
2736  {
2737  printf("azimuth = % 14.9e deg\n", rad_to_deg(azimuth));
2738  printf("altitude = % 14.9e deg\n", rad_to_deg(altitude));
2739  }
2740 
2741  resp_plus[cnt] = resp_local(0., LAL_PI_2 - altitude, azimuth,
2742  gwpol_plus);
2743  resp_cros[cnt] = resp_local(0., LAL_PI_2 - altitude, azimuth,
2744  gwpol_cross);
2745  }
2746  }
2747 
2748 
2749  if (k == 0)
2750  {
2751  skygrid_print("GRASP-computed response to plus",
2752  resp_plus, "ff_local_plus.txt");
2753  skygrid_print("GRASP-computed response to cross",
2754  resp_cros, "ff_local_cros.txt");
2755 
2756  skygrid_print("LAL-computed response to plus",
2757  plus, "ff_lal_plus.txt");
2758  skygrid_print("LAL-computed response to cross",
2759  cross, "ff_lal_cros.txt");
2760 
2761  skygrid_subtract(tmp3, resp_plus, plus);
2762  skygrid_fabs(tmp3, tmp3);
2763  skygrid_print("Abs. difference between GRASP and LAL for plus",
2764  tmp3, "ff_diff_plus.txt");
2765 
2766  skygrid_subtract(tmp3, resp_cros, cross);
2767  skygrid_fabs(tmp3, tmp3);
2768  skygrid_print("Abs. difference between GRASP and LAL for cross",
2769  tmp3, "ff_diff_cros.txt");
2770  }
2771 
2772  skygrid_square(tmp1, resp_plus);
2773  skygrid_square(tmp2, resp_cros);
2774  skygrid_add(tmp1, tmp1, tmp2);
2775 
2776  if (verbose_p >= 4)
2777  printf("avg(F+^2 + Fx^2) using resp_local() = % 14.9e\n",
2778  skygrid_avg(tmp1));
2779 
2780  skygrid_subtract(tmp3, resp_plus, plus);
2781  if (verbose_level & 8)
2782  printf("RMS difference for plus = % 20.14e\n", skygrid_rms(tmp3));
2783  fprintf(rms_diff_plus_file, "% 20.14e % 20.14e\n",
2784  fudge_factor, skygrid_rms(tmp3));
2785  if (verbose_level & 8)
2786  printf("RMS difference for cross = % 20.14e\n", skygrid_rms(tmp3));
2787  fprintf(rms_diff_cros_file, "% 20.14e % 20.14e\n",
2788  fudge_factor, skygrid_rms(tmp3));
2789  } /* for (k = -128; ..) */
2790  if (verbose_level & 4)
2791  printf("... Done with looping over fudge_factor.\n");
2792 
2793  xfclose(rms_diff_plus_file);
2794  xfclose(rms_diff_cros_file);
2795 
2796  return;
2797 }
2798 
2799 
2800 
2801 void set_source_params(LALSource * source, const char *name, REAL8 ra_rad,
2802  REAL8 dec_rad, REAL8 orien_rad)
2803 {
2804  (void)laldr_strlcpy(source->name, name, LALNameLength);
2805  source->equatorialCoords.longitude = ra_rad;
2806  source->equatorialCoords.latitude = dec_rad;
2808  source->orientation = orien_rad;
2809 } /* END: set_source_params() */
2810 
2811 
2812 
2814 {
2815  /*
2816  * LALSource src_0_0_p;
2817  * LALSource src_0_0_c;
2818  * LALSource src_0_90_p;
2819  * LALSource src_0_90_c;
2820  * LALSource src_0_45_p;
2821  * LALSource src_0_45_c;
2822  */
2823  static BOOLEAN global_sources_set_p = FALSE;
2824 
2825  if (global_sources_set_p == FALSE)
2826  {
2827  set_source_params(&src_0_0_p, "RA=0deg, Dec=0deg, plus",
2828  0., 0., deg_to_rad(-90.));
2829  set_source_params(&src_0_0_c, "RA=0deg, Dec=0deg, cros",
2830  0., 0., deg_to_rad(-45.));
2831 
2834 
2835  set_source_params(&src_0_90_p, "RA=0deg, Dec=90deg, plus",
2836  0., deg_to_rad(90.), deg_to_rad(-90.));
2837  set_source_params(&src_0_90_c, "RA=0deg, Dec=90deg, cros",
2838  0., deg_to_rad(90.), deg_to_rad(-45.));
2839 
2842 
2843  set_source_params(&src_0_45_p, "RA=0deg, Dec=45deg, plus",
2844  0., deg_to_rad(45.), deg_to_rad(-90.));
2845  set_source_params(&src_0_45_c, "RA=0deg, Dec=45deg, cros",
2846  0., deg_to_rad(45.), deg_to_rad(-45.));
2847 
2850 
2851  global_sources_set_p = TRUE;
2852  }
2853 
2854  return;
2855 } /* END: setup_global_sources */
2856 
2857 
2858 void find_zero_gmst(void)
2859 {
2860  REAL8 gmst1;
2861  LIGOTimeGPS gps;
2862  INT4 k;
2863 
2864  gmst1 = 0.;
2865  gps.gpsSeconds = 13675020;
2866  gps.gpsNanoSeconds = 943728500;
2867 
2868  printf("2*Pi = % 22.14e\n", 2. * LAL_PI);
2869 
2870  for (k = 0; k < 4096; ++k)
2871  {
2872  /* to avoid printing out all the LAL INFO messages */
2873  gmst1 = XLALGreenwichMeanSiderealTime(&gps);
2874 
2875  printf("k = %9d; GPS = %d:%d;\t\tgmst1 = % 22.14e; gmst1-2*Pi = % 20.14e\n",
2876  k, gps.gpsSeconds, gps.gpsNanoSeconds,
2877  gmst1, (gmst1-2.*(double)LAL_PI));
2878 
2879  /* increment observation time */
2880  XLALGPSAdd(&gps, 1e-9);
2881  }
2882  printf("AUF WIEDERSEHEN!\n");
2883 }
2884 
2885 
2886 
2887 
2888 void print_source_maybe(const LALSource * source)
2889 {
2890  if (verbose_level & 4)
2891  {
2892  printf("Source name: %s\n", source->name);
2893  printf("RA: % 14.20e rad\n",
2894  source->equatorialCoords.longitude);
2895  printf("Dec: % 14.20e rad\n",
2896  source->equatorialCoords.latitude);
2897  printf("Orientation: % 14.20e rad\n", source->orientation);
2898  }
2899 }
2900 
2901 
2902 
2904 {
2905  LALSource crab_pulsar;
2907  LALDetAndSource det_and_pulsar;
2908  LALDetAMResponseSeries am_response_series = {NULL,NULL,NULL};
2909  REAL4TimeSeries plus_series, cross_series, scalar_series;
2910  LALTimeIntervalAndNSample time_info;
2911 
2912  printf("MAHALO!\n");
2913  fflush(stdout);
2914 
2915  if (verbose_level & 4)
2916  {
2917  PrintLALDetector(&detector);
2918  }
2919 
2920  set_source_params(&crab_pulsar, "Crab Pulsar",
2921  deg_to_rad((5. + 34./60. + 32./3600.) * 15.),
2922  deg_to_rad(22. + 0. + 52./3600.), 0.);
2923  print_source_maybe(&crab_pulsar);
2924 
2925  det_and_pulsar.pDetector = &detector;
2926  det_and_pulsar.pSource = &crab_pulsar;
2927 
2928  plus_series.data = NULL;
2929  cross_series.data = NULL;
2930  scalar_series.data = NULL;
2931 
2932  am_response_series.pPlus = &(plus_series);
2933  am_response_series.pCross = &(cross_series);
2934  am_response_series.pScalar = &(scalar_series);
2935 
2936  LALSCreateVector(status, &(am_response_series.pPlus->data), 1);
2937  LALSCreateVector(status, &(am_response_series.pCross->data), 1);
2938  LALSCreateVector(status, &(am_response_series.pScalar->data), 1);
2939 
2940  time_info.epoch.gpsSeconds = 709398013;
2941  time_info.epoch.gpsNanoSeconds = 0;
2942  time_info.deltaT = 864;
2943  time_info.nSample = 100;
2944 
2945  LALComputeDetAMResponseSeries(status, &am_response_series,
2946  &det_and_pulsar,
2947  &time_info);
2948 
2949  LALSPrintTimeSeries(am_response_series.pPlus, "crab_plus.txt");
2950  LALSPrintTimeSeries(am_response_series.pCross, "crab_cross.txt");
2951 
2952  LALSDestroyVector(status, &(am_response_series.pPlus->data));
2953  LALSDestroyVector(status, &(am_response_series.pCross->data));
2954  LALSDestroyVector(status, &(am_response_series.pScalar->data));
2955 }
2956 
2957 
2959 {
2960  BOOLEAN retval = TRUE;
2961  LALDR_33Matrix A; /* test matrices */
2962  LALDR_33Matrix B;
2963  LALDR_33Matrix C;
2964  LALDR_33Matrix D;
2965  LALDR_3Vector u; /* test vector */
2966  LALDR_3Vector v;
2967  LALDR_3Vector w;
2968  LALDR_3Vector x;
2969  REAL8 c; /* test scalar */
2970  REAL8 d;
2971  unsigned int iter, jter;
2972 
2973 
2974  if (verbose_p)
2975  {
2976  printf("TEST OF MATRIX AND VECTOR FUNCTIONS\n");
2977  printf("-----------------------------------\n");
2978  }
2979 
2980  /* Print33Matrix */
2981  A[0][0] = 0.; A[0][1] = 0.; A[0][2] = 0.;
2982  A[1][0] = 0.; A[1][1] = 0.; A[1][2] = 0.;
2983  A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 0.;
2984 
2985  if (verbose_p)
2986  {
2987  printf("Print33Matrix output:\n");
2988  LALDR_Print33Matrix(&A, "A", 0, stdout, "");
2989  printf("\n");
2990  }
2991 
2992  if (verbose_p)
2993  {
2994  printf("Expected output:\n");
2995  printf("A:\n");
2996 
2997  for (iter = 0; iter < 3; ++iter)
2998  {
2999  for (jter = 0; jter < 3; ++jter)
3000  {
3001  printf("% 20.14e\t", A[iter][jter]);
3002  }
3003  printf("\n");
3004  }
3005  }
3006 
3007  if (verbose_p)
3008  printf("\n- - - - -\n\n");
3009 
3010  A[0][0] = -4.; A[0][1] = -3.; A[0][2] = -2.;
3011  A[1][0] = -1.; A[1][1] = 0.; A[1][2] = 1.;
3012  A[2][0] = 2.; A[2][1] = 3.; A[2][2] = 4.;
3013 
3014  if (verbose_p)
3015  {
3016  printf("Print33Matrix output:\n");
3017  LALDR_Print33Matrix(&A, "A", 0, stdout, "");
3018  printf("\n");
3019  }
3020 
3021  if (verbose_p)
3022  {
3023  printf("Expected output:\n");
3024  printf("A:\n");
3025 
3026  for (iter = 0; iter < 3; ++iter)
3027  {
3028  for (jter = 0; jter < 3; ++jter)
3029  {
3030  printf("% 20.14e\t", A[iter][jter]);
3031  }
3032  printf("\n");
3033  }
3034  }
3035 
3037 
3038 
3039  /* Zero33Matrix */
3040  LALDR_Zero33Matrix(&A);
3041  B[0][0] = 0.; B[0][1] = 0.; B[0][2] = 0.;
3042  B[1][0] = 0.; B[1][1] = 0.; B[1][2] = 0.;
3043  B[2][0] = 0.; B[2][1] = 0.; B[2][2] = 0.;
3044 
3045  print_m_results_maybe("Zero33Matrix test", &A, &B);
3046 
3047  if (!matrix_ok_p(&A, &B, zero_tolerance))
3048  {
3049  fprintf(stderr, "ERROR: A != B\n");
3050 
3051  return 1;
3052  }
3053  else
3054  {
3056  }
3057 
3059 
3060  /* Set33Matrix */
3061  LALDR_Set33Matrix(&A,
3062  4., 3., 2.,
3063  1., 0., -1.,
3064  -2., -3., -4.);
3065  B[0][0] = 4.; B[0][1] = 3.; B[0][2] = 2.;
3066  B[1][0] = 1.; B[1][1] = 0.; B[1][2] = -1.;
3067  B[2][0] = -2.; B[2][1] = -3.; B[2][2] = -4.;
3068 
3069  print_m_results_maybe("Set33Matrix test", &A, &B);
3070 
3071  if (!matrix_ok_p(&A, &B, zero_tolerance))
3072  {
3073  fprintf(stderr, "ERROR: A != B\n");
3074 
3075  return 1;
3076  }
3077  else
3078  {
3080  }
3081 
3083 
3084 
3085  /* Matrix addition */
3086  LALDR_Add33Matrix(&C, &A, &B);
3087  LALDR_Set33Matrix(&D,
3088  8., 6., 4.,
3089  2., 0., -2.,
3090  -4., -6., -8.);
3091 
3092  print_m_results_maybe("Add33Matrix test", &C, &D);
3093 
3094  if (!matrix_ok_p(&C, &D, zero_tolerance))
3095  {
3096  fprintf(stderr, "ERROR: C != D\n");
3097 
3098  return 1;
3099  }
3100  else
3101  {
3103  }
3104 
3106 
3107 
3108  /* Matrix multiplication */
3109  LALDR_Set33Matrix(&A,
3110  4., 3., 2.,
3111  1., 0., -4.,
3112  -3., -2., -1.);
3113 
3114  LALDR_Set33Matrix(&B,
3115  8., 17., 5.,
3116  7., -23., -9.,
3117  -11., 13., 31.);
3118 
3119  LALDR_Set33Matrix(&D,
3120  31., 25., 55.,
3121  52., -35., -119.,
3122  -27., -18., -28.);
3123 
3124  LALDR_Multiply33Matrix(&C, &A, &B);
3125 
3126  print_m_results_maybe("Multiply33Matrix test", &C, &D);
3127 
3128  if (!matrix_ok_p(&C, &D, zero_tolerance))
3129  {
3130  fprintf(stderr, "ERROR: C != D\n");
3131 
3132  return 1;
3133  }
3134  else
3135  {
3137  }
3138 
3140 
3141 
3142  /* Scalar * matrix */
3143  c = 1.69e-3;
3144  LALDR_Set33Matrix(&D,
3145  1.352e-2, 2.873e-2, 8.45e-3,
3146  1.183e-2, -3.887e-2, -1.521e-2,
3147  -1.859e-2, 2.197e-2, 5.239e-2);
3148 
3149  LALDR_ScalarMult33Matrix(&C, c, &B);
3150 
3151  print_m_results_maybe("ScalarMult33Matrix test", &C, &D);
3152 
3153  if (!matrix_ok_p(&C, &D, zero_tolerance))
3154  {
3155  fprintf(stderr, "ERROR: C != D\n");
3156 
3157  return 1;
3158  }
3159  else
3160  {
3162  }
3163 
3165 
3166 
3167  /* scalar product of matrices */
3168  d = 112.;
3169 
3170  c = LALDR_DotProd33Matrix(&A, &B);
3171 
3172  print_s_results_maybe("DotProd33Matrix test", c, d);
3173 
3175  {
3176  fprintf(stderr, "ERROR: c != d\n");
3177 
3178  return 1;
3179  }
3180  else
3181  {
3183  }
3184 
3186 
3187  /* Transpose */
3188  LALDR_Set33Matrix(&A,
3189  4., 3., 2.,
3190  1., 0., -1.,
3191  -2., -3., -4.);
3192  LALDR_Transpose33Matrix(&B, &A);
3193 
3194  LALDR_Set33Matrix(&C,
3195  4., 1., -2.,
3196  3., 0., -3.,
3197  2., -1., -4.);
3198 
3199  print_m_results_maybe("Transpose33Matrix test", &B, &C);
3200 
3201  if (!matrix_ok_p(&B, &C, zero_tolerance))
3202  {
3203  fprintf(stderr, "ERROR: B != C\n");
3204 
3205  return 1;
3206  }
3207  else
3208  {
3210  }
3211 
3213 
3214  /* Set3Vector test */
3215  v[0] = 1.; v[1] = -2.; v[2] = 3.;
3216  LALDR_Set3Vector(&u, 1., -2., 3.);
3217 
3218  print_v_results_maybe("Set3Vector test", &u, &v);
3219 
3220  if (!vector_ok_p(&u, &v, zero_tolerance))
3221  {
3222  fprintf(stderr, "ERROR: u != v\n");
3223 
3224  return 1;
3225  }
3226  else
3227  {
3229  }
3230 
3232 
3233 
3234  /* DotProd3Vector test */
3235  LALDR_Set3Vector(&v, 13., -11., 51.);
3236  c = LALDR_DotProd3Vector(&u, &v);
3237 
3238  d = 188.;
3239 
3240  print_s_results_maybe("DotProd3Vector test", c, d);
3241 
3243  {
3244  fprintf(stderr, "ERROR: c != d\n");
3245 
3246  return 1;
3247  }
3248  else
3249  {
3251  }
3252 
3254 
3255  /* CrossProd3Vector test */
3256  LALDR_Set3Vector(&u, 4., -11., 2.);
3257  LALDR_Set3Vector(&v, -3., 17., 5.);
3258  LALDR_CrossProd3Vector(&w, &u, &v);
3259 
3260  LALDR_Set3Vector(&x, -89., -26., 35.);
3261 
3262  print_v_results_maybe("CrossProd3Vector test", &w, &x);
3263 
3264  if (!vector_ok_p(&w, &x, zero_tolerance))
3265  {
3266  fprintf(stderr, "ERROR: w != x\n");
3267 
3268  return 1;
3269  }
3270  else
3271  {
3273  }
3274 
3276 
3277 
3278  /* OuterProd3Vector test */
3279  LALDR_OuterProd3Vector(&A, &u, &v);
3280 
3281  LALDR_Set33Matrix(&B,
3282  -12., 68., 20.,
3283  33., -187., -55.,
3284  -6., 34., 10.);
3285 
3286  print_m_results_maybe("OuterProd3Vector test", &A, &B);
3287 
3288  if (!matrix_ok_p(&A, &B, zero_tolerance))
3289  {
3290  fprintf(stderr, "ERROR: A != B\n");
3291 
3292  return 1;
3293  }
3294  else
3295  {
3297  }
3298 
3300 
3301  return retval;
3302 } /* END: pass_matrix_test_p() */
3303 
3304 
3305 
3307 {
3308  /*
3309  * TEST -1: Test of almost_equal_real[48]_p() functions
3310  */
3311 
3312  REAL4 foo4, bar4;
3313  REAL8 foo8, bar8;
3314 
3315  if (verbose_p)
3316  {
3317  printf("TEST OF almost_equal_real[48]_p() functions\n");
3318  printf("-------------------------------------------\n");
3319  }
3320 
3321  foo4 = 0.;
3322  bar4 = real4_tolerance/2.;
3323 
3324  if (!almost_equal_real4_p(foo4, bar4, real4_tolerance))
3325  {
3326  fprintf(stderr, "ERROR: almost_equal_real4_p() failed test 1\n");
3327 
3328  return FALSE;
3329  }
3330 
3331  if (verbose_p)
3332  {
3333  printf("PASS: almost_equal_real4_p() test 1\n");
3334  printf("\n- - - - -\n");
3335  }
3336 
3337 
3338  bar4 = 0.;
3339 
3340  if (!almost_equal_real4_p(foo4, bar4, 0.))
3341  {
3342  fprintf(stderr, "ERROR: almost_equal_real4_p() failed test 2\n");
3343 
3344  return FALSE;
3345  }
3346 
3347  if (verbose_p)
3348  {
3349  printf("PASS: almost_equal_real4_p() test 2\n");
3350  printf("\n- - - - -\n");
3351  }
3352 
3353  bar4 = 2.*real4_tolerance;
3354 
3355  if (almost_equal_real4_p(foo4, bar4, real4_tolerance))
3356  {
3357  fprintf(stderr, "ERROR: almost_equal_real4_p() failed test 3\n");
3358 
3359  return FALSE;
3360  }
3361 
3362  if (verbose_p)
3363  {
3364  printf("PASS: almost_equal_real4_p() test 3\n");
3365  printf("\n- - - - -\n");
3366  }
3367 
3368  foo8 = 0.;
3369  bar8 = real8_tolerance/2.;
3370 
3371  if (!almost_equal_real8_p(foo8, bar8, real8_tolerance))
3372  {
3373  fprintf(stderr, "ERROR: almost_equal_real8_p() failed test 1\n");
3374 
3375  return 1;
3376  }
3377 
3378  if (verbose_p)
3379  {
3380  printf("PASS: almost_equal_real8_p() test 1\n");
3381  printf("\n- - - - -\n");
3382  }
3383 
3384  bar8 = 0.;
3385 
3386  if (!almost_equal_real8_p(foo8, bar8, 0.))
3387  {
3388  fprintf(stderr, "ERROR: almost_equal_real8_p() failed test 2\n");
3389 
3390  return FALSE;
3391  }
3392 
3393  if (verbose_p)
3394  {
3395  printf("PASS: almost_equal_real8_p() test 2\n");
3396  printf("\n- - - - -\n");
3397  }
3398 
3399  bar8 = 2.*real8_tolerance;
3400 
3401  if (almost_equal_real8_p(foo8, bar8, real8_tolerance))
3402  {
3403  fprintf(stderr, "ERROR: almost_equal_real8_p() failed test 3\n");
3404 
3405  return FALSE;
3406  }
3407 
3408  if (verbose_p)
3409  {
3410  printf("PASS: almost_equal_real8_p() test 3\n");
3411  }
3412 
3414 
3415  return TRUE;
3416 } /* END: passed_almost_equal_tests_p() */
3417 
3418 
3419 
3420 #if 0
3421 static int local_strncasecmp(const char * a, const char * b, size_t maxlen)
3422 {
3423  char tmp_a[LALNameLength];
3424  char tmp_b[LALNameLength];
3425  size_t i;
3426 
3427  strncpy(tmp_a, a, maxlen);
3428  strncpy(tmp_b, b, maxlen);
3429 
3430  for (i = 0; i < maxlen; ++i)
3431  {
3432  tmp_a[i] = tolower(tmp_a[i]);
3433  tmp_b[i] = tolower(tmp_b[i]);
3434  }
3435 
3436  return strncmp(tmp_a, tmp_b, maxlen);
3437 }
3438 #endif
void skygrid_print(const char *comments, const skygrid_t input, const char *filename)
int verbose_level
void crab_pulsar_test(LALStatus *status)
#define NUM_RA
LALDetector det_green_tropic_of_cancer
int main(int argc, char *argv[])
void skygrid_square(skygrid_t square, const skygrid_t input)
BOOLEAN passed_matrix_test_p(void)
static void LALDR_Add33Matrix(LALDR_33Matrix *result, LALDR_33Matrix *matrix1, LALDR_33Matrix *matrix2)
static int print_small_separator_maybe(void)
static REAL8 deg_to_rad(REAL8 degrees)
static REAL8 LALDR_DotProd33Matrix(LALDR_33Matrix *a, LALDR_33Matrix *b)
LALSource src_0_45_p
void setup_global_sources(void)
static void print_s_results_maybe(const char *title, REAL8 computed, REAL8 expected)
void skygrid_subtract(skygrid_t sum, const skygrid_t a, const skygrid_t b)
static void LALDR_Print33Matrix(LALDR_33Matrix *matrix, const CHAR *varname, UINT4 format, FILE *file, const CHAR *graph_title)
static BOOLEAN frdetector_ok_p(LALFrDetector *computed, const LALFrDetector *expected)
void set_source_params(LALSource *source, const char *name, REAL8 ra_rad, REAL8 dec_rad, REAL8 orien_rad)
static void LALDR_Set3Vector(LALDR_3Vector *v, REAL8 v1, REAL8 v2, REAL8 v3)
FILE * xfopen(const char *path, const char *mode)
LALDR_Axis_t
@ yAxis
@ zAxis
@ xAxis
static BOOLEAN almost_equal_real8_p(REAL8 a, REAL8 b, REAL8 tolerance)
REAL8 real8_tolerance
void setup_global_detectors(void)
void print_source_maybe(const LALSource *source)
INT4 skygrid_copy(skygrid_t dest, const skygrid_t src)
static BOOLEAN matrix_ok_p(LALDR_33Matrix *computed, LALDR_33Matrix *expected, REAL8 tolerance)
GWPolarization
@ gwpol_plus
@ gwpol_scalar
@ gwpol_cross
static BOOLEAN vector_relative_ok_p(LALDR_3Vector *computed, const LALDR_3Vector *expected, REAL8 tolerance)
static REAL8 rad_to_deg(REAL8 radians)
LALDetector det_foo_tropic_of_cancer
static BOOLEAN almost_equal_real4_p(REAL4 a, REAL4 b, REAL4 tolerance)
LALSource src_0_0_p
static void handle_detresponse_test(BOOLEAN passed_p, int line)
LALSource src_0_90_p
static void LALDR_Print3Vector(LALDR_3Vector *vector, const CHAR *varname, FILE *file)
static void LALDR_Zero33Matrix(LALDR_33Matrix *matrix)
static void print_m_results_maybe(const char *title, LALDR_33Matrix *computed, LALDR_33Matrix *expected)
static void LALDR_Set33Matrix(LALDR_33Matrix *matrix, REAL8 a11, REAL8 a12, REAL8 a13, REAL8 a21, REAL8 a22, REAL8 a23, REAL8 a31, REAL8 a32, REAL8 a33)
REAL4 real4_tolerance
LALDetector det_south_pole
void fudge_factor_test(LALStatus *status)
LALSource src_0_45_c
const REAL8 zero_tolerance
static void PrintLALDetector(const LALDetector *detector)
void skygrid_sqrt(skygrid_t result, const skygrid_t input)
static BOOLEAN vector_ok_p(LALDR_3Vector *computed, LALDR_3Vector *expected, REAL8 tolerance)
#define LALDR_MATRIXSIZE
#define TESTDR_MIN(a, b)
static void PrintDetResponse(const LALDetAMResponse *const response, const char *const title)
LALSource src_0_90_c
void skygrid_add(skygrid_t sum, const skygrid_t a, const skygrid_t b)
static void print_v_results_maybe(const char *title, LALDR_3Vector *computed, LALDR_3Vector *expected)
#define TRUE
#define FALSE
static void LALDR_OuterProd3Vector(LALDR_33Matrix *a, LALDR_3Vector *u, LALDR_3Vector *v)
static int print_passed_maybe(void)
#define NUM_DEC
void find_zero_gmst(void)
static BOOLEAN almost_equal_real4_relative_p(REAL4 computed, REAL4 expected, REAL4 tolerance)
char * laldr_strlcpy(char *dst, const char *src, size_t len)
const INT4 oneBillion
const INT4 declim
LALDetector det_north_pole
static BOOLEAN detresponse_ok_p(LALStatus *status, LALDetAndSource *det_and_src, LIGOTimeGPS *gps, LALDetAMResponse *expected_resp, REAL4 tolerance)
int xfclose(FILE *stream)
void skygrid_fabs(skygrid_t absgrid, const skygrid_t input)
LALDetector det_green_equator
static BOOLEAN detector_ok_p(LALDetector *computed, const LALDetector *expected)
static void LALDR_CrossProd3Vector(LALDR_3Vector *result, LALDR_3Vector *a, LALDR_3Vector *b)
REAL4 skygrid_t[NUM_RA *NUM_DEC]
static void LALDR_Transpose33Matrix(LALDR_33Matrix *transpose, LALDR_33Matrix *matrix)
static REAL8 LALDR_DotProd3Vector(LALDR_3Vector *a, LALDR_3Vector *b)
BOOLEAN passed_almost_equal_tests_p(void)
REAL8 LALDR_3Vector[3]
REAL4 resp_local(REAL8 psi, REAL8 theta, REAL8 phi, GWPolarization pol)
static void LALDR_ScalarMult33Matrix(LALDR_33Matrix *result, REAL8 coefficient, LALDR_33Matrix *matrix)
REAL4 skygrid_avg(const skygrid_t response)
LALSource src_0_0_c
REAL8 LALDR_33Matrix[3][3]
REAL4 skygrid_rms(const skygrid_t input)
BOOLEAN passed_special_locations_tests_p(LALStatus *status)
static void LALDR_Multiply33Matrix(LALDR_33Matrix *product, LALDR_33Matrix *matrixL, LALDR_33Matrix *matrixR)
const INT4 lim
static int print_separator_maybe(void)
BOOLEAN verbose_p
void skygrid_scalar_mult(skygrid_t result, const skygrid_t a, REAL4 b)
@ LALDetectorIndexLHODIFF
Definition: DetectorSite.h:40
void REPORTSTATUS(LALStatus *status)
Definition: LALError.c:322
void LALCheckMemoryLeaks(void)
Definition: LALMalloc.c:784
#define fprintf
const char *const name
type name
Definition: UserInput.c:193
static double f(double theta, double y, double xi)
Definition: XLALMarcumQ.c:258
static double psi(double theta, double xi)
Definition: XLALMarcumQ.c:273
void LALSCreateArraySequence(LALStatus *status, REAL4ArraySequence **arraySequence, CreateArraySequenceIn *aSeqParams)
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_REAL8_EPS
Difference between 1 and the next resolvable REAL8 2^-52.
Definition: LALConstants.h:61
#define LAL_AWGS84_SI
Semimajor axis of WGS-84 Reference Ellipsoid, m.
Definition: LALConstants.h:422
#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
#define LAL_PI_4
pi/4 is the least positive solution to sin(x) = cos(x)
Definition: LALConstants.h:182
#define LAL_REAL4_EPS
Difference between 1 and the next resolvable REAL4 2^-23.
Definition: LALConstants.h:57
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
double REAL8
Double precision real floating-point number (8 bytes).
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).
@ LALNameLength
Definition: LALDatatypes.h:508
#define lalDebugLevel
Definition: LALDebugLevel.h:58
@ LALDETECTORTYPE_ABSENT
No FrDetector associated with this detector.
Definition: LALDetectors.h:239
@ LALDETECTORTYPE_IFODIFF
IFO in differential mode.
Definition: LALDetectors.h:240
void LALSPrintTimeSeries(REAL4TimeSeries *series, const CHAR *filename)
static const INT4 a
Definition: Random.c:79
@ COORDINATESYSTEM_EQUATORIAL
The sky-fixed equatorial coordinate system.
const LALUnit lalDimensionlessUnit
dimensionless units
Definition: UnitDefs.c:156
void LALSDestroyVector(LALStatus *, REAL4Vector **)
void LALSCreateVector(LALStatus *, REAL4Vector **, UINT4)
INT4 XLALUTCToGPS(const struct tm *utc)
Returns the GPS seconds since the GPS epoch for a specified UTC time structure.
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
Convenience wrapper, calling XLALGreenwichSiderealTime() with the equation of equinoxes set to 0.
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
Adds a double to a GPS time.
Definition: XLALTime.c:131
LIGOTimeGPS * XLALGPSSet(LIGOTimeGPS *epoch, INT4 gpssec, INT8 gpsnan)
Sets GPS time given GPS integer seconds and residual nanoseconds.
Definition: XLALTime.c:63
This structure stores the input required for creating an array sequence.
Definition: SeqFactories.h:115
UINT4Vector * dimLength
The dimensions of each array index (the same for every array in the sequence)
Definition: SeqFactories.h:117
UINT4 length
The sequence length.
Definition: SeqFactories.h:116
This structure encapsulates the detector AM (beam pattern) coefficients for one source at one instanc...
Definition: DetResponse.h:140
REAL4 plus
Detector response to -polarized gravitational radiation
Definition: DetResponse.h:141
REAL4 scalar
Detector response to scalar gravitational radiation (NB: ignored at present – scalar response computa...
Definition: DetResponse.h:143
REAL4 cross
Detector response to -polarized gravitational radiation.
Definition: DetResponse.h:142
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
REAL4 response[3][3]
The Earth-fixed Cartesian components of the detector's response tensor .
Definition: LALDetectors.h:280
LALDetectorType type
The type of the detector (e.g., IFO in differential mode, cylindrical bar, etc.)
Definition: LALDetectors.h:281
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 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
Sequence of REAL4 multidimensional arrays, see DATATYPE-ArraySequence types for more details.
Definition: LALDatatypes.h:421
UINT4Vector * dimLength
Pointer to a vector of length m storing the array dimensions.
Definition: LALDatatypes.h:424
UINT4 length
The number l of vectors.
Definition: LALDatatypes.h:422
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
LALUnit sampleUnits
The physical units of the quantity being sampled.
Definition: LALDatatypes.h:575
REAL8 deltaT
The time step between samples of the time series in seconds.
Definition: LALDatatypes.h:573
LIGOTimeGPS epoch
The start time of the time series.
Definition: LALDatatypes.h:572
REAL8 f0
The heterodyning frequency, in Hertz (zero if not heterodyned).
Definition: LALDatatypes.h:574
Vector of type REAL4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:145
REAL4 * data
Pointer to the data array.
Definition: LALDatatypes.h:150
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:149
This structure stores the two spherical coordinates of a sky position; ie a generic latitude and long...
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.
Vector of type UINT4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:118
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:122
UINT4 * data
Pointer to the data array.
Definition: LALDatatypes.h:123