Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInspiral 5.0.3.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SimInspiralUtils.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Drew Keppel, George Birthisel, Patrick Brady, Peter Shawhan, Stephen Fairhurst
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 *
22 * File Name: SimInspiralUtils.c
23 *
24 * Author: Brady, P. R., Brown, D. A., and Fairhurst, S
25 *
26 *-----------------------------------------------------------------------
27 */
28
29#include <math.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <lal/XLALError.h>
33#include <lal/LALError.h>
34#include <lal/LALStdlib.h>
35#include <lal/LALStdio.h>
36#include <lal/LIGOMetadataTables.h>
37#include <lal/LIGOMetadataUtils.h>
38#include <lal/LIGOMetadataInspiralUtils.h>
39#include <lal/Date.h>
40#include <lal/SkyCoordinates.h>
41#include <lal/GeneratePPNInspiral.h>
42#include <lal/DetectorSite.h>
43#include <lal/DetResponse.h>
44#include <lal/TimeDelay.h>
45
46/**
47 * \author Brown, D. A.
48 * \file
49 *
50 * \brief Provides a set of utilities for manipulating \c simInspiralTables.
51 *
52 * ### Description ###
53 *
54 * The function <tt>LALInspiralSiteTimeAndDist()</tt> calculates detector end
55 * time (\c endTime) and effective distance (\c effDist) for an
56 * inspiral signal from a specific location in the sky (\c skyPos) assumed
57 * to be given in equatorial coordinates. The detector end time is obtained by
58 * using <tt>LALTimeDelayFromEarthCenter()</tt>, while the effective distance
59 * requires calculation of the detector response, calculated using
60 * <tt>LALComputeDetAMResponse()</tt>.
61 *
62 * The function <tt>LALPopulateSimInspiralSiteInfo()</tt> populates the end time
63 * and effective distance for each of the interferometer sites. The sky location
64 * (in equatorial coordinates) is assumed to be already contained in the input
65 * \c SimInspiralTable. The end time and effective distance for each site
66 * is calculated by calling <tt>LALInspiralSiteTimeAndDist()</tt> once for each
67 * of the detectors, and setting the \c detector appropriately.
68 *
69 * ### Algorithm ###
70 *
71 * None.
72 *
73 * ### Uses ###
74 *
75 * LALGetInspiralParams(), LALGPStoGMST1(), LALTimeDelayFromEarthCenter(),
76 * LALComputeDetAMResponse().
77 *
78 */
79
80 /* a few useful static functions */
82{
83 return(XLALGPSToINT8NS(&x->geocent_end_time));
84}
85
86
87void
90 SimInspiralTable *output,
93 )
94
95{
96 PPNParamStruc ppnParams;
97 SkyPosition skyPos;
98 LALSource source;
101 LALDetAndSource detAndSource;
102 LALDetAMResponse resp;
103 REAL8 time_diff;
104 REAL4 splus, scross, cosiota;
105
108
111 ASSERT( input, status,
115
116
117 /*
118 *
119 * compute sky position and inspiral params
120 *
121 */
122
123
124 /* generate the ppn inspiral params */
125 memset( &ppnParams, 0, sizeof(PPNParamStruc) );
126 LALGetInspiralParams( status->statusPtr, &ppnParams, input, params );
128
130 {
132 }
133
134 /* copy the inspiral data into sim_inspiral table */
135 output->mass1 = input->m1;
136 output->mass2 = input->m2;
137 output->eta = ppnParams.eta;
138 output->distance = ppnParams.d / (1.0e6 * LAL_PC_SI); /* Mpc */
139 output->longitude = ppnParams.position.longitude;
140 output->latitude = ppnParams.position.latitude;
141 output->inclination = ppnParams.inc;
142 output->coa_phase = ppnParams.phi;
143 output->polarization = ppnParams.psi;
144
145 /* populate geocentric end time */
146 output->geocent_end_time = input->geocentEndTime;
147
148 /* populate gmst field (hours) */
149 output->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime(
150 &output->geocent_end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours*/
152
153 /* set up params for the site end times and detector response */
154 memset( &skyPos, 0, sizeof(SkyPosition) );
155 memset( &source, 0, sizeof(LALSource) );
156 memset( &detAndSource, 0, sizeof(LALDetAndSource) );
157
158 skyPos.longitude = output->longitude;
159 skyPos.latitude = output->latitude;
161
162 source.equatorialCoords = skyPos;
163 source.orientation = output->polarization;
164
165 detAndSource.pSource = &source;
166
167
168 /*
169 *
170 * compute site end times
171 *
172 */
173
174
175 /* initialize end times with geocentric value */
176 output->h_end_time = output->l_end_time = input->geocentEndTime;
177
178 /* ligo hanford observatory */
179 time_diff = XLALTimeDelayFromEarthCenter( lho.location, skyPos.longitude, skyPos.latitude, &(output->geocent_end_time) );
180 XLALGPSAdd(&(output->h_end_time), time_diff);
181
182 /* ligo livingston observatory */
183 time_diff = XLALTimeDelayFromEarthCenter( llo.location, skyPos.longitude, skyPos.latitude, &(output->geocent_end_time) );
184 XLALGPSAdd(&(output->l_end_time), time_diff);
185
186
187 /*
188 *
189 * compute the effective distance of the inspiral
190 *
191 */
192
193
194 /* initialize distances with real distance and compute splus and scross */
195 output->eff_dist_h = output->eff_dist_l = 2.0 * output->distance;
196 cosiota = cos( output->inclination );
197 splus = -( 1.0 + cosiota * cosiota );
198 scross = -2.0 * cosiota;
199
200 /* compute the response of the LHO detectors */
201 detAndSource.pDetector = &lho;
202 LALComputeDetAMResponse( status->statusPtr, &resp, &detAndSource,
203 &output->geocent_end_time );
205
206 /* compute the effective distance for LHO */
207 output->eff_dist_h /= sqrt(
208 splus*splus*resp.plus*resp.plus + scross*scross*resp.cross*resp.cross );
209
210 /* compute the response of the LLO detector */
211 detAndSource.pDetector = &llo;
212 LALComputeDetAMResponse( status->statusPtr, &resp, &detAndSource,
213 &output->geocent_end_time );
215
216 /* compute the effective distance for LLO */
217 output->eff_dist_l /= sqrt(
218 splus*splus*resp.plus*resp.plus + scross*scross*resp.cross*resp.cross );
219
220
221 /*
222 *
223 * normal exit
224 *
225 */
226
227
229 RETURN (status);
230}
231
232
233static void
236 SimInspiralTable *output,
237 LALDetector *detector,
238 LIGOTimeGPS *endTime,
239 REAL4 *effDist,
240 SkyPosition *skyPos
241 )
242
243{
244 LALSource source;
245 LALDetAndSource detAndSource;
246 LALDetAMResponse resp;
247 REAL8 time_diff;
248 REAL4 splus, scross, cosiota;
249
252
253 /* check that the arguments are not null */
258 ASSERT( endTime, status,
260 ASSERT( effDist, status,
262 ASSERT( skyPos, status,
264
265 memset( &source, 0, sizeof(LALSource) );
266 memset( &detAndSource, 0, sizeof(LALDetAndSource) );
267
268 source.equatorialCoords = *skyPos;
269 source.orientation = output->polarization;
270
271 detAndSource.pSource = &source;
272 detAndSource.pDetector = detector;
273
274 /* initialize end time with geocentric value */
275 *endTime = output->geocent_end_time;
276
277 /* calculate the detector end time */
278 time_diff = XLALTimeDelayFromEarthCenter( detector->location, skyPos->longitude, skyPos->latitude, &(output->geocent_end_time) );
279 XLALGPSAdd(endTime, time_diff);
280
281 /* initialize distance with real distance and compute splus and scross */
282 *effDist = 2.0 * output->distance;
283 cosiota = cos( output->inclination );
284 splus = -( 1.0 + cosiota * cosiota );
285 scross = -2.0 * cosiota;
286
287 /* compute the response of the detector */
288 LALComputeDetAMResponse( status->statusPtr, &resp, &detAndSource,
289 &output->geocent_end_time );
291
292 /* compute the effective distance */
293 *effDist /= sqrt(
294 splus*splus*resp.plus*resp.plus + scross*scross*resp.cross*resp.cross );
295
296 /* normal exit */
298 RETURN (status);
299}
300
301
302
303
304void
307 SimInspiralTable *output
308 )
309
310{
311 SkyPosition skyPos;
313 REAL4 *eff_dist;
315
316
319
322
323 /* set up params for the geocent end time and source location */
324 memset( &skyPos, 0, sizeof(SkyPosition) );
325
326 skyPos.longitude = output->longitude;
327 skyPos.latitude = output->latitude;
329
330 /* LIGO Hanford observatory*/
332 end_time = &(output->h_end_time);
333 eff_dist = &(output->eff_dist_h);
335 eff_dist, &skyPos);
336
337 /* LIGO Livingston observatory*/
339 end_time = &(output->l_end_time);
340 eff_dist = &(output->eff_dist_l);
342 eff_dist, &skyPos);
343
344 /* GEO observatory*/
346 end_time = &(output->g_end_time);
347 eff_dist = &(output->eff_dist_g);
349 eff_dist, &skyPos);
350
351 /* TAMA observatory*/
353 end_time = &(output->t_end_time);
354 eff_dist = &(output->eff_dist_t);
356 eff_dist, &skyPos);
357
358 /* Virgo observatory*/
360 end_time = &(output->v_end_time);
361 eff_dist = &(output->eff_dist_v);
363 eff_dist, &skyPos);
364
365 /*
366 *
367 * normal exit
368 *
369 */
370
371
373 RETURN (status);
374}
375
376
377void
379 SimInspiralTable **head,
380 int (*comparefunc)(const SimInspiralTable * const *,
381 const SimInspiralTable * const *)
382 )
383
384{
385 INT4 i;
386 INT4 length;
388 SimInspiralTable **array;
389
390 /* empty list --> no-op */
391 if(!head || !*head)
392 return;
393
394 /* count the number of events in the list */
395 for(length = 0, event = *head; event; event = event->next)
396 length++;
397
398 /* construct an array of pointers into the list */
399 array = LALCalloc(length, sizeof(*array));
400 for(i = 0, event = *head; event; event = event->next)
401 array[i++] = event;
402
403 /* sort the array using the specified function */
404 qsort(array, length, sizeof(*array),
405 (int(*)(const void *, const void *)) comparefunc);
406
407 /* re-link the list according to the sorted array */
408 for(i = 0; i < length; i++, head = &(*head)->next)
409 *head = array[i];
410 *head = NULL;
411
412 /* free the array */
413 LALFree(array);
414}
415
416
417int
419 const SimInspiralTable * const *a,
420 const SimInspiralTable * const *b
421 )
422
423{
424 INT8 ta, tb;
425 INT8 epsilon = 10; /* nanoseconds */
426
427 ta = geocent_end_time(*a);
428 tb = geocent_end_time(*b);
429
430 if(ta > tb + epsilon)
431 return(1);
432 if(ta < tb - epsilon)
433 return(-1);
434 return(0);
435}
LALDetectorIndexLLODIFF
LALDetectorIndexGEO600DIFF
LALDetectorIndexTAMA300DIFF
LALDetectorIndexVIRGODIFF
LALDetectorIndexLHODIFF
#define LAL_NULL_MSG
#define LAL_FAIL_ERR
#define LAL_NULL_ERR
#define LAL_FAIL_MSG
#define LAL_BADPARM_MSG
#define LAL_BADPARM_ERR
#define LALCalloc(m, n)
#define LALFree(p)
#define ABORT(statusptr, code, mesg)
#define CHECKSTATUSPTR(statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
static void LALInspiralSiteTimeAndDist(LALStatus *status, SimInspiralTable *output, LALDetector *detector, LIGOTimeGPS *endTime, REAL4 *effDist, SkyPosition *skyPos)
void LALGalacticInspiralParamsToSimInspiralTable(LALStatus *status, SimInspiralTable *output, GalacticInspiralParamStruc *input, RandomParams *params)
int XLALCompareSimInspiralByGeocentEndTime(const SimInspiralTable *const *a, const SimInspiralTable *const *b)
static INT8 geocent_end_time(const SimInspiralTable *x)
void LALPopulateSimInspiralSiteInfo(LALStatus *status, SimInspiralTable *output)
void XLALSortSimInspiral(SimInspiralTable **head, int(*comparefunc)(const SimInspiralTable *const *, const SimInspiralTable *const *))
static INT8 end_time(const SnglInspiralTable *x)
double i
const char * detector
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
void LALComputeDetAMResponse(LALStatus *status, LALDetAMResponse *pResponse, const LALDetAndSource *pDetAndSrc, const LIGOTimeGPS *gps)
void LALGetInspiralParams(LALStatus *, PPNParamStruc *output, GalacticInspiralParamStruc *input, RandomParams *params)
Computes the input parameters for a PPN inspiral.
#define LAL_TWOPI
#define LAL_PC_SI
double REAL8
int64_t INT8
int32_t INT4
float REAL4
static const INT4 a
COORDINATESYSTEM_EQUATORIAL
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
#define XLAL_IS_REAL8_FAIL_NAN(val)
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
INT8 XLALGPSToINT8NS(const LIGOTimeGPS *epoch)
x
This structure stores the position and mass parameters of a galactic inspiral event.
LIGOTimeGPS geocentEndTime
The geocentric end time of the inspiral event.
REAL4 m2
The masses of the binary components, in solar masses.
LALSource * pSource
const LALDetector * pDetector
REAL8 location[3]
SkyPosition equatorialCoords
REAL8 orientation
This structure stores the parameters for constructing a restricted post-Newtonian waveform.
REAL4 phi
The phase at coalescence (or arbitrary reference phase for a post -Newtonian approximation),...
REAL4 psi
polarization angle (radians)
SkyPosition position
location of source on sky
REAL4 eta
The mass ratio of the binary system; Physically this parameter must lie in the range ; values outsid...
REAL4 d
The distance to the system, in metres.
REAL4 inc
The inclination of the system to the line of sight, in radians.
struct tagSimInspiralTable * next
REAL8 longitude
REAL8 latitude
CoordinateSystem system
Definition: _thinca.c:157
char output[FILENAME_MAX]