31 #include <lal/LALConfig.h>
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>
41 #include <lal/PrintFTSeries.h>
42 #include <lal/StreamOutput.h>
45 #define UNUSED __attribute__ ((unused))
52 #define LALDR_MATRIXSIZE 3
54 #define TESTDR_MIN(a, b) (((a) < (b)) ? (a) : (b))
104 const char *
const title);
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];
220 result += (*
a)[i] * (*b)[i];
237 (*
a)[i][j] = (*u)[i] * (*v)[j];
255 result += (*
a)[i][j] * (*b)[i][j];
272 (*matrix)[0][0] = a11; (*matrix)[0][1] = a12; (*matrix)[0][2] = a13;
274 (*matrix)[1][0] = a21; (*matrix)[1][1] = a22; (*matrix)[1][2] = a23;
276 (*matrix)[2][0] = a31; (*matrix)[2][1] = a32; (*matrix)[2][2] = a33;
294 (*target)[i][j] = (*source)[i][j];
342 (*product)[i][k] += (*matrixL)[i][j] * (*matrixR)[j][k];
361 (*result)[i][j] = coefficient * (*matrix)[i][j];
380 (*result)[i][j] = (*matrix1)[i][j] + (*matrix2)[i][j];
400 (*result)[i][j] = (*matrix1)[i][j] - (*matrix2)[i][j];
427 (*transpose)[i][j] = (*matrix)[j][i];
446 l2norm += (*matrix)[i][j] * (*matrix)[i][j];
448 l2norm = sqrt((
double)l2norm);
469 rmsnorm += (*matrix)[i][j] * (*matrix)[i][j];
471 rmsnorm = sqrt((
double)rmsnorm / 9.);
491 if (fabs((
double)((*matrix)[i][j])) > infnorm)
492 infnorm = fabs((*matrix)[i][j]);
508 const CHAR *graph_title)
540 if (fabs((*matrix)[i][j]) > max)
541 max = fabs((*matrix)[i][j]);
546 fprintf(
file,
"setoptions3d(shading=ZHUE,style=PATCHCONTOUR,");
548 fprintf(
file,
"title=`%s (abs. max = %10.5e)`):\n",
549 graph_title, fabs(max));
559 if (i == 2 && j == 2)
561 fabs((*matrix)[i][j]));
564 j, i, fabs((*matrix)[i][j]));
580 const CHAR * varname,
612 REAL8 cosTheta, sinTheta;
614 cosTheta = cos((
double)theta);
615 sinTheta = sin((
double)theta);
621 cosTheta, sinTheta, 0.,
622 -sinTheta, cosTheta, 0.,
628 cosTheta, 0., -sinTheta,
630 sinTheta, 0., cosTheta);
636 0., cosTheta, sinTheta,
637 0., -sinTheta, cosTheta);
684 FILE *
xfopen(
const char *
path,
const char *mode);
712 REAL8 theta_x, phi_x;
713 REAL8 theta_y, phi_y;
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);
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);
785 delta_loc.
latitude = atan2(normal[0], normal[2]);
800 int main(
int argc,
char *argv[])
814 circ_series, sum_series;
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;
887 fprintf(stderr,
"Matrix test failed");
895 printf(
"TEST OF XLALCreateDetector()\n");
896 printf(
"---------------------------\n\n");
897 printf(
"Manual inspection required.\n");
967 fprintf(stderr,
"WARNING: LHO computed w/ Frame spec != LHO cached\n");
974 printf(
"LHO tensor converted from LALFrDetector (Frame spec):\n");
976 printf(
"\n- - - - -\n");
981 (void)
laldr_strlcpy(frdet.
name,
"LHO, from FrDetector struct (package-tools spec)",
997 fprintf(stderr,
"WARNING: LHO computed w/ package-tools spec != LHO cached\n");
1003 printf(
"LHO tensor converted from LALFrDetector (package-tools spec):\n");
1005 printf(
"\n- - -\n");
1009 (void)
laldr_strlcpy(frdet.
name,
"LHO, from FrDetector struct (numbers from doco)",
1026 "WARNING: LHO computed w/ numbers from LAL documentation != LHO cached\n");
1031 printf(
"LHO tensor converted from LALFrDetector (numbers from doco):\n");
1033 printf(
"\n- - -\n");
1043 printf(
"LHO tensor, cached by DetectorSite:\n");
1069 "LALTestDetResponse0: XLALCreateDetector failed, line %i, %s\n",
1072 return status.statusCode;
1078 printf(
"TRIVIAL 1 (converted from FrDetector):\n");
1091 printf(
"TEST OF LALDetAMResponse()\n");
1092 printf(
"--------------------------\n\n");
1093 printf(
"Tolerance = % 15.8e\n\n", tolerance);
1114 det_and_pulsar.pDetector = &detector;
1115 det_and_pulsar.pSource = &pulsar;
1118 expected_resp.
plus = 1.;
1119 expected_resp.
cross = 0.;
1120 expected_resp.
scalar = 0.;
1123 &gps, &expected_resp,
1131 expected_resp.
plus = 0.;
1132 expected_resp.
cross = -1.;
1133 expected_resp.
scalar = 0.;
1136 &gps, &expected_resp,
1144 expected_resp.
plus = -1.;
1145 expected_resp.
cross = 0.;
1146 expected_resp.
scalar = 0.;
1149 &gps, &expected_resp,
1157 expected_resp.
plus = 0.5;
1158 expected_resp.
cross = -sqrt(3.)/2.;
1159 expected_resp.
scalar = 0.;
1162 &gps, &expected_resp,
1189 det_and_pulsar.pDetector = &detector;
1190 det_and_pulsar.pSource = &pulsar;
1193 expected_resp.
plus = 1.;
1194 expected_resp.
cross = 0.;
1195 expected_resp.
scalar = 0.;
1198 &gps, &expected_resp,
1206 expected_resp.
plus = 0.;
1207 expected_resp.
cross = -1.;
1208 expected_resp.
scalar = 0.;
1211 &gps, &expected_resp,
1219 expected_resp.
plus = -1.;
1220 expected_resp.
cross = 0.;
1221 expected_resp.
scalar = 0.;
1224 &gps, &expected_resp,
1232 expected_resp.
plus = 0.5;
1233 expected_resp.
cross = -sqrt(3.)/2.;
1234 expected_resp.
scalar = 0.;
1237 &gps, &expected_resp,
1261 "LALTestDetResponse0: XLALCreateDetector failed, line %i, %s\n",
1264 return status.statusCode;
1267 utcDate.tm_sec = 46;
1268 utcDate.tm_min = 20;
1269 utcDate.tm_hour = 8;
1270 utcDate.tm_mday = 17;
1272 utcDate.tm_year = 1994 - 1900;
1273 utcDate.tm_wday = 2;
1274 utcDate.tm_yday = 136;
1275 utcDate.tm_isdst = 0;
1282 printf(
"GMST1 = % 14.9e rad.\n", tmpgmst);
1284 expected_resp.
plus = 0.5;
1285 expected_resp.
cross = 0.;
1286 expected_resp.
scalar = 0.;
1288 det_and_pulsar.pDetector = &detector;
1289 det_and_pulsar.pSource = &pulsar;
1298 &gps, &expected_resp, tolerance),
1313 utcDate.tm_sec = 46;
1314 utcDate.tm_min = 20;
1315 utcDate.tm_hour = 8;
1316 utcDate.tm_mday = 17;
1318 utcDate.tm_year = 1994 - 1900;
1319 utcDate.tm_wday = 2;
1320 utcDate.tm_yday = 136;
1321 utcDate.tm_isdst = 0;
1325 det_and_pulsar.pDetector = &detector;
1326 det_and_pulsar.pSource = &pulsar;
1329 expected_resp.
plus = 3.08260644404358e-01;
1330 expected_resp.
cross = -9.51301793267616e-01;
1331 expected_resp.
scalar = 0.;
1334 &gps, &expected_resp,
1354 det_and_pulsar.pDetector = &detector;
1355 det_and_pulsar.pSource = &pulsar;
1361 printf(
"Starting vector test\n");
1394 printf(
"Series test...\n");
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;
1404 am_response_series.
pPlus = &(plus_series);
1405 am_response_series.
pCross = &(cross_series);
1406 am_response_series.
pScalar = &(scalar_series);
1416 printf(
"am_response_series.pPlus->data->length = %d\n",
1418 printf(
"am_response_series.pCros->data->length = %d\n",
1420 printf(
"am_response_series.pScalar->data->length = %d\n",
1422 printf(
"circ_series.data->length = %d\n", circ_series.
data->
length);
1423 printf(
"sum_series.data->length = %d\n", sum_series.
data->
length);
1433 &am_response_series,
1440 "LALTestDetResponse0: error in LALComputeDetAMResponseSeries, line %i, %s\n",
1442 return status.statusCode;
1447 printf(
"Done computing AM response vectors\n");
1449 printf(
"am_response_series.pPlus->data->length = %d\n",
1451 printf(
"am_response_series.pCross->data->length = %d\n",
1453 printf(
"am_response_series.pScalar->data->length = %d\n",
1456 printf(
"TimeSeries data written to files plus_series.txt, ");
1457 printf(
"cross_series.txt, and scalar_series.txt\n");
1468 printf(
"circ_series.data->length = %d\n", circ_series.
data->
length);
1473 printf(
"sum_series.data->length = %d\n", sum_series.
data->
length);
1477 circ_series.
f0 = am_response_series.
pPlus->
f0;
1482 sum_series.
f0 = am_response_series.
pPlus->
f0;
1507 printf(
"mean = % 14.7e\n", mean);
1518 printf(
"% 14.6e, ", am_response_series.
pPlus->
data->
data[k]);
1529 printf(
"scalar: (");
1538 printf(
"sqrt(PLUS^2 + CROSS^2): (");
1541 printf(
"% 1.6e, ", sqrt(am_response_series.
pPlus->
data->
data[k] *
1559 printf(
"time_info.nSample = %d\n", time_info.
nSample);
1569 printf(
"\nStarting whole-sky test...\n");
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");
1589 printf(
"Done opening files.\n");
1598 printf(
"N sample = %d\n", time_info.
nSample);
1602 for (k = 0; k < (int)time_info.
nSample; ++k)
1607 printf(
"GRAR: k = %6d; gmst1 = % 20.14e\n", k, gmst1);
1609 for (j = 0; j <
NUM_RA; ++j)
1619 printf(
"OY: k = %6d; j = %6d; i = %6d\n", k, j, i);
1624 if (k == 0 && j == 0 && i == -
declim)
1625 printf(
"FOO: gmst1 = % 20.14e\n", gmst1);
1627 &det_and_pulsar, &gps);
1629 plus[cnt] = am_response.
plus;
1630 cross[cnt] = am_response.
cross;
1631 sqsum[cnt] = (plus[cnt] * plus[cnt])
1632 + (cross[cnt] * cross[cnt]);
1634 if (i == 0 && j == 0)
1636 fprintf(file_plus_at_0_0,
"%4d % 14.9e %9d % 14.9e\n",
1638 fprintf(file_cross_at_0_0,
"%4d % 14.9e %9d % 14.9e\n",
1641 fprintf(file_sum_sq,
"%4d % 14.9e %9d % 14.9e\n",
1646 if (i == 2 && j == 10)
1648 fprintf(file_plus_at_2_10,
"% 14.9e % 14.9e\n",
1650 fprintf(file_cross_at_2_10,
"% 14.9e % 14.9e\n",
1654 if (i == 4 && j == 15)
1656 fprintf(file_plus_at_4_15,
"% 14.9e % 14.9e\n", gmst1,
1658 fprintf(file_cross_at_4_15,
"% 14.9e % 14.9e\n",
1662 if (i == -4 && j == 15)
1664 fprintf(file_plus_at_m4_15,
"% 14.9e\n", plus[cnt]);
1665 fprintf(file_cross_at_m4_15,
"% 14.9e\n", cross[cnt]);
1678 skygrid_add(plus_sq_time_avg, plus_sq_time_avg, tmpskygrid);
1681 skygrid_add(cross_sq_time_avg, cross_sq_time_avg, tmpskygrid2);
1683 skygrid_add(sum_of_sq_time_avg, plus_sq_time_avg, cross_sq_time_avg);
1695 printf(
"BAR: gmst1 = % 20.15e\n", gmst1);
1696 printf(
"avg(F+^2 + Fx^2) = % 14.8e\n",
skygrid_avg(tmpskygrid));
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");
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");
1725 printf(
"avg(F+^2 + Fx^2) = % 14.8e\n",
skygrid_avg(sqsum));
1757 printf(
"\n\nGOODBYE.\n");
1779 static void REAL4VectorSubtraction(
REAL4Vector *pA,
1789 fprintf(stderr,
"VectorSubtraction: ERROR: incompatible dimensions\n");
1793 for (i = 0; i < pA->
length; ++i)
1808 for (i = 0; i < pVector->
length; ++i)
1810 result += pVector->
data[i] * pVector->
data[i];
1813 result /= pVector->
length;
1815 return sqrt(result);
1823 printf(
"Detector = \n");
1825 printf(
" { % 22.15e, % 22.15e, % 22.15e },\n",
1830 printf(
" { % 22.15e, % 22.15e, % 22.15e },\n",
1834 printf(
" { % 22.15e, % 22.15e, % 22.15e },\n",
1838 printf(
" { % 22.15e, % 22.15e, % 22.15e }\n },\n",
1844 printf(
" vertex longitude = % 22.15e,\n",
1846 printf(
" vertex latitude = % 22.15e,\n",
1848 printf(
" vertex elevation = % 22.15e,\n",
1850 printf(
" X-arm altitude = % 22.15e,\n",
1852 printf(
" X-arm azimuth = % 22.15e,\n",
1854 printf(
" Y-arm altitude = % 22.15e,\n",
1856 printf(
" Y-arm azimuth = % 22.15e\n }\n}\n",
1871 for (i = 0; i < 2; ++i)
1872 for (j = 0; j < 2; ++j)
1875 (
REAL8)((*expected)[i][j]),
1881 "INFO: matrix_ok_p(): expected",
1884 "INFO: matrix_ok_p(): computed",
1940 REAL8 relative_diff;
1945 relative_diff = fabs((*computed)[i]/(*expected)[i] - 1.);
1947 if (relative_diff <= tolerance)
1968 size_t title_length = strlen(title);
1972 printf(
"%s:\n", title);
1973 for (i = 0; i < title_length + 1; ++i)
1988 size_t title_length = strlen(title);
1992 printf(
"%s:\n", title);
1993 for (i = 0; i < title_length + 1; ++i)
2007 size_t title_length = strlen(title);
2011 printf(
"%s:\n", title);
2012 for (i = 0; i < title_length + 1; ++i)
2015 printf(
"Computed = %22.14e\n", computed);
2016 printf(
"Expected = %22.14e\n", expected);
2025 return printf(
"\n* * * * * * * * * *\n\n");
2035 return printf(
"\n- - - - -\n\n");
2045 return printf(
"\nPASS\n");
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);
2061 if (tolerance == 0.)
2064 return ((
REAL4)fabs(
a - b) <= tolerance);
2071 if (tolerance == 0.)
2074 return ((
REAL8)fabs(
a - b) <= tolerance);
2084 if (tolerance == 0.)
2086 return (computed == expected);
2090 relative_err = fabs(computed - expected)/fabs(expected);
2091 if (relative_err <= tolerance)
2112 REAL4 computed_circ_resp, expected_circ_resp;
2116 expected_circ_resp = sqrt((expected_resp->
plus) * (expected_resp->
plus)
2117 + (expected_resp->
cross) * (expected_resp->
cross));
2119 computed_circ_resp = sqrt(computed_resp.
plus * computed_resp.
plus
2120 + computed_resp.
cross * computed_resp.
cross);
2129 if (expected_resp->
plus == 0.)
2132 expected_resp->
plus,
2138 expected_resp->
plus,
2144 printf(
"INFO: detresponse_ok_p(): resp_plus_ok_p = %d\n",
2146 printf(
" computed = % 14.10e\n",
2147 computed_resp.
plus);
2148 printf(
" expected = % 14.10e\n",
2149 expected_resp->
plus);
2152 if (expected_resp->
cross == 0.)
2154 expected_resp->
cross,
2158 expected_resp->
cross,
2163 printf(
"INFO: detresponse_ok_p(): resp_cross_ok_p = %d\n",
2165 printf(
" computed = % 14.10e\n",
2166 computed_resp.
cross);
2167 printf(
" expected = % 14.10e\n",
2168 expected_resp->
cross);
2175 result = (resp_plus_ok_p && resp_cross_ok_p && resp_scalar_ok_p);
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);
2194 fprintf(stderr,
"ERROR in LALComputeDetAMResponse(): computed result != expected result; line %d\n", line);
2207 const char *
const title)
2209 REAL4 circ_response = sqrt((response->
plus) * (response->
plus)
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);
2277 &&
matrix_ok_p(&tmp_computed, &tmp_expected, 1.e-4)
2278 && computed->
type == expected->
type
2289 for (j = 0; j <
NUM_RA; ++j)
2294 retval += response[cnt];
2315 for (i = 0; i <
lim; ++i)
2316 square[i] = (input[i]) * (input[i]);
2327 for (i = 0; i <
lim; ++i)
2328 result[i] = (
REAL4)sqrt((
double)(input[i]));
2347 for (i = 0; i <
lim; ++i)
2359 FILE * outfile = NULL;
2363 if (comments != (
char *)NULL)
2364 fprintf(outfile,
"# %s\n", comments);
2366 for (i = 0; i <
NUM_RA; ++i)
2382 for (i = 0; i <
lim; ++i)
2383 absgrid[i] = fabs(input[i]);
2392 for (i = 0; i <
lim; ++i)
2393 sum[i] =
a[i] + b[i];
2400 for (i = 0; i <
lim; ++i)
2401 sum[i] =
a[i] - b[i];
2408 for (i = 0; i <
lim; ++i)
2409 result[i] = b *
a[i];
2427 dimLength.
data = data;
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);
2448 printf(
"sequence->dimLength->data[%d] = % 5d\n", i,
2459 f = fopen(
path, mode);
2464 perror(
"could not open file");
2472 if (stream != (FILE *)NULL)
2473 return fclose(stream);
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;
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.;
2493 retval = half_cos_sq_theta_p1_cos_2_phi * cos_2_psi
2494 - cos_theta_sin_2_phi * sin_2_psi;
2496 retval = half_cos_sq_theta_p1_cos_2_phi * sin_2_psi
2497 + cos_theta_sin_2_phi * cos_2_psi;
2501 return (
REAL4)retval;
2519 printf(
"global_detectors_set_p = %d\n", global_detectors_set_p);
2522 if (global_detectors_set_p ==
FALSE)
2614 global_detectors_set_p =
TRUE;
2631 char *retval = strncpy(
dst,
src, len-1);
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",
2656 REAL8 altitude = 0.;
2665 REAL8 fudge_factor = 0.;
2666 FILE *rms_diff_plus_file = (FILE *)NULL;
2667 FILE *rms_diff_cros_file = (FILE *)NULL;
2670 printf(
"\n\nSTARTING FUDGE FACTOR TEST NOW...\n");
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");
2681 printf(
"gmst1 = % 20.14e\n", gmst1);
2686 det_and_pulsar.
pSource = &pulsar;
2692 for (j = 0; j <
NUM_RA; ++j)
2705 &det_and_pulsar, &gps);
2707 plus[cnt] = am_response.
plus;
2708 cross[cnt] = am_response.
cross;
2714 printf(
" Starting to loop over fudge_factor...\n");
2716 for (k = -128; k < 129; ++k)
2718 fudge_factor = ((double)k) / 256. * (double)(
LAL_PI_2)/16.;
2722 printf(
"k = %d\n", k);
2723 printf(
"fudge_factor = % 20.14e\n", fudge_factor);
2726 for (j = 0; j <
NUM_RA; ++j)
2737 printf(
"azimuth = % 14.9e deg\n",
rad_to_deg(azimuth));
2738 printf(
"altitude = % 14.9e deg\n",
rad_to_deg(altitude));
2752 resp_plus,
"ff_local_plus.txt");
2754 resp_cros,
"ff_local_cros.txt");
2757 plus,
"ff_lal_plus.txt");
2759 cross,
"ff_lal_cros.txt");
2763 skygrid_print(
"Abs. difference between GRASP and LAL for plus",
2764 tmp3,
"ff_diff_plus.txt");
2768 skygrid_print(
"Abs. difference between GRASP and LAL for cross",
2769 tmp3,
"ff_diff_cros.txt");
2777 printf(
"avg(F+^2 + Fx^2) using resp_local() = % 14.9e\n",
2782 printf(
"RMS difference for plus = % 20.14e\n",
skygrid_rms(tmp3));
2783 fprintf(rms_diff_plus_file,
"% 20.14e % 20.14e\n",
2786 printf(
"RMS difference for cross = % 20.14e\n",
skygrid_rms(tmp3));
2787 fprintf(rms_diff_cros_file,
"% 20.14e % 20.14e\n",
2791 printf(
"... Done with looping over fudge_factor.\n");
2825 if (global_sources_set_p ==
FALSE)
2851 global_sources_set_p =
TRUE;
2868 printf(
"2*Pi = % 22.14e\n", 2. *
LAL_PI);
2870 for (k = 0; k < 4096; ++k)
2875 printf(
"k = %9d; GPS = %d:%d;\t\tgmst1 = % 22.14e; gmst1-2*Pi = % 20.14e\n",
2877 gmst1, (gmst1-2.*(
double)
LAL_PI));
2882 printf(
"AUF WIEDERSEHEN!\n");
2892 printf(
"Source name: %s\n", source->
name);
2893 printf(
"RA: % 14.20e rad\n",
2895 printf(
"Dec: % 14.20e rad\n",
2897 printf(
"Orientation: % 14.20e rad\n", source->
orientation);
2912 printf(
"MAHALO!\n");
2921 deg_to_rad((5. + 34./60. + 32./3600.) * 15.),
2926 det_and_pulsar.
pSource = &crab_pulsar;
2928 plus_series.
data = NULL;
2929 cross_series.
data = NULL;
2930 scalar_series.
data = NULL;
2932 am_response_series.
pPlus = &(plus_series);
2933 am_response_series.
pCross = &(cross_series);
2934 am_response_series.
pScalar = &(scalar_series);
2971 unsigned int iter, jter;
2976 printf(
"TEST OF MATRIX AND VECTOR FUNCTIONS\n");
2977 printf(
"-----------------------------------\n");
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.;
2987 printf(
"Print33Matrix output:\n");
2994 printf(
"Expected output:\n");
2997 for (iter = 0; iter < 3; ++iter)
2999 for (jter = 0; jter < 3; ++jter)
3001 printf(
"% 20.14e\t", A[iter][jter]);
3008 printf(
"\n- - - - -\n\n");
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.;
3016 printf(
"Print33Matrix output:\n");
3023 printf(
"Expected output:\n");
3026 for (iter = 0; iter < 3; ++iter)
3028 for (jter = 0; jter < 3; ++jter)
3030 printf(
"% 20.14e\t", A[iter][jter]);
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.;
3049 fprintf(stderr,
"ERROR: A != B\n");
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.;
3073 fprintf(stderr,
"ERROR: A != B\n");
3096 fprintf(stderr,
"ERROR: C != D\n");
3130 fprintf(stderr,
"ERROR: C != D\n");
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);
3155 fprintf(stderr,
"ERROR: C != D\n");
3176 fprintf(stderr,
"ERROR: c != d\n");
3203 fprintf(stderr,
"ERROR: B != C\n");
3215 v[0] = 1.; v[1] = -2.; v[2] = 3.;
3222 fprintf(stderr,
"ERROR: u != v\n");
3244 fprintf(stderr,
"ERROR: c != d\n");
3266 fprintf(stderr,
"ERROR: w != x\n");
3290 fprintf(stderr,
"ERROR: A != B\n");
3317 printf(
"TEST OF almost_equal_real[48]_p() functions\n");
3318 printf(
"-------------------------------------------\n");
3326 fprintf(stderr,
"ERROR: almost_equal_real4_p() failed test 1\n");
3333 printf(
"PASS: almost_equal_real4_p() test 1\n");
3334 printf(
"\n- - - - -\n");
3342 fprintf(stderr,
"ERROR: almost_equal_real4_p() failed test 2\n");
3349 printf(
"PASS: almost_equal_real4_p() test 2\n");
3350 printf(
"\n- - - - -\n");
3357 fprintf(stderr,
"ERROR: almost_equal_real4_p() failed test 3\n");
3364 printf(
"PASS: almost_equal_real4_p() test 3\n");
3365 printf(
"\n- - - - -\n");
3373 fprintf(stderr,
"ERROR: almost_equal_real8_p() failed test 1\n");
3380 printf(
"PASS: almost_equal_real8_p() test 1\n");
3381 printf(
"\n- - - - -\n");
3388 fprintf(stderr,
"ERROR: almost_equal_real8_p() failed test 2\n");
3395 printf(
"PASS: almost_equal_real8_p() test 2\n");
3396 printf(
"\n- - - - -\n");
3403 fprintf(stderr,
"ERROR: almost_equal_real8_p() failed test 3\n");
3410 printf(
"PASS: almost_equal_real8_p() test 3\n");
3421 static int local_strncasecmp(
const char *
a,
const char * b,
size_t maxlen)
3427 strncpy(tmp_a,
a, maxlen);
3428 strncpy(tmp_b, b, maxlen);
3430 for (i = 0; i < maxlen; ++i)
3432 tmp_a[i] = tolower(tmp_a[i]);
3433 tmp_b[i] = tolower(tmp_b[i]);
3436 return strncmp(tmp_a, tmp_b, maxlen);
void skygrid_print(const char *comments, const skygrid_t input, const char *filename)
void crab_pulsar_test(LALStatus *status)
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)
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)
static BOOLEAN almost_equal_real8_p(REAL8 a, REAL8 b, 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)
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)
static void handle_detresponse_test(BOOLEAN passed_p, int line)
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)
LALDetector det_south_pole
void fudge_factor_test(LALStatus *status)
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)
static void PrintDetResponse(const LALDetAMResponse *const response, const char *const title)
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)
static void LALDR_OuterProd3Vector(LALDR_33Matrix *a, LALDR_3Vector *u, LALDR_3Vector *v)
static int print_passed_maybe(void)
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)
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)
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)
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)
static int print_separator_maybe(void)
void skygrid_scalar_mult(skygrid_t result, const skygrid_t a, REAL4 b)
@ LALDetectorIndexLHODIFF
void REPORTSTATUS(LALStatus *status)
void LALCheckMemoryLeaks(void)
static double f(double theta, double y, double xi)
static double psi(double theta, double xi)
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)
void LALComputeDetAMResponseSeries(LALStatus *status, LALDetAMResponseSeries *pResponseSeries, const LALDetAndSource *pDetAndSource, const LALTimeIntervalAndNSample *pTimeInfo)
Computes REAL4TimeSeries containing time series of response amplitudes.
#define LAL_REAL8_EPS
Difference between 1 and the next resolvable REAL8 2^-52.
#define LAL_AWGS84_SI
Semimajor axis of WGS-84 Reference Ellipsoid, m.
#define LAL_PI
Archimedes's constant, pi.
#define LAL_TWOPI
2*pi is circumference of a circle divided by its radius
#define LAL_PI_4
pi/4 is the least positive solution to sin(x) = cos(x)
#define LAL_REAL4_EPS
Difference between 1 and the next resolvable REAL4 2^-23.
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).
@ LALDETECTORTYPE_ABSENT
No FrDetector associated with this detector.
@ LALDETECTORTYPE_IFODIFF
IFO in differential mode.
void LALSPrintTimeSeries(REAL4TimeSeries *series, const CHAR *filename)
@ COORDINATESYSTEM_EQUATORIAL
The sky-fixed equatorial coordinate system.
const LALUnit lalDimensionlessUnit
dimensionless units
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.
LIGOTimeGPS * XLALGPSSet(LIGOTimeGPS *epoch, INT4 gpssec, INT8 gpsnan)
Sets GPS time given GPS integer seconds and residual nanoseconds.
This structure stores the input required for creating an array sequence.
UINT4Vector * dimLength
The dimensions of each array index (the same for every array in the sequence)
UINT4 length
The sequence length.
This structure encapsulates the detector AM (beam pattern) coefficients for one source at one instanc...
REAL4 plus
Detector response to -polarized gravitational radiation
REAL4 scalar
Detector response to scalar gravitational radiation (NB: ignored at present – scalar response computa...
REAL4 cross
Detector response to -polarized gravitational radiation.
This structure aggregates together three REAL4TimeSeries objects containing time series of detector A...
REAL4TimeSeries * pCross
timeseries of detector response to -polarized gravitational radiation
REAL4TimeSeries * pPlus
timeseries of detector response to -polarized gravitational radiation
REAL4TimeSeries * pScalar
timeseries of detector response to scalar gravitational radiation (NB: not yet implemented....
This structure aggregates a pointer to a LALDetector and a LALSource.
LALSource * pSource
Pointer to LALSource object containing information about the source.
const LALDetector * pDetector
Pointer to LALDetector object containing information about the detector.
REAL4 response[3][3]
The Earth-fixed Cartesian components of the detector's response tensor .
LALDetectorType type
The type of the detector (e.g., IFO in differential mode, cylindrical bar, etc.)
REAL8 location[3]
The three components, in an Earth-fixed Cartesian coordinate system, of the position vector from the ...
LALFrDetector frDetector
The original LALFrDetector structure from which this was created.
Detector frame data structure Structure to contain the data that appears in a FrDetector structure in...
REAL8 vertexLongitudeRadians
The geodetic longitude of the vertex in radians.
REAL8 vertexLatitudeRadians
The geodetic latitude of the vertex in radians.
REAL4 vertexElevation
The height of the vertex above the reference ellipsoid in meters.
REAL4 xArmAzimuthRadians
The angle clockwise from North to the projection of the X arm (or bar's cylidrical axis) into the lo...
REAL4 yArmAltitudeRadians
The angle up from the local tangent plane of the reference ellipsoid to the Y arm in radians (unused...
REAL4 yArmAzimuthRadians
The angle clockwise from North to the projection of the Y arm into the local tangent plane of the re...
REAL4 xArmAltitudeRadians
The angle up from the local tangent plane of the reference ellipsoid to the X arm (or bar's cylidric...
CHAR name[LALNameLength]
A unique identifying string.
This structure contains gravitational wave source position (in Equatorial coördinates),...
SkyPosition equatorialCoords
equatorial coordinates of source, in decimal RADIANS
REAL8 orientation
Orientation angle ( ) of source: counter-clockwise angle -axis makes with a line perpendicular to mer...
CHAR name[LALNameLength]
name of source, eg catalog number
LAL status structure, see The LALStatus structure for more details.
This structure encapsulates time and sampling information for computing a LALDetAMResponseSeries.
LIGOTimeGPS epoch
The start time of the time series.
UINT4 nSample
The total number of samples to be computed.
REAL8 deltaT
The sampling interval , in seconds.
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
INT4 gpsSeconds
Seconds since 0h UTC 6 Jan 1980.
INT4 gpsNanoSeconds
Residual nanoseconds.
Sequence of REAL4 multidimensional arrays, see DATATYPE-ArraySequence types for more details.
UINT4Vector * dimLength
Pointer to a vector of length m storing the array dimensions.
UINT4 length
The number l of vectors.
Time series of REAL4 data, see DATATYPE-TimeSeries types for more details.
REAL4Sequence * data
The sequence of sampled data.
LALUnit sampleUnits
The physical units of the quantity being sampled.
REAL8 deltaT
The time step between samples of the time series in seconds.
LIGOTimeGPS epoch
The start time of the time series.
REAL8 f0
The heterodyning frequency, in Hertz (zero if not heterodyned).
Vector of type REAL4, see DATATYPE-Vector types for more details.
REAL4 * data
Pointer to the data array.
UINT4 length
Number of elements in array.
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.
UINT4 length
Number of elements in array.
UINT4 * data
Pointer to the data array.