Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALApps 10.1.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
spininj.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Drew Keppel, Gareth Jones, Patrick Brady, Thomas Cokelaer
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 :
22 *
23 * Purpose : generate xml file for binary injections (spinning case)
24 *
25 */
26#include <stdio.h>
27#include <stdlib.h>
28#include <config.h>
29
30#include <math.h>
31#include <ctype.h>
32#include <string.h>
33#include <time.h>
34#include <gsl/gsl_errno.h>
35#include <gsl/gsl_math.h>
36#include <gsl/gsl_roots.h>
37#include <lal/LALStdio.h>
38#include <lal/LALStdlib.h>
39#include <lal/LALConstants.h>
40#include <lal/LIGOLwXML.h>
41#include <lal/LIGOMetadataInspiralUtils.h>
42#include <lal/LIGOMetadataTables.h>
43#include <lal/LIGOMetadataUtils.h>
44#include <lal/Date.h>
45#include <lal/SkyCoordinates.h>
46#include <lal/GeneratePPNInspiral.h>
47#include <lal/GenerateInspiral.h>
48#include <lal/DetectorSite.h>
49#include <lal/DetResponse.h>
50#include <lal/TimeDelay.h>
51#include <LALAppsVCSInfo.h>
52
53
54#define CVS_ID_STRING "$Id$"
55#define CVS_NAME_STRING "$Name$"
56#define CVS_REVISION "$Revision$"
57#define CVS_SOURCE "$Source$"
58#define CVS_DATE "$Date$"
59#define PROGRAM_NAME "spininj"
60
61#define USAGE \
62"lalapps_spininj [options]\n"\
63"\nDefaults are shown in brackets\n\n" \
64" --help display this message\n"\
65" --verbose print mass and galactocentic cartesian coordinates\n"\
66" --gps-start-time TIME start injections at GPS time TIME (729273613)\n"\
67" --gps-end-time TIME end injections at GPS time TIME (734367613)\n"\
68" --time-step STEP space injections by ave of STEP sec (2630/PI)\n"\
69" --time-interval TIME distribute injections in interval TIME (0)\n"\
70" --seed SEED seed random number generator with SEED (1)\n"\
71" --user-tag STRING set the usertag to STRING\n"\
72" --waveform WVF set the injection waveform to WVF\n"\
73" (EOB, TaylorT1, TaylorT3,PadeT1; followed by the\n"\
74" order: newtonian, onePN, onePointFivePN, twoPN,\n"\
75" twoPointFivePN, threePN) (default: EOBtwoPN)\n"\
76" --fLower set the lower cutoff frequency of the isnpiral waveform (40)\n\n"\
77" --dist-distr DDISTR set method of simulated source distance distr to DDISTR \n"\
78" SPININJ_distance : uniform distr of sources in distance \n"\
79" SPININJ_logDistance : uniform distr of sources in log(distance) \n"\
80" SPININJ_volume : uniform distr of sources in volume \n"\
81" Default is SPININJ_logDistance \n"\
82" --distance-min set minimal value of simulated sources distance in kpc \n"\
83" --distance-max set maximal value of simulated sources distance in kpc \n\n"\
84" --coa-phase-min set minimal value of the initial orbital angle coa-phase (0)\n"\
85" --coa-phase-max set maximal value of the initial orbital angle coa-phase (2 pi)\n"\
86" --coa-phase-range set range of the initial orbital angle coa-phase (0 - 2 pi)\n\n"\
87" --inclination-min set minimal value of the initial inclination (>=0.01 \n"\
88" --inclination-max set maximal value of the initial inclination (<=pi)\n"\
89" --inclination-range set range of the initial inclination (0.01 - pi)\n\n"\
90" --spin1-min set minimal value of the initial spin (>=0)\n"\
91" --spin1-max set maximal value of the initial spin (<=1)\n"\
92" --spin1-range set range of the initial spin (0 - 1)\n\n"\
93" --spin2-min set minimal value of the initial spin (>=0)\n"\
94" --spin2-max set maximal value of the initial spin (<=1)\n"\
95" --spin2-range set range of the initial spin (0 - 1)\n\n"\
96" --mass-distr MDISTR set method of simulated source mass distr to MDISTR \n"\
97" SPININJ_m1Andm2 : uniform distr of sources component mass \n"\
98" SPININJ_totalMass : uniform distr of sources total mass \n"\
99" Default is SPININJ_totalMass \n"\
100" --mass1-range set range of the first mass (3 - 20 )\n"\
101" --mass2-range set range of the second mass (3 - 20)\n\n"\
102"\n"
103
104const INT4 S2StartTime = 729273613; /* Feb 14 2003 16:00:00 UTC */
105const INT4 S2StopTime = 734367613; /* Apr 14 2003 15:00:00 UTC */
106
107
108typedef enum{
112
113typedef enum{
118
119typedef struct{
120 double min;
121 double max;
123
124
125typedef struct {
138 REAL4 theta0, phi0;
143
144
145
147
148
149
152 SimInspiralTable *this_inj);
153
154
155
158 SimInspiralTable *this_inj);
159
162 SimInspiralTable *this_inj );
163
166 SimInspiralTable *this_inj);
167
169 SimInspiralTable *this_inj);
170
171
172
173
174
177 SimInspiralTable *this_inj);
178
180 char**,
182
183
185
186
187
188static ProcessParamsTable *next_process_param( const char *name, const char *type,
189 const char *fmt, ... )
190{
192 va_list ap;
193 pp = calloc( 1, sizeof( *pp ) );
194 if ( ! pp )
195 {
196 perror( "next_process_param" );
197 exit( 1 );
198 }
199 strncpy( pp->program, PROGRAM_NAME, LIGOMETA_PROGRAM_MAX );
200 snprintf( pp->param, LIGOMETA_PARAM_MAX, "--%s", name );
201 strncpy( pp->type, type, LIGOMETA_TYPE_MAX - 1 );
202 va_start( ap, fmt );
203 vsnprintf( pp->value, LIGOMETA_VALUE_MAX, fmt, ap );
204 va_end( ap );
205 return pp;
206}
207
208
209extern int vrbflg;
213
214
215int main( int argc, char *argv[] )
216{
217
218 static LALStatus status ;
219
220 /* command line options */
221
224 SimInspiralTable *this_inj = NULL;
225
226 /* set up inital debugging values */
228
229 LALParserInspiralInjection( argc, argv, &paramsIn );
230
232 &status );
233
234 /*
235 *
236 * loop over duration of desired output times
237 *
238 */
239
240 while ( XLALGPSCmp(&(paramsIn.gpsStartTime), &(paramsIn.gpsEndTime)) < 0 )
241 {
242
243 /* rho, z and lGal are the galactocentric galactic axial coordinates */
244 /* r and phi are the geocentric galactic spherical coordinates */
245
246 /* create the sim_inspiral table */
247 if ( injections )
248 {
249 this_inj = this_inj->next = (SimInspiralTable *)
250 LALCalloc( 1, sizeof(SimInspiralTable) );
251 }
252 else
253 {
254 injections = this_inj = (SimInspiralTable *)
255 LALCalloc( 1, sizeof(SimInspiralTable) );
256 }
257
258 LAL_CALL(LALSetGeoCentricEndTime(&status, paramsIn, this_inj),
259 &status);
260 LAL_CALL( LALSetIndividualMasses(&status, paramsIn, this_inj),
261 &status);
262 LAL_CALL( LALSetSpin(&status, paramsIn, this_inj),
263 &status);
264 LAL_CALL( LALSetDistance(&status, paramsIn, this_inj),
265 &status);
266 LAL_CALL( LALSetSpatialDistribution(&status, paramsIn, this_inj),
267 &status);
269 &status);
270
271 /* increment the injection time */
272 XLALGPSAdd( &(paramsIn.gpsStartTime), paramsIn.meanTimeStep );
273
274 this_inj->f_lower = paramsIn.fLower;
275 memcpy (this_inj->waveform, paramsIn.waveform, sizeof(CHAR) * LIGOMETA_WAVEFORM_MAX);
276 } /* end loop over injection times */
277
279
280 /*
281 *
282 * write output to LIGO_LW XML file
283 *
284 */
285
286 /* write the sim_inspiral table */
287 if ( injections )
289 /* close the injection file */
291
292 /* check for memory leaks and exit */
294 return 0;
295}
296
297
298
299/*################################################*/
301{
302 XLALSimInspiralAssignIDs ( *injtable, 0, 0 );
304 XLALDestroySimInspiralTable( *injtable );
305}
306
307
308
309
310/* TODO check uniformity of totalmass and (2) set mchirp*/
311
314 SimInspiralTable *this_inj )
315{
316
317 REAL4 deltaM1 = params.m1.max - params.m1.min;
318 REAL4 deltaM2 = params.m2.max - params.m2.min;
319
320
321 REAL4 u, mtotal;
322
323 switch(params.mdistr){
324 case SPININJ_m1Andm2:
326 this_inj->mass1 = params.m1.min + u * deltaM1;
328 this_inj->mass2 = params.m2.min + u * deltaM2;
329 mtotal = this_inj->mass1 + this_inj->mass2 ;
330 this_inj->eta = this_inj->mass1 * this_inj->mass2 / ( mtotal * mtotal );
331 break;
333 mtotal = params.m1.min + params.m2.min;
335 mtotal += u* (deltaM1+deltaM2);
336
338 this_inj->mass1 = params.m1.min + u * deltaM1;
339 this_inj->mass2 = mtotal - this_inj->mass1;
340 while (this_inj->mass2 >= params.m2.max
341 || this_inj->mass2 <= params.m2.min )
342 {
344 this_inj->mass1 = params.m1.min + u * deltaM1;
345 this_inj->mass2 = mtotal - this_inj->mass1;
346 }
347 this_inj->eta = this_inj->mass1 * this_inj->mass2 / ( mtotal * mtotal );
348 break;
349 }
350
351 this_inj->mchirp = pow( this_inj->eta, 0.6) *
352 (this_inj->mass1 + this_inj->mass2);
353
354}
355
356
359 SimInspiralTable *this_inj )
360{
361 REAL4 u;
362 REAL4 spin1Mag;
363 REAL4 spin2Mag;
364 REAL4 r1;
365 REAL4 r2;
366 REAL4 phi1;
367 REAL4 phi2;
368
369 /* spin1Mag */
371 spin1Mag = params.spin1.min + u * (params.spin1.max - params.spin1.min);
372
373 /* spin1z */
375 this_inj->spin1z = (u - 0.5) * 2 * (spin1Mag);
376
377 r1 = pow( ((spin1Mag * spin1Mag) - (this_inj->spin1z * this_inj->spin1z)) , 0.5);
378
379 /* phi1 */
381 phi1 = u * LAL_TWOPI;
382
383 /* spin1x and spin1y */
384 this_inj->spin1x = r1 * cos(phi1);
385 this_inj->spin1y = r1 * sin(phi1);
386
387 /* spin2Mag */
389 spin2Mag = params.spin2.min + u * (params.spin2.max - params.spin2.min);
390
391 /* spin2z */
393 this_inj->spin2z = (u - 0.5) * 2 * (spin2Mag);
394
395 r2 = pow( ((spin2Mag * spin2Mag) - (this_inj->spin2z * this_inj->spin2z)) , 0.5);
396
397 /* phi2 */
399 phi2 = u * LAL_TWOPI;
400
401 /* spin2x and spin2y */
402 this_inj->spin2x = r2 * cos(phi2);
403 this_inj->spin2y = r2 * sin(phi2);
404
405}
406
407/* TODO to check */
410 SimInspiralTable *this_inj)
411{
412 REAL4 u, deltaL, lmin,lmax, d3min,d3max,deltad3,d3, exponent;
413
414 switch (params.ddistr){
415 case SPININJ_distance:
417 this_inj->distance = params.distance.min + u * (params.distance.max - params.distance.min);
418
419 break;
420
422 lmin = log10(params.distance.min);
423 lmax = log10(params.distance.max);
424 deltaL = lmax - lmin;
426 exponent = lmin + deltaL * u;
427 this_inj->distance = pow(10.0,(REAL4) exponent);
428 break;
429
430 case SPININJ_volume:
431 d3min = params.distance.min * params.distance.min * params.distance.min;
432 d3max = params.distance.max * params.distance.max * params.distance.max;
433 deltad3 = d3max - d3min ;
435 d3 = d3min + u * deltad3 ;
436 this_inj->distance = pow(d3, 1.0/3.0);
437 break;
438 }
439
440 this_inj->distance = this_inj->distance / 1000.0; /*convert to Mpc */
441
442
443
444}
445
446
449 SimInspiralTable *this_inj
450 )
451{
452 REAL4 u;
453
454 /*TO check */
456
457 /* we are setting min value of inclination to 0.01
458 * inclination = 0 causes initial orb ang mmtm to coincide with
459 * a coord singularity in the injection code.
460 */
461
462 this_inj->inclination =
463 acos( cos(params.inclination.min)
464 + u *(cos(params.inclination.max) - cos(params.inclination.min)));
465
466 /* provide an input argument ? */
468 this_inj->polarization = LAL_TWOPI * u ;
469
471 this_inj->coa_phase = params.coa_phase.min + u * (params.coa_phase.max - params.coa_phase.min);
472
473 /* compute random longitude and latitude ; TODO input arguments ? */
475 this_inj->longitude = LAL_TWOPI * u;
477 this_inj->latitude = asin(2.0 * u - 1);
478
479}
480
481
483 SimInspiralTable *this_inj)
484
485{
486 SkyPosition skyPos;
487 LALSource source;
488 LALDetAndSource detAndSource;
489 REAL4 cosiota, splus, scross;
492 LALDetAMResponse resp;
493 REAL8 time_diff;
494
495 /* set up params for the site end times and detector response */
496 memset( &skyPos, 0, sizeof(SkyPosition) );
497 memset( &source, 0, sizeof(LALSource) );
498 memset( &detAndSource, 0, sizeof(LALDetAndSource) );
499
500 skyPos.longitude = this_inj->longitude;
501 skyPos.latitude = this_inj->latitude;
503
504 source.equatorialCoords = skyPos;
505 source.orientation = this_inj->polarization;
506
507 detAndSource.pSource = &source;
508
509 /*
510 * compute site end times
511 * (copied from SnglInspiralUtils.c)
512 */
513
514 /* initialize end times with geocentric value */
515 this_inj->h_end_time = this_inj->l_end_time = this_inj->geocent_end_time;
516
517 /* lho */
518 time_diff = XLALTimeDelayFromEarthCenter( lho.location, this_inj->longitude, this_inj->latitude, &(this_inj->geocent_end_time) );
519 XLALGPSAdd( &(this_inj->h_end_time), time_diff );
520
521 /* llo */
522 time_diff = XLALTimeDelayFromEarthCenter( llo.location, this_inj->longitude, this_inj->latitude, &(this_inj->geocent_end_time) );
523 XLALGPSAdd( &(this_inj->l_end_time), time_diff );
524
525 /* temporarily, populate the fields for the */
526 /* GEO, TAMA and VIRGO times */
527
528 memset( &(this_inj->g_end_time), 0,sizeof((this_inj->l_end_time)) );
529 memset( &(this_inj->t_end_time), 0,sizeof((this_inj->l_end_time)) );
530 memset( &(this_inj->v_end_time), 0,sizeof((this_inj->l_end_time)) );
531
532 /*
533 * compute the effective distance of the inspiral
534 * (copied from SnglInspiralUtils.c)
535 */
536
537
538 /* initialize distances with real distance and compute splus and scross*/
539 this_inj->eff_dist_h = this_inj->eff_dist_l = 2.0 * this_inj->distance;
540 cosiota = cos( this_inj->inclination );
541 splus = -( 1.0 + cosiota * cosiota );
542 scross = -2.0 * cosiota;
543
544
545 /* compute the response of the LHO detectors */
546
547 detAndSource.pDetector = &lho;
548 LAL_CALL( LALComputeDetAMResponse( status, &resp, &detAndSource,
549 &this_inj->geocent_end_time ), status );
550
551
552 /* compute the effective distance for LHO */
553 this_inj->eff_dist_h /= sqrt( splus*splus*resp.plus*resp.plus +
554 scross*scross*resp.cross*resp.cross );
555
556
557 /* compute the response of the LLO detector */
558 detAndSource.pDetector = &llo;
559 LAL_CALL( LALComputeDetAMResponse( status, &resp, &detAndSource,
560 &this_inj->geocent_end_time ), status);
561
562
563 /* compute the effective distance for LLO */
564 this_inj->eff_dist_l /= sqrt( splus*splus*resp.plus*resp.plus
565 + scross*scross*resp.cross*resp.cross );
566
567 /* temporarily, populate the fields for the */
568 /* GEO, TAMA and VIRGO effective distances */
569
570
571 memset( &(this_inj->eff_dist_g), 0, sizeof((this_inj->eff_dist_g)) );
572 memset( &(this_inj->eff_dist_t), 0, sizeof((this_inj->eff_dist_g)) );
573 memset( &(this_inj->eff_dist_v), 0, sizeof((this_inj->eff_dist_g)) );
574
575
576
577
578}
579
580
581
584 SimInspiralTable *this_inj)
585{
586 REAL4 u;
587
588 /* set the geocentric end time of the injection */
589 /* XXX CHECK XXX */
590 this_inj->geocent_end_time = params.gpsStartTime;
591 if ( params.timeInterval )
592 {
594 XLALGPSAdd( &(this_inj->geocent_end_time), u * params.timeInterval );
595 }
596
597 /* set gmst */
599 &this_inj->geocent_end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */
601}
602
603
604
606 char **argv,
608{
609 ProcessTable *proctable;
610 ProcessParamsTable *procparams;
611 ProcessParamsTable *this_proc_param;
612 int i;
613
614
615
616 /* create the process and process params tables */
617 proctable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) );
618
619 XLALGPSTimeNow(&(proctable->start_time));
622 snprintf( proctable->comment, LIGOMETA_COMMENT_MAX, " " );
623 this_proc_param = procparams = (ProcessParamsTable *)
624 calloc( 1, sizeof(ProcessParamsTable) );
625
626 /* clear the waveform field */
627 memset( params->waveform, 0, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR) );
628
629 /* Default values */
630 params->theta0 = 0; /* variable not used for spinning inj */
631 params->inclination.min = 0.01; /* can not be set to zero */
633 params->phi0 = 0.0; /* set =0 with no less of generality */
634 params->spin1.min = 0.;
635 params->spin2.min = 0.;
636 params->spin1.max = 1.;
637 params->spin2.max = 1.;
638 params->coa_phase.min = 0.;
639 params->coa_phase.max = LAL_TWOPI;
640 params->fLower = 40;
641 params->gpsStartTime.gpsSeconds = S2StartTime;
642 params->gpsStartTime.gpsNanoSeconds = 0;
643 params->gpsEndTime.gpsSeconds = S2StopTime;
644 params->gpsEndTime.gpsNanoSeconds = 0;
645 params->randSeed = 1;
646 params->m1.min = 3.;
647 params->m1.max = 20.;
648 params->m2.min = 3.;
649 params->m2.max = 20.;
650 params->timeInterval = 1000.;
651 params->meanTimeStep = 2630 / LAL_PI;
652 params->distance.min = 1.0;
653 params->distance.max = 20000.0;
654 params->mdistr = SPININJ_totalMass;
655 params->ddistr = SPININJ_logDistance;
656 params->userTag = NULL;
657 snprintf( params->waveform, LIGOMETA_WAVEFORM_MAX, "EOBtwoPN");
658 snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d-%d-%d.xml",
659 params->randSeed, params->gpsStartTime.gpsSeconds,
660 params->gpsEndTime.gpsSeconds - params->gpsStartTime.gpsSeconds );
661
662 /* Actual parsing is here; we do not check validity of the input arguments
663 for the time being*/
664 i = 1;
665
666 while (i < argc)
667 {
668 if ( (strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "-h") == 0) ){
669 fprintf( stderr, USAGE );
670 exit(1);
671 }
672 else if ( strcmp(argv[i], "--user-tag") == 0){
673 /* create storage for the usertag */
674 params->userTag = (CHAR *) calloc( strlen( argv[i+1] ) + 1, sizeof(CHAR) );
675 memcpy( params->userTag, argv[i+1], strlen( argv[i+1] ) + 1 );
676 this_proc_param = this_proc_param->next =
677 next_process_param( "user-tag", "string", "%s", argv[i+1] );
678 i++;
679 }
680 else if ( strcmp(argv[i], "--gps-start-time") == 0){
681 params->gpsStartTime.gpsSeconds = atol(argv[++i]);
682 this_proc_param = this_proc_param->next =
683 next_process_param( "gps-start-time", "int", "%ld", params->gpsStartTime.gpsSeconds);
684 }
685 else if ( strcmp(argv[i], "--gps-end-time") == 0){
686 params->gpsEndTime.gpsSeconds = atol(argv[++i]);
687 this_proc_param = this_proc_param->next =
688 next_process_param( "gps-end-time", "int", "%ld", params->gpsEndTime.gpsSeconds );
689 }
690 else if ( strcmp(argv[i], "--seed") == 0){
691 params->randSeed = atoi( argv[++i]);
692 this_proc_param = this_proc_param->next =
693 next_process_param( "seed", "int", "%d", params->randSeed );
694 }
695 else if ( strcmp(argv[i] , "--time-interval") == 0 ){
696 params->timeInterval = atof( argv[++i] );
697 this_proc_param = this_proc_param->next =
698 next_process_param( "time-interval", "float", "%le", params->timeInterval );
699 }
700 else if ( strcmp(argv[i] , "--time-step") == 0 ){
701 params->meanTimeStep = atof( argv[++i] );
702 this_proc_param = this_proc_param->next =
703 next_process_param( "time-step", "float", "%le", params->meanTimeStep );
704 }
705 else if ( strcmp(argv[i] , "--coa-phase-min") == 0 ){
706 params->coa_phase.min = atof( argv[++i] );
707 this_proc_param = this_proc_param->next =
708 next_process_param( "coa-phase-min", "float", "%le", params->coa_phase.min );
709 }
710 else if ( strcmp(argv[i] , "--coa-phase-max") == 0 ){
711 params->coa_phase.max = atof( argv[++i] );
712 this_proc_param = this_proc_param->next =
713 next_process_param( "coa-phase-max", "float", "%le", params->coa_phase.max );
714 }
715 else if ( strcmp(argv[i] , "--coa-phase-range") == 0 ){
716 params->coa_phase.min = atof( argv[++i] );
717 params->coa_phase.max = atof( argv[++i] );
718 this_proc_param = this_proc_param->next =
719 next_process_param( "coa-phase-min", "float", "%le", params->coa_phase.min );
720 this_proc_param = this_proc_param->next =
721 next_process_param( "coa-phase-max", "float", "%le", params->coa_phase.max );
722 }
723 else if ( strcmp(argv[i] , "--mass1-min") == 0 ){
724 params->m1.min = atof( argv[++i] );
725 this_proc_param = this_proc_param->next =
726 next_process_param( "mass1-min", "float", "%le", params->m1.min );
727 }
728 else if ( strcmp(argv[i] , "--mass1-max") == 0 ){
729 params->m1.max = atof( argv[++i] );
730 this_proc_param = this_proc_param->next =
731 next_process_param( "mass1-max", "float", "%le", params->m1.max );
732 }
733 else if ( strcmp(argv[i] , "--mass1-range") == 0 ){
734 params->m1.min = atof( argv[++i] );
735 params->m1.max = atof( argv[++i] );
736 this_proc_param = this_proc_param->next =
737 next_process_param( "mass1-min", "float", "%le", params->m1.min );
738 this_proc_param = this_proc_param->next =
739 next_process_param( "mass1-max", "float", "%le", params->m1.max );
740 }
741 else if ( strcmp(argv[i] , "--fLower") == 0 ){
742 params->fLower = atof( argv[++i] );
743 this_proc_param = this_proc_param->next =
744 next_process_param( "fLower", "float", "%le", params->fLower );
745 }
746 else if ( strcmp(argv[i] , "--mass2-min") == 0 ){
747 params->m2.min = atof( argv[++i] );
748 this_proc_param = this_proc_param->next =
749 next_process_param( "mass2-min", "float", "%le", params->m2.min );
750 }
751 else if ( strcmp(argv[i] , "--mass2-max") == 0 ){
752 params->m2.max = atof( argv[++i] );
753 this_proc_param = this_proc_param->next =
754 next_process_param( "mass2-max", "float", "%le", params->m2.max );
755 }
756 else if ( strcmp(argv[i] , "--mass2-range") == 0 ){
757 params->m2.min = atof( argv[++i] );
758 params->m2.max = atof( argv[++i] );
759 this_proc_param = this_proc_param->next =
760 next_process_param( "mass2-min", "float", "%le", params->m2.min );
761 this_proc_param = this_proc_param->next =
762 next_process_param( "mass2-max", "float", "%le", params->m2.max );
763 }
764 else if ( strcmp(argv[i] , "--distance-min") == 0 ){
765 params->distance.min = atof( argv[++i] );
766 this_proc_param = this_proc_param->next =
767 next_process_param( "distance-min", "float", "%le", params->distance.min );
768 }
769 else if ( strcmp(argv[i] , "--distance-max") == 0 ){
770 params->distance.max = atof( argv[++i] );
771 this_proc_param = this_proc_param->next =
772 next_process_param( "distance-max", "float", "%le", params->distance.max );
773 }
774 else if ( strcmp(argv[i] , "--distance-range") == 0 ){
775 params->distance.min = atof( argv[++i] );
776 params->distance.max = atof( argv[++i] );
777 this_proc_param = this_proc_param->next =
778 next_process_param( "distance-min", "float", "%le", params->distance.min );
779 this_proc_param = this_proc_param->next =
780 next_process_param( "distance-max", "float", "%le", params->distance.max );
781 }
782 else if ( strcmp(argv[i] , "--spin1-min") == 0 ){
783 params->spin1.min = atof( argv[++i] );
784 this_proc_param = this_proc_param->next =
785 next_process_param( "spin1-min", "float", "%le", params->spin1.min );
786 }
787 else if ( strcmp(argv[i] , "--spin2-min") == 0 ){
788 params->spin2.min = atof( argv[++i] );
789 this_proc_param = this_proc_param->next =
790 next_process_param( "spin2-min", "float", "%le", params->spin2.min );
791 }
792 else if ( strcmp(argv[i] , "--spin1-max") == 0 ){
793 params->spin1.max = atof( argv[++i] );
794 this_proc_param = this_proc_param->next =
795 next_process_param( "spin1-max", "float", "%le", params->spin1.max );
796 }
797 else if ( strcmp(argv[i] , "--spin2-max") == 0 ){
798 params->spin2.max = atof( argv[++i] );
799 this_proc_param = this_proc_param->next =
800 next_process_param( "spin2-max", "float", "%le", params->spin2.max );
801 }
802 else if ( strcmp(argv[i] , "--spin1-range") == 0 ){
803 params->spin1.min = atof( argv[++i] );
804 params->spin1.max = atof( argv[++i] );
805
806 this_proc_param = this_proc_param->next =
807 next_process_param( "spin1-min", "float", "%le", params->spin1.min );
808 this_proc_param = this_proc_param->next =
809 next_process_param( "spin1-max", "float", "%le", params->spin1.max );
810 }
811 else if ( strcmp(argv[i] , "--spin2-range") == 0 ){
812 params->spin2.min = atof( argv[++i] );
813 params->spin2.max = atof( argv[++i] );
814
815 this_proc_param = this_proc_param->next =
816 next_process_param( "spin2-min", "float", "%le", params->spin2.min );
817 this_proc_param = this_proc_param->next =
818 next_process_param( "spin2-max", "float", "%le", params->spin2.max );
819 }
820 else if ( strcmp(argv[i] , "--inclination-min") == 0 ){
821 params->inclination.min = atof( argv[++i] );
822 this_proc_param = this_proc_param->next =
823 next_process_param( "inclination-min", "float", "%le", params->inclination.min );
824 }
825 else if ( strcmp(argv[i] , "--inclination-max") == 0 ){
826 params->inclination.max = atof( argv[++i] );
827 this_proc_param = this_proc_param->next =
828 next_process_param( "inclination-max", "float", "%le", params->inclination.max );
829 }
830 else if ( strcmp(argv[i] , "--inclination-range") == 0 ){
831 params->inclination.min = atof( argv[++i] );
832 params->inclination.max = atof( argv[++i] );
833
834 this_proc_param = this_proc_param->next =
835 next_process_param( "inclination-min", "float", "%le", params->inclination.min );
836 this_proc_param = this_proc_param->next =
837 next_process_param( "inclination-max", "float", "%le", params->inclination.max );
838 }
839 else if ( strcmp(argv[i] , "--waveform") == 0 ){
840 snprintf( params->waveform, LIGOMETA_WAVEFORM_MAX, "%s", argv[++i]);
841 this_proc_param = this_proc_param->next =
842 next_process_param( "waveform", "string",
843 "%s",argv[i] );
844 }
845 else if ( strcmp(argv[i] , "--mass-distr") == 0 ){
846 if ( ! strcmp( "SPININJ_m1Andm2", argv[++i] ) )
847 {
848 params->mdistr = SPININJ_m1Andm2;
849 }
850 else if ( ! strcmp( "SPININJ_totalMass", argv[i] ) )
851 {
852 params->mdistr = SPININJ_totalMass;
853 }
854 else
855 {
856 fprintf( stderr, "invalid arg to --mass-distr \n");
857 exit(1);
858 }
859 this_proc_param = this_proc_param->next =
860 next_process_param( "mass-distr", "string",
861 "%s",argv[i] );
862 }
863 else if ( strcmp(argv[i] , "--dist-distr") == 0 ){
864 if ( ! strcmp( "SPININJ_distance", argv[++i] ) )
865 {
866 params->ddistr = SPININJ_distance;
867 }
868 else if ( ! strcmp( "SPININJ_logDistance", argv[i] ) )
869 {
870 params->ddistr = SPININJ_logDistance;
871 }
872 else if ( ! strcmp( "SPININJ_volume", argv[i] ) )
873 {
874 params->ddistr = SPININJ_volume;
875 }
876 else
877 {
878 fprintf( stderr, "invalid arg to --dist-distr \n");
879 exit(1);
880 }
881 this_proc_param = this_proc_param->next =
882 next_process_param( "dist-distr", "string",
883 "%s",argv[i] );
884 }
885 else {
886 fprintf(stderr, "option %s unknown !!! abort\n", argv[i]);
887 exit(1);
888 }
889
890
891 i++;
892 }
893
894 if (params->userTag){
895 snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d_%s-%d-%d.xml",
896 params->randSeed, params->userTag, params->gpsStartTime.gpsSeconds,
897 params->gpsEndTime.gpsSeconds - params->gpsStartTime.gpsSeconds );
898 }
899
900 /* Let us check now the validity of the arguments */
902
903
904
905 /* and finally stored the arguments in the process table */
906
908
909 /* write the process table */
910 snprintf( proctable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" );
911 XLALGPSTimeNow(&(proctable->end_time));
912
914
915 XLALDestroyProcessTable( proctable );
916
917 this_proc_param = procparams;
918 procparams = procparams->next;
919 free( this_proc_param );
920
921 /* write the process params table */
922 if ( procparams )
923 {
925 XLALDestroyProcessParamsTable( procparams );
926 }
927 /* We dont close right now. it will be done within the main function
928 after having written the injection data*/
929
930 /* DETATCHSTATUSPTR(status);
931 RETURN (status); */
932}
933
934
936{
937 if ( params.fLower <= 5 || params.fLower >=1000)
938 {
939 fprintf( stderr, "invalid argument to --%s:\n"
940 "fLower should not be less than 5Hz or greater than 1000Hz "
941 "(%f specified)\n",
942 "fLower", params.fLower );
943 exit( 1 );
944 }
945 if ( params.gpsStartTime.gpsSeconds < 441417609 )
946 {
947 fprintf( stderr, "invalid argument to --%s:\n"
948 "GPS start time is prior to "
949 "Jan 01, 1994 00:00:00 UTC:\n"
950 "(%d specified)\n",
951 "gps-start-time", params.gpsStartTime.gpsSeconds );
952 exit( 1 );
953 }
954 /* check that the start time is before the end time */
955 if ( params.meanTimeStep <= 0 )
956 {
957 fprintf( stderr, "invalid argument to --%s:\n"
958 "time step must be > 0: (%e seconds specified)\n",
959 "mean-time", params.meanTimeStep );
960 exit( 1 );
961 }
962 if ( params.timeInterval < 0 )
963 {
964 fprintf( stderr, "invalid argument to --%s:\n"
965 "time interval must be >= 0: (%e seconds specified)\n",
966 "time-interval", params.timeInterval );
967 exit( 1 );
968 }
969 if ( params.m1.min < 0 || params.m2.max < 0 )
970 {
971 fprintf( stderr, "invalid argument to --%s:\n"
972 "miniumum component mass must be > 0: \n",
973 "mass-range" );
974
975 exit( 1 );
976 }
977 if ( params.m1.min > params.m1.max )
978 {
979 fprintf( stderr, "invalid argument to --%s:\n"
980 "minimum component (%f) mass must be < maximum component (%f) : \n",
981 "mass-range", params.m1.min, params.m1.max);
982
983 exit( 1 );
984 }
985 if ( params.m2.min > params.m2.max )
986 {
987 fprintf( stderr, "invalid argument to --%s:\n"
988 "minimum component (%f) mass must be < maximum component (%f) : \n",
989 "mass-range", params.m2.min, params.m2.max);
990
991 exit( 1 );
992 }
993 if ( params.distance.min <= 0)
994 {
995 fprintf( stderr, "invalid argument to --%s:\n"
996 "minimum distance must be > 0: "
997 "(%f kpc specified)\n", "distance-range",params.distance.min);
998
999 exit( 1 );
1000 }
1001 if ( params.distance.max < params.distance.min)
1002 {
1003 fprintf( stderr, "invalid argument to --%s:\n"
1004 "maximum distance max (%f) must be > distance min (%f)",
1005 "distance-range",params.distance.max, params.distance.min);
1006
1007 exit( 1 );
1008 }
1009 if ( params.coa_phase.max < params.coa_phase.min)
1010 {
1011 fprintf( stderr, "invalid argument to --%s:\n"
1012 "maximum coa_phase max (%f) must be > coa_phase min (%f)",
1013 "coa-phase-range",params.coa_phase.max, params.coa_phase.min);
1014
1015 exit( 1 );
1016 }
1017
1018
1019 if ( params.spin1.min < 0 || params.spin1.max < 0)
1020 {
1021 fprintf( stderr, "invalid argument to --%s:\n"
1022 "spin1-min (%f) and spin1-max (%f) must be > 0 \n",
1023 "spin1-min or spin1-max",params.spin1.min, params.spin1.max);
1024
1025 exit( 1 );
1026 }
1027
1028 if ( params.spin1.max < params.spin1.min)
1029 {
1030 fprintf( stderr, "invalid argument to --%s:\n"
1031 "spin1-min (%f) must be < spin1-max (%f) \n",
1032 "spin1-min or spin1-max",params.spin1.min, params.spin1.max);
1033
1034 exit( 1 );
1035 }
1036
1037 if ( params.spin2.min < 0 || params.spin2.max < 0)
1038 {
1039 fprintf( stderr, "invalid argument to --%s:\n"
1040 "spin2-min (%f) and spin2-max (%f) must be > 0 \n",
1041 "spin2-min or spin2-max",params.spin2.min, params.spin2.max);
1042
1043 exit( 1 );
1044 }
1045
1046 if ( params.spin2.max < params.spin2.min)
1047 {
1048 fprintf( stderr, "invalid argument to --%s:\n"
1049 "spin2-min (%f) must be < spin2-max (%f) \n",
1050 "spin2-min or spin2-max",params.spin2.min, params.spin2.max);
1051
1052 exit( 1 );
1053 }
1054
1055 if ( params.inclination.max > LAL_PI)
1056 {
1057 fprintf( stderr, "invalid argument to --%s:\n"
1058 "inclination-max (%f) must be < pi \n",
1059 "inclination-max", params.inclination.max);
1060
1061 exit( 1 );
1062 }
1063
1064 if ( params.inclination.min < 0.01)
1065 {
1066 fprintf( stderr, "invalid argument to --%s:\n"
1067 "inclination-min (%f) must be > 0.01 \n",
1068 "inclination-min", params.inclination.min);
1069
1070 exit( 1 );
1071 }
1072
1073 if ( params.inclination.max < params.inclination.min)
1074 {
1075 fprintf( stderr, "invalid argument to --%s:\n"
1076 "inclination-min (%f) must be < inclination-max (%f) \n",
1077 "inclination-min or inclination-max",params.inclination.min, params.inclination.max);
1078
1079 exit( 1 );
1080 }
1081
1082
1083}
LALDetectorIndexLLODIFF
LALDetectorIndexLHODIFF
const LALVCSInfo lalAppsVCSIdentInfo
Identable VCS and build information for LALApps.
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
#define LAL_FAIL_ERR
#define LAL_FAIL_MSG
#define LAL_CALL(function, statusptr)
void LALCheckMemoryLeaks(void)
#define LALCalloc(m, n)
#define ASSERT(assertion, statusptr, code, mesg)
int XLALCloseLIGOLwXMLFile(LIGOLwXMLStream *xml)
LIGOLwXMLStream * XLALOpenLIGOLwXMLFile(const char *path)
int XLALWriteLIGOLwXMLProcessTable(LIGOLwXMLStream *, const ProcessTable *)
int XLALWriteLIGOLwXMLProcessParamsTable(LIGOLwXMLStream *, const ProcessParamsTable *)
int XLALWriteLIGOLwXMLSimInspiralTable(LIGOLwXMLStream *, const SimInspiralTable *)
#define LIGOMETA_IFOS_MAX
#define LIGOMETA_COMMENT_MAX
#define LIGOMETA_TYPE_MAX
#define LIGOMETA_WAVEFORM_MAX
#define LIGOMETA_PROGRAM_MAX
#define LIGOMETA_VALUE_MAX
#define LIGOMETA_PARAM_MAX
void XLALDestroyProcessParamsTable(ProcessParamsTable *)
void XLALDestroySimInspiralTable(SimInspiralTable *head)
void XLALDestroyProcessTable(ProcessTable *)
int XLALPopulateProcessTable(ProcessTable *ptable, const char *program_name, const char *cvs_revision, const char *cvs_source, const char *cvs_date, long process_id)
long XLALSimInspiralAssignIDs(SimInspiralTable *head, long process_id, long simulation_id)
#define fprintf
const double pp
const double u
const double r2
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
LIGOTimeGPS * XLALGPSTimeNow(LIGOTimeGPS *gpstime)
void LALComputeDetAMResponse(LALStatus *status, LALDetAMResponse *pResponse, const LALDetAndSource *pDetAndSrc, const LIGOTimeGPS *gps)
#define LAL_PI
#define LAL_TWOPI
double REAL8
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
void LALCreateRandomParams(LALStatus *status, RandomParams **params, INT4 seed)
void LALUniformDeviate(LALStatus *status, REAL4 *deviate, RandomParams *params)
void LALDestroyRandomParams(LALStatus *status, RandomParams **params)
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)
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
SimInspiralTable * injections
Definition: inspfrinj.c:339
char name[LIGOMETA_SOURCE_MAX]
Definition: inspinj.c:561
static LALStatus status
Definition: inspinj.c:552
int i
Definition: inspinj.c:596
type
m2
phi2
phi1
mtotal
waveform
fmt
float atol
int main(int argc, char *argv[])
Definition: spininj.c:215
RandomParams * randParams
Definition: spininj.c:212
LIGOLwXMLStream * xmlfp
Definition: spininj.c:210
#define PROGRAM_NAME
Definition: spininj.c:59
distributionEnum
Definition: spininj.c:113
@ SPININJ_distance
Definition: spininj.c:114
@ SPININJ_logDistance
Definition: spininj.c:115
@ SPININJ_volume
Definition: spininj.c:116
void LALSetSpin(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
Definition: spininj.c:357
massEnum
Definition: spininj.c:108
@ SPININJ_m1Andm2
Definition: spininj.c:109
@ SPININJ_totalMass
Definition: spininj.c:110
#define USAGE
Definition: spininj.c:61
static ProcessParamsTable * next_process_param(const char *name, const char *type, const char *fmt,...)
Definition: spininj.c:188
void LALSetSiteParameters(LALStatus *status, SimInspiralTable *this_inj)
Definition: spininj.c:482
void XLALCheckInspiralInjectionParameters(InspiralInjectionParameters params)
Definition: spininj.c:935
void LALSetSpatialDistribution(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
Definition: spininj.c:447
const INT4 S2StartTime
Definition: spininj.c:104
void LALSetGeoCentricEndTime(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
Definition: spininj.c:582
void LALParserInspiralInjection(int, char **, InspiralInjectionParameters *)
Definition: spininj.c:605
int vrbflg
defined in lal/lib/std/LALError.c
void LALSetIndividualMasses(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
Definition: spininj.c:312
CHAR fname[256]
Definition: spininj.c:211
const INT4 S2StopTime
Definition: spininj.c:105
void LALSimInspiralTablePopulate(SimInspiralTable **this_inj)
Definition: spininj.c:300
void LALSetDistance(LALStatus *status, InspiralInjectionParameters, SimInspiralTable *this_inj)
Definition: spininj.c:408
SPININJrange inclination
Definition: spininj.c:141
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
Definition: spininj.c:134
LIGOTimeGPS gpsStartTime
Definition: spininj.c:127
distributionEnum ddistr
Definition: spininj.c:137
SPININJrange coa_phase
Definition: spininj.c:140
LALSource * pSource
const LALDetector * pDetector
REAL8 location[3]
SkyPosition equatorialCoords
REAL8 orientation
const char *const vcsDate
const char *const vcsStatus
const char *const vcsId
struct tagProcessParamsTable * next
LIGOTimeGPS start_time
CHAR ifos[LIGOMETA_IFOS_MAX]
LIGOTimeGPS end_time
CHAR comment[LIGOMETA_COMMENT_MAX]
double min
Definition: spininj.c:120
double max
Definition: spininj.c:121
LIGOTimeGPS l_end_time
LIGOTimeGPS geocent_end_time
LIGOTimeGPS v_end_time
struct tagSimInspiralTable * next
LIGOTimeGPS t_end_time
LIGOTimeGPS g_end_time
LIGOTimeGPS h_end_time
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
REAL8 longitude
REAL8 latitude
CoordinateSystem system
double inclination
double m1
double m2
double distance
int waveform