Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
DetectorSiteTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton, John Whelan
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 J. T. Whelan <john.whelan@ligo.org>
22 * \file
23 * \ingroup LALDetectors_h
24 *
25 * \brief Tests the detector response and site parameter structures and the
26 * routine to create one from the other.
27 *
28 * ### Usage ###
29 *
30 * \code
31 * DetectorSiteTest [options]
32 * Options:
33 * -h print help
34 * -q quiet: run silently
35 * -v verbose: print extra information
36 * -d level set lalDebugLevel to level
37 * \endcode
38 *
39 * ### Description ###
40 *
41 * Right now the test routine does very little. It contains a static
42 * function <tt>PrintLALDetector()</tt> which will print the fields of a
43 * \c LALDetector to standard output in the same format that would
44 * be used for a C initialization. This function is not currently
45 * called. It also contains a static function <tt>CheckDetector()</tt>
46 * which extracts the \c LALFrDetector and type from a
47 * \c LALDetector, changes the name of the \c LALFrDetector
48 * (in case it's one of the predefined constant detectors), constructs a
49 * new \c LALDetector and compares the values of the fields of the
50 * old and new structures. The program currently performs this check
51 * for the two LIGO sites.
52 *
53 * ### Uses ###
54 *
55 * \code
56 * XLALCreateDetector()
57 * \endcode
58 */
59
60/**\name Error Codes */ /** @{ */
61#define DETECTORSITETESTC_ENOM 0 /**< Nominal exit */
62#define DETECTORSITETESTC_ECHK 1 /**< Error checking failed to catch bad data */
63#define DETECTORSITETESTC_EFLS 2 /**< Incorrect answer for valid data */
64/** @} */
65
66/** \cond DONT_DOXYGEN */
67
68#define DETECTORSITETESTC_MSGENOM "Nominal exit"
69#define DETECTORSITETESTC_MSGECHK "Error checking failed to catch bad data"
70#define DETECTORSITETESTC_MSGEFLS "Incorrect answer for valid data"
71
72#include <config.h>
73
74#include <stdlib.h>
75
76#include <lal/LALStdlib.h>
77#include <lal/LALConstants.h>
78#include <lal/DetectorSite.h>
79#include <lal/LALgetopt.h>
80
81#define CODES_(x) #x
82#define CODES(x) CODES_(x)
83
84int verbose = 0;
85
86static void
87Usage (const char *program, int exitflag);
88
89static void
90ParseOptions (int argc, char *argv[]);
91
92#define DETECTORSITETESTC_LOCTOL 3e-2
93#define DETECTORSITETESTC_RESTOL 1e-06
94
95#if 0
96static void
98{
99 printf( " = { { %.15e, %.15e, %.15e },\n", detector->location[0],
100 detector->location[1], detector->location[2] );
101 printf( " { { %.15g, %.15g, %.15g },\n", detector->response[0][0],
102 detector->response[0][1], detector->response[0][2]);
103 printf( " { %.15g, %.15g, %.15g },\n", detector->response[1][0],
104 detector->response[1][1], detector->response[1][2]);
105 printf( " { %.15g, %.15g, %.15g } },\n", detector->response[2][0],
106 detector->response[2][1], detector->response[2][2]);
107 printf(" { \"%s\",\n", detector->frDetector.name);
108 printf(" %.15g, %.15g, %.15g,\n",
111 detector->frDetector.vertexElevation);
112 printf(" %.15e, %.15g,\n",
115 printf(" %.15e, %.15g } }\n",
118 return;
119}
120#endif
121
122
123static int
124CheckDetector(LALDetector *cachedDetector)
125{
126 LALDetector constructedDetector;
127 LALDetectorType type = cachedDetector->type;
128 LALFrDetector frDetector = cachedDetector->frDetector;
129 INT2 i, j;
130
131 printf(" Name is \"%s\",\n", frDetector.name);
132
133 frDetector.name[1] = '?';
134
135 printf(" Changing to \"%s\",\n", frDetector.name);
136
137 XLALCreateDetector(&constructedDetector, &frDetector, type );
138
139 printf(" Enum'ed type is %d (LALDETECTORTYPE_IFODIFF=%d)\n",
140 constructedDetector.type, LALDETECTORTYPE_IFODIFF);
141
142 for (i=0; i<3; ++i)
143 {
144 printf(" x[%d]:\n cached: %.15g calc: %.15g diff: %g\n", i+1,
145 cachedDetector->location[i],
146 constructedDetector.location[i],
147 cachedDetector->location[i] - constructedDetector.location[i]);
148 if ( cachedDetector->location[i] - constructedDetector.location[i]
149 >= DETECTORSITETESTC_LOCTOL )
150 {
152 }
153 }
154
155 for (i=0; i<3; ++i)
156 {
157 for (j=0; j<3; ++j)
158 {
159 printf(" d[%d,%d]:\n cached: %g calc: %g diff: %g\n", i+1, j+1,
160 cachedDetector->response[i][j],
161 constructedDetector.response[i][j],
162 cachedDetector->response[i][j]
163 - constructedDetector.response[i][j]);
164 if ( cachedDetector->response[i][j]
165 - constructedDetector.response[i][j] >= DETECTORSITETESTC_RESTOL )
166 {
168 }
169 }
170 }
171
172 printf(" Latitude:\n cached: %g calc: %g diff: %g\n",
173 cachedDetector->frDetector.vertexLatitudeRadians,
174 constructedDetector.frDetector.vertexLatitudeRadians,
175 cachedDetector->frDetector.vertexLatitudeRadians -
176 constructedDetector.frDetector.vertexLatitudeRadians);
177
178 if ( cachedDetector->frDetector.vertexLatitudeRadians !=
179 constructedDetector.frDetector.vertexLatitudeRadians)
180 {
182 }
183
184 printf(" Longitude:\n cached: %g calc: %g diff: %g\n",
185 cachedDetector->frDetector.vertexLongitudeRadians,
186 constructedDetector.frDetector.vertexLongitudeRadians,
187 cachedDetector->frDetector.vertexLongitudeRadians -
188 constructedDetector.frDetector.vertexLongitudeRadians);
189
190 if ( cachedDetector->frDetector.vertexLongitudeRadians !=
191 constructedDetector.frDetector.vertexLongitudeRadians)
192 {
194 }
195
196 printf(" X Arm altitide:\n cached: %g calc: %g diff: %g\n",
197 cachedDetector->frDetector.xArmAltitudeRadians,
198 constructedDetector.frDetector.xArmAltitudeRadians,
199 cachedDetector->frDetector.xArmAltitudeRadians -
200 constructedDetector.frDetector.xArmAltitudeRadians);
201
202 if ( cachedDetector->frDetector.xArmAltitudeRadians !=
203 constructedDetector.frDetector.xArmAltitudeRadians)
204 {
206 }
207
208 printf(" X Arm azimuth:\n cached: %g calc: %g diff: %g\n",
209 cachedDetector->frDetector.xArmAzimuthRadians,
210 constructedDetector.frDetector.xArmAzimuthRadians,
211 cachedDetector->frDetector.xArmAzimuthRadians -
212 constructedDetector.frDetector.xArmAzimuthRadians);
213
214 if ( cachedDetector->frDetector.xArmAzimuthRadians !=
215 constructedDetector.frDetector.xArmAzimuthRadians)
216 {
218 }
219
220 printf(" Y Arm altitide:\n cached: %g calc: %g diff: %g\n",
221 cachedDetector->frDetector.yArmAltitudeRadians,
222 constructedDetector.frDetector.yArmAltitudeRadians,
223 cachedDetector->frDetector.yArmAltitudeRadians -
224 constructedDetector.frDetector.yArmAltitudeRadians);
225 if ( cachedDetector->frDetector.yArmAltitudeRadians !=
226 constructedDetector.frDetector.yArmAltitudeRadians)
227 {
229 }
230
231 printf(" Y Arm azimuth:\n cached: %g calc: %g diff: %g\n",
232 cachedDetector->frDetector.yArmAzimuthRadians,
233 constructedDetector.frDetector.yArmAzimuthRadians,
234 cachedDetector->frDetector.yArmAzimuthRadians -
235 constructedDetector.frDetector.yArmAzimuthRadians);
236
237 if ( cachedDetector->frDetector.yArmAzimuthRadians !=
238 constructedDetector.frDetector.yArmAzimuthRadians)
239 {
241 }
242
244}
245
246/* The main function */
247int main( int argc, char *argv[] )
248{
249 int code;
250
251 /*
252 LALFrDetector testFrDetector = {"Test Site",
253 0.0, 0.0, 0.0,
254 0.0, 0.0,
255 0.0, LAL_PI_2 };
256 LALFrDetector lhoFrDetector
257 = {"LIGO Hanford Observatory",
258 -119.40765714, 46.4551467, 142.544,
259 -6.195e-4, 2.199104,
260 1.25e-5, 3.769901 };
261 LALFrDetector lloFrDetector
262 = {"LIGO Livingston Observatory",
263 -90.77424039, 30.56289433, -6.574,
264 -3.121e-4, 3.4508039,
265 -6.107e-4, 5.021600 };
266 */
267 /*
268 LALDetector testDetector
269 = { { 4510094.634714941322397L, 4510094.634714941322397L, 0.0L },
270 { { 0.0, 0.0, 0.0 },
271 { 0.0, 0.0, 0.0 },
272 { 0.0, 0.0, 0.0 }
273 },
274 LALDETECTORTYPE_IFODIFF,
275 { "Test Interferometer",
276 45.0L, 0.0L, 100.0,
277 0.0, 0.0,
278 0.0, 0.0
279 }
280 };
281 = { { 4517590.8789357600195508L, 0.0L, 4487348.40860601410662157L },
282 { { 0.0, 0.0, 0.0 },
283 { 0.0, 0.0, 0.0 },
284 { 0.0, 0.0, 0.0 }
285 },
286 LALDETECTORTYPE_IFODIFF,
287 { "Test Interferometer",
288 0.0L, 45.0L, 0.0,
289 0.0, 0.0,
290 0.0, 0.0
291 }
292 };
293 */
294
295 LALDetector cachedDetector;
296
297
298 ParseOptions( argc, argv );
299
300 printf("Checking LHO...\n");
302
303 if ( ( code = CheckDetector( &cachedDetector ) ) )
304 {
305 return code;
306 }
307
308 printf("Checking LLO...\n");
310 if ( ( code = CheckDetector( &cachedDetector ) ) )
311 {
312 return code;
313 }
314
315 printf("Checking VIRGO...\n");
317 if ( ( code = CheckDetector( &cachedDetector ) ) )
318 {
319 return code;
320 }
321
322 printf("Checking GEO600...\n");
324 if ( ( code = CheckDetector( &cachedDetector ) ) )
325 {
326 return code;
327 }
328
329
330 printf("Checking TAMA300...\n");
332 if ( ( code = CheckDetector( &cachedDetector ) ) )
333 {
334 return code;
335 }
336
337 printf("Checking CIT40...\n");
339 if ( ( code = CheckDetector( &cachedDetector ) ) )
340 {
341 return code;
342 }
343
344 /*
345 printf("Checking trivial detector...\n");
346
347 if ( code = CheckDetector( &testDetector ) )
348 {
349 return code;
350 }
351
352 */
353 /*
354
355 PrintLALDetector(&lalCachedDetector[LALDetectorIndexLHODIFF]);
356 PrintLALDetector(&lalCachedDetector[LALDetectorIndexLLODIFF]);
357
358 XLALCreateDetector( &lalDetector, &testFrDetector, &type );
359 PrintLALDetector( &lalDetector );
360
361 XLALCreateDetector( &lalDetector, &lloFrDetector, &type );
362 PrintLALDetector( &lalDetector );
363
364 XLALCreateDetector( &lalDetector, &lhoFrDetector, &type );
365 PrintLALDetector( &lalDetector );
366
367 printf("%15g %15g %15g\n\n", lalDetector.location[0],
368 lalDetector.location[1], lalDetector.location[2]);
369
370 for (i=0; i<3; ++i)
371 {
372 printf("%15g %15g %15g\n", lalDetector.response[i][0],
373 lalDetector.response[i][1], lalDetector.response[i][2]);
374 }
375 */
376
378
379 printf("PASS: All tests\n");
380
382}
383
384
385/*----------------------------------------------------------------------*/
386
387
388/*
389 * Usage ()
390 *
391 * Prints a usage message for program program and exits with code exitcode.
392 *
393 */
394static void
395Usage (const char *program, int exitcode)
396{
397 fprintf (stderr, "Usage: %s [options]\n", program);
398 fprintf (stderr, "Options:\n");
399 fprintf (stderr, " -h print this message\n");
400 fprintf (stderr, " -q quiet: run silently\n");
401 fprintf (stderr, " -v verbose: print extra information\n");
402 fprintf (stderr, " -d level set lalDebugLevel to level\n");
403 exit (exitcode);
404}
405
406
407/*
408 * ParseOptions ()
409 *
410 * Parses the argc - 1 option strings in argv[].
411 *
412 */
413static void
414ParseOptions (int argc, char *argv[])
415{
416 while (1)
417 {
418 int c = -1;
419
420 c = LALgetopt (argc, argv, "hqvd:");
421 if (c == -1)
422 {
423 break;
424 }
425
426 switch (c)
427 {
428 case 'd': /* set debug level */
429 break;
430
431 case 'v': /* verbose */
432 ++verbose;
433 break;
434
435 case 'q': /* quiet: run silently (ignore error messages) */
436 if ( freopen ("/dev/null", "w", stderr) == NULL )
437 printf ("Failed call: freopen(/dev/null, 'w', stderr)\n");
438 if ( freopen ("/dev/null", "w", stdout) == NULL )
439 printf ("Failed call: freopen(/dev/null, 'w', stdout)\n");
440 break;
441
442 case 'h':
443 Usage (argv[0], 0);
444 break;
445
446 default:
447 Usage (argv[0], 1);
448 }
449
450 }
451
452 if (LALoptind < argc)
453 {
454 Usage (argv[0], 1);
455 }
456
457 return;
458}
459
460/** \endcond */
const char * program
@ LALDetectorIndexLLODIFF
Definition: DetectorSite.h:41
@ LALDetectorIndexGEO600DIFF
Definition: DetectorSite.h:43
@ LALDetectorIndexTAMA300DIFF
Definition: DetectorSite.h:44
@ LALDetectorIndexVIRGODIFF
Definition: DetectorSite.h:42
@ LALDetectorIndexCIT40DIFF
Definition: DetectorSite.h:45
@ LALDetectorIndexLHODIFF
Definition: DetectorSite.h:40
#define DETECTORSITETESTC_ENOM
Nominal exit.
#define DETECTORSITETESTC_EFLS
Incorrect answer for valid data.
void PrintLALDetector(const LALDetector *detector)
void LALCheckMemoryLeaks(void)
Definition: LALMalloc.c:784
int LALgetopt(int argc, char *const *argv, const char *optstring)
Definition: LALgetopt.c:172
int LALoptind
Definition: LALgetopt.c:79
#define fprintf
static void Usage(const char *program, int exitcode)
Definition: XLALChisqTest.c:70
static void ParseOptions(int argc, char *argv[])
Definition: XLALChisqTest.c:88
int main(int argc, char *argv[])
Definition: cache.c:25
LALDetector * XLALCreateDetector(LALDetector *detector, const LALFrDetector *frDetector, LALDetectorType type)
UNDOCUMENTED.
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
Pre-existing detectors.
int16_t INT2
Two-byte signed integer.
LALDetectorType
Detector type, which determines how the detector response is determined.
Definition: LALDetectors.h:238
@ LALDETECTORTYPE_IFODIFF
IFO in differential mode.
Definition: LALDetectors.h:240
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
int verbose
Definition: tconvert.c:103